From 2389eac219d3b7d3922761d22de535f24fdd0e38 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 26 Jul 2018 17:57:35 -0700 Subject: [PATCH 1/6] Remove index signatures from js literals, use an object flag to indicate errors should be ignored instead --- src/compiler/checker.ts | 55 +++++++++++++-- src/compiler/types.ts | 1 + .../reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + .../chainedPrototypeAssignment.types | 26 +++---- ...checkDestructuringShorthandAssigment.types | 6 +- .../checkJsdocTypeTagOnObjectProperty1.types | 20 +++--- .../checkJsdocTypeTagOnObjectProperty2.types | 8 +-- .../checkSpecialPropertyAssignments.types | 2 +- .../contextualThisTypeInJavascript.types | 12 ++-- .../contextualTypedSpecialAssignment.types | 10 +-- .../contextuallyTypeArgumentsKeyword.types | 4 +- .../exportDefaultMarksIdentifierAsUsed.types | 6 +- .../reference/exportNestedNamespaces.types | 2 +- .../reference/exportNestedNamespaces2.types | 16 ++--- .../reference/functionExpressionNames.types | 8 +-- .../jsContainerMergeJsContainer.types | 22 +++--- .../jsContainerMergeTsDeclaration2.types | 8 +-- .../jsContainerMergeTsDeclaration3.types | 10 +-- ...PropertyInitalizationInObjectLiteral.types | 12 ++-- ...sFileCompilationBindStrictModeErrors.types | 8 +-- .../jsFileCompilationShortHandProperty.types | 4 +- .../jsObjectsMarkedAsOpenEnded.types | 70 +++++++++---------- ...opertyAssignedAfterMethodDeclaration.types | 6 +- ...ignedAfterMethodDeclaration_nonError.types | 6 +- .../reference/jsdocTemplateTag2.types | 4 +- .../reference/moduleExportAlias3.types | 10 +-- .../reference/moduleExportAssignment4.types | 4 +- .../moduleExportNestedNamespaces.types | 2 +- ...oduleExportPropertyAssignmentDefault.types | 28 ++++---- ...eExportWithExportPropertyAssignment3.types | 40 +++++------ .../reference/nestedPrototypeAssignment.types | 10 +-- .../propertyAssignmentOnImportedSymbol.types | 8 +-- tests/baselines/reference/thisTag1.types | 6 +- .../reference/typeFromJSInitializer.types | 8 +-- .../typeFromPropertyAssignment10.types | 8 +-- .../typeFromPropertyAssignment11.types | 28 ++++---- .../typeFromPropertyAssignment13.types | 30 ++++---- .../typeFromPropertyAssignment14.types | 40 +++++------ .../typeFromPropertyAssignment15.types | 2 +- .../typeFromPropertyAssignment16.types | 40 +++++------ .../typeFromPropertyAssignment18.types | 38 +++++----- .../typeFromPropertyAssignment24.types | 2 +- .../typeFromPropertyAssignment25.types | 2 +- .../typeFromPropertyAssignment26.types | 2 +- .../typeFromPropertyAssignment27.types | 16 ++--- .../typeFromPropertyAssignment28.errors.txt | 4 +- .../typeFromPropertyAssignment28.types | 4 +- .../typeFromPropertyAssignment4.types | 2 +- .../typeFromPropertyAssignment7.types | 2 +- .../typeFromPropertyAssignment8.types | 14 ++-- .../typeFromPropertyAssignment9.types | 28 ++++---- ...typeFromPropertyAssignmentOutOfOrder.types | 6 +- ...typeFromPropertyAssignmentWithExport.types | 10 +-- .../reference/typedefCrossModule2.symbols | 2 - .../reference/typedefCrossModule2.types | 30 ++++---- .../reference/typedefCrossModule3.types | 2 +- .../reference/typedefCrossModule4.types | 10 +-- .../untypedModuleImport_allowJs.types | 12 ++-- 59 files changed, 411 insertions(+), 367 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2b255da7ae34d..85f8f3d0e7038 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -420,7 +420,6 @@ namespace ts { const resolvingSignaturesArray = [resolvingSignature]; const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); - const jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); const globals = createSymbolTable(); let amalgamatedDuplicates: Map<{ firstFile: SourceFile, secondFile: SourceFile, firstFileInstances: Map<{ instances: Node[], blockScoped: boolean }>, secondFileInstances: Map<{ instances: Node[], blockScoped: boolean }> }> | undefined; @@ -4801,13 +4800,15 @@ namespace ts { members.set(name, s); } }); - return createAnonymousType( + const result = createAnonymousType( exportedType.symbol, members, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo); + result.objectFlags |= (getObjectFlags(type) & ObjectFlags.JSLiteral); // Propagate JSLiteral flag + return result; } if (isEmptyArrayLiteralType(type)) { if (noImplicitAny) { @@ -5114,7 +5115,9 @@ namespace ts { if (s && hasEntries(s.exports)) { mergeSymbolTable(exports, s.exports); } - return createAnonymousType(symbol, exports, emptyArray, emptyArray, jsObjectLiteralIndexInfo, undefined); + const type = createAnonymousType(symbol, exports, emptyArray, emptyArray, undefined, undefined); + type.objectFlags |= ObjectFlags.JSLiteral; + return type; } } @@ -9055,6 +9058,31 @@ namespace ts { return type; } + /** + * Returns if a type is or consists of a JSLiteral object type + */ + function isJSLiteralType(type: Type): boolean { + // In addition to objects which are directly literals, + // * unions where every element is a jsliteral + // * intersections where at least one element is a jsliteral + // * and instantiable types constrained to a jsliteral + // Should all count as literals and not print errors on access or assignment of imaginary properties. + // This mirrors the behavior of the index signature propagation in the old implementation which utilized one. + if (getObjectFlags(type) & ObjectFlags.JSLiteral) { + return true; + } + if (type.flags & TypeFlags.Union) { + return every((type as UnionType).types, isJSLiteralType); + } + if (type.flags & TypeFlags.Intersection) { + return some((type as IntersectionType).types, isJSLiteralType); + } + if (type.flags & TypeFlags.Instantiable) { + return isJSLiteralType(getResolvedBaseConstraint(type)); + } + return false; + } + function getPropertyTypeForIndexType(objectType: Type, indexType: Type, accessNode: ElementAccessExpression | IndexedAccessTypeNode | undefined, cacheSymbol: boolean) { const accessExpression = accessNode && accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode : undefined; const propName = isTypeUsableAsLateBoundName(indexType) ? getLateBoundNameFromType(indexType) : @@ -9103,6 +9131,9 @@ namespace ts { if (indexType.flags & TypeFlags.Never) { return neverType; } + if (isJSLiteralType(objectType)) { + return anyType; // TODO: We should consider still marking these as errors if `noImplictAny` is on + } if (accessExpression && !isConstEnumObjectType(objectType)) { if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(objectType, IndexKind.Number)) { @@ -9123,6 +9154,9 @@ namespace ts { return anyType; } } + if (isJSLiteralType(objectType)) { + return anyType; // TODO: We should consider still marking these as errors if `noImplictAny` is on + } if (accessNode) { const indexNode = accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) { @@ -12732,9 +12766,11 @@ namespace ts { } const stringIndexInfo = getIndexInfoOfType(type, IndexKind.String); const numberIndexInfo = getIndexInfoOfType(type, IndexKind.Number); - return createAnonymousType(type.symbol, members, emptyArray, emptyArray, + const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly)); + result.objectFlags |= (getObjectFlags(type) & ObjectFlags.JSLiteral); // Retain js literal flag through widening + return result; } function getWidenedType(type: Type) { @@ -16707,12 +16743,15 @@ namespace ts { return createObjectLiteralType(); function createObjectLiteralType() { - const stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; + const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.String) : undefined; const numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; result.flags |= TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag | (typeFlags & TypeFlags.PropagatingFlags); result.objectFlags |= ObjectFlags.ObjectLiteral; + if (isJSObjectLiteral) { + result.objectFlags |= ObjectFlags.JSLiteral; + } if (patternWithComputedProperties) { result.objectFlags |= ObjectFlags.ObjectLiteralPatternWithComputedProperties; } @@ -17788,6 +17827,9 @@ namespace ts { if (!prop) { const indexInfo = getIndexInfoOfType(apparentType, IndexKind.String); if (!(indexInfo && indexInfo.type)) { + if (isJSLiteralType(leftType)) { + return anyType; // TODO: We should consider still marking these as errors if `noImplictAny` is on + } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, leftType.flags & TypeFlags.TypeParameter && (leftType as TypeParameter).isThisType ? apparentType : leftType); } @@ -19920,7 +19962,8 @@ namespace ts { if (decl) { const jsSymbol = getSymbolOfNode(decl); if (jsSymbol && hasEntries(jsSymbol.exports)) { - jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, emptyArray, emptyArray, jsObjectLiteralIndexInfo, undefined); + jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, emptyArray, emptyArray, undefined, undefined); + (jsAssignmentType as ObjectType).objectFlags |= ObjectFlags.JSLiteral; } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 99d2291e89847..458252b9b1117 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3803,6 +3803,7 @@ namespace ts { ReverseMapped = 1 << 11, // Object contains a property from a reverse-mapped type JsxAttributes = 1 << 12, // Jsx attributes type MarkerType = 1 << 13, // Marker type used for variance probing + JSLiteral = 1 << 14, // Object type declared in JS - disables errors on read/write of nonexisting members ClassOrInterface = Class | Interface } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 99a9c3b610098..93d6f1e562bf5 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2225,6 +2225,7 @@ declare namespace ts { ReverseMapped = 2048, JsxAttributes = 4096, MarkerType = 8192, + JSLiteral = 16384, ClassOrInterface = 3 } interface ObjectType extends Type { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 41510d5192bda..510bd04a4adce 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2225,6 +2225,7 @@ declare namespace ts { ReverseMapped = 2048, JsxAttributes = 4096, MarkerType = 8192, + JSLiteral = 16384, ClassOrInterface = 3 } interface ObjectType extends Type { diff --git a/tests/baselines/reference/chainedPrototypeAssignment.types b/tests/baselines/reference/chainedPrototypeAssignment.types index a893ae63022c6..08ddcbf2baf71 100644 --- a/tests/baselines/reference/chainedPrototypeAssignment.types +++ b/tests/baselines/reference/chainedPrototypeAssignment.types @@ -7,15 +7,15 @@ var mod = require('./mod'); >'./mod' : "./mod" var a = new mod.A() ->a : A & { [x: string]: any; m(n: number): number; } ->new mod.A() : A & { [x: string]: any; m(n: number): number; } +>a : A & { m(n: number): number; } +>new mod.A() : A & { m(n: number): number; } >mod.A : typeof A >mod : typeof import("tests/cases/conformance/salsa/mod") >A : typeof A var b = new mod.B() ->b : B & { [x: string]: any; m(n: number): number; } ->new mod.B() : B & { [x: string]: any; m(n: number): number; } +>b : B & { m(n: number): number; } +>new mod.B() : B & { m(n: number): number; } >mod.B : typeof B >mod : typeof import("tests/cases/conformance/salsa/mod") >B : typeof B @@ -23,14 +23,14 @@ var b = new mod.B() a.m('nope') >a.m('nope') : number >a.m : (n: number) => number ->a : A & { [x: string]: any; m(n: number): number; } +>a : A & { m(n: number): number; } >m : (n: number) => number >'nope' : "nope" b.m('not really') >b.m('not really') : number >b.m : (n: number) => number ->b : B & { [x: string]: any; m(n: number): number; } +>b : B & { m(n: number): number; } >m : (n: number) => number >'not really' : "not really" @@ -81,15 +81,15 @@ exports.B = B >B : typeof B A.prototype = B.prototype = { ->A.prototype = B.prototype = { /** @param {number} n */ m(n) { return n + 1 }} : { [x: string]: any; m(n: number): number; } ->A.prototype : { [x: string]: any; m(n: number): number; } +>A.prototype = B.prototype = { /** @param {number} n */ m(n) { return n + 1 }} : { m(n: number): number; } +>A.prototype : { m(n: number): number; } >A : typeof A ->prototype : { [x: string]: any; m(n: number): number; } ->B.prototype = { /** @param {number} n */ m(n) { return n + 1 }} : { [x: string]: any; m(n: number): number; } ->B.prototype : { [x: string]: any; m(n: number): number; } +>prototype : { m(n: number): number; } +>B.prototype = { /** @param {number} n */ m(n) { return n + 1 }} : { m(n: number): number; } +>B.prototype : { m(n: number): number; } >B : typeof B ->prototype : { [x: string]: any; m(n: number): number; } ->{ /** @param {number} n */ m(n) { return n + 1 }} : { [x: string]: any; m(n: number): number; } +>prototype : { m(n: number): number; } +>{ /** @param {number} n */ m(n) { return n + 1 }} : { m(n: number): number; } /** @param {number} n */ m(n) { diff --git a/tests/baselines/reference/checkDestructuringShorthandAssigment.types b/tests/baselines/reference/checkDestructuringShorthandAssigment.types index 692b3a0f03f53..5e22b7f7e0718 100644 --- a/tests/baselines/reference/checkDestructuringShorthandAssigment.types +++ b/tests/baselines/reference/checkDestructuringShorthandAssigment.types @@ -1,17 +1,17 @@ === tests/cases/compiler/bug25434.js === // should not crash while checking function Test({ b = '' } = {}) {} ->Test : ({ b }?: { [x: string]: any; }) => void +>Test : ({ b }?: {}) => void >b : string >'' : "" >{} : { b?: string; } Test(({ b = '5' } = {})); >Test(({ b = '5' } = {})) : void ->Test : ({ b }?: { [x: string]: any; }) => void +>Test : ({ b }?: {}) => void >({ b = '5' } = {}) : { b?: any; } >{ b = '5' } = {} : { b?: any; } ->{ b = '5' } : { [x: string]: any; b?: any; } +>{ b = '5' } : { b?: any; } >b : any >'5' : "5" >{} : { b?: any; } diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.types b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.types index 2601309b504b2..eba23433568cd 100644 --- a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.types +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty1.types @@ -5,8 +5,8 @@ var lol = "hello Lol" >"hello Lol" : "hello Lol" const obj = { ->obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } ->{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } +>obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } +>{ /** @type {string|undefined} */ foo: undefined, /** @type {string|undefined} */ bar: "42", /** @type {function(number): number} */ method1(n1) { return n1 + 42; }, /** @type {string} */ lol, /** @type {number} */ ['b' + 'ar1']: 42, /** @type {function(number): number} */ arrowFunc: (num) => num + 42} : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } /** @type {string|undefined} */ foo: undefined, @@ -53,19 +53,19 @@ const obj = { obj.foo = 'string' >obj.foo = 'string' : "string" >obj.foo : string | undefined ->obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } +>obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } >foo : string | undefined >'string' : "string" obj.lol >obj.lol : string ->obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } +>obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } >lol : string obj.bar = undefined; >obj.bar = undefined : undefined >obj.bar : string | undefined ->obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } +>obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } >bar : string | undefined >undefined : undefined @@ -73,21 +73,21 @@ var k = obj.method1(0); >k : number >obj.method1(0) : number >obj.method1 : (arg0: number) => number ->obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } +>obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } >method1 : (arg0: number) => number >0 : 0 obj.bar1 = "42"; >obj.bar1 = "42" : "42" ->obj.bar1 : any ->obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } ->bar1 : any +>obj.bar1 : string | number | ((arg0: number) => number) | undefined +>obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } +>bar1 : string | number | ((arg0: number) => number) | undefined >"42" : "42" obj.arrowFunc(0); >obj.arrowFunc(0) : number >obj.arrowFunc : (arg0: number) => number ->obj : { [x: string]: any; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } +>obj : { [x: string]: string | number | ((arg0: number) => number) | undefined; foo: string | undefined; bar: string | undefined; method1(arg0: number): number; lol: string; arrowFunc: (arg0: number) => number; } >arrowFunc : (arg0: number) => number >0 : 0 diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types index 94aad119feb9b..37c2bc2d24013 100644 --- a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types @@ -4,8 +4,8 @@ var lol; >lol : any const obj = { ->obj : { [x: string]: any; bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } ->{ /** @type {string|undefined} */ bar: 42, /** @type {function(number): number} */ method1(n1) { return "42"; }, /** @type {function(number): number} */ method2: (n1) => "lol", /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, /** @type {string} */ lol} : { [x: string]: any; bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } +>obj : { bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } +>{ /** @type {string|undefined} */ bar: 42, /** @type {function(number): number} */ method1(n1) { return "42"; }, /** @type {function(number): number} */ method2: (n1) => "lol", /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, /** @type {string} */ lol} : { bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } /** @type {string|undefined} */ bar: 42, @@ -52,7 +52,7 @@ var s = obj.method1(0); >s : string >obj.method1(0) : number >obj.method1 : (arg0: number) => number ->obj : { [x: string]: any; bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } +>obj : { bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } >method1 : (arg0: number) => number >0 : 0 @@ -61,7 +61,7 @@ var s1 = obj.method2("0"); >s1 : string >obj.method2("0") : number >obj.method2 : (arg0: number) => number ->obj : { [x: string]: any; bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } +>obj : { bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } >method2 : (arg0: number) => number >"0" : "0" diff --git a/tests/baselines/reference/checkSpecialPropertyAssignments.types b/tests/baselines/reference/checkSpecialPropertyAssignments.types index 879038b6f9471..14043231b0294 100644 --- a/tests/baselines/reference/checkSpecialPropertyAssignments.types +++ b/tests/baselines/reference/checkSpecialPropertyAssignments.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/bug24252.js === var A = {}; >A : typeof A ->{} : { [x: string]: any; } +>{} : {} A.B = class { >A.B = class { m() { /** @type {string[]} */ var x = []; /** @type {number[]} */ var y; y = x; }} : typeof B diff --git a/tests/baselines/reference/contextualThisTypeInJavascript.types b/tests/baselines/reference/contextualThisTypeInJavascript.types index 355b7295e6e97..b3ccecb9eab46 100644 --- a/tests/baselines/reference/contextualThisTypeInJavascript.types +++ b/tests/baselines/reference/contextualThisTypeInJavascript.types @@ -1,7 +1,7 @@ === tests/cases/conformance/types/thisType/context.js === const obj = { ->obj : { [x: string]: any; prop: number; method(): void; } ->{ prop: 2, method() { this; this.prop; this.method; this.unknown; // ok, obj has a string indexer }} : { [x: string]: any; prop: number; method(): void; } +>obj : { prop: number; method(): void; } +>{ prop: 2, method() { this; this.prop; this.method; this.unknown; // ok, obj has a string indexer }} : { prop: number; method(): void; } prop: 2, >prop : number @@ -11,21 +11,21 @@ const obj = { >method : () => void this; ->this : { [x: string]: any; prop: number; method(): void; } +>this : { prop: number; method(): void; } this.prop; >this.prop : number ->this : { [x: string]: any; prop: number; method(): void; } +>this : { prop: number; method(): void; } >prop : number this.method; >this.method : () => void ->this : { [x: string]: any; prop: number; method(): void; } +>this : { prop: number; method(): void; } >method : () => void this.unknown; // ok, obj has a string indexer >this.unknown : any ->this : { [x: string]: any; prop: number; method(): void; } +>this : { prop: number; method(): void; } >unknown : any } } diff --git a/tests/baselines/reference/contextualTypedSpecialAssignment.types b/tests/baselines/reference/contextualTypedSpecialAssignment.types index c178799c94dda..31865449ae3a3 100644 --- a/tests/baselines/reference/contextualTypedSpecialAssignment.types +++ b/tests/baselines/reference/contextualTypedSpecialAssignment.types @@ -6,14 +6,14 @@ // property assignment var ns = {} ->ns : { [x: string]: any; x: { status: "done"; m(n: number): void; }; } ->{} : { [x: string]: any; } +>ns : { x: { status: "done"; m(n: number): void; }; } +>{} : {} /** @type {DoneStatus} */ ns.x = { >ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } >ns.x : { status: "done"; m(n: number): void; } ->ns : { [x: string]: any; x: { status: "done"; m(n: number): void; }; } +>ns : { x: { status: "done"; m(n: number): void; }; } >x : { status: "done"; m(n: number): void; } >{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } @@ -29,7 +29,7 @@ ns.x = { ns.x = { >ns.x = { status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } >ns.x : { status: "done"; m(n: number): void; } ->ns : { [x: string]: any; x: { status: "done"; m(n: number): void; }; } +>ns : { x: { status: "done"; m(n: number): void; }; } >x : { status: "done"; m(n: number): void; } >{ status: 'done', m(n) { }} : { status: "done"; m(n: number): void; } @@ -43,7 +43,7 @@ ns.x = { } ns.x >ns.x : { status: "done"; m(n: number): void; } ->ns : { [x: string]: any; x: { status: "done"; m(n: number): void; }; } +>ns : { x: { status: "done"; m(n: number): void; }; } >x : { status: "done"; m(n: number): void; } diff --git a/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types index 2f90f47f3702d..24bcdaf7ad104 100644 --- a/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types +++ b/tests/baselines/reference/contextuallyTypeArgumentsKeyword.types @@ -1,8 +1,8 @@ === tests/cases/compiler/foo.js === // Repro for #16585 const x = { ->x : { [x: string]: any; bar(): void; } ->{ bar() { setTimeout(function() { arguments }, 0); }} : { [x: string]: any; bar(): void; } +>x : { bar(): void; } +>{ bar() { setTimeout(function() { arguments }, 0); }} : { bar(): void; } bar() { >bar : () => void diff --git a/tests/baselines/reference/exportDefaultMarksIdentifierAsUsed.types b/tests/baselines/reference/exportDefaultMarksIdentifierAsUsed.types index 73ab0a11b2172..f2c20778de05f 100644 --- a/tests/baselines/reference/exportDefaultMarksIdentifierAsUsed.types +++ b/tests/baselines/reference/exportDefaultMarksIdentifierAsUsed.types @@ -1,10 +1,10 @@ === tests/cases/compiler/a.js === const Obj = {}; ->Obj : { [x: string]: any; } ->{} : { [x: string]: any; } +>Obj : {} +>{} : {} export default Obj; ->Obj : { [x: string]: any; } +>Obj : {} === tests/cases/compiler/b.js === import Obj from './a'; diff --git a/tests/baselines/reference/exportNestedNamespaces.types b/tests/baselines/reference/exportNestedNamespaces.types index 664429d802ca8..e072d99ae188a 100644 --- a/tests/baselines/reference/exportNestedNamespaces.types +++ b/tests/baselines/reference/exportNestedNamespaces.types @@ -4,7 +4,7 @@ exports.n = {}; >exports.n : typeof n >exports : typeof import("tests/cases/conformance/salsa/mod") >n : typeof n ->{} : { [x: string]: any; } +>{} : {} exports.n.K = function () { >exports.n.K = function () { this.x = 10;} : typeof K diff --git a/tests/baselines/reference/exportNestedNamespaces2.types b/tests/baselines/reference/exportNestedNamespaces2.types index 5d32eb29215e4..ea21edf983f5a 100644 --- a/tests/baselines/reference/exportNestedNamespaces2.types +++ b/tests/baselines/reference/exportNestedNamespaces2.types @@ -1,11 +1,11 @@ === tests/cases/conformance/salsa/mod.js === // Based on a pattern from adonis exports.formatters = {} ->exports.formatters = {} : { [x: string]: any; } ->exports.formatters : { [x: string]: any; } +>exports.formatters = {} : {} +>exports.formatters : {} >exports : typeof import("tests/cases/conformance/salsa/mod") ->formatters : { [x: string]: any; } ->{} : { [x: string]: any; } +>formatters : {} +>{} : {} === tests/cases/conformance/salsa/first.js === exports = require('./mod') @@ -56,18 +56,18 @@ import * as debug from './mod' debug.formatters.j >debug.formatters.j : any ->debug.formatters : { [x: string]: any; } +>debug.formatters : {} >debug : typeof debug ->formatters : { [x: string]: any; } +>formatters : {} >j : any var one = debug.formatters.o(1) >one : any >debug.formatters.o(1) : any >debug.formatters.o : any ->debug.formatters : { [x: string]: any; } +>debug.formatters : {} >debug : typeof debug ->formatters : { [x: string]: any; } +>formatters : {} >o : any >1 : 1 diff --git a/tests/baselines/reference/functionExpressionNames.types b/tests/baselines/reference/functionExpressionNames.types index 66edd4a154b71..c3e09b4ba466f 100644 --- a/tests/baselines/reference/functionExpressionNames.types +++ b/tests/baselines/reference/functionExpressionNames.types @@ -21,8 +21,8 @@ var e = new exports.E(); >E : typeof E var o = { ->o : { [x: string]: any; C: typeof C; } ->{ C: function () { this.c = 'nested object' }} : { [x: string]: any; C: typeof C; } +>o : { C: typeof C; } +>{ C: function () { this.c = 'nested object' }} : { C: typeof C; } C: function () { >C : typeof C @@ -31,7 +31,7 @@ var o = { this.c = 'nested object' >this.c = 'nested object' : "nested object" >this.c : any ->this : { [x: string]: any; C: typeof C; } +>this : { C: typeof C; } >c : any >'nested object' : "nested object" } @@ -40,7 +40,7 @@ var og = new o.C(); >og : C >new o.C() : C >o.C : typeof C ->o : { [x: string]: any; C: typeof C; } +>o : { C: typeof C; } >C : typeof C var V = function () { diff --git a/tests/baselines/reference/jsContainerMergeJsContainer.types b/tests/baselines/reference/jsContainerMergeJsContainer.types index 5759b08561324..73e61aded0df9 100644 --- a/tests/baselines/reference/jsContainerMergeJsContainer.types +++ b/tests/baselines/reference/jsContainerMergeJsContainer.types @@ -2,22 +2,22 @@ // #24131 const a = {}; >a : typeof a ->{} : { [x: string]: any; } +>{} : {} a.d = function() {}; ->a.d = function() {} : { (): void; prototype: { [x: string]: any; }; } ->a.d : { (): void; prototype: { [x: string]: any; }; } +>a.d = function() {} : { (): void; prototype: {}; } +>a.d : { (): void; prototype: {}; } >a : typeof a ->d : { (): void; prototype: { [x: string]: any; }; } ->function() {} : { (): void; prototype: { [x: string]: any; }; } +>d : { (): void; prototype: {}; } +>function() {} : { (): void; prototype: {}; } === tests/cases/conformance/salsa/b.js === a.d.prototype = {}; ->a.d.prototype = {} : { [x: string]: any; } ->a.d.prototype : { [x: string]: any; } ->a.d : { (): void; prototype: { [x: string]: any; }; } +>a.d.prototype = {} : {} +>a.d.prototype : {} +>a.d : { (): void; prototype: {}; } >a : typeof a ->d : { (): void; prototype: { [x: string]: any; }; } ->prototype : { [x: string]: any; } ->{} : { [x: string]: any; } +>d : { (): void; prototype: {}; } +>prototype : {} +>{} : {} diff --git a/tests/baselines/reference/jsContainerMergeTsDeclaration2.types b/tests/baselines/reference/jsContainerMergeTsDeclaration2.types index aec24cb7f5e20..7991487abb3d1 100644 --- a/tests/baselines/reference/jsContainerMergeTsDeclaration2.types +++ b/tests/baselines/reference/jsContainerMergeTsDeclaration2.types @@ -7,11 +7,11 @@ declare namespace C { } === tests/cases/conformance/salsa/b.js === C.prototype = {}; ->C.prototype = {} : { [x: string]: any; } ->C.prototype : { [x: string]: any; } +>C.prototype = {} : {} +>C.prototype : {} >C : typeof C ->prototype : { [x: string]: any; } ->{} : { [x: string]: any; } +>prototype : {} +>{} : {} C.bar = 2; >C.bar = 2 : 2 diff --git a/tests/baselines/reference/jsContainerMergeTsDeclaration3.types b/tests/baselines/reference/jsContainerMergeTsDeclaration3.types index d03c13764e657..11fd9acee9bf8 100644 --- a/tests/baselines/reference/jsContainerMergeTsDeclaration3.types +++ b/tests/baselines/reference/jsContainerMergeTsDeclaration3.types @@ -5,12 +5,12 @@ declare class A {} === tests/cases/conformance/salsa/b.js === const A = { }; >A : typeof A ->{ } : { [x: string]: any; } +>{ } : {} A.d = { }; ->A.d = { } : { [x: string]: any; } ->A.d : { [x: string]: any; } +>A.d = { } : {} +>A.d : {} >A : typeof A ->d : { [x: string]: any; } ->{ } : { [x: string]: any; } +>d : {} +>{ } : {} diff --git a/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.types b/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.types index 08378166f7c7a..dc24aeae8597d 100644 --- a/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.types +++ b/tests/baselines/reference/jsFileClassPropertyInitalizationInObjectLiteral.types @@ -1,16 +1,16 @@ === tests/cases/compiler/foo.js === module.exports = function () { ->module.exports = function () { class A { } return { c: A.b = 1, }} : () => { [x: string]: any; c: number; } ->module.exports : () => { [x: string]: any; c: number; } ->module : { "tests/cases/compiler/foo": () => { [x: string]: any; c: number; }; } ->exports : () => { [x: string]: any; c: number; } ->function () { class A { } return { c: A.b = 1, }} : () => { [x: string]: any; c: number; } +>module.exports = function () { class A { } return { c: A.b = 1, }} : () => { c: number; } +>module.exports : () => { c: number; } +>module : { "tests/cases/compiler/foo": () => { c: number; }; } +>exports : () => { c: number; } +>function () { class A { } return { c: A.b = 1, }} : () => { c: number; } class A { } >A : A return { ->{ c: A.b = 1, } : { [x: string]: any; c: number; } +>{ c: A.b = 1, } : { c: number; } c: A.b = 1, >c : number diff --git a/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.types b/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.types index f4cbef8f7887d..4f59172ff9ace 100644 --- a/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.types +++ b/tests/baselines/reference/jsFileCompilationBindStrictModeErrors.types @@ -3,8 +3,8 @@ >"use strict" : "use strict" var a = { ->a : { [x: string]: any; a: number; b: number; } ->{ a: "hello", // error b: 10, a: 10 // error} : { [x: string]: any; a: number; b: number; } +>a : { a: number; b: number; } +>{ a: "hello", // error b: 10, a: 10 // error} : { a: number; b: number; } a: "hello", // error >a : string @@ -25,7 +25,7 @@ var let = 10; // error delete a; // error >delete a : boolean ->a : { [x: string]: any; a: number; b: number; } +>a : { a: number; b: number; } try { } catch (eval) { // error @@ -36,7 +36,7 @@ function arguments() { // error } with (a) { ->a : { [x: string]: any; a: number; b: number; } +>a : { a: number; b: number; } b = 10; >b = 10 : any diff --git a/tests/baselines/reference/jsFileCompilationShortHandProperty.types b/tests/baselines/reference/jsFileCompilationShortHandProperty.types index d929247ca332c..0cb700b20f57f 100644 --- a/tests/baselines/reference/jsFileCompilationShortHandProperty.types +++ b/tests/baselines/reference/jsFileCompilationShortHandProperty.types @@ -1,6 +1,6 @@ === tests/cases/compiler/a.js === function foo() { ->foo : () => { [x: string]: any; a: number; b: string; } +>foo : () => { a: number; b: string; } var a = 10; >a : number @@ -11,7 +11,7 @@ function foo() { >"Hello" : "Hello" return { ->{ a, b } : { [x: string]: any; a: number; b: string; } +>{ a, b } : { a: number; b: string; } a, >a : number diff --git a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types index 7c17e7c22bbf6..c30a5e99b2af4 100644 --- a/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types +++ b/tests/baselines/reference/jsObjectsMarkedAsOpenEnded.types @@ -1,12 +1,12 @@ === tests/cases/conformance/salsa/a.js === var variable = {}; ->variable : { [x: string]: any; a: number; } ->{} : { [x: string]: any; } +>variable : { a: number; } +>{} : {} variable.a = 0; >variable.a = 0 : 0 >variable.a : number ->variable : { [x: string]: any; a: number; } +>variable : { a: number; } >a : number >0 : 0 @@ -14,57 +14,57 @@ class C { >C : C initializedMember = {}; ->initializedMember : { [x: string]: any; } ->{} : { [x: string]: any; } +>initializedMember : {} +>{} : {} constructor() { this.member = {}; ->this.member = {} : { [x: string]: any; } ->this.member : { [x: string]: any; } +>this.member = {} : {} +>this.member : {} >this : this ->member : { [x: string]: any; } ->{} : { [x: string]: any; } +>member : {} +>{} : {} this.member.a = 0; >this.member.a = 0 : 0 >this.member.a : any ->this.member : { [x: string]: any; } +>this.member : {} >this : this ->member : { [x: string]: any; } +>member : {} >a : any >0 : 0 } } var obj = { ->obj : { [x: string]: any; property: { [x: string]: any; }; } ->{ property: {}} : { [x: string]: any; property: { [x: string]: any; }; } +>obj : { property: {}; } +>{ property: {}} : { property: {}; } property: {} ->property : { [x: string]: any; } ->{} : { [x: string]: any; } +>property : {} +>{} : {} }; obj.property.a = 0; >obj.property.a = 0 : 0 >obj.property.a : any ->obj.property : { [x: string]: any; } ->obj : { [x: string]: any; property: { [x: string]: any; }; } ->property : { [x: string]: any; } +>obj.property : {} +>obj : { property: {}; } +>property : {} >a : any >0 : 0 var arr = [{}]; ->arr : { [x: string]: any; }[] ->[{}] : { [x: string]: any; }[] ->{} : { [x: string]: any; } +>arr : {}[] +>[{}] : {}[] +>{} : {} function getObj() { ->getObj : () => { [x: string]: any; } +>getObj : () => {} return {}; ->{} : { [x: string]: any; } +>{} : {} } @@ -72,46 +72,46 @@ function getObj() { variable.a = 1; >variable.a = 1 : 1 >variable.a : number ->variable : { [x: string]: any; a: number; } +>variable : { a: number; } >a : number >1 : 1 (new C()).member.a = 1; >(new C()).member.a = 1 : 1 >(new C()).member.a : any ->(new C()).member : { [x: string]: any; } +>(new C()).member : {} >(new C()) : C >new C() : C >C : typeof C ->member : { [x: string]: any; } +>member : {} >a : any >1 : 1 (new C()).initializedMember.a = 1; >(new C()).initializedMember.a = 1 : 1 >(new C()).initializedMember.a : any ->(new C()).initializedMember : { [x: string]: any; } +>(new C()).initializedMember : {} >(new C()) : C >new C() : C >C : typeof C ->initializedMember : { [x: string]: any; } +>initializedMember : {} >a : any >1 : 1 obj.property.a = 1; >obj.property.a = 1 : 1 >obj.property.a : any ->obj.property : { [x: string]: any; } ->obj : { [x: string]: any; property: { [x: string]: any; }; } ->property : { [x: string]: any; } +>obj.property : {} +>obj : { property: {}; } +>property : {} >a : any >1 : 1 arr[0].a = 1; >arr[0].a = 1 : 1 >arr[0].a : any ->arr[0] : { [x: string]: any; } ->arr : { [x: string]: any; }[] +>arr[0] : {} +>arr : {}[] >0 : 0 >a : any >1 : 1 @@ -119,8 +119,8 @@ arr[0].a = 1; getObj().a = 1; >getObj().a = 1 : 1 >getObj().a : any ->getObj() : { [x: string]: any; } ->getObj : () => { [x: string]: any; } +>getObj() : {} +>getObj : () => {} >a : any >1 : 1 diff --git a/tests/baselines/reference/jsPropertyAssignedAfterMethodDeclaration.types b/tests/baselines/reference/jsPropertyAssignedAfterMethodDeclaration.types index da04f9caca2f3..de1a96b03514a 100644 --- a/tests/baselines/reference/jsPropertyAssignedAfterMethodDeclaration.types +++ b/tests/baselines/reference/jsPropertyAssignedAfterMethodDeclaration.types @@ -1,7 +1,7 @@ === /a.js === const o = { ->o : { [x: string]: any; a(): void; } ->{ a() { // Should not be treated as a declaration. Should be an error. this.a = 0; }} : { [x: string]: any; a(): void; } +>o : { a(): void; } +>{ a() { // Should not be treated as a declaration. Should be an error. this.a = 0; }} : { a(): void; } a() { >a : () => void @@ -10,7 +10,7 @@ const o = { this.a = 0; >this.a = 0 : 0 >this.a : () => void ->this : { [x: string]: any; a(): void; } +>this : { a(): void; } >a : () => void >0 : 0 } diff --git a/tests/baselines/reference/jsPropertyAssignedAfterMethodDeclaration_nonError.types b/tests/baselines/reference/jsPropertyAssignedAfterMethodDeclaration_nonError.types index 8fed2b3679767..6ec5e02e5e3b1 100644 --- a/tests/baselines/reference/jsPropertyAssignedAfterMethodDeclaration_nonError.types +++ b/tests/baselines/reference/jsPropertyAssignedAfterMethodDeclaration_nonError.types @@ -1,7 +1,7 @@ === /a.js === const o = { ->o : { [x: string]: any; a(): void; } ->{ a() { // Should not be treated as a declaration. this.a = () => {}; }} : { [x: string]: any; a(): void; } +>o : { a(): void; } +>{ a() { // Should not be treated as a declaration. this.a = () => {}; }} : { a(): void; } a() { >a : () => void @@ -10,7 +10,7 @@ const o = { this.a = () => {}; >this.a = () => {} : () => void >this.a : () => void ->this : { [x: string]: any; a(): void; } +>this : { a(): void; } >a : () => void >() => {} : () => void } diff --git a/tests/baselines/reference/jsdocTemplateTag2.types b/tests/baselines/reference/jsdocTemplateTag2.types index d35724fb9b690..e81a6377d6892 100644 --- a/tests/baselines/reference/jsdocTemplateTag2.types +++ b/tests/baselines/reference/jsdocTemplateTag2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/github17339.js === var obj = { ->obj : { [x: string]: any; x: (a: T) => T; } ->{ /** * @template T * @param {T} a * @returns {T} */ x: function (a) { return a; },} : { [x: string]: any; x: (a: T) => T; } +>obj : { x: (a: T) => T; } +>{ /** * @template T * @param {T} a * @returns {T} */ x: function (a) { return a; },} : { x: (a: T) => T; } /** * @template T diff --git a/tests/baselines/reference/moduleExportAlias3.types b/tests/baselines/reference/moduleExportAlias3.types index 23994aeca175f..1d21df40eab59 100644 --- a/tests/baselines/reference/moduleExportAlias3.types +++ b/tests/baselines/reference/moduleExportAlias3.types @@ -4,11 +4,11 @@ class C { >C : C } module.exports = { ->module.exports = { C} : { [x: string]: any; C: typeof C; } ->module.exports : { [x: string]: any; C: typeof C; } ->module : { "tests/cases/conformance/salsa/bug24062": { [x: string]: any; C: typeof C; }; } ->exports : { [x: string]: any; C: typeof C; } ->{ C} : { [x: string]: any; C: typeof C; } +>module.exports = { C} : { C: typeof C; } +>module.exports : { C: typeof C; } +>module : { "tests/cases/conformance/salsa/bug24062": { C: typeof C; }; } +>exports : { C: typeof C; } +>{ C} : { C: typeof C; } C >C : typeof C diff --git a/tests/baselines/reference/moduleExportAssignment4.types b/tests/baselines/reference/moduleExportAssignment4.types index 56e0e6463813c..64f25db234f72 100644 --- a/tests/baselines/reference/moduleExportAssignment4.types +++ b/tests/baselines/reference/moduleExportAssignment4.types @@ -1,10 +1,10 @@ === tests/cases/conformance/salsa/async.js === exports.default = { m: 1, a: 1 } ->exports.default = { m: 1, a: 1 } : { [x: string]: any; m: number; a: number; } +>exports.default = { m: 1, a: 1 } : { m: number; a: number; } >exports.default : any >exports : any >default : any ->{ m: 1, a: 1 } : { [x: string]: any; m: number; a: number; } +>{ m: 1, a: 1 } : { m: number; a: number; } >m : number >1 : 1 >a : number diff --git a/tests/baselines/reference/moduleExportNestedNamespaces.types b/tests/baselines/reference/moduleExportNestedNamespaces.types index 0267a4a4f9709..31309b7b3cdc9 100644 --- a/tests/baselines/reference/moduleExportNestedNamespaces.types +++ b/tests/baselines/reference/moduleExportNestedNamespaces.types @@ -6,7 +6,7 @@ module.exports.n = {}; >module : { "tests/cases/conformance/salsa/mod": typeof import("tests/cases/conformance/salsa/mod"); } >exports : typeof import("tests/cases/conformance/salsa/mod") >n : typeof n ->{} : { [x: string]: any; } +>{} : {} module.exports.n.K = function C() { >module.exports.n.K = function C() { this.x = 10;} : typeof C diff --git a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types index a65961e4daa1d..05d88c53cb064 100644 --- a/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types +++ b/tests/baselines/reference/moduleExportPropertyAssignmentDefault.types @@ -1,21 +1,21 @@ === tests/cases/conformance/salsa/axios.js === var axios = {} ->axios : { [x: string]: any; default: { [x: string]: any; default: any; }; } ->{} : { [x: string]: any; } +>axios : { default: { default: any; }; } +>{} : {} module.exports = axios // both assignments should be ok ->module.exports = axios : { [x: string]: any; default: any; } ->module.exports : { [x: string]: any; default: any; } ->module : { "tests/cases/conformance/salsa/axios": { [x: string]: any; default: any; }; } ->exports : { [x: string]: any; default: any; } ->axios : { [x: string]: any; default: { [x: string]: any; default: any; }; } +>module.exports = axios : { default: any; } +>module.exports : { default: any; } +>module : { "tests/cases/conformance/salsa/axios": { default: any; }; } +>exports : { default: any; } +>axios : { default: { default: any; }; } module.exports.default = axios ->module.exports.default = axios : { [x: string]: any; default: { [x: string]: any; default: any; }; } ->module.exports.default : { [x: string]: any; default: any; } ->module.exports : { [x: string]: any; default: any; } ->module : { "tests/cases/conformance/salsa/axios": { [x: string]: any; default: any; }; } ->exports : { [x: string]: any; default: any; } ->default : { [x: string]: any; default: any; } ->axios : { [x: string]: any; default: { [x: string]: any; default: any; }; } +>module.exports.default = axios : { default: { default: any; }; } +>module.exports.default : { default: any; } +>module.exports : { default: any; } +>module : { "tests/cases/conformance/salsa/axios": { default: any; }; } +>exports : { default: any; } +>default : { default: any; } +>axios : { default: { default: any; }; } diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.types b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.types index 71b7dbe7089c7..90729191313ad 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.types +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment3.types @@ -1,8 +1,8 @@ === tests/cases/conformance/salsa/a.js === /// var mod1 = require('./mod1') ->mod1 : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } ->require('./mod1') : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>require('./mod1') : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >require : (name: string) => any >'./mod1' : "./mod1" @@ -10,7 +10,7 @@ mod1.justExport.toFixed() >mod1.justExport.toFixed() : string >mod1.justExport.toFixed : (fractionDigits?: number) => string >mod1.justExport : number ->mod1 : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >justExport : number >toFixed : (fractionDigits?: number) => string @@ -18,7 +18,7 @@ mod1.bothBefore.toFixed() // error, 'toFixed' not on 'string | number' >mod1.bothBefore.toFixed() : any >mod1.bothBefore.toFixed : any >mod1.bothBefore : string | number ->mod1 : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >bothBefore : string | number >toFixed : any @@ -26,14 +26,14 @@ mod1.bothAfter.toFixed() // error, 'toFixed' not on 'string | number' >mod1.bothAfter.toFixed() : any >mod1.bothAfter.toFixed : any >mod1.bothAfter : string | number ->mod1 : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >bothAfter : string | number >toFixed : any mod1.justProperty.length >mod1.justProperty.length : number >mod1.justProperty : string ->mod1 : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>mod1 : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >justProperty : string >length : number @@ -51,18 +51,18 @@ declare function require(name: string): any; module.exports.bothBefore = 'string' >module.exports.bothBefore = 'string' : "string" >module.exports.bothBefore : string | number ->module.exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } ->module : { "tests/cases/conformance/salsa/mod1": { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } ->exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module.exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module : { "tests/cases/conformance/salsa/mod1": { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } +>exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >bothBefore : string | number >'string' : "string" module.exports = { ->module.exports = { justExport: 1, bothBefore: 2, bothAfter: 3,} : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } ->module.exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } ->module : { "tests/cases/conformance/salsa/mod1": { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } ->exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } ->{ justExport: 1, bothBefore: 2, bothAfter: 3,} : { [x: string]: any; justExport: number; bothBefore: number; bothAfter: number; } +>module.exports = { justExport: 1, bothBefore: 2, bothAfter: 3,} : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module.exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module : { "tests/cases/conformance/salsa/mod1": { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } +>exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>{ justExport: 1, bothBefore: 2, bothAfter: 3,} : { justExport: number; bothBefore: number; bothAfter: number; } justExport: 1, >justExport : number @@ -79,18 +79,18 @@ module.exports = { module.exports.bothAfter = 'string' >module.exports.bothAfter = 'string' : "string" >module.exports.bothAfter : string | number ->module.exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } ->module : { "tests/cases/conformance/salsa/mod1": { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } ->exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module.exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module : { "tests/cases/conformance/salsa/mod1": { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } +>exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >bothAfter : string | number >'string' : "string" module.exports.justProperty = 'string' >module.exports.justProperty = 'string' : "string" >module.exports.justProperty : string ->module.exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } ->module : { "tests/cases/conformance/salsa/mod1": { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } ->exports : { [x: string]: any; justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module.exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } +>module : { "tests/cases/conformance/salsa/mod1": { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; }; } +>exports : { justExport: number; bothBefore: string | number; bothAfter: string | number; justProperty: string; } >justProperty : string >'string' : "string" diff --git a/tests/baselines/reference/nestedPrototypeAssignment.types b/tests/baselines/reference/nestedPrototypeAssignment.types index 1ac8ea1ad0328..c87ba39c50eee 100644 --- a/tests/baselines/reference/nestedPrototypeAssignment.types +++ b/tests/baselines/reference/nestedPrototypeAssignment.types @@ -5,16 +5,16 @@ C.prototype = {} >C.prototype : typeof C.prototype >C : typeof C >prototype : typeof C.prototype ->{} : { [x: string]: any; } +>{} : {} C.prototype.bar.foo = {}; ->C.prototype.bar.foo = {} : { [x: string]: any; } ->C.prototype.bar.foo : { [x: string]: any; } +>C.prototype.bar.foo = {} : {} +>C.prototype.bar.foo : {} >C.prototype.bar : typeof C.prototype.bar >C.prototype : typeof C.prototype >C : typeof C >prototype : typeof C.prototype >bar : typeof C.prototype.bar ->foo : { [x: string]: any; } ->{} : { [x: string]: any; } +>foo : {} +>{} : {} diff --git a/tests/baselines/reference/propertyAssignmentOnImportedSymbol.types b/tests/baselines/reference/propertyAssignmentOnImportedSymbol.types index c14617911d1fc..8df4f984574a8 100644 --- a/tests/baselines/reference/propertyAssignmentOnImportedSymbol.types +++ b/tests/baselines/reference/propertyAssignmentOnImportedSymbol.types @@ -1,16 +1,16 @@ === tests/cases/conformance/salsa/mod1.js === export var hurk = {} ->hurk : { [x: string]: any; } ->{} : { [x: string]: any; } +>hurk : {} +>{} : {} === tests/cases/conformance/salsa/bug24658.js === import { hurk } from './mod1' ->hurk : { [x: string]: any; } +>hurk : {} hurk.expando = 4 >hurk.expando = 4 : 4 >hurk.expando : any ->hurk : { [x: string]: any; } +>hurk : {} >expando : any >4 : 4 diff --git a/tests/baselines/reference/thisTag1.types b/tests/baselines/reference/thisTag1.types index 1ef6ae8d28f5a..1a20b8dc53757 100644 --- a/tests/baselines/reference/thisTag1.types +++ b/tests/baselines/reference/thisTag1.types @@ -18,8 +18,8 @@ function f(s) { } const o = { ->o : { [x: string]: any; f: (s: string) => number; n: number; } ->{ f, n: 1} : { [x: string]: any; f: (s: string) => number; n: number; } +>o : { f: (s: string) => number; n: number; } +>{ f, n: 1} : { f: (s: string) => number; n: number; } f, >f : (s: string) => number @@ -31,7 +31,7 @@ const o = { o.f('hi') >o.f('hi') : number >o.f : (s: string) => number ->o : { [x: string]: any; f: (s: string) => number; n: number; } +>o : { f: (s: string) => number; n: number; } >f : (s: string) => number >'hi' : "hi" diff --git a/tests/baselines/reference/typeFromJSInitializer.types b/tests/baselines/reference/typeFromJSInitializer.types index 747c562b9766d..39bc8a9214633 100644 --- a/tests/baselines/reference/typeFromJSInitializer.types +++ b/tests/baselines/reference/typeFromJSInitializer.types @@ -44,11 +44,11 @@ a.unknown = true >true : true a.unknown = {} ->a.unknown = {} : { [x: string]: any; } +>a.unknown = {} : {} >a.unknown : any >a : A >unknown : any ->{} : { [x: string]: any; } +>{} : {} a.unknown = 'hi' >a.unknown = 'hi' : "hi" @@ -72,11 +72,11 @@ a.unknowable = true >true : true a.unknowable = {} ->a.unknowable = {} : { [x: string]: any; } +>a.unknowable = {} : {} >a.unknowable : any >a : A >unknowable : any ->{} : { [x: string]: any; } +>{} : {} a.unknowable = 'hi' >a.unknowable = 'hi' : "hi" diff --git a/tests/baselines/reference/typeFromPropertyAssignment10.types b/tests/baselines/reference/typeFromPropertyAssignment10.types index 86c525ac96174..f78a4b22c54ef 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment10.types +++ b/tests/baselines/reference/typeFromPropertyAssignment10.types @@ -1,20 +1,20 @@ === tests/cases/conformance/salsa/module.js === var Outer = Outer || {}; >Outer : typeof Outer ->Outer || {} : typeof Outer | { [x: string]: any; } +>Outer || {} : typeof Outer | {} >Outer : typeof Outer ->{} : { [x: string]: any; } +>{} : {} Outer.app = Outer.app || {}; >Outer.app = Outer.app || {} : typeof Outer.app >Outer.app : typeof Outer.app >Outer : typeof Outer >app : typeof Outer.app ->Outer.app || {} : { [x: string]: any; } +>Outer.app || {} : {} >Outer.app : typeof Outer.app >Outer : typeof Outer >app : typeof Outer.app ->{} : { [x: string]: any; } +>{} : {} === tests/cases/conformance/salsa/someview.js === Outer.app.SomeView = (function () { diff --git a/tests/baselines/reference/typeFromPropertyAssignment11.types b/tests/baselines/reference/typeFromPropertyAssignment11.types index 8c90e824f23c5..001003ac76e5e 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment11.types +++ b/tests/baselines/reference/typeFromPropertyAssignment11.types @@ -4,11 +4,11 @@ var Inner = function() {} >function() {} : typeof Inner Inner.prototype = { ->Inner.prototype = { m() { }, i: 1} : { [x: string]: any; m(): void; i: number; } ->Inner.prototype : { [x: string]: any; m(): void; i: number; } +>Inner.prototype = { m() { }, i: 1} : { m(): void; i: number; } +>Inner.prototype : { m(): void; i: number; } >Inner : typeof Inner ->prototype : { [x: string]: any; m(): void; i: number; } ->{ m() { }, i: 1} : { [x: string]: any; m(): void; i: number; } +>prototype : { m(): void; i: number; } +>{ m() { }, i: 1} : { m(): void; i: number; } m() { }, >m : () => void @@ -21,43 +21,43 @@ Inner.prototype = { Inner.prototype.j = 2 >Inner.prototype.j = 2 : 2 >Inner.prototype.j : any ->Inner.prototype : { [x: string]: any; m(): void; i: number; } +>Inner.prototype : { m(): void; i: number; } >Inner : typeof Inner ->prototype : { [x: string]: any; m(): void; i: number; } +>prototype : { m(): void; i: number; } >j : any >2 : 2 /** @type {string} */ Inner.prototype.k; >Inner.prototype.k : any ->Inner.prototype : { [x: string]: any; m(): void; i: number; } +>Inner.prototype : { m(): void; i: number; } >Inner : typeof Inner ->prototype : { [x: string]: any; m(): void; i: number; } +>prototype : { m(): void; i: number; } >k : any var inner = new Inner() ->inner : Inner & { [x: string]: any; m(): void; i: number; } ->new Inner() : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } +>new Inner() : Inner & { m(): void; i: number; } >Inner : typeof Inner inner.m() >inner.m() : void >inner.m : () => void ->inner : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } >m : () => void inner.i >inner.i : number ->inner : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } >i : number inner.j >inner.j : number ->inner : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } >j : number inner.k >inner.k : string ->inner : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } >k : string diff --git a/tests/baselines/reference/typeFromPropertyAssignment13.types b/tests/baselines/reference/typeFromPropertyAssignment13.types index f85325a60a22c..051b066ffd834 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment13.types +++ b/tests/baselines/reference/typeFromPropertyAssignment13.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/module.js === var Outer = {} >Outer : typeof Outer ->{} : { [x: string]: any; } +>{} : {} Outer.Inner = function() {} >Outer.Inner = function() {} : typeof Inner @@ -11,13 +11,13 @@ Outer.Inner = function() {} >function() {} : typeof Inner Outer.Inner.prototype = { ->Outer.Inner.prototype = { m() { }, i: 1} : { [x: string]: any; m(): void; i: number; } ->Outer.Inner.prototype : { [x: string]: any; m(): void; i: number; } +>Outer.Inner.prototype = { m() { }, i: 1} : { m(): void; i: number; } +>Outer.Inner.prototype : { m(): void; i: number; } >Outer.Inner : typeof Inner >Outer : typeof Outer >Inner : typeof Inner ->prototype : { [x: string]: any; m(): void; i: number; } ->{ m() { }, i: 1} : { [x: string]: any; m(): void; i: number; } +>prototype : { m(): void; i: number; } +>{ m() { }, i: 1} : { m(): void; i: number; } m() { }, >m : () => void @@ -30,27 +30,27 @@ Outer.Inner.prototype = { Outer.Inner.prototype.j = 2 >Outer.Inner.prototype.j = 2 : 2 >Outer.Inner.prototype.j : any ->Outer.Inner.prototype : { [x: string]: any; m(): void; i: number; } +>Outer.Inner.prototype : { m(): void; i: number; } >Outer.Inner : typeof Inner >Outer : typeof Outer >Inner : typeof Inner ->prototype : { [x: string]: any; m(): void; i: number; } +>prototype : { m(): void; i: number; } >j : any >2 : 2 /** @type {string} */ Outer.Inner.prototype.k; >Outer.Inner.prototype.k : any ->Outer.Inner.prototype : { [x: string]: any; m(): void; i: number; } +>Outer.Inner.prototype : { m(): void; i: number; } >Outer.Inner : typeof Inner >Outer : typeof Outer >Inner : typeof Inner ->prototype : { [x: string]: any; m(): void; i: number; } +>prototype : { m(): void; i: number; } >k : any var inner = new Outer.Inner() ->inner : Inner & { [x: string]: any; m(): void; i: number; } ->new Outer.Inner() : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } +>new Outer.Inner() : Inner & { m(): void; i: number; } >Outer.Inner : typeof Inner >Outer : typeof Outer >Inner : typeof Inner @@ -58,21 +58,21 @@ var inner = new Outer.Inner() inner.m() >inner.m() : void >inner.m : () => void ->inner : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } >m : () => void inner.i >inner.i : number ->inner : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } >i : number inner.j >inner.j : number ->inner : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } >j : number inner.k >inner.k : string ->inner : Inner & { [x: string]: any; m(): void; i: number; } +>inner : Inner & { m(): void; i: number; } >k : string diff --git a/tests/baselines/reference/typeFromPropertyAssignment14.types b/tests/baselines/reference/typeFromPropertyAssignment14.types index a20a5a15fc3c6..bc1b2a69be9b0 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment14.types +++ b/tests/baselines/reference/typeFromPropertyAssignment14.types @@ -1,24 +1,24 @@ === tests/cases/conformance/salsa/def.js === var Outer = {}; >Outer : typeof Outer ->{} : { [x: string]: any; } +>{} : {} === tests/cases/conformance/salsa/work.js === Outer.Inner = function () {} ->Outer.Inner = function () {} : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } ->Outer.Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>Outer.Inner = function () {} : { (): void; prototype: { x: number; m(): void; }; } +>Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } >Outer : typeof Outer ->Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } ->function () {} : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>Inner : { (): void; prototype: { x: number; m(): void; }; } +>function () {} : { (): void; prototype: { x: number; m(): void; }; } Outer.Inner.prototype = { ->Outer.Inner.prototype = { x: 1, m() { }} : { [x: string]: any; x: number; m(): void; } ->Outer.Inner.prototype : { [x: string]: any; x: number; m(): void; } ->Outer.Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>Outer.Inner.prototype = { x: 1, m() { }} : { x: number; m(): void; } +>Outer.Inner.prototype : { x: number; m(): void; } +>Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } >Outer : typeof Outer ->Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } ->prototype : { [x: string]: any; x: number; m(): void; } ->{ x: 1, m() { }} : { [x: string]: any; x: number; m(): void; } +>Inner : { (): void; prototype: { x: number; m(): void; }; } +>prototype : { x: number; m(): void; } +>{ x: 1, m() { }} : { x: number; m(): void; } x: 1, >x : number @@ -31,35 +31,35 @@ Outer.Inner.prototype = { === tests/cases/conformance/salsa/use.js === /** @type {Outer.Inner} */ var inner ->inner : { [x: string]: any; x: number; m(): void; } +>inner : { x: number; m(): void; } inner.x >inner.x : number ->inner : { [x: string]: any; x: number; m(): void; } +>inner : { x: number; m(): void; } >x : number inner.m() >inner.m() : void >inner.m : () => void ->inner : { [x: string]: any; x: number; m(): void; } +>inner : { x: number; m(): void; } >m : () => void var inno = new Outer.Inner() ->inno : { [x: string]: any; x: number; m(): void; } ->new Outer.Inner() : { [x: string]: any; x: number; m(): void; } ->Outer.Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>inno : { x: number; m(): void; } +>new Outer.Inner() : { x: number; m(): void; } +>Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } >Outer : typeof Outer ->Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>Inner : { (): void; prototype: { x: number; m(): void; }; } inno.x >inno.x : number ->inno : { [x: string]: any; x: number; m(): void; } +>inno : { x: number; m(): void; } >x : number inno.m() >inno.m() : void >inno.m : () => void ->inno : { [x: string]: any; x: number; m(): void; } +>inno : { x: number; m(): void; } >m : () => void diff --git a/tests/baselines/reference/typeFromPropertyAssignment15.types b/tests/baselines/reference/typeFromPropertyAssignment15.types index 8731d8dee4e19..e1573a21e758b 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment15.types +++ b/tests/baselines/reference/typeFromPropertyAssignment15.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/a.js === var Outer = {}; >Outer : typeof Outer ->{} : { [x: string]: any; } +>{} : {} Outer.Inner = class { >Outer.Inner = class { constructor() { this.x = 1 } m() { }} : typeof Inner diff --git a/tests/baselines/reference/typeFromPropertyAssignment16.types b/tests/baselines/reference/typeFromPropertyAssignment16.types index ce0ae3ae16e23..f2cb476e5fa30 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment16.types +++ b/tests/baselines/reference/typeFromPropertyAssignment16.types @@ -1,23 +1,23 @@ === tests/cases/conformance/salsa/a.js === var Outer = {}; >Outer : typeof Outer ->{} : { [x: string]: any; } +>{} : {} Outer.Inner = function () {} ->Outer.Inner = function () {} : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } ->Outer.Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>Outer.Inner = function () {} : { (): void; prototype: { x: number; m(): void; }; } +>Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } >Outer : typeof Outer ->Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } ->function () {} : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>Inner : { (): void; prototype: { x: number; m(): void; }; } +>function () {} : { (): void; prototype: { x: number; m(): void; }; } Outer.Inner.prototype = { ->Outer.Inner.prototype = { x: 1, m() { }} : { [x: string]: any; x: number; m(): void; } ->Outer.Inner.prototype : { [x: string]: any; x: number; m(): void; } ->Outer.Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>Outer.Inner.prototype = { x: 1, m() { }} : { x: number; m(): void; } +>Outer.Inner.prototype : { x: number; m(): void; } +>Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } >Outer : typeof Outer ->Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } ->prototype : { [x: string]: any; x: number; m(): void; } ->{ x: 1, m() { }} : { [x: string]: any; x: number; m(): void; } +>Inner : { (): void; prototype: { x: number; m(): void; }; } +>prototype : { x: number; m(): void; } +>{ x: 1, m() { }} : { x: number; m(): void; } x: 1, >x : number @@ -29,34 +29,34 @@ Outer.Inner.prototype = { /** @type {Outer.Inner} */ var inner ->inner : { [x: string]: any; x: number; m(): void; } +>inner : { x: number; m(): void; } inner.x >inner.x : number ->inner : { [x: string]: any; x: number; m(): void; } +>inner : { x: number; m(): void; } >x : number inner.m() >inner.m() : void >inner.m : () => void ->inner : { [x: string]: any; x: number; m(): void; } +>inner : { x: number; m(): void; } >m : () => void var inno = new Outer.Inner() ->inno : { [x: string]: any; x: number; m(): void; } ->new Outer.Inner() : { [x: string]: any; x: number; m(): void; } ->Outer.Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>inno : { x: number; m(): void; } +>new Outer.Inner() : { x: number; m(): void; } +>Outer.Inner : { (): void; prototype: { x: number; m(): void; }; } >Outer : typeof Outer ->Inner : { (): void; prototype: { [x: string]: any; x: number; m(): void; }; } +>Inner : { (): void; prototype: { x: number; m(): void; }; } inno.x >inno.x : number ->inno : { [x: string]: any; x: number; m(): void; } +>inno : { x: number; m(): void; } >x : number inno.m() >inno.m() : void >inno.m : () => void ->inno : { [x: string]: any; x: number; m(): void; } +>inno : { x: number; m(): void; } >m : () => void diff --git a/tests/baselines/reference/typeFromPropertyAssignment18.types b/tests/baselines/reference/typeFromPropertyAssignment18.types index 94f859426022e..6973115a0f8a5 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment18.types +++ b/tests/baselines/reference/typeFromPropertyAssignment18.types @@ -1,52 +1,52 @@ === tests/cases/conformance/salsa/a.js === var GLOBSTAR = m.GLOBSTAR = {} ->GLOBSTAR : { [x: string]: any; q: number; p: number; } ->m.GLOBSTAR = {} : { [x: string]: any; q: number; p: number; } ->m.GLOBSTAR : { [x: string]: any; q: number; p: number; } ->m : { (): void; GLOBSTAR: { [x: string]: any; q: number; p: number; }; } ->GLOBSTAR : { [x: string]: any; q: number; p: number; } ->{} : { [x: string]: any; } +>GLOBSTAR : { q: number; p: number; } +>m.GLOBSTAR = {} : { q: number; p: number; } +>m.GLOBSTAR : { q: number; p: number; } +>m : { (): void; GLOBSTAR: { q: number; p: number; }; } +>GLOBSTAR : { q: number; p: number; } +>{} : {} function m() { ->m : { (): void; GLOBSTAR: { [x: string]: any; q: number; p: number; }; } +>m : { (): void; GLOBSTAR: { q: number; p: number; }; } } GLOBSTAR.p = 1 >GLOBSTAR.p = 1 : 1 >GLOBSTAR.p : number ->GLOBSTAR : { [x: string]: any; q: number; p: number; } +>GLOBSTAR : { q: number; p: number; } >p : number >1 : 1 m.GLOBSTAR.q = 2 >m.GLOBSTAR.q = 2 : 2 >m.GLOBSTAR.q : number ->m.GLOBSTAR : { [x: string]: any; q: number; p: number; } ->m : { (): void; GLOBSTAR: { [x: string]: any; q: number; p: number; }; } ->GLOBSTAR : { [x: string]: any; q: number; p: number; } +>m.GLOBSTAR : { q: number; p: number; } +>m : { (): void; GLOBSTAR: { q: number; p: number; }; } +>GLOBSTAR : { q: number; p: number; } >q : number >2 : 2 GLOBSTAR.p >GLOBSTAR.p : number ->GLOBSTAR : { [x: string]: any; q: number; p: number; } +>GLOBSTAR : { q: number; p: number; } >p : number GLOBSTAR.q >GLOBSTAR.q : number ->GLOBSTAR : { [x: string]: any; q: number; p: number; } +>GLOBSTAR : { q: number; p: number; } >q : number m.GLOBSTAR.p >m.GLOBSTAR.p : number ->m.GLOBSTAR : { [x: string]: any; q: number; p: number; } ->m : { (): void; GLOBSTAR: { [x: string]: any; q: number; p: number; }; } ->GLOBSTAR : { [x: string]: any; q: number; p: number; } +>m.GLOBSTAR : { q: number; p: number; } +>m : { (): void; GLOBSTAR: { q: number; p: number; }; } +>GLOBSTAR : { q: number; p: number; } >p : number m.GLOBSTAR.q >m.GLOBSTAR.q : number ->m.GLOBSTAR : { [x: string]: any; q: number; p: number; } ->m : { (): void; GLOBSTAR: { [x: string]: any; q: number; p: number; }; } ->GLOBSTAR : { [x: string]: any; q: number; p: number; } +>m.GLOBSTAR : { q: number; p: number; } +>m : { (): void; GLOBSTAR: { q: number; p: number; }; } +>GLOBSTAR : { q: number; p: number; } >q : number diff --git a/tests/baselines/reference/typeFromPropertyAssignment24.types b/tests/baselines/reference/typeFromPropertyAssignment24.types index a8d1760c5ea1f..38a8af5602820 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment24.types +++ b/tests/baselines/reference/typeFromPropertyAssignment24.types @@ -35,7 +35,7 @@ x.name === tests/cases/conformance/salsa/def.js === var Outer = {} >Outer : typeof Outer ->{} : { [x: string]: any; } +>{} : {} Outer.Inner = class { >Outer.Inner = class { name() { return 'hi' }} : typeof Inner diff --git a/tests/baselines/reference/typeFromPropertyAssignment25.types b/tests/baselines/reference/typeFromPropertyAssignment25.types index 13fae2c861f07..d27b4a70165c2 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment25.types +++ b/tests/baselines/reference/typeFromPropertyAssignment25.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/bug24703.js === var Common = {}; >Common : typeof Common ->{} : { [x: string]: any; } +>{} : {} Common.I = class { >Common.I = class { constructor() { this.i = 1 }} : typeof I diff --git a/tests/baselines/reference/typeFromPropertyAssignment26.types b/tests/baselines/reference/typeFromPropertyAssignment26.types index d40ca74137287..a6bc478348842 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment26.types +++ b/tests/baselines/reference/typeFromPropertyAssignment26.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/bug24730.js === var UI = {} >UI : typeof UI ->{} : { [x: string]: any; } +>{} : {} UI.TreeElement = class { >UI.TreeElement = class { constructor() { this.treeOutline = 12 }} : typeof TreeElement diff --git a/tests/baselines/reference/typeFromPropertyAssignment27.types b/tests/baselines/reference/typeFromPropertyAssignment27.types index dcaefe7a95575..b7c3557c86edc 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment27.types +++ b/tests/baselines/reference/typeFromPropertyAssignment27.types @@ -9,26 +9,26 @@ function C() { this.p = 1; } >1 : 1 C.prototype = { q: 2 }; ->C.prototype = { q: 2 } : { [x: string]: any; q: number; } ->C.prototype : { [x: string]: any; q: number; } +>C.prototype = { q: 2 } : { q: number; } +>C.prototype : { q: number; } >C : typeof C ->prototype : { [x: string]: any; q: number; } ->{ q: 2 } : { [x: string]: any; q: number; } +>prototype : { q: number; } +>{ q: 2 } : { q: number; } >q : number >2 : 2 const c = new C() ->c : C & { [x: string]: any; q: number; } ->new C() : C & { [x: string]: any; q: number; } +>c : C & { q: number; } +>new C() : C & { q: number; } >C : typeof C c.p >c.p : number ->c : C & { [x: string]: any; q: number; } +>c : C & { q: number; } >p : number c.q >c.q : number ->c : C & { [x: string]: any; q: number; } +>c : C & { q: number; } >q : number diff --git a/tests/baselines/reference/typeFromPropertyAssignment28.errors.txt b/tests/baselines/reference/typeFromPropertyAssignment28.errors.txt index 2f048840a1edb..3fb90fc92f426 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment28.errors.txt +++ b/tests/baselines/reference/typeFromPropertyAssignment28.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/salsa/a.js(7,17): error TS2322: Type '{ [x: string]: any; q: number; }' is not assignable to type 'C'. +tests/cases/conformance/salsa/a.js(7,17): error TS2322: Type '{ q: number; }' is not assignable to type 'C'. Object literal may only specify known properties, and 'q' does not exist in type 'C'. tests/cases/conformance/salsa/a.js(11,3): error TS2339: Property 'q' does not exist on type 'C'. @@ -12,7 +12,7 @@ tests/cases/conformance/salsa/a.js(11,3): error TS2339: Property 'q' does not ex // (Object.defineProperty isn't recognised as a JS special assignment right now.) C.prototype = { q: 2 }; ~~~~ -!!! error TS2322: Type '{ [x: string]: any; q: number; }' is not assignable to type 'C'. +!!! error TS2322: Type '{ q: number; }' is not assignable to type 'C'. !!! error TS2322: Object literal may only specify known properties, and 'q' does not exist in type 'C'. const c = new C() diff --git a/tests/baselines/reference/typeFromPropertyAssignment28.types b/tests/baselines/reference/typeFromPropertyAssignment28.types index 89056ee139850..dc25e6426be5c 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment28.types +++ b/tests/baselines/reference/typeFromPropertyAssignment28.types @@ -13,11 +13,11 @@ class C { constructor() { this.p = 1; } } // and that only works on classes with no superclass. // (Object.defineProperty isn't recognised as a JS special assignment right now.) C.prototype = { q: 2 }; ->C.prototype = { q: 2 } : { [x: string]: any; q: number; } +>C.prototype = { q: 2 } : { q: number; } >C.prototype : C >C : typeof C >prototype : C ->{ q: 2 } : { [x: string]: any; q: number; } +>{ q: 2 } : { q: number; } >q : number >2 : 2 diff --git a/tests/baselines/reference/typeFromPropertyAssignment4.types b/tests/baselines/reference/typeFromPropertyAssignment4.types index 612a0f696e103..d4ad58f296ede 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment4.types +++ b/tests/baselines/reference/typeFromPropertyAssignment4.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/def.js === var Outer = {}; >Outer : typeof Outer ->{} : { [x: string]: any; } +>{} : {} === tests/cases/conformance/salsa/a.js === Outer.Inner = class { diff --git a/tests/baselines/reference/typeFromPropertyAssignment7.types b/tests/baselines/reference/typeFromPropertyAssignment7.types index 395dbee2c418d..5447fdf9713e5 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment7.types +++ b/tests/baselines/reference/typeFromPropertyAssignment7.types @@ -1,7 +1,7 @@ === tests/cases/conformance/salsa/a.js === var obj = {}; >obj : typeof obj ->{} : { [x: string]: any; } +>{} : {} obj.method = function (hunch) { >obj.method = function (hunch) { return true;} : (hunch: any) => boolean diff --git a/tests/baselines/reference/typeFromPropertyAssignment8.types b/tests/baselines/reference/typeFromPropertyAssignment8.types index 8aa93afb463c9..c3cf6ed9121d0 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment8.types +++ b/tests/baselines/reference/typeFromPropertyAssignment8.types @@ -1,20 +1,20 @@ === tests/cases/conformance/salsa/a.js === var my = my || {}; >my : typeof my ->my || {} : typeof my | { [x: string]: any; } +>my || {} : typeof my | {} >my : typeof my ->{} : { [x: string]: any; } +>{} : {} my.app = my.app || {}; >my.app = my.app || {} : typeof my.app >my.app : typeof my.app >my : typeof my >app : typeof my.app ->my.app || {} : { [x: string]: any; } +>my.app || {} : {} >my.app : typeof my.app >my : typeof my >app : typeof my.app ->{} : { [x: string]: any; } +>{} : {} my.app.Application = (function () { >my.app.Application = (function () {var Application = function () { //...};return Application;})() : () => void @@ -52,18 +52,18 @@ var min = window.min || {}; >window.min : any >window : Window >min : any ->{} : { [x: string]: any; } +>{} : {} min.app = min.app || {}; >min.app = min.app || {} : typeof min.app >min.app : typeof min.app >min : typeof min >app : typeof min.app ->min.app || {} : { [x: string]: any; } +>min.app || {} : {} >min.app : typeof min.app >min : typeof min >app : typeof min.app ->{} : { [x: string]: any; } +>{} : {} min.app.Application = (function () { >min.app.Application = (function () {var Application = function () { //...};return Application;})() : () => void diff --git a/tests/baselines/reference/typeFromPropertyAssignment9.types b/tests/baselines/reference/typeFromPropertyAssignment9.types index e9212f950678d..88b9a862c7ec3 100644 --- a/tests/baselines/reference/typeFromPropertyAssignment9.types +++ b/tests/baselines/reference/typeFromPropertyAssignment9.types @@ -1,9 +1,9 @@ === tests/cases/conformance/salsa/a.js === var my = my || {}; >my : typeof my ->my || {} : typeof my | { [x: string]: any; } +>my || {} : typeof my | {} >my : typeof my ->{} : { [x: string]: any; } +>{} : {} /** @param {number} n */ my.method = function(n) { @@ -27,22 +27,22 @@ my.number = 1; >1 : 1 my.object = {}; ->my.object = {} : { [x: string]: any; } ->my.object : { [x: string]: any; } +>my.object = {} : {} +>my.object : {} >my : typeof my ->object : { [x: string]: any; } ->{} : { [x: string]: any; } +>object : {} +>{} : {} my.predicate = my.predicate || {}; >my.predicate = my.predicate || {} : typeof my.predicate >my.predicate : typeof my.predicate >my : typeof my >predicate : typeof my.predicate ->my.predicate || {} : { [x: string]: any; } +>my.predicate || {} : {} >my.predicate : typeof my.predicate >my : typeof my >predicate : typeof my.predicate ->{} : { [x: string]: any; } +>{} : {} my.predicate.query = function () { >my.predicate.query = function () { var me = this; me.property = false;} : { (): void; another(): number; result: string; } @@ -149,7 +149,7 @@ var min = window.min || {}; >window.min : any >window : Window >min : any ->{} : { [x: string]: any; } +>{} : {} min.nest = this.min.nest || function () { }; >min.nest = this.min.nest || function () { } : { (): void; other: typeof other; } @@ -182,15 +182,15 @@ min.nest.other = self.min.nest.other || class { }; >class { } : typeof other min.property = global.min.property || {}; ->min.property = global.min.property || {} : { [x: string]: any; } ->min.property : { [x: string]: any; } +>min.property = global.min.property || {} : {} +>min.property : {} >min : typeof min ->property : { [x: string]: any; } ->global.min.property || {} : { [x: string]: any; } +>property : {} +>global.min.property || {} : {} >global.min.property : any >global.min : any >global : any >min : any >property : any ->{} : { [x: string]: any; } +>{} : {} diff --git a/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.types b/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.types index 947028db3852d..a7326f2d3875c 100644 --- a/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.types +++ b/tests/baselines/reference/typeFromPropertyAssignmentOutOfOrder.types @@ -34,13 +34,13 @@ var am; === tests/cases/conformance/salsa/roots.js === var First = {}; >First : typeof First ->{} : { [x: string]: any; } +>{} : {} var Common = {}; >Common : typeof Common ->{} : { [x: string]: any; } +>{} : {} var Workspace = {}; >Workspace : typeof Workspace ->{} : { [x: string]: any; } +>{} : {} diff --git a/tests/baselines/reference/typeFromPropertyAssignmentWithExport.types b/tests/baselines/reference/typeFromPropertyAssignmentWithExport.types index cd7823d00b22a..d12377c08e47a 100644 --- a/tests/baselines/reference/typeFromPropertyAssignmentWithExport.types +++ b/tests/baselines/reference/typeFromPropertyAssignmentWithExport.types @@ -3,14 +3,14 @@ export const Adapter = {}; >Adapter : typeof Adapter ->{} : { [x: string]: any; } +>{} : {} Adapter.prop = {}; ->Adapter.prop = {} : { [x: string]: any; } ->Adapter.prop : { [x: string]: any; } +>Adapter.prop = {} : {} +>Adapter.prop : {} >Adapter : typeof Adapter ->prop : { [x: string]: any; } ->{} : { [x: string]: any; } +>prop : {} +>{} : {} // comment this out, and it works Adapter.asyncMethod = function() {} diff --git a/tests/baselines/reference/typedefCrossModule2.symbols b/tests/baselines/reference/typedefCrossModule2.symbols index 5e080e66c0308..ba1f7c39a0b87 100644 --- a/tests/baselines/reference/typedefCrossModule2.symbols +++ b/tests/baselines/reference/typedefCrossModule2.symbols @@ -14,9 +14,7 @@ var bb; var bbb = new mod.Baz(); >bbb : Symbol(bbb, Decl(use.js, 5, 3)) ->mod.Baz : Symbol(Baz) >mod : Symbol(mod, Decl(use.js, 0, 3)) ->Baz : Symbol(Baz) === tests/cases/conformance/jsdoc/mod1.js === // error diff --git a/tests/baselines/reference/typedefCrossModule2.types b/tests/baselines/reference/typedefCrossModule2.types index 27b5933b311db..419a176227d4a 100644 --- a/tests/baselines/reference/typedefCrossModule2.types +++ b/tests/baselines/reference/typedefCrossModule2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/jsdoc/use.js === var mod = require('./mod1.js'); ->mod : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } ->require('./mod1.js') : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } +>mod : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>require('./mod1.js') : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } >require : any >'./mod1.js' : "./mod1.js" @@ -17,7 +17,7 @@ var bbb = new mod.Baz(); >bbb : any >new mod.Baz() : any >mod.Baz : any ->mod : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } +>mod : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } >Baz : any === tests/cases/conformance/jsdoc/mod1.js === @@ -31,17 +31,17 @@ class Foo { } // should error exports.Bar = class { } >exports.Bar = class { } : typeof Bar >exports.Bar : typeof Bar ->exports : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } +>exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } >Bar : typeof Bar >class { } : typeof Bar /** @typedef {number} Baz */ module.exports = { ->module.exports = { Baz: class { }} : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } ->module.exports : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } ->module : { "tests/cases/conformance/jsdoc/mod1": { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; }; } ->exports : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } ->{ Baz: class { }} : { [x: string]: any; Baz: typeof Baz; } +>module.exports = { Baz: class { }} : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>module.exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>module : { "tests/cases/conformance/jsdoc/mod1": { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; }; } +>exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>{ Baz: class { }} : { Baz: typeof Baz; } Baz: class { } >Baz : typeof Baz @@ -59,17 +59,17 @@ var Qux = 2; exports.Quid = 2; >exports.Quid = 2 : 2 >exports.Quid : any ->exports : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } +>exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } >Quid : any >2 : 2 /** @typedef {number} Quack */ module.exports = { ->module.exports = { Quack: 2} : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } ->module.exports : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } ->module : { "tests/cases/conformance/jsdoc/mod1": { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; }; } ->exports : { [x: string]: any; Baz: any; Bar: typeof Bar; Quid: any; } | { [x: string]: any; Quack: any; Bar: typeof Bar; Quid: any; } ->{ Quack: 2} : { [x: string]: any; Quack: number; } +>module.exports = { Quack: 2} : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>module.exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>module : { "tests/cases/conformance/jsdoc/mod1": { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; }; } +>exports : { Baz: any; Bar: typeof Bar; Quid: any; } | { Quack: any; Bar: typeof Bar; Quid: any; } +>{ Quack: 2} : { Quack: number; } Quack: 2 >Quack : number diff --git a/tests/baselines/reference/typedefCrossModule3.types b/tests/baselines/reference/typedefCrossModule3.types index 3685895022056..a2352eea7fffd 100644 --- a/tests/baselines/reference/typedefCrossModule3.types +++ b/tests/baselines/reference/typedefCrossModule3.types @@ -2,7 +2,7 @@ /** @typedef {number} Foo */ const ns = {}; >ns : typeof ns ->{} : { [x: string]: any; } +>{} : {} ns.Foo = class {} >ns.Foo = class {} : typeof Foo diff --git a/tests/baselines/reference/typedefCrossModule4.types b/tests/baselines/reference/typedefCrossModule4.types index 479e247327363..c14a6741aa896 100644 --- a/tests/baselines/reference/typedefCrossModule4.types +++ b/tests/baselines/reference/typedefCrossModule4.types @@ -4,11 +4,11 @@ class Bar { } >Bar : Bar module.exports = { Foo: Bar }; ->module.exports = { Foo: Bar } : { [x: string]: any; Foo: any; } ->module.exports : { [x: string]: any; Foo: any; } ->module : { "tests/cases/conformance/jsdoc/mod3": { [x: string]: any; Foo: any; }; } ->exports : { [x: string]: any; Foo: any; } ->{ Foo: Bar } : { [x: string]: any; Foo: typeof Bar; } +>module.exports = { Foo: Bar } : { Foo: any; } +>module.exports : { Foo: any; } +>module : { "tests/cases/conformance/jsdoc/mod3": { Foo: any; }; } +>exports : { Foo: any; } +>{ Foo: Bar } : { Foo: typeof Bar; } >Foo : typeof Bar >Bar : typeof Bar diff --git a/tests/baselines/reference/untypedModuleImport_allowJs.types b/tests/baselines/reference/untypedModuleImport_allowJs.types index 91cd7614eee99..70f03b38d90a5 100644 --- a/tests/baselines/reference/untypedModuleImport_allowJs.types +++ b/tests/baselines/reference/untypedModuleImport_allowJs.types @@ -1,22 +1,22 @@ === /a.ts === import foo from "foo"; ->foo : { [x: string]: any; bar(): number; } +>foo : { bar(): number; } foo.bar(); >foo.bar() : number >foo.bar : () => number ->foo : { [x: string]: any; bar(): number; } +>foo : { bar(): number; } >bar : () => number === /node_modules/foo/index.js === // Same as untypedModuleImport.ts but with --allowJs, so the package will actually be typed. exports.default = { bar() { return 0; } } ->exports.default = { bar() { return 0; } } : { [x: string]: any; bar(): number; } ->exports.default : { [x: string]: any; bar(): number; } +>exports.default = { bar() { return 0; } } : { bar(): number; } +>exports.default : { bar(): number; } >exports : typeof import("/node_modules/foo/index") ->default : { [x: string]: any; bar(): number; } ->{ bar() { return 0; } } : { [x: string]: any; bar(): number; } +>default : { bar(): number; } +>{ bar() { return 0; } } : { bar(): number; } >bar : () => number >0 : 0 From b3096e7bae62a538882fe0b7d430eff1508c2d6f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 26 Jul 2018 18:05:47 -0700 Subject: [PATCH 2/6] Add focused test on the keyof problem --- ...kJsObjectLiteralHasCheckedKeyof.errors.txt | 18 ++++++++++++ .../checkJsObjectLiteralHasCheckedKeyof.js | 25 +++++++++++++++++ ...heckJsObjectLiteralHasCheckedKeyof.symbols | 22 +++++++++++++++ .../checkJsObjectLiteralHasCheckedKeyof.types | 28 +++++++++++++++++++ .../checkJsObjectLiteralHasCheckedKeyof.ts | 14 ++++++++++ 5 files changed, 107 insertions(+) create mode 100644 tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.errors.txt create mode 100644 tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.js create mode 100644 tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.symbols create mode 100644 tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.types create mode 100644 tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts diff --git a/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.errors.txt b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.errors.txt new file mode 100644 index 0000000000000..978cd8e82b7ea --- /dev/null +++ b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.errors.txt @@ -0,0 +1,18 @@ +tests/cases/compiler/file.js(11,1): error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. + + +==== tests/cases/compiler/file.js (1 errors) ==== + // @ts-check + const obj = { + x: 1, + y: 2 + }; + + /** + * @type {keyof typeof obj} + */ + let selected = "x"; + selected = "z"; // should fail + ~~~~~~~~ +!!! error TS2322: Type '"z"' is not assignable to type '"x" | "y"'. + \ No newline at end of file diff --git a/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.js b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.js new file mode 100644 index 0000000000000..66c46c9214d77 --- /dev/null +++ b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.js @@ -0,0 +1,25 @@ +//// [file.js] +// @ts-check +const obj = { + x: 1, + y: 2 +}; + +/** + * @type {keyof typeof obj} + */ +let selected = "x"; +selected = "z"; // should fail + + +//// [file.js] +// @ts-check +var obj = { + x: 1, + y: 2 +}; +/** + * @type {keyof typeof obj} + */ +var selected = "x"; +selected = "z"; // should fail diff --git a/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.symbols b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.symbols new file mode 100644 index 0000000000000..1380ef733ccbd --- /dev/null +++ b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/file.js === +// @ts-check +const obj = { +>obj : Symbol(obj, Decl(file.js, 1, 5)) + + x: 1, +>x : Symbol(x, Decl(file.js, 1, 13)) + + y: 2 +>y : Symbol(y, Decl(file.js, 2, 9)) + +}; + +/** + * @type {keyof typeof obj} + */ +let selected = "x"; +>selected : Symbol(selected, Decl(file.js, 9, 3)) + +selected = "z"; // should fail +>selected : Symbol(selected, Decl(file.js, 9, 3)) + diff --git a/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.types b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.types new file mode 100644 index 0000000000000..7483991884872 --- /dev/null +++ b/tests/baselines/reference/checkJsObjectLiteralHasCheckedKeyof.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/file.js === +// @ts-check +const obj = { +>obj : { x: number; y: number; } +>{ x: 1, y: 2} : { x: number; y: number; } + + x: 1, +>x : number +>1 : 1 + + y: 2 +>y : number +>2 : 2 + +}; + +/** + * @type {keyof typeof obj} + */ +let selected = "x"; +>selected : "x" | "y" +>"x" : "x" + +selected = "z"; // should fail +>selected = "z" : "z" +>selected : "x" | "y" +>"z" : "z" + diff --git a/tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts b/tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts new file mode 100644 index 0000000000000..f290ddea29eb8 --- /dev/null +++ b/tests/cases/compiler/checkJsObjectLiteralHasCheckedKeyof.ts @@ -0,0 +1,14 @@ +// @allowJs: true +// @outDir: ./out +// @filename: file.js +// @ts-check +const obj = { + x: 1, + y: 2 +}; + +/** + * @type {keyof typeof obj} + */ +let selected = "x"; +selected = "z"; // should fail From 3503b1fee678bb2e5e11428c026c6eeb3da73032 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 26 Jul 2018 18:12:14 -0700 Subject: [PATCH 3/6] Fix fourslash test --- tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts index 0b2669e41f829..8e816b7937f16 100644 --- a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts +++ b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts @@ -28,7 +28,7 @@ verify.rangeIs(` m2(c: C): any { throw new Error("Method not implemented."); } - y: { [x: string]: any; }; + y: {}; m1(): any { throw new Error("Method not implemented."); } From 943c5ac66df19f46e7a8e85ed93626a04c509c2e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 31 Jul 2018 15:29:42 -0700 Subject: [PATCH 4/6] Reenable errors with noImplicitAny flag --- src/compiler/checker.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 44325e58b2d00..0fc006db367e5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9082,6 +9082,9 @@ namespace ts { * Returns if a type is or consists of a JSLiteral object type */ function isJSLiteralType(type: Type): boolean { + if (noImplicitAny) { + return false; // Flag is meaningless under `noImplicitAny` mode + } // In addition to objects which are directly literals, // * unions where every element is a jsliteral // * intersections where at least one element is a jsliteral @@ -9152,7 +9155,7 @@ namespace ts { return neverType; } if (isJSLiteralType(objectType)) { - return anyType; // TODO: We should consider still marking these as errors if `noImplictAny` is on + return anyType; } if (accessExpression && !isConstEnumObjectType(objectType)) { if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { @@ -9175,7 +9178,7 @@ namespace ts { } } if (isJSLiteralType(objectType)) { - return anyType; // TODO: We should consider still marking these as errors if `noImplictAny` is on + return anyType; } if (accessNode) { const indexNode = accessNode.kind === SyntaxKind.ElementAccessExpression ? accessNode.argumentExpression : accessNode.indexType; @@ -17913,7 +17916,7 @@ namespace ts { const indexInfo = getIndexInfoOfType(apparentType, IndexKind.String); if (!(indexInfo && indexInfo.type)) { if (isJSLiteralType(leftType)) { - return anyType; // TODO: We should consider still marking these as errors if `noImplictAny` is on + return anyType; } if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) { reportNonexistentProperty(right, leftType.flags & TypeFlags.TypeParameter && (leftType as TypeParameter).isThisType ? apparentType : leftType); From ce8bff9f7344edd83717f55db288555233b35b9e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 31 Jul 2018 16:19:02 -0700 Subject: [PATCH 5/6] Also disable excess property checks outside of noImplicitAny mode for js literals --- src/compiler/checker.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0fc006db367e5..8b0d1bd19312e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11255,6 +11255,9 @@ namespace ts { } function hasExcessProperties(source: FreshObjectLiteralType, target: Type, discriminant: Type | undefined, reportErrors: boolean): boolean { + if (!noImplicitAny && getObjectFlags(source) & ObjectFlags.JSLiteral) { + return false; // DIsable excess property checks on JS literals to simulate having an implicit "index signature" - but only outside of noImplicitAny + } if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { const isComparingJsxAttributes = !!(getObjectFlags(source) & ObjectFlags.JsxAttributes); if ((relation === assignableRelation || relation === definitelyAssignableRelation || relation === comparableRelation) && @@ -12743,7 +12746,7 @@ namespace ts { resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags & ~TypeFlags.FreshLiteral; - regularNew.objectFlags |= ObjectFlags.ObjectLiteral; + regularNew.objectFlags |= ObjectFlags.ObjectLiteral | (getObjectFlags(resolved) & ObjectFlags.JSLiteral); (type).regularType = regularNew; return regularNew; } From ff4a7116fbd383364d1edc17185ac5b51fdab2c3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 1 Aug 2018 11:40:34 -0700 Subject: [PATCH 6/6] Edit and move comments --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a0f241f31ca30..7430052c01182 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9077,17 +9077,17 @@ namespace ts { /** * Returns if a type is or consists of a JSLiteral object type + * In addition to objects which are directly literals, + * * unions where every element is a jsliteral + * * intersections where at least one element is a jsliteral + * * and instantiable types constrained to a jsliteral + * Should all count as literals and not print errors on access or assignment of possibly existing properties. + * This mirrors the behavior of the index signature propagation, to which this behaves similarly (but doesn't affect assignability or inference). */ function isJSLiteralType(type: Type): boolean { if (noImplicitAny) { return false; // Flag is meaningless under `noImplicitAny` mode } - // In addition to objects which are directly literals, - // * unions where every element is a jsliteral - // * intersections where at least one element is a jsliteral - // * and instantiable types constrained to a jsliteral - // Should all count as literals and not print errors on access or assignment of imaginary properties. - // This mirrors the behavior of the index signature propagation in the old implementation which utilized one. if (getObjectFlags(type) & ObjectFlags.JSLiteral) { return true; }