From dc1ffe92039e06d130a9c4fdaa4aa9b37968d3bb Mon Sep 17 00:00:00 2001 From: Titian Cernicova-Dragomir Date: Sun, 21 Jan 2024 15:44:16 +0000 Subject: [PATCH] Switched over to `entityNameToString` Signed-off-by: Titian Cernicova-Dragomir --- src/compiler/debug.ts | 14 +- .../transformers/declarations/emitResolver.ts | 120 +++++++----------- ...eclarationErrorsExpandoFunctions.d.ts.diff | 2 +- .../isolatedDeclarationLazySymbols.d.ts.diff | 45 +++++++ .../dte/isolatedDeclarationLazySymbols.d.ts | 87 +++++++++++++ .../tsc/isolatedDeclarationLazySymbols.d.ts | 87 +++++++++++++ .../isolatedDeclarationLazySymbols.errors.txt | 40 ++++++ .../isolatedDeclarationLazySymbols.js | 45 +++++++ .../isolatedDeclarationLazySymbols.symbols | 69 ++++++++++ .../isolatedDeclarationLazySymbols.types | 89 +++++++++++++ ...olatedDeclarationErrorsExpandoFunctions.ts | 2 +- .../isolatedDeclarationLazySymbols.ts | 29 +++++ 12 files changed, 548 insertions(+), 81 deletions(-) create mode 100644 tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationLazySymbols.d.ts.diff create mode 100644 tests/baselines/reference/isolated-declarations/auto-fixed/dte/isolatedDeclarationLazySymbols.d.ts create mode 100644 tests/baselines/reference/isolated-declarations/auto-fixed/tsc/isolatedDeclarationLazySymbols.d.ts create mode 100644 tests/baselines/reference/isolatedDeclarationLazySymbols.errors.txt create mode 100644 tests/baselines/reference/isolatedDeclarationLazySymbols.js create mode 100644 tests/baselines/reference/isolatedDeclarationLazySymbols.symbols create mode 100644 tests/baselines/reference/isolatedDeclarationLazySymbols.types create mode 100644 tests/cases/compiler/isolatedDeclarationLazySymbols.ts diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index 8912ffee391f1..a07e302de0d0c 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -4,6 +4,7 @@ import { AssertionLevel, BigIntLiteralType, CheckMode, + Comparer, compareValues, EmitFlags, every, @@ -386,7 +387,7 @@ export namespace Debug { * Formats an enum value as a string for debugging and debug assertions. */ export function formatEnum(value = 0, enumObject: any, isFlags?: boolean) { - const members = getEnumMembers(enumObject); + const members = getEnumMembers(enumObject, isFlags); if (value === 0) { return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0"; } @@ -394,10 +395,10 @@ export namespace Debug { const result: string[] = []; let remainingFlags = value; for (const [enumValue, enumName] of members) { - if (enumValue > value) { + if (enumValue > remainingFlags) { break; } - if (enumValue !== 0 && enumValue & value) { + if (enumValue !== 0 && enumValue & remainingFlags) { result.push(enumName); remainingFlags &= ~enumValue; } @@ -418,7 +419,7 @@ export namespace Debug { const enumMemberCache = new Map>(); - function getEnumMembers(enumObject: any) { + function getEnumMembers(enumObject: any, isFlags?: boolean) { // Assuming enum objects do not change at runtime, we can cache the enum members list // to reuse later. This saves us from reconstructing this each and every time we call // a formatting function (which can be expensive for large enums like SyntaxKind). @@ -435,7 +436,10 @@ export namespace Debug { } } - const sorted = stableSort<[number, string]>(result, (x, y) => compareValues(x[0], y[0])); + const comparer: Comparer<[number, string]> = isFlags ? + (x, y) => compareValues(x[0] >>> 0, y[0] >>> 0) : + (x, y) => compareValues(x[0], y[0]); + const sorted = stableSort(result, comparer); enumMemberCache.set(enumObject, sorted); return sorted; } diff --git a/src/compiler/transformers/declarations/emitResolver.ts b/src/compiler/transformers/declarations/emitResolver.ts index 9117bd115dddc..ccef24871a1f3 100644 --- a/src/compiler/transformers/declarations/emitResolver.ts +++ b/src/compiler/transformers/declarations/emitResolver.ts @@ -1,5 +1,6 @@ import { __String, + BigIntLiteral, bindSourceFile, CompilerOptions, ComputedPropertyName, @@ -14,6 +15,7 @@ import { determineIfDeclarationIsVisible, ElementAccessExpression, emptyArray, + entityNameToString, EnumDeclaration, EnumMember, ExportSpecifier, @@ -35,7 +37,6 @@ import { Identifier, InternalSymbolName, isAccessor, - isBigIntLiteral, isBinaryExpression, isComputedPropertyName, isDeclarationReadonly, @@ -54,27 +55,25 @@ import { isIdentifier, isInfinityOrNaNString, isModuleDeclaration, - isNumericLiteral, - isPrefixUnaryExpression, isPrimitiveLiteralValue, isPropertyAccessExpression, isPropertyName, isSetAccessor, isSetAccessorDeclaration, isStringLiteralLike, - isTemplateExpression, isVarConst, isVariableDeclaration, LateBoundDeclaration, - MemberName, ModifierFlags, Node, NodeFlags, nodeIsPresent, NoSubstitutionTemplateLiteral, + NumericLiteral, objectAllocator, ParameterDeclaration, parsePseudoBigInt, + PrefixUnaryExpression, PropertyAccessExpression, PropertyDeclaration, PropertyName, @@ -82,11 +81,13 @@ import { skipParentheses, some, SourceFile, + StringLiteralLike, Symbol, SymbolAccessibility, SymbolFlags, SymbolTable, SyntaxKind, + TemplateExpression, VariableDeclaration, } from "../../_namespaces/ts"; @@ -357,48 +358,44 @@ export function createEmitDeclarationResolver(file: SourceFile, options: Compile onNumericLiteral() {}, }); function clonePrimitiveLiteralValue(node: Expression): Expression { - if (isNumericLiteral(node)) { - return factory.createNumericLiteral(node.text); - } - if (isBigIntLiteral(node)) { - return factory.createBigIntLiteral({ negative: false, base10Value: parsePseudoBigInt(node.text) }); - } - if (isStringLiteralLike(node)) { - return factory.createStringLiteral(node.text); - } - - if (node.kind === SyntaxKind.FalseKeyword) { - return factory.createFalse(); - } - - if (node.kind === SyntaxKind.TrueKeyword) { - return factory.createTrue(); - } - - if (isPrefixUnaryExpression(node)) { - return factory.createPrefixUnaryExpression( - node.operator, - clonePrimitiveLiteralValue(node.operand), - ); - } - if (isTemplateExpression(node)) { - const evaluatedValue = evaluate(node); - if (evaluatedValue !== undefined) { - return factory.createStringLiteral(evaluatedValue); - } - return factory.createTemplateExpression( - factory.createTemplateHead(node.head.text, node.head.rawText, node.head.templateFlags), - node.templateSpans.map(t => - factory.createTemplateSpan( - clonePrimitiveLiteralValue(t.expression), - t.literal.kind === SyntaxKind.TemplateMiddle ? - factory.createTemplateMiddle(t.literal.text, t.literal.rawText, t.literal.templateFlags) : - factory.createTemplateTail(t.literal.text, t.literal.rawText, t.literal.templateFlags), - ) - ), - ); + switch(node.kind) { + case SyntaxKind.NumericLiteral: + return factory.createNumericLiteral((node as NumericLiteral).text); + case SyntaxKind.BigIntLiteral: + return factory.createBigIntLiteral({ negative: false, base10Value: parsePseudoBigInt((node as BigIntLiteral).text) }); + case SyntaxKind.StringLiteral: + case SyntaxKind.NoSubstitutionTemplateLiteral: + return factory.createStringLiteral((node as StringLiteralLike).text); + case SyntaxKind.FalseKeyword: + return factory.createFalse(); + case SyntaxKind.TrueKeyword: + return factory.createTrue(); + case SyntaxKind.PrefixUnaryExpression: + return factory.createPrefixUnaryExpression( + (node as PrefixUnaryExpression).operator, + clonePrimitiveLiteralValue((node as PrefixUnaryExpression).operand), + ); + case SyntaxKind.TemplateExpression: + const templateExpression = node as TemplateExpression + const evaluatedValue = evaluate(templateExpression); + if (evaluatedValue !== undefined) { + return factory.createStringLiteral(evaluatedValue); + } + const templateHead = templateExpression.head + return factory.createTemplateExpression( + factory.createTemplateHead(templateHead.text, templateHead.rawText, templateHead.templateFlags), + templateExpression.templateSpans.map(t => + factory.createTemplateSpan( + clonePrimitiveLiteralValue(t.expression), + t.literal.kind === SyntaxKind.TemplateMiddle ? + factory.createTemplateMiddle(t.literal.text, t.literal.rawText, t.literal.templateFlags) : + factory.createTemplateTail(t.literal.text, t.literal.rawText, t.literal.templateFlags), + ) + ), + ); + default: + Debug.assert(false, `Unable to clone unknown literal type. Kind: ${node.kind}`); } - Debug.assert(false, `Unable to clone unknown literal type. Kind: ${node.kind}`); } function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { @@ -627,37 +624,12 @@ function getSymbolName(name: ElementAccessExpression | PropertyName): __String | return getDynamicSymbolName(name); } -function getEntityNameComponent(identifier: MemberName): __String { - const name = getPropertyNameForPropertyNameNode(identifier); - if (name && name.indexOf(".")) { - return name.replace(/\./g, "..") as __String; - } - return name; -} - function getDynamicSymbolName(name: ElementAccessExpression | PropertyName) { - let computedName = isComputedPropertyName(name) ? name.expression : + const computedName = isComputedPropertyName(name) ? name.expression : isElementAccessExpression(name) ? name.argumentExpression : undefined; - - if (computedName) { - let fullId = "__!"; - // We only support dotted identifiers as property keys - while (true) { - if (isIdentifier(computedName)) { - const componentName = getEntityNameComponent(computedName); - fullId += componentName; - return fullId as __String; - } - else if (isPropertyAccessExpression(computedName)) { - const componentName = getEntityNameComponent(computedName.name); - computedName = computedName.expression; - fullId += componentName + "."; - } - else { - return undefined; - } - } + if (computedName && isEntityNameExpression(computedName)) { + return ("__!" + entityNameToString(computedName)) as __String; } return undefined; } diff --git a/tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationErrorsExpandoFunctions.d.ts.diff b/tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationErrorsExpandoFunctions.d.ts.diff index 5bfaa64825de6..f677c51d38b54 100644 --- a/tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationErrorsExpandoFunctions.d.ts.diff +++ b/tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationErrorsExpandoFunctions.d.ts.diff @@ -1,4 +1,4 @@ -// [[Reason: Function declarations are not fixed.]] //// +// [[Reason: Expando function declarations are not fixed.]] //// //// [tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts] //// diff --git a/tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationLazySymbols.d.ts.diff b/tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationLazySymbols.d.ts.diff new file mode 100644 index 0000000000000..8a06b4b452bc8 --- /dev/null +++ b/tests/baselines/reference/isolated-declarations/auto-fixed/diff/isolatedDeclarationLazySymbols.d.ts.diff @@ -0,0 +1,45 @@ +// [[Reason: Expando function declarations are not fixed.]] //// + +//// [tests/cases/compiler/isolatedDeclarationLazySymbols.ts] //// + +=================================================================== +--- TSC declarations ++++ DTE declarations +@@ -1,11 +1,8 @@ + + + //// [isolatedDeclarationLazySymbols.d.ts] + export declare function foo(): void; +-export declare namespace foo { +- var b: string; +-} + declare const o: { + readonly "prop.inner": "a"; + readonly prop: { + readonly inner: "b"; +@@ -20,12 +17,13 @@ + export {}; + //# sourceMappingURL=isolatedDeclarationLazySymbols.d.ts.map + /// [Errors] //// + ++isolatedDeclarationLazySymbols.ts(13,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function. + isolatedDeclarationLazySymbols.ts(16,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. + + +-==== isolatedDeclarationLazySymbols.ts (1 errors) ==== ++==== isolatedDeclarationLazySymbols.ts (2 errors) ==== + export function foo(): void { + + } + +@@ -37,8 +35,10 @@ + } as const + + foo[o["prop.inner"]] ="A"; + foo[o.prop.inner] = "B"; ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function. + + export class Foo { + [o["prop.inner"]] ="A" + ~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/isolated-declarations/auto-fixed/dte/isolatedDeclarationLazySymbols.d.ts b/tests/baselines/reference/isolated-declarations/auto-fixed/dte/isolatedDeclarationLazySymbols.d.ts new file mode 100644 index 0000000000000..d6d0fe041e302 --- /dev/null +++ b/tests/baselines/reference/isolated-declarations/auto-fixed/dte/isolatedDeclarationLazySymbols.d.ts @@ -0,0 +1,87 @@ +//// [tests/cases/compiler/isolatedDeclarationLazySymbols.ts] //// + +//// [isolatedDeclarationLazySymbols.ts] +export function foo(): void { + +} + +const o = { + ["prop.inner"]: "a", + prop: { + inner: "b", + } +} as const + +foo[o["prop.inner"]] ="A"; +foo[o.prop.inner] = "B"; + +export class Foo { + [o["prop.inner"]] ="A" + [o.prop.inner] = "B" +} + +export let oo: { + a: string; + [o.prop.inner]: string; +} = { + [o['prop.inner']]:"A", + [o.prop.inner]: "B", +} + +/// [Declarations] //// + + + +//// [isolatedDeclarationLazySymbols.d.ts] +export declare function foo(): void; +declare const o: { + readonly "prop.inner": "a"; + readonly prop: { + readonly inner: "b"; + }; +}; +export declare class Foo { +} +export declare let oo: { + a: string; + [o.prop.inner]: string; +}; +export {}; +//# sourceMappingURL=isolatedDeclarationLazySymbols.d.ts.map +/// [Errors] //// + +isolatedDeclarationLazySymbols.ts(13,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function. +isolatedDeclarationLazySymbols.ts(16,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. + + +==== isolatedDeclarationLazySymbols.ts (2 errors) ==== + export function foo(): void { + + } + + const o = { + ["prop.inner"]: "a", + prop: { + inner: "b", + } + } as const + + foo[o["prop.inner"]] ="A"; + foo[o.prop.inner] = "B"; + ~~~~~~~~~~~~~~~~~ +!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function. + + export class Foo { + [o["prop.inner"]] ="A" + ~~~~~~~~~~~~~~~~~ +!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. + [o.prop.inner] = "B" + } + + export let oo: { + a: string; + [o.prop.inner]: string; + } = { + [o['prop.inner']]:"A", + [o.prop.inner]: "B", + } \ No newline at end of file diff --git a/tests/baselines/reference/isolated-declarations/auto-fixed/tsc/isolatedDeclarationLazySymbols.d.ts b/tests/baselines/reference/isolated-declarations/auto-fixed/tsc/isolatedDeclarationLazySymbols.d.ts new file mode 100644 index 0000000000000..69724d1fc0654 --- /dev/null +++ b/tests/baselines/reference/isolated-declarations/auto-fixed/tsc/isolatedDeclarationLazySymbols.d.ts @@ -0,0 +1,87 @@ +//// [tests/cases/compiler/isolatedDeclarationLazySymbols.ts] //// + +//// [isolatedDeclarationLazySymbols.ts] +export function foo(): void { + +} + +const o = { + ["prop.inner"]: "a", + prop: { + inner: "b", + } +} as const + +foo[o["prop.inner"]] ="A"; +foo[o.prop.inner] = "B"; + +export class Foo { + [o["prop.inner"]] ="A" + [o.prop.inner] = "B" +} + +export let oo: { + a: string; + [o.prop.inner]: string; +} = { + [o['prop.inner']]:"A", + [o.prop.inner]: "B", +} + +/// [Declarations] //// + + + +//// [isolatedDeclarationLazySymbols.d.ts] +export declare function foo(): void; +export declare namespace foo { + var b: string; +} +declare const o: { + readonly "prop.inner": "a"; + readonly prop: { + readonly inner: "b"; + }; +}; +export declare class Foo { +} +export declare let oo: { + a: string; + [o.prop.inner]: string; +}; +export {}; +//# sourceMappingURL=isolatedDeclarationLazySymbols.d.ts.map +/// [Errors] //// + +isolatedDeclarationLazySymbols.ts(16,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. + + +==== isolatedDeclarationLazySymbols.ts (1 errors) ==== + export function foo(): void { + + } + + const o = { + ["prop.inner"]: "a", + prop: { + inner: "b", + } + } as const + + foo[o["prop.inner"]] ="A"; + foo[o.prop.inner] = "B"; + + export class Foo { + [o["prop.inner"]] ="A" + ~~~~~~~~~~~~~~~~~ +!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. + [o.prop.inner] = "B" + } + + export let oo: { + a: string; + [o.prop.inner]: string; + } = { + [o['prop.inner']]:"A", + [o.prop.inner]: "B", + } \ No newline at end of file diff --git a/tests/baselines/reference/isolatedDeclarationLazySymbols.errors.txt b/tests/baselines/reference/isolatedDeclarationLazySymbols.errors.txt new file mode 100644 index 0000000000000..bb46d672d1099 --- /dev/null +++ b/tests/baselines/reference/isolatedDeclarationLazySymbols.errors.txt @@ -0,0 +1,40 @@ +isolatedDeclarationLazySymbols.ts(1,17): error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. +isolatedDeclarationLazySymbols.ts(13,1): error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function. +isolatedDeclarationLazySymbols.ts(16,5): error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. +isolatedDeclarationLazySymbols.ts(21,5): error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations. + + +==== isolatedDeclarationLazySymbols.ts (4 errors) ==== + export function foo() { + ~~~ +!!! error TS9007: Function must have an explicit return type annotation with --isolatedDeclarations. +!!! related TS9031 isolatedDeclarationLazySymbols.ts:1:17: Add a return type to the function declaration. + + } + + const o = { + ["prop.inner"]: "a", + prop: { + inner: "b", + } + } as const + + foo[o["prop.inner"]] ="A"; + foo[o.prop.inner] = "B"; + ~~~~~~~~~~~~~~~~~ +!!! error TS9023: Assigning properties to functions without declaring them is not supported with --isolatedDeclarations. Add an explicit declaration for the properties assigned to this function. + + export class Foo { + [o["prop.inner"]] ="A" + ~~~~~~~~~~~~~~~~~ +!!! error TS1166: A computed property name in a class property declaration must have a simple literal type or a 'unique symbol' type. + [o.prop.inner] = "B" + } + + export let oo = { + [o['prop.inner']]:"A", + ~~~~~~~~~~~~~~~~~ +!!! error TS9014: Computed properties must be number or string literals, variables or dotted expressions with --isolatedDeclarations. +!!! related TS9027 isolatedDeclarationLazySymbols.ts:20:12: Add a type annotation to the variable oo. + [o.prop.inner]: "B", + } \ No newline at end of file diff --git a/tests/baselines/reference/isolatedDeclarationLazySymbols.js b/tests/baselines/reference/isolatedDeclarationLazySymbols.js new file mode 100644 index 0000000000000..fbcc574d35f63 --- /dev/null +++ b/tests/baselines/reference/isolatedDeclarationLazySymbols.js @@ -0,0 +1,45 @@ +//// [tests/cases/compiler/isolatedDeclarationLazySymbols.ts] //// + +//// [isolatedDeclarationLazySymbols.ts] +export function foo() { + +} + +const o = { + ["prop.inner"]: "a", + prop: { + inner: "b", + } +} as const + +foo[o["prop.inner"]] ="A"; +foo[o.prop.inner] = "B"; + +export class Foo { + [o["prop.inner"]] ="A" + [o.prop.inner] = "B" +} + +export let oo = { + [o['prop.inner']]:"A", + [o.prop.inner]: "B", +} + +//// [isolatedDeclarationLazySymbols.js] +export function foo() { +} +const o = { + ["prop.inner"]: "a", + prop: { + inner: "b", + } +}; +foo[o["prop.inner"]] = "A"; +foo[o.prop.inner] = "B"; +export class Foo { + [o["prop.inner"]] = "A"[o.prop.inner] = "B"; +} +export let oo = { + [o['prop.inner']]: "A", + [o.prop.inner]: "B", +}; diff --git a/tests/baselines/reference/isolatedDeclarationLazySymbols.symbols b/tests/baselines/reference/isolatedDeclarationLazySymbols.symbols new file mode 100644 index 0000000000000..f2df8038e2c75 --- /dev/null +++ b/tests/baselines/reference/isolatedDeclarationLazySymbols.symbols @@ -0,0 +1,69 @@ +//// [tests/cases/compiler/isolatedDeclarationLazySymbols.ts] //// + +=== isolatedDeclarationLazySymbols.ts === +export function foo() { +>foo : Symbol(foo, Decl(isolatedDeclarationLazySymbols.ts, 0, 0), Decl(isolatedDeclarationLazySymbols.ts, 9, 10), Decl(isolatedDeclarationLazySymbols.ts, 11, 26)) + +} + +const o = { +>o : Symbol(o, Decl(isolatedDeclarationLazySymbols.ts, 4, 5)) + + ["prop.inner"]: "a", +>["prop.inner"] : Symbol(["prop.inner"], Decl(isolatedDeclarationLazySymbols.ts, 4, 11)) +>"prop.inner" : Symbol(["prop.inner"], Decl(isolatedDeclarationLazySymbols.ts, 4, 11)) + + prop: { +>prop : Symbol(prop, Decl(isolatedDeclarationLazySymbols.ts, 5, 24)) + + inner: "b", +>inner : Symbol(inner, Decl(isolatedDeclarationLazySymbols.ts, 6, 11)) + } +} as const +>const : Symbol(const) + +foo[o["prop.inner"]] ="A"; +>foo : Symbol(foo, Decl(isolatedDeclarationLazySymbols.ts, 0, 0), Decl(isolatedDeclarationLazySymbols.ts, 9, 10), Decl(isolatedDeclarationLazySymbols.ts, 11, 26)) +>o : Symbol(o, Decl(isolatedDeclarationLazySymbols.ts, 4, 5)) +>"prop.inner" : Symbol(["prop.inner"], Decl(isolatedDeclarationLazySymbols.ts, 4, 11)) + +foo[o.prop.inner] = "B"; +>foo : Symbol(foo, Decl(isolatedDeclarationLazySymbols.ts, 0, 0), Decl(isolatedDeclarationLazySymbols.ts, 9, 10), Decl(isolatedDeclarationLazySymbols.ts, 11, 26)) +>o.prop.inner : Symbol(inner, Decl(isolatedDeclarationLazySymbols.ts, 6, 11)) +>o.prop : Symbol(prop, Decl(isolatedDeclarationLazySymbols.ts, 5, 24)) +>o : Symbol(o, Decl(isolatedDeclarationLazySymbols.ts, 4, 5)) +>prop : Symbol(prop, Decl(isolatedDeclarationLazySymbols.ts, 5, 24)) +>inner : Symbol(inner, Decl(isolatedDeclarationLazySymbols.ts, 6, 11)) + +export class Foo { +>Foo : Symbol(Foo, Decl(isolatedDeclarationLazySymbols.ts, 12, 24)) + + [o["prop.inner"]] ="A" +>[o["prop.inner"]] : Symbol(Foo[o["prop.inner"]], Decl(isolatedDeclarationLazySymbols.ts, 14, 18)) +>o : Symbol(o, Decl(isolatedDeclarationLazySymbols.ts, 4, 5)) +>"prop.inner" : Symbol(["prop.inner"], Decl(isolatedDeclarationLazySymbols.ts, 4, 11)) + + [o.prop.inner] = "B" +>o.prop.inner : Symbol(inner, Decl(isolatedDeclarationLazySymbols.ts, 6, 11)) +>o.prop : Symbol(prop, Decl(isolatedDeclarationLazySymbols.ts, 5, 24)) +>o : Symbol(o, Decl(isolatedDeclarationLazySymbols.ts, 4, 5)) +>prop : Symbol(prop, Decl(isolatedDeclarationLazySymbols.ts, 5, 24)) +>inner : Symbol(inner, Decl(isolatedDeclarationLazySymbols.ts, 6, 11)) +} + +export let oo = { +>oo : Symbol(oo, Decl(isolatedDeclarationLazySymbols.ts, 19, 10)) + + [o['prop.inner']]:"A", +>[o['prop.inner']] : Symbol([o['prop.inner']], Decl(isolatedDeclarationLazySymbols.ts, 19, 17)) +>o : Symbol(o, Decl(isolatedDeclarationLazySymbols.ts, 4, 5)) +>'prop.inner' : Symbol(["prop.inner"], Decl(isolatedDeclarationLazySymbols.ts, 4, 11)) + + [o.prop.inner]: "B", +>[o.prop.inner] : Symbol([o.prop.inner], Decl(isolatedDeclarationLazySymbols.ts, 20, 26)) +>o.prop.inner : Symbol(inner, Decl(isolatedDeclarationLazySymbols.ts, 6, 11)) +>o.prop : Symbol(prop, Decl(isolatedDeclarationLazySymbols.ts, 5, 24)) +>o : Symbol(o, Decl(isolatedDeclarationLazySymbols.ts, 4, 5)) +>prop : Symbol(prop, Decl(isolatedDeclarationLazySymbols.ts, 5, 24)) +>inner : Symbol(inner, Decl(isolatedDeclarationLazySymbols.ts, 6, 11)) +} diff --git a/tests/baselines/reference/isolatedDeclarationLazySymbols.types b/tests/baselines/reference/isolatedDeclarationLazySymbols.types new file mode 100644 index 0000000000000..10a376bec89d9 --- /dev/null +++ b/tests/baselines/reference/isolatedDeclarationLazySymbols.types @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/isolatedDeclarationLazySymbols.ts] //// + +=== isolatedDeclarationLazySymbols.ts === +export function foo() { +>foo : typeof foo + +} + +const o = { +>o : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } +>{ ["prop.inner"]: "a", prop: { inner: "b", }} as const : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } +>{ ["prop.inner"]: "a", prop: { inner: "b", }} : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } + + ["prop.inner"]: "a", +>["prop.inner"] : "a" +>"prop.inner" : "prop.inner" +>"a" : "a" + + prop: { +>prop : { readonly inner: "b"; } +>{ inner: "b", } : { readonly inner: "b"; } + + inner: "b", +>inner : "b" +>"b" : "b" + } +} as const + +foo[o["prop.inner"]] ="A"; +>foo[o["prop.inner"]] ="A" : "A" +>foo[o["prop.inner"]] : any +>foo : typeof foo +>o["prop.inner"] : "a" +>o : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } +>"prop.inner" : "prop.inner" +>"A" : "A" + +foo[o.prop.inner] = "B"; +>foo[o.prop.inner] = "B" : "B" +>foo[o.prop.inner] : string +>foo : typeof foo +>o.prop.inner : "b" +>o.prop : { readonly inner: "b"; } +>o : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } +>prop : { readonly inner: "b"; } +>inner : "b" +>"B" : "B" + +export class Foo { +>Foo : Foo + + [o["prop.inner"]] ="A" +>[o["prop.inner"]] : string +>o["prop.inner"] : "a" +>o : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } +>"prop.inner" : "prop.inner" +>"A" [o.prop.inner] = "B" : "B" +>"A" [o.prop.inner] : any +>"A" : "A" + + [o.prop.inner] = "B" +>o.prop.inner : "b" +>o.prop : { readonly inner: "b"; } +>o : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } +>prop : { readonly inner: "b"; } +>inner : "b" +>"B" : "B" +} + +export let oo = { +>oo : { a: string; b: string; } +>{ [o['prop.inner']]:"A", [o.prop.inner]: "B",} : { a: string; b: string; } + + [o['prop.inner']]:"A", +>[o['prop.inner']] : string +>o['prop.inner'] : "a" +>o : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } +>'prop.inner' : "prop.inner" +>"A" : "A" + + [o.prop.inner]: "B", +>[o.prop.inner] : string +>o.prop.inner : "b" +>o.prop : { readonly inner: "b"; } +>o : { readonly "prop.inner": "a"; readonly prop: { readonly inner: "b"; }; } +>prop : { readonly inner: "b"; } +>inner : "b" +>"B" : "B" +} diff --git a/tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts b/tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts index 503c3de6cb3f8..2afd232fdb232 100644 --- a/tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts +++ b/tests/cases/compiler/isolatedDeclarationErrorsExpandoFunctions.ts @@ -2,7 +2,7 @@ // @isolatedDeclarations: true // @declarationMap: false // @target: ESNext -// @isolatedDeclarationFixedDiffReason: Function declarations are not fixed. +// @isolatedDeclarationFixedDiffReason: Expando function declarations are not fixed. export function foo() {} diff --git a/tests/cases/compiler/isolatedDeclarationLazySymbols.ts b/tests/cases/compiler/isolatedDeclarationLazySymbols.ts new file mode 100644 index 0000000000000..c8b1fbf602d24 --- /dev/null +++ b/tests/cases/compiler/isolatedDeclarationLazySymbols.ts @@ -0,0 +1,29 @@ +// @declaration: true +// @isolatedDeclarations: true +// @target: ESNext +// @isolatedDeclarationFixedDiffReason: Expando function declarations are not fixed. + + +export function foo() { + +} + +const o = { + ["prop.inner"]: "a", + prop: { + inner: "b", + } +} as const + +foo[o["prop.inner"]] ="A"; +foo[o.prop.inner] = "B"; + +export class Foo { + [o["prop.inner"]] ="A" + [o.prop.inner] = "B" +} + +export let oo = { + [o['prop.inner']]:"A", + [o.prop.inner]: "B", +} \ No newline at end of file