From cc7777358b896abe13456930cd899bfba03e51bf Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 4 Jul 2024 07:00:35 -0700 Subject: [PATCH 1/9] Revert #56753 but keep tests --- src/compiler/checker.ts | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 770e1a7c1c60a..923eecf1c2c9f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11808,7 +11808,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // contextual type or, if the element itself is a binding pattern, with the type implied by that binding // pattern. const contextualType = isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, /*includePatternInType*/ true, /*reportErrors*/ false) : unknownType; - return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors ? CheckMode.Normal : CheckMode.Contextual, contextualType))); + return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, CheckMode.Normal, contextualType))); } if (isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -11985,16 +11985,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return false; } - function getTypeOfVariableOrParameterOrProperty(symbol: Symbol, checkMode?: CheckMode): Type { + function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { - const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode); + const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol); // For a contextually typed parameter it is possible that a type has already // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want // to preserve this type. In fact, we need to _prefer_ that type, but it won't // be assigned until contextual typing is complete, so we need to defer in // cases where contextual typing may take place. - if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) { + if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) { links.type = type; } return type; @@ -12002,7 +12002,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return links.type; } - function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol, checkMode?: CheckMode): Type { + function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol): Type { // Handle prototype property if (symbol.flags & SymbolFlags.Prototype) { return getTypeOfPrototypeProperty(symbol); @@ -12045,16 +12045,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) { return getTypeOfFuncClassEnumModule(symbol); } - - // When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore - // end up in a circularity-like situation. This is not a true circularity so we should not report such an error. - // For example, here the looping could happen when trying to get the type of `a` (binding element): - // - // const { a, b = a } = { a: 0 } - // - if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) { - return errorType; - } return reportCircularityError(symbol); } let type: Type; @@ -12127,16 +12117,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (symbol.flags & SymbolFlags.ValueModule && !(symbol.flags & SymbolFlags.Assignment)) { return getTypeOfFuncClassEnumModule(symbol); } - - // When trying to get the *contextual* type of a binding element, it's possible to fall in a loop and therefore - // end up in a circularity-like situation. This is not a true circularity so we should not report such an error. - // For example, here the looping could happen when trying to get the type of `a` (binding element): - // - // const { a, b = a } = { a: 0 } - // - if (isBindingElement(declaration) && checkMode === CheckMode.Contextual) { - return type; - } return reportCircularityError(symbol); } return type; @@ -12419,7 +12399,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return getTypeOfSymbol(symbol); } - function getTypeOfSymbol(symbol: Symbol, checkMode?: CheckMode): Type { + function getTypeOfSymbol(symbol: Symbol): Type { const checkFlags = getCheckFlags(symbol); if (checkFlags & CheckFlags.DeferredType) { return getTypeOfSymbolWithDeferredType(symbol); @@ -12434,7 +12414,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return getTypeOfReverseMappedSymbol(symbol as ReverseMappedSymbol); } if (symbol.flags & (SymbolFlags.Variable | SymbolFlags.Property)) { - return getTypeOfVariableOrParameterOrProperty(symbol, checkMode); + return getTypeOfVariableOrParameterOrProperty(symbol); } if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) { return getTypeOfFuncClassEnumModule(symbol); @@ -30072,8 +30052,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier, checkMode?: CheckMode) { - const type = getTypeOfSymbol(symbol, checkMode); + function getNarrowedTypeOfSymbol(symbol: Symbol, location: Identifier) { + const type = getTypeOfSymbol(symbol); const declaration = symbol.valueDeclaration; if (declaration) { // If we have a non-rest binding element with no initializer declared as a const variable or a const-like @@ -30256,7 +30236,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); let declaration = localOrExportSymbol.valueDeclaration; - let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode); + let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); const assignmentKind = getAssignmentTargetKind(node); if (assignmentKind) { From 5cf08e52b8e7e2462cd9ae31bd0206f2f8f88153 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 4 Jul 2024 07:09:03 -0700 Subject: [PATCH 2/9] Accept new baselines --- .../circularReferenceInReturnType2.types | 16 ++-- ...ingArrayBindingPatternAndAssignment3.types | 24 ++--- ...ndAssignment5SiblingInitializer.errors.txt | 49 ++++++++++ ...ternAndAssignment5SiblingInitializer.types | 72 +++++++-------- ...ndAssignment9SiblingInitializer.errors.txt | 49 ++++++++++ ...ternAndAssignment9SiblingInitializer.types | 92 +++++++++---------- 6 files changed, 200 insertions(+), 102 deletions(-) create mode 100644 tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.errors.txt create mode 100644 tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.errors.txt diff --git a/tests/baselines/reference/circularReferenceInReturnType2.types b/tests/baselines/reference/circularReferenceInReturnType2.types index 53a5ae6890bac..650aeb78c3538 100644 --- a/tests/baselines/reference/circularReferenceInReturnType2.types +++ b/tests/baselines/reference/circularReferenceInReturnType2.types @@ -104,8 +104,8 @@ type Something = { foo: number }; // inference fails here, but ideally should not const A = object()({ ->A : ObjectType -> : ^^^^^^^^^^^^^^^^^^^^^ +>A : any +> : ^^^ >object()({ name: "A", fields: () => ({ a: field({ type: A, resolve() { return { foo: 100, }; }, }), }),}) : ObjectType > : ^^^^^^^^^^^^^^^^^^^^^ >object() : ; }>(config: { name: string; fields: Fields | (() => Fields); }) => ObjectType @@ -138,14 +138,14 @@ const A = object()({ > : ^^^^^^^^^^^^^^^^^^^^^ >field : , Key extends string>(field: FieldFuncArgs) => Field > : ^ ^^ ^^^^^^^^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^ ->{ type: A, resolve() { return { foo: 100, }; }, } : { type: ObjectType; resolve(): { foo: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ type: A, resolve() { return { foo: 100, }; }, } : { type: any; resolve(): { foo: number; }; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type: A, ->type : ObjectType -> : ^^^^^^^^^^^^^^^^^^^^^ ->A : ObjectType -> : ^^^^^^^^^^^^^^^^^^^^^ +>type : any +> : ^^^ +>A : any +> : ^^^ resolve() { >resolve : () => { foo: number; } diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types index 20866fba043b6..e8922db8ba9a7 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types @@ -2,24 +2,24 @@ === destructuringArrayBindingPatternAndAssignment3.ts === const [a, b = a] = [1]; // ok ->a : number -> : ^^^^^^ ->b : number -> : ^^^^^^ ->a : number -> : ^^^^^^ +>a : any +> : ^^^ +>b : any +> : ^^^ +>a : any +> : ^^^ >[1] : [number] > : ^^^^^^^^ >1 : 1 > : ^ const [c, d = c, e = e] = [1]; // error for e = e ->c : number -> : ^^^^^^ ->d : number -> : ^^^^^^ ->c : number -> : ^^^^^^ +>c : any +> : ^^^ +>d : any +> : ^^^ +>c : any +> : ^^^ >e : any > : ^^^ >e : any diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.errors.txt new file mode 100644 index 0000000000000..aa9bfae11e314 --- /dev/null +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.errors.txt @@ -0,0 +1,49 @@ +destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(3,12): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(4,12): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(9,12): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(10,12): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(15,12): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(16,12): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(23,13): error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts (7 errors) ==== + // To be inferred as `number` + function f1() { + const [a1, b1 = a1] = [1]; + ~~ +!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + const [a2, b2 = 1 + a2] = [1]; + ~~ +!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + + // To be inferred as `string` + function f2() { + const [a1, b1 = a1] = ['hi']; + ~~ +!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + const [a2, b2 = a2 + '!'] = ['hi']; + ~~ +!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + + // To be inferred as `string | number` + function f3() { + const [a1, b1 = a1] = ['hi', 1]; + ~~ +!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + const [a2, b2 = a2 + '!'] = ['hi', 1]; + ~~ +!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + + // Based on comment: + // - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 + declare const yadda: [number, number] | undefined + function f4() { + const [ a, b = a ] = yadda ?? []; + ~ +!!! error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types index f97afc115f46c..692a90d250ee2 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types @@ -7,28 +7,28 @@ function f1() { > : ^^^^^^^^^^ const [a1, b1 = a1] = [1]; ->a1 : number -> : ^^^^^^ ->b1 : number -> : ^^^^^^ ->a1 : number -> : ^^^^^^ +>a1 : any +> : ^^^ +>b1 : any +> : ^^^ +>a1 : any +> : ^^^ >[1] : [number] > : ^^^^^^^^ >1 : 1 > : ^ const [a2, b2 = 1 + a2] = [1]; ->a2 : number -> : ^^^^^^ ->b2 : number -> : ^^^^^^ ->1 + a2 : number -> : ^^^^^^ +>a2 : any +> : ^^^ +>b2 : any +> : ^^^ +>1 + a2 : any +> : ^^^ >1 : 1 > : ^ ->a2 : number -> : ^^^^^^ +>a2 : any +> : ^^^ >[1] : [number] > : ^^^^^^^^ >1 : 1 @@ -41,26 +41,26 @@ function f2() { > : ^^^^^^^^^^ const [a1, b1 = a1] = ['hi']; ->a1 : string -> : ^^^^^^ ->b1 : string -> : ^^^^^^ ->a1 : string -> : ^^^^^^ +>a1 : any +> : ^^^ +>b1 : any +> : ^^^ +>a1 : any +> : ^^^ >['hi'] : [string] > : ^^^^^^^^ >'hi' : "hi" > : ^^^^ const [a2, b2 = a2 + '!'] = ['hi']; ->a2 : string -> : ^^^^^^ +>a2 : any +> : ^^^ >b2 : string > : ^^^^^^ >a2 + '!' : string > : ^^^^^^ ->a2 : string -> : ^^^^^^ +>a2 : any +> : ^^^ >'!' : "!" > : ^^^ >['hi'] : [string] @@ -75,12 +75,12 @@ function f3() { > : ^^^^^^^^^^ const [a1, b1 = a1] = ['hi', 1]; ->a1 : string -> : ^^^^^^ ->b1 : string | number -> : ^^^^^^^^^^^^^^^ ->a1 : string -> : ^^^^^^ +>a1 : any +> : ^^^ +>b1 : any +> : ^^^ +>a1 : any +> : ^^^ >['hi', 1] : [string, number] > : ^^^^^^^^^^^^^^^^ >'hi' : "hi" @@ -89,14 +89,14 @@ function f3() { > : ^ const [a2, b2 = a2 + '!'] = ['hi', 1]; ->a2 : string -> : ^^^^^^ +>a2 : any +> : ^^^ >b2 : string | number > : ^^^^^^^^^^^^^^^ >a2 + '!' : string > : ^^^^^^ ->a2 : string -> : ^^^^^^ +>a2 : any +> : ^^^ >'!' : "!" > : ^^^ >['hi', 1] : [string, number] @@ -118,8 +118,8 @@ function f4() { > : ^^^^^^^^^^ const [ a, b = a ] = yadda ?? []; ->a : number -> : ^^^^^^ +>a : any +> : ^^^ >b : number > : ^^^^^^ >a : number diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.errors.txt new file mode 100644 index 0000000000000..506000005bbff --- /dev/null +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.errors.txt @@ -0,0 +1,49 @@ +destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(3,13): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(4,13): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(9,13): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(10,13): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(15,13): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(16,13): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. +destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(23,13): error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + + +==== destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts (7 errors) ==== + // To be inferred as `number` + function f1() { + const { a1, b1 = a1 } = { a1: 1 }; + ~~ +!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + const { a2, b2 = 1 + a2 } = { a2: 1 }; + ~~ +!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + + // To be inferred as `string` + function f2() { + const { a1, b1 = a1 } = { a1: 'hi' }; + ~~ +!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + const { a2, b2 = a2 + '!' } = { a2: 'hi' }; + ~~ +!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + + // To be inferred as `string | number` + function f3() { + const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; + ~~ +!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; + ~~ +!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + + // Based on comment: + // - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 + declare const yadda: { a?: number, b?: number } | undefined + function f4() { + const { a, b = a } = yadda ?? {}; + ~ +!!! error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. + } + \ No newline at end of file diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types index 5d8a6dcf495ba..3454414067311 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types @@ -7,32 +7,32 @@ function f1() { > : ^^^^^^^^^^ const { a1, b1 = a1 } = { a1: 1 }; ->a1 : number -> : ^^^^^^ ->b1 : number -> : ^^^^^^ ->a1 : number -> : ^^^^^^ ->{ a1: 1 } : { a1: number; b1?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>a1 : any +> : ^^^ +>b1 : any +> : ^^^ +>a1 : any +> : ^^^ +>{ a1: 1 } : { a1: number; b1?: any; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ >a1 : number > : ^^^^^^ >1 : 1 > : ^ const { a2, b2 = 1 + a2 } = { a2: 1 }; ->a2 : number -> : ^^^^^^ ->b2 : number -> : ^^^^^^ ->1 + a2 : number -> : ^^^^^^ +>a2 : any +> : ^^^ +>b2 : any +> : ^^^ +>1 + a2 : any +> : ^^^ >1 : 1 > : ^ ->a2 : number -> : ^^^^^^ ->{ a2: 1 } : { a2: number; b2?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>a2 : any +> : ^^^ +>{ a2: 1 } : { a2: number; b2?: any; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ >a2 : number > : ^^^^^^ >1 : 1 @@ -45,28 +45,28 @@ function f2() { > : ^^^^^^^^^^ const { a1, b1 = a1 } = { a1: 'hi' }; ->a1 : string -> : ^^^^^^ ->b1 : string -> : ^^^^^^ ->a1 : string -> : ^^^^^^ ->{ a1: 'hi' } : { a1: string; b1?: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>a1 : any +> : ^^^ +>b1 : any +> : ^^^ +>a1 : any +> : ^^^ +>{ a1: 'hi' } : { a1: string; b1?: any; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ >a1 : string > : ^^^^^^ >'hi' : "hi" > : ^^^^ const { a2, b2 = a2 + '!' } = { a2: 'hi' }; ->a2 : string -> : ^^^^^^ +>a2 : any +> : ^^^ >b2 : string > : ^^^^^^ >a2 + '!' : string > : ^^^^^^ ->a2 : string -> : ^^^^^^ +>a2 : any +> : ^^^ >'!' : "!" > : ^^^ >{ a2: 'hi' } : { a2: string; b2?: string; } @@ -83,12 +83,12 @@ function f3() { > : ^^^^^^^^^^ const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; ->a1 : string -> : ^^^^^^ ->b1 : string | number -> : ^^^^^^^^^^^^^^^ ->a1 : string -> : ^^^^^^ +>a1 : any +> : ^^^ +>b1 : any +> : ^^^ +>a1 : any +> : ^^^ >{ a1: 'hi', b1: 1 } : { a1: string; b1?: number; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a1 : string @@ -101,14 +101,14 @@ function f3() { > : ^ const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; ->a2 : string -> : ^^^^^^ +>a2 : any +> : ^^^ >b2 : string | number > : ^^^^^^^^^^^^^^^ >a2 + '!' : string > : ^^^^^^ ->a2 : string -> : ^^^^^^ +>a2 : any +> : ^^^ >'!' : "!" > : ^^^ >{ a2: 'hi', b2: 1 } : { a2: string; b2?: number; } @@ -138,12 +138,12 @@ function f4() { > : ^^^^^^^^^^ const { a, b = a } = yadda ?? {}; ->a : number -> : ^^^^^^ ->b : number -> : ^^^^^^ ->a : number -> : ^^^^^^ +>a : any +> : ^^^ +>b : any +> : ^^^ +>a : any +> : ^^^ >yadda ?? {} : { a?: number; b?: number; } > : ^^^^^^ ^^^^^^ ^^^ >yadda : { a?: number; b?: number; } From bdfc038fc02aa36754a882b4b0e2d031fa1ff075 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 4 Jul 2024 16:50:32 -0700 Subject: [PATCH 3/9] Don't use contextual type when padding destructured object literals --- src/compiler/checker.ts | 112 ++++++++++++++++++++++------------------ src/compiler/types.ts | 2 +- 2 files changed, 63 insertions(+), 51 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 923eecf1c2c9f..d92f8f03fe08a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11211,6 +11211,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { parentType = getTypeWithFacts(parentType, TypeFacts.NEUndefined); } + const accessFlags = AccessFlags.ExpressionPosition | (noTupleBoundsCheck || hasDefaultValue(declaration) ? AccessFlags.AllowMissing : 0); let type: Type | undefined; if (pattern.kind === SyntaxKind.ObjectBindingPattern) { if (declaration.dotDotDotToken) { @@ -11231,7 +11232,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Use explicitly specified property name ({ p: xxx } form), or otherwise the implied name ({ p } form) const name = declaration.propertyName || declaration.name as Identifier; const indexType = getLiteralTypeFromPropertyName(name); - const declaredType = getIndexedAccessType(parentType, indexType, AccessFlags.ExpressionPosition, name); + const declaredType = getIndexedAccessType(parentType, indexType, accessFlags, name); type = getFlowTypeOfDestructuring(declaration, declaredType); } } @@ -11252,7 +11253,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } else if (isArrayLikeType(parentType)) { const indexType = getNumberLiteralType(index); - const accessFlags = AccessFlags.ExpressionPosition | (noTupleBoundsCheck || hasDefaultValue(declaration) ? AccessFlags.NoTupleBoundsCheck : 0); const declaredType = getIndexedAccessTypeOrUndefined(parentType, indexType, accessFlags, declaration.name) || errorType; type = getFlowTypeOfDestructuring(declaration, declaredType); } @@ -18565,7 +18565,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } if (everyType(objectType, isTupleType) && isNumericLiteralName(propName)) { const index = +propName; - if (accessNode && everyType(objectType, t => !((t as TupleTypeReference).target.combinedFlags & ElementFlags.Variable)) && !(accessFlags & AccessFlags.NoTupleBoundsCheck)) { + if (accessNode && everyType(objectType, t => !((t as TupleTypeReference).target.combinedFlags & ElementFlags.Variable)) && !(accessFlags & AccessFlags.AllowMissing)) { const indexNode = getIndexNodeForAccessExpression(accessNode); if (isTupleType(objectType)) { if (index < 0) { @@ -18700,6 +18700,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return undefined; } } + if (accessFlags & AccessFlags.AllowMissing && isObjectLiteralType(objectType)) { + return undefinedType; + } if (isJSLiteralType(objectType)) { return anyType; } @@ -32316,9 +32319,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type; } - function hasDefaultValue(node: BindingElement | Expression): boolean { - return (node.kind === SyntaxKind.BindingElement && !!(node as BindingElement).initializer) || - (node.kind === SyntaxKind.BinaryExpression && (node as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken); + function hasDefaultValue(node: BindingElement | ObjectLiteralElementLike | Expression): boolean { + return node.kind === SyntaxKind.BindingElement && !!(node as BindingElement).initializer || + node.kind === SyntaxKind.PropertyAssignment && hasDefaultValue((node as PropertyAssignment).initializer) || + node.kind === SyntaxKind.ShorthandPropertyAssignment && !!(node as ShorthandPropertyAssignment).objectAssignmentInitializer || + node.kind === SyntaxKind.BinaryExpression && (node as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken; } function isSpreadIntoCallOrNew(node: ArrayLiteralExpression) { @@ -32583,14 +32588,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { prop.links.nameType = nameType; } - if (inDestructuringPattern) { + if (inDestructuringPattern && hasDefaultValue(memberDecl)) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. - const isOptional = (memberDecl.kind === SyntaxKind.PropertyAssignment && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment && memberDecl.objectAssignmentInitializer); - if (isOptional) { - prop.flags |= SymbolFlags.Optional; - } + prop.flags |= SymbolFlags.Optional; } else if (contextualTypeHasPattern && !(getObjectFlags(contextualType) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { // If object literal is contextually typed by the implied type of a binding pattern, and if the @@ -32688,35 +32689,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } popContextualType(); - // If object literal is contextually typed by the implied type of a binding pattern, augment the result - // type with those properties for which the binding pattern specifies a default value. - // If the object literal is spread into another object literal, skip this step and let the top-level object - // literal handle it instead. Note that this might require full traversal to the root pattern's parent - // as it's the guaranteed to be the common ancestor of the pattern node and the current object node. - // It's not possible to check if the immediate parent node is a spread assignment - // since the type flows in non-obvious ways through conditional expressions, IIFEs and more. - if (contextualTypeHasPattern) { - const rootPatternParent = findAncestor(contextualType.pattern!.parent, n => - n.kind === SyntaxKind.VariableDeclaration || - n.kind === SyntaxKind.BinaryExpression || - n.kind === SyntaxKind.Parameter); - const spreadOrOutsideRootObject = findAncestor(node, n => - n === rootPatternParent || - n.kind === SyntaxKind.SpreadAssignment)!; - - if (spreadOrOutsideRootObject.kind !== SyntaxKind.SpreadAssignment) { - for (const prop of getPropertiesOfType(contextualType)) { - if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) { - if (!(prop.flags & SymbolFlags.Optional)) { - error(prop.valueDeclaration || tryCast(prop, isTransientSymbol)?.links.bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); - } - propertiesTable.set(prop.escapedName, prop); - propertiesArray.push(prop); - } - } - } - } - if (isErrorType(spread)) { return errorType; } @@ -39114,7 +39086,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { checkPropertyAccessibility(property, /*isSuper*/ false, /*writing*/ true, objectLiteralType, prop); } } - const elementType = getIndexedAccessType(objectLiteralType, exprType, AccessFlags.ExpressionPosition, name); + const elementType = getIndexedAccessType(objectLiteralType, exprType, AccessFlags.ExpressionPosition | (hasDefaultValue(property) ? AccessFlags.AllowMissing : 0), name); const type = getFlowTypeOfDestructuring(property, elementType); return checkDestructuringAssignment(property.kind === SyntaxKind.ShorthandPropertyAssignment ? property : property.initializer, type); } @@ -39173,7 +39145,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (isArrayLikeType(sourceType)) { // We create a synthetic expression so that getIndexedAccessType doesn't get confused // when the element is a SyntaxKind.ElementAccessExpression. - const accessFlags = AccessFlags.ExpressionPosition | (hasDefaultValue(element) ? AccessFlags.NoTupleBoundsCheck : 0); + const accessFlags = AccessFlags.ExpressionPosition | (hasDefaultValue(element) ? AccessFlags.AllowMissing : 0); const elementType = getIndexedAccessTypeOrUndefined(sourceType, indexType, accessFlags, createSyntheticExpression(element, indexType)) || errorType; const assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType, TypeFacts.NEUndefined) : elementType; const type = getFlowTypeOfDestructuring(element, assignedType); @@ -40140,16 +40112,56 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return checkSatisfiesExpressionWorker(initializer, typeNode, checkMode); } } - const type = getQuickTypeOfExpression(initializer) || - (contextualType ? - checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || CheckMode.Normal) - : checkExpressionCached(initializer, checkMode)); - return isParameter(declaration) && declaration.name.kind === SyntaxKind.ArrayBindingPattern && - isTupleType(type) && !(type.target.combinedFlags & ElementFlags.Variable) && getTypeReferenceArity(type) < declaration.name.elements.length ? - padTupleType(type, declaration.name) : type; + const type = getQuickTypeOfExpression(initializer) || (contextualType ? + checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || CheckMode.Normal) : + checkExpressionCached(initializer, checkMode)); + if (isParameter(declaration)) { + if (declaration.name.kind === SyntaxKind.ObjectBindingPattern && isObjectLiteralType(type)) { + return padObjectLiteralType(type as ObjectType, declaration.name); + } + if (declaration.name.kind === SyntaxKind.ArrayBindingPattern && isTupleType(type)) { + return padTupleType(type, declaration.name); + } + } + return type; + } + + function padObjectLiteralType(type: ObjectType, pattern: ObjectBindingPattern): Type { + let missingElements: BindingElement[] | undefined; + for (const e of pattern.elements) { + if (e.initializer) { + const name = getPropertyNameFromBindingElement(e); + if (name && !getPropertyOfType(type, name)) { + missingElements = append(missingElements, e); + } + } + } + if (!missingElements) { + return type; + } + const members = createSymbolTable(); + for (const prop of getPropertiesOfObjectType(type)) { + members.set(prop.escapedName, prop); + } + for (const e of missingElements) { + const symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Optional, getPropertyNameFromBindingElement(e)!); + symbol.links.type = getTypeFromBindingElement(e, /*includePatternInType*/ false, /*reportErrors*/ false); + members.set(symbol.escapedName, symbol); + } + const result = createAnonymousType(type.symbol, members, emptyArray, emptyArray, getIndexInfosOfType(type)); + result.objectFlags = type.objectFlags; + return result; + } + + function getPropertyNameFromBindingElement(e: BindingElement) { + const exprType = getLiteralTypeFromPropertyName(e.propertyName || e.name as Identifier); + return isTypeUsableAsPropertyName(exprType) ? getPropertyNameFromType(exprType) : undefined; } function padTupleType(type: TupleTypeReference, pattern: ArrayBindingPattern) { + if (type.target.combinedFlags & ElementFlags.Variable || getTypeReferenceArity(type) >= pattern.elements.length) { + return type; + } const patternElements = pattern.elements; const elementTypes = getElementTypes(type).slice(); const elementFlags = type.target.elementFlags.slice(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 508042f69bee8..4ee28b04b819b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -6693,7 +6693,7 @@ export const enum AccessFlags { NoIndexSignatures = 1 << 1, Writing = 1 << 2, CacheSymbol = 1 << 3, - NoTupleBoundsCheck = 1 << 4, + AllowMissing = 1 << 4, ExpressionPosition = 1 << 5, ReportDeprecated = 1 << 6, SuppressNoImplicitAnyError = 1 << 7, From f4652e184e415a44fe1d496214ce743bbc2966d6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 4 Jul 2024 16:50:52 -0700 Subject: [PATCH 4/9] Accept new baselines --- ...checkDestructuringShorthandAssigment.types | 16 ++--- ...estructuringShorthandAssigment2.errors.txt | 5 +- ...rInitalizedVariablesFiltersUndefined.types | 4 +- ...FlowDestructuringVariablesInTryCatch.types | 4 +- .../declarationsAndAssignments.errors.txt | 8 +-- .../declarationsAndAssignments.types | 4 +- ...redLateBoundNameHasCorrectTypes.errors.txt | 6 +- ...ructuredLateBoundNameHasCorrectTypes.types | 4 +- .../destructuringFromUnionSpread.errors.txt | 4 +- .../destructuringFromUnionSpread.types | 4 +- ...ectBindingPatternAndAssignment3.errors.txt | 5 +- ...ngObjectBindingPatternAndAssignment3.types | 4 +- ...ternAndAssignment9SiblingInitializer.types | 16 ++--- .../reference/destructuringSpread.errors.txt | 4 +- .../reference/destructuringSpread.types | 4 +- ...destructuringWithLiteralInitializers.types | 44 ++++++------ ...ngEmitHelpers-classDecorator.17.errors.txt | 5 +- .../missingAndExcessProperties.errors.txt | 50 +++++-------- .../missingAndExcessProperties.types | 64 ++++++++--------- .../parserForOfStatement25.errors.txt | 11 --- .../reference/parserForOfStatement25.types | 8 +-- .../reference/parserForStatement9.types | 4 +- ...ldDestructuredBinding(target=es2015).types | 12 ++-- ...ldDestructuredBinding(target=es2022).types | 12 ++-- ...ldDestructuredBinding(target=esnext).types | 12 ++-- ...ldDestructuredBinding(target=es2015).types | 12 ++-- ...ldDestructuredBinding(target=es2022).types | 12 ++-- ...ldDestructuredBinding(target=esnext).types | 12 ++-- ...pertyAssignmentsInDestructuring.errors.txt | 15 +--- ...ndPropertyAssignmentsInDestructuring.types | 72 +++++++++---------- ...yAssignmentsInDestructuring_ES6.errors.txt | 15 +--- ...opertyAssignmentsInDestructuring_ES6.types | 72 +++++++++---------- 32 files changed, 231 insertions(+), 293 deletions(-) delete mode 100644 tests/baselines/reference/parserForOfStatement25.errors.txt diff --git a/tests/baselines/reference/checkDestructuringShorthandAssigment.types b/tests/baselines/reference/checkDestructuringShorthandAssigment.types index 0ca8f3d1a8e9d..705c1b672ceca 100644 --- a/tests/baselines/reference/checkDestructuringShorthandAssigment.types +++ b/tests/baselines/reference/checkDestructuringShorthandAssigment.types @@ -9,24 +9,24 @@ function Test({ b = '' } = {}) {} > : ^^^^^^ >'' : "" > : ^^ ->{} : { b?: string; } -> : ^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ Test(({ b = '5' } = {})); >Test(({ b = '5' } = {})) : void > : ^^^^ >Test : ({ b }?: { b?: string; }) => void > : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->({ b = '5' } = {}) : { b?: any; } -> : ^^^^^^^^^^^^ ->{ b = '5' } = {} : { b?: any; } -> : ^^^^^^^^^^^^ +>({ b = '5' } = {}) : {} +> : ^^ +>{ b = '5' } = {} : {} +> : ^^ >{ b = '5' } : { b?: any; } > : ^^^^^^^^^^^^ >b : any > : ^^^ >'5' : "5" > : ^^^ ->{} : { b?: any; } -> : ^^^^^^^^^^^^ +>{} : {} +> : ^^ diff --git a/tests/baselines/reference/checkDestructuringShorthandAssigment2.errors.txt b/tests/baselines/reference/checkDestructuringShorthandAssigment2.errors.txt index 42032f9db1bb1..bb320b0ba28be 100644 --- a/tests/baselines/reference/checkDestructuringShorthandAssigment2.errors.txt +++ b/tests/baselines/reference/checkDestructuringShorthandAssigment2.errors.txt @@ -1,14 +1,11 @@ -checkDestructuringShorthandAssigment2.ts(4,7): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. checkDestructuringShorthandAssigment2.ts(4,27): error TS2353: Object literal may only specify known properties, and '[k]' does not exist in type '{ x: any; }'. -==== checkDestructuringShorthandAssigment2.ts (2 errors) ==== +==== checkDestructuringShorthandAssigment2.ts (1 errors) ==== // GH #38175 -- should not crash while checking let o: any, k: any; let { x } = { x: 1, ...o, [k]: 1 }; - ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~~ !!! error TS2353: Object literal may only specify known properties, and '[k]' does not exist in type '{ x: any; }'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types index e046fab296264..8bf023a872882 100644 --- a/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types +++ b/tests/baselines/reference/contextualTypeForInitalizedVariablesFiltersUndefined.types @@ -10,8 +10,8 @@ const fInferred = ({ a = 0 } = {}) => a; > : ^^^^^^ >0 : 0 > : ^ ->{} : { a?: number | undefined; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ >a : number > : ^^^^^^ diff --git a/tests/baselines/reference/controlFlowDestructuringVariablesInTryCatch.types b/tests/baselines/reference/controlFlowDestructuringVariablesInTryCatch.types index d6de3df9f4fa5..d27c0515fe8b6 100644 --- a/tests/baselines/reference/controlFlowDestructuringVariablesInTryCatch.types +++ b/tests/baselines/reference/controlFlowDestructuringVariablesInTryCatch.types @@ -53,8 +53,8 @@ try { > : ^^^^^^ >1 : 1 > : ^ ->{ } : { e?: number | undefined; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ } : {} +> : ^^ } catch { console.error("error"); diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 332a127335f04..935c5f230bba6 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -11,8 +11,8 @@ declarationsAndAssignments.ts(63,13): error TS2493: Tuple type '[number]' of len declarationsAndAssignments.ts(63,16): error TS2493: Tuple type '[number]' of length '1' has no element at index '2'. declarationsAndAssignments.ts(67,9): error TS2461: Type '{}' is not an array type. declarationsAndAssignments.ts(68,9): error TS2461: Type '{ 0: number; 1: number; }' is not an array type. -declarationsAndAssignments.ts(73,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +declarationsAndAssignments.ts(73,11): error TS2339: Property 'a' does not exist on type '{}'. +declarationsAndAssignments.ts(73,14): error TS2339: Property 'b' does not exist on type '{}'. declarationsAndAssignments.ts(74,11): error TS2339: Property 'a' does not exist on type 'undefined[]'. declarationsAndAssignments.ts(74,14): error TS2339: Property 'b' does not exist on type 'undefined[]'. declarationsAndAssignments.ts(106,17): error TS2741: Property 'x' is missing in type '{ y: false; }' but required in type '{ x: any; y?: boolean; }'. @@ -122,9 +122,9 @@ declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assigna function f10() { var { a, b } = {}; // Error ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'a' does not exist on type '{}'. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'b' does not exist on type '{}'. var { a, b } = []; // Error ~ !!! error TS2339: Property 'a' does not exist on type 'undefined[]'. diff --git a/tests/baselines/reference/declarationsAndAssignments.types b/tests/baselines/reference/declarationsAndAssignments.types index 9cef609f57bf7..7f50a7b18bc5a 100644 --- a/tests/baselines/reference/declarationsAndAssignments.types +++ b/tests/baselines/reference/declarationsAndAssignments.types @@ -486,8 +486,8 @@ function f10() { > : ^^^ >b : any > : ^^^ ->{} : { a: any; b: any; } -> : ^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ var { a, b } = []; // Error >a : any diff --git a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.errors.txt b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.errors.txt index a0907af1dce40..b5768d2cecde6 100644 --- a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.errors.txt +++ b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.errors.txt @@ -1,4 +1,4 @@ -destructuredLateBoundNameHasCorrectTypes.ts(11,21): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +destructuredLateBoundNameHasCorrectTypes.ts(11,8): error TS2339: Property 'prop2' does not exist on type '{ prop: string; }'. destructuredLateBoundNameHasCorrectTypes.ts(11,37): error TS2353: Object literal may only specify known properties, and 'prop' does not exist in type '{ prop2: any; }'. @@ -14,8 +14,8 @@ destructuredLateBoundNameHasCorrectTypes.ts(11,37): error TS2353: Object literal const notPresent = "prop2"; let { [notPresent]: computed2 } = { prop: "b" }; - ~~~~~~~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. + ~~~~~~~~~~ +!!! error TS2339: Property 'prop2' does not exist on type '{ prop: string; }'. ~~~~ !!! error TS2353: Object literal may only specify known properties, and 'prop' does not exist in type '{ prop2: any; }'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types index a72bf873fb4ca..f5b1a5511f45c 100644 --- a/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types +++ b/tests/baselines/reference/destructuredLateBoundNameHasCorrectTypes.types @@ -54,8 +54,8 @@ let { [notPresent]: computed2 } = { prop: "b" }; > : ^^^^^^^ >computed2 : any > : ^^^ ->{ prop: "b" } : { prop: string; prop2: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ prop: "b" } : { prop: string; } +> : ^^^^^^^^^^^^^^^^^ >prop : string > : ^^^^^^ >"b" : "b" diff --git a/tests/baselines/reference/destructuringFromUnionSpread.errors.txt b/tests/baselines/reference/destructuringFromUnionSpread.errors.txt index 82e58168ab9d2..2300456dd3215 100644 --- a/tests/baselines/reference/destructuringFromUnionSpread.errors.txt +++ b/tests/baselines/reference/destructuringFromUnionSpread.errors.txt @@ -1,4 +1,4 @@ -destructuringFromUnionSpread.ts(5,9): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +destructuringFromUnionSpread.ts(5,9): error TS2339: Property 'a' does not exist on type '{ a: string; } | { b: number; }'. ==== destructuringFromUnionSpread.ts (1 errors) ==== @@ -8,5 +8,5 @@ destructuringFromUnionSpread.ts(5,9): error TS2525: Initializer provides no valu declare const x: A | B; const { a } = { ...x } // error ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'a' does not exist on type '{ a: string; } | { b: number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringFromUnionSpread.types b/tests/baselines/reference/destructuringFromUnionSpread.types index a9eb75f2347f2..23d1a977c6de1 100644 --- a/tests/baselines/reference/destructuringFromUnionSpread.types +++ b/tests/baselines/reference/destructuringFromUnionSpread.types @@ -16,8 +16,8 @@ declare const x: A | B; const { a } = { ...x } // error >a : any > : ^^^ ->{ ...x } : { a: any; } | { a: any; b: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ +>{ ...x } : { a: string; } | { b: number; } +> : ^^^^^ ^^^^^^^^^^^ ^^^ >x : A | B > : ^^^^^ diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt index 822cb4d6c512d..165d25f1338ec 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.errors.txt @@ -2,14 +2,13 @@ destructuringObjectBindingPatternAndAssignment3.ts(2,7): error TS1005: ',' expec destructuringObjectBindingPatternAndAssignment3.ts(3,5): error TS2322: Type '{ i: number; }' is not assignable to type 'string | number'. destructuringObjectBindingPatternAndAssignment3.ts(3,6): error TS2339: Property 'i' does not exist on type 'string | number'. destructuringObjectBindingPatternAndAssignment3.ts(4,6): error TS2339: Property 'i1' does not exist on type 'string | number | {}'. -destructuringObjectBindingPatternAndAssignment3.ts(5,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. destructuringObjectBindingPatternAndAssignment3.ts(5,21): error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. destructuringObjectBindingPatternAndAssignment3.ts(6,7): error TS1005: ':' expected. destructuringObjectBindingPatternAndAssignment3.ts(6,15): error TS1005: ':' expected. destructuringObjectBindingPatternAndAssignment3.ts(7,12): error TS1005: ':' expected. -==== destructuringObjectBindingPatternAndAssignment3.ts (9 errors) ==== +==== destructuringObjectBindingPatternAndAssignment3.ts (8 errors) ==== // Error var {h?} = { h?: 1 }; ~ @@ -23,8 +22,6 @@ destructuringObjectBindingPatternAndAssignment3.ts(7,12): error TS1005: ':' expe ~~ !!! error TS2339: Property 'i1' does not exist on type 'string | number | {}'. var { f2: {f21} = { f212: "string" } }: any = undefined; - ~~~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. ~~~~ !!! error TS2353: Object literal may only specify known properties, and 'f212' does not exist in type '{ f21: any; }'. var {1} = { 1 }; diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.types index 3c59be34a8277..427f102f70fe6 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment3.types @@ -37,8 +37,8 @@ var { f2: {f21} = { f212: "string" } }: any = undefined; > : ^^^ >f21 : any > : ^^^ ->{ f212: "string" } : { f212: string; f21: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ f212: "string" } : { f212: string; } +> : ^^^^^^^^^^^^^^^^^ >f212 : string > : ^^^^^^ >"string" : "string" diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types index 3454414067311..a08c84f3ed1a5 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types @@ -13,8 +13,8 @@ function f1() { > : ^^^ >a1 : any > : ^^^ ->{ a1: 1 } : { a1: number; b1?: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ a1: 1 } : { a1: number; } +> : ^^^^^^^^^^^^^^^ >a1 : number > : ^^^^^^ >1 : 1 @@ -31,8 +31,8 @@ function f1() { > : ^ >a2 : any > : ^^^ ->{ a2: 1 } : { a2: number; b2?: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ a2: 1 } : { a2: number; } +> : ^^^^^^^^^^^^^^^ >a2 : number > : ^^^^^^ >1 : 1 @@ -51,8 +51,8 @@ function f2() { > : ^^^ >a1 : any > : ^^^ ->{ a1: 'hi' } : { a1: string; b1?: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ a1: 'hi' } : { a1: string; } +> : ^^^^^^^^^^^^^^^ >a1 : string > : ^^^^^^ >'hi' : "hi" @@ -69,8 +69,8 @@ function f2() { > : ^^^ >'!' : "!" > : ^^^ ->{ a2: 'hi' } : { a2: string; b2?: string; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ a2: 'hi' } : { a2: string; } +> : ^^^^^^^^^^^^^^^ >a2 : string > : ^^^^^^ >'hi' : "hi" diff --git a/tests/baselines/reference/destructuringSpread.errors.txt b/tests/baselines/reference/destructuringSpread.errors.txt index 7734af7092743..bec3f7e218667 100644 --- a/tests/baselines/reference/destructuringSpread.errors.txt +++ b/tests/baselines/reference/destructuringSpread.errors.txt @@ -1,4 +1,4 @@ -destructuringSpread.ts(16,21): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +destructuringSpread.ts(16,21): error TS2339: Property 'g' does not exist on type '{ f: number; e: number; d: number; c: number; }'. ==== destructuringSpread.ts (1 errors) ==== @@ -19,7 +19,7 @@ destructuringSpread.ts(16,21): error TS2525: Initializer provides no value for t const { c, d, e, f, g } = { ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'g' does not exist on type '{ f: number; e: number; d: number; c: number; }'. ...{ ...{ ...{ diff --git a/tests/baselines/reference/destructuringSpread.types b/tests/baselines/reference/destructuringSpread.types index 4c5756eb7060f..b8a321a65b1ef 100644 --- a/tests/baselines/reference/destructuringSpread.types +++ b/tests/baselines/reference/destructuringSpread.types @@ -78,8 +78,8 @@ const { c, d, e, f, g } = { > : ^^^^^^ >g : any > : ^^^ ->{ ...{ ...{ ...{ c: 0, }, d: 0 }, e: 0 }, f: 0} : { f: number; g: any; e: number; d: number; c: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ ...{ ...{ ...{ c: 0, }, d: 0 }, e: 0 }, f: 0} : { f: number; e: number; d: number; c: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...{ >{ ...{ ...{ c: 0, }, d: 0 }, e: 0 } : { e: number; d: number; c: number; } diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types index 127033b4f888a..706dbb17b1ed7 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.types +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -177,8 +177,8 @@ function f5({ x, y = 0 } = { x: 0 }) { } > : ^^^^^^ >0 : 0 > : ^ ->{ x: 0 } : { x: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ x: 0 } : { x: number; } +> : ^^^^^^^^^^^^^^ >x : number > : ^^^^^^ >0 : 0 @@ -230,8 +230,8 @@ function f6({ x = 0, y = 0 } = {}) { } > : ^^^^^^ >0 : 0 > : ^ ->{} : { x?: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ f6(); >f6() : void @@ -289,8 +289,8 @@ f6({ x: 1, y: 1 }); // (arg?: { a: { x?: number, y?: number } }) => void function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } ->f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ >a : any > : ^^^ >x : number @@ -301,24 +301,24 @@ function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } > : ^^^^^^ >0 : 0 > : ^ ->{ a: {} } : { a: { x?: number; y?: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->a : { x?: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{} : { x?: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{ a: {} } : { a: {}; } +> : ^^^^^^^^^^ +>a : {} +> : ^^ +>{} : {} +> : ^^ f7(); >f7() : void > : ^^^^ ->f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ f7({ a: {} }); >f7({ a: {} }) : void > : ^^^^ ->f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ >{ a: {} } : { a: {}; } > : ^^^^^^^^^^ >a : {} @@ -329,8 +329,8 @@ f7({ a: {} }); f7({ a: { x: 1 } }); >f7({ a: { x: 1 } }) : void > : ^^^^ ->f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ >{ a: { x: 1 } } : { a: { x: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^ >a : { x: number; } @@ -345,8 +345,8 @@ f7({ a: { x: 1 } }); f7({ a: { y: 1 } }); >f7({ a: { y: 1 } }) : void > : ^^^^ ->f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ >{ a: { y: 1 } } : { a: { y: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^ >a : { y: number; } @@ -361,8 +361,8 @@ f7({ a: { y: 1 } }); f7({ a: { x: 1, y: 1 } }); >f7({ a: { x: 1, y: 1 } }) : void > : ^^^^ ->f7 : ({ a: { x, y } }?: { a: { x?: number; y?: number; }; }) => void -> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>f7 : ({ a: { x, y } }?: { a: {}; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^ >{ a: { x: 1, y: 1 } } : { a: { x: number; y: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : { x: number; y: number; } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.17.errors.txt b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.17.errors.txt index d40d7effd2e15..f510b08fac8a5 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.17.errors.txt +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.17.errors.txt @@ -1,10 +1,9 @@ -main.ts(8,5): error TS2538: Type 'any' cannot be used as an index type. main.ts(8,13): error TS2343: This syntax requires an imported helper named '__esDecorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(8,13): error TS2343: This syntax requires an imported helper named '__runInitializers' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. main.ts(8,13): error TS2343: This syntax requires an imported helper named '__setFunctionName' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. -==== main.ts (4 errors) ==== +==== main.ts (3 errors) ==== export {}; declare var dec: any; declare var x: any; @@ -13,8 +12,6 @@ main.ts(8,13): error TS2343: This syntax requires an imported helper named '__se // uses __esDecorate, __runInitializers, __setFunctionName, __propKey ({ [x]: C = @dec class {} } = {}); - ~ -!!! error TS2538: Type 'any' cannot be used as an index type. ~~~~ !!! error TS2343: This syntax requires an imported helper named '__esDecorate' which does not exist in 'tslib'. Consider upgrading your version of 'tslib'. ~~~~ diff --git a/tests/baselines/reference/missingAndExcessProperties.errors.txt b/tests/baselines/reference/missingAndExcessProperties.errors.txt index f0448190c907a..0c2727dc54356 100644 --- a/tests/baselines/reference/missingAndExcessProperties.errors.txt +++ b/tests/baselines/reference/missingAndExcessProperties.errors.txt @@ -1,15 +1,11 @@ -missingAndExcessProperties.ts(3,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -missingAndExcessProperties.ts(3,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -missingAndExcessProperties.ts(4,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. -missingAndExcessProperties.ts(4,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -missingAndExcessProperties.ts(5,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -missingAndExcessProperties.ts(5,14): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. -missingAndExcessProperties.ts(6,11): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. -missingAndExcessProperties.ts(6,18): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. -missingAndExcessProperties.ts(12,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -missingAndExcessProperties.ts(12,11): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -missingAndExcessProperties.ts(13,18): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. -missingAndExcessProperties.ts(14,8): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +missingAndExcessProperties.ts(3,11): error TS2339: Property 'x' does not exist on type '{}'. +missingAndExcessProperties.ts(3,14): error TS2339: Property 'y' does not exist on type '{}'. +missingAndExcessProperties.ts(4,18): error TS2339: Property 'y' does not exist on type '{}'. +missingAndExcessProperties.ts(5,11): error TS2339: Property 'x' does not exist on type '{}'. +missingAndExcessProperties.ts(12,8): error TS2339: Property 'x' does not exist on type '{}'. +missingAndExcessProperties.ts(12,11): error TS2339: Property 'y' does not exist on type '{}'. +missingAndExcessProperties.ts(13,18): error TS2339: Property 'y' does not exist on type '{}'. +missingAndExcessProperties.ts(14,8): error TS2339: Property 'x' does not exist on type '{}'. missingAndExcessProperties.ts(21,25): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. missingAndExcessProperties.ts(22,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. missingAndExcessProperties.ts(29,14): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{}'. @@ -18,33 +14,21 @@ missingAndExcessProperties.ts(30,22): error TS2353: Object literal may only spec missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: number; }'. -==== missingAndExcessProperties.ts (18 errors) ==== +==== missingAndExcessProperties.ts (14 errors) ==== // Missing properties function f1() { var { x, y } = {}; ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'x' does not exist on type '{}'. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'y' does not exist on type '{}'. var { x = 1, y } = {}; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. -!!! related TS6203 missingAndExcessProperties.ts:3:11: 'x' was also declared here. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'y' does not exist on type '{}'. var { x, y = 1 } = {}; ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. -!!! related TS6203 missingAndExcessProperties.ts:3:14: 'y' was also declared here. +!!! error TS2339: Property 'x' does not exist on type '{}'. var { x = 1, y = 1 } = {}; - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'any', but here has type 'number'. -!!! related TS6203 missingAndExcessProperties.ts:3:11: 'x' was also declared here. - ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'any', but here has type 'number'. -!!! related TS6203 missingAndExcessProperties.ts:3:14: 'y' was also declared here. } // Missing properties @@ -52,15 +36,15 @@ missingAndExcessProperties.ts(31,16): error TS2353: Object literal may only spec var x: number, y: number; ({ x, y } = {}); ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'x' does not exist on type '{}'. ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'y' does not exist on type '{}'. ({ x: x = 1, y } = {}); ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'y' does not exist on type '{}'. ({ x, y: y = 1 } = {}); ~ -!!! error TS2525: Initializer provides no value for this binding element and the binding element has no default value. +!!! error TS2339: Property 'x' does not exist on type '{}'. ({ x: x = 1, y: y = 1 } = {}); } diff --git a/tests/baselines/reference/missingAndExcessProperties.types b/tests/baselines/reference/missingAndExcessProperties.types index f702ab6a2ce57..c5ddbd7581dc2 100644 --- a/tests/baselines/reference/missingAndExcessProperties.types +++ b/tests/baselines/reference/missingAndExcessProperties.types @@ -11,8 +11,8 @@ function f1() { > : ^^^ >y : any > : ^^^ ->{} : { x: any; y: any; } -> : ^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ var { x = 1, y } = {}; >x : any @@ -21,8 +21,8 @@ function f1() { > : ^ >y : any > : ^^^ ->{} : { x?: number; y: any; } -> : ^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ var { x, y = 1 } = {}; >x : any @@ -31,8 +31,8 @@ function f1() { > : ^^^ >1 : 1 > : ^ ->{} : { x: any; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ var { x = 1, y = 1 } = {}; >x : any @@ -43,8 +43,8 @@ function f1() { > : ^^^ >1 : 1 > : ^ ->{} : { x?: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ } // Missing properties @@ -59,24 +59,24 @@ function f2() { > : ^^^^^^ ({ x, y } = {}); ->({ x, y } = {}) : { x: number; y: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ x, y } = {} : { x: number; y: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ x, y } = {}) : {} +> : ^^ +>{ x, y } = {} : {} +> : ^^ >{ x, y } : { x: number; y: number; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^ >x : number > : ^^^^^^ >y : number > : ^^^^^^ ->{} : { x: number; y: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ ({ x: x = 1, y } = {}); ->({ x: x = 1, y } = {}) : { x?: number; y: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ x: x = 1, y } = {} : { x?: number; y: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ x: x = 1, y } = {}) : {} +> : ^^ +>{ x: x = 1, y } = {} : {} +> : ^^ >{ x: x = 1, y } : { x?: number; y: number; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : number @@ -89,14 +89,14 @@ function f2() { > : ^ >y : number > : ^^^^^^ ->{} : { x?: number; y: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ ({ x, y: y = 1 } = {}); ->({ x, y: y = 1 } = {}) : { x: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ x, y: y = 1 } = {} : { x: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ x, y: y = 1 } = {}) : {} +> : ^^ +>{ x, y: y = 1 } = {} : {} +> : ^^ >{ x, y: y = 1 } : { x: number; y?: number; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : number @@ -109,14 +109,14 @@ function f2() { > : ^^^^^^ >1 : 1 > : ^ ->{} : { x: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ ({ x: x = 1, y: y = 1 } = {}); ->({ x: x = 1, y: y = 1 } = {}) : { x?: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ x: x = 1, y: y = 1 } = {} : { x?: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ x: x = 1, y: y = 1 } = {}) : {} +> : ^^ +>{ x: x = 1, y: y = 1 } = {} : {} +> : ^^ >{ x: x = 1, y: y = 1 } : { x?: number; y?: number; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ >x : number @@ -135,8 +135,8 @@ function f2() { > : ^^^^^^ >1 : 1 > : ^ ->{} : { x?: number; y?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ } // Excess properties diff --git a/tests/baselines/reference/parserForOfStatement25.errors.txt b/tests/baselines/reference/parserForOfStatement25.errors.txt deleted file mode 100644 index 68a6589ca56dc..0000000000000 --- a/tests/baselines/reference/parserForOfStatement25.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -parserForOfStatement25.ts(4,11): error TS2339: Property 'x' does not exist on type '{}'. - - -==== parserForOfStatement25.ts (1 errors) ==== - // repro from https://github.com/microsoft/TypeScript/issues/54769 - - for (let [x = 'a' in {}] of [[]]) console.log(x) - for (let {x = 'a' in {}} of [{}]) console.log(x) - ~ -!!! error TS2339: Property 'x' does not exist on type '{}'. - \ No newline at end of file diff --git a/tests/baselines/reference/parserForOfStatement25.types b/tests/baselines/reference/parserForOfStatement25.types index 0a80626a619fa..66f6d3ad7f5a8 100644 --- a/tests/baselines/reference/parserForOfStatement25.types +++ b/tests/baselines/reference/parserForOfStatement25.types @@ -28,8 +28,8 @@ for (let [x = 'a' in {}] of [[]]) console.log(x) > : ^^^^^^^ for (let {x = 'a' in {}} of [{}]) console.log(x) ->x : any -> : ^^^ +>x : boolean +> : ^^^^^^^ >'a' in {} : boolean > : ^^^^^^^ >'a' : "a" @@ -48,6 +48,6 @@ for (let {x = 'a' in {}} of [{}]) console.log(x) > : ^^^^^^^ >log : (...data: any[]) => void > : ^^^^ ^^ ^^^^^ ->x : any -> : ^^^ +>x : boolean +> : ^^^^^^^ diff --git a/tests/baselines/reference/parserForStatement9.types b/tests/baselines/reference/parserForStatement9.types index 8f7f2f3f836bb..e4b025dfa51d8 100644 --- a/tests/baselines/reference/parserForStatement9.types +++ b/tests/baselines/reference/parserForStatement9.types @@ -46,8 +46,8 @@ for (let {x = 'a' in {}} = {}; !x; x = !x) console.log(x) > : ^^^ >{} : {} > : ^^ ->{} : { x?: boolean; } -> : ^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ >!x : boolean > : ^^^^^^^ >x : boolean diff --git a/tests/baselines/reference/privateNameFieldDestructuredBinding(target=es2015).types b/tests/baselines/reference/privateNameFieldDestructuredBinding(target=es2015).types index 85dfe8b55f6f3..d2738266e4be3 100644 --- a/tests/baselines/reference/privateNameFieldDestructuredBinding(target=es2015).types +++ b/tests/baselines/reference/privateNameFieldDestructuredBinding(target=es2015).types @@ -157,10 +157,10 @@ class A { > : ^ ({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }); ->({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ ->{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; } +> : ^^^^^^^^^^ +>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; } +> : ^^^^^^^^^^ >{ a: this.#field = 1, b: [this.#field = 1] } : { a?: number; b: [number]; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : number @@ -185,8 +185,8 @@ class A { > : ^^^^ >1 : 1 > : ^ ->{ b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ b: [] } : { b: []; } +> : ^^^^^^^^^^ >b : [] > : ^^ >[] : [] diff --git a/tests/baselines/reference/privateNameFieldDestructuredBinding(target=es2022).types b/tests/baselines/reference/privateNameFieldDestructuredBinding(target=es2022).types index 85dfe8b55f6f3..d2738266e4be3 100644 --- a/tests/baselines/reference/privateNameFieldDestructuredBinding(target=es2022).types +++ b/tests/baselines/reference/privateNameFieldDestructuredBinding(target=es2022).types @@ -157,10 +157,10 @@ class A { > : ^ ({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }); ->({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ ->{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; } +> : ^^^^^^^^^^ +>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; } +> : ^^^^^^^^^^ >{ a: this.#field = 1, b: [this.#field = 1] } : { a?: number; b: [number]; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : number @@ -185,8 +185,8 @@ class A { > : ^^^^ >1 : 1 > : ^ ->{ b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ b: [] } : { b: []; } +> : ^^^^^^^^^^ >b : [] > : ^^ >[] : [] diff --git a/tests/baselines/reference/privateNameFieldDestructuredBinding(target=esnext).types b/tests/baselines/reference/privateNameFieldDestructuredBinding(target=esnext).types index 85dfe8b55f6f3..d2738266e4be3 100644 --- a/tests/baselines/reference/privateNameFieldDestructuredBinding(target=esnext).types +++ b/tests/baselines/reference/privateNameFieldDestructuredBinding(target=esnext).types @@ -157,10 +157,10 @@ class A { > : ^ ({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }); ->({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ ->{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>({ a: this.#field = 1, b: [this.#field = 1] } = { b: [] }) : { b: []; } +> : ^^^^^^^^^^ +>{ a: this.#field = 1, b: [this.#field = 1] } = { b: [] } : { b: []; } +> : ^^^^^^^^^^ >{ a: this.#field = 1, b: [this.#field = 1] } : { a?: number; b: [number]; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : number @@ -185,8 +185,8 @@ class A { > : ^^^^ >1 : 1 > : ^ ->{ b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ b: [] } : { b: []; } +> : ^^^^^^^^^^ >b : [] > : ^^ >[] : [] diff --git a/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=es2015).types b/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=es2015).types index 3141d2ef0dea9..e85c8d14a447f 100644 --- a/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=es2015).types +++ b/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=es2015).types @@ -155,10 +155,10 @@ class A { > : ^ ({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }); ->({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ ->{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; } +> : ^^^^^^^^^^ +>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; } +> : ^^^^^^^^^^ >{ a: A.#field = 1, b: [A.#field = 1] } : { a?: number; b: [number]; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : number @@ -183,8 +183,8 @@ class A { > : ^^^^^^^^ >1 : 1 > : ^ ->{ b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ b: [] } : { b: []; } +> : ^^^^^^^^^^ >b : [] > : ^^ >[] : [] diff --git a/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=es2022).types b/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=es2022).types index 3141d2ef0dea9..e85c8d14a447f 100644 --- a/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=es2022).types +++ b/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=es2022).types @@ -155,10 +155,10 @@ class A { > : ^ ({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }); ->({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ ->{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; } +> : ^^^^^^^^^^ +>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; } +> : ^^^^^^^^^^ >{ a: A.#field = 1, b: [A.#field = 1] } : { a?: number; b: [number]; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : number @@ -183,8 +183,8 @@ class A { > : ^^^^^^^^ >1 : 1 > : ^ ->{ b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ b: [] } : { b: []; } +> : ^^^^^^^^^^ >b : [] > : ^^ >[] : [] diff --git a/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=esnext).types b/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=esnext).types index 3141d2ef0dea9..e85c8d14a447f 100644 --- a/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=esnext).types +++ b/tests/baselines/reference/privateNameStaticFieldDestructuredBinding(target=esnext).types @@ -155,10 +155,10 @@ class A { > : ^ ({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }); ->({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ ->{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>({ a: A.#field = 1, b: [A.#field = 1] } = { b: [] }) : { b: []; } +> : ^^^^^^^^^^ +>{ a: A.#field = 1, b: [A.#field = 1] } = { b: [] } : { b: []; } +> : ^^^^^^^^^^ >{ a: A.#field = 1, b: [A.#field = 1] } : { a?: number; b: [number]; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : number @@ -183,8 +183,8 @@ class A { > : ^^^^^^^^ >1 : 1 > : ^ ->{ b: [] } : { b: []; a?: number; } -> : ^^^^^^^^^^^^^^^^^^^^^^ +>{ b: [] } : { b: []; } +> : ^^^^^^^^^^ >b : [] > : ^^ >[] : [] diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt index cdc3707a21171..6a12186cc76bd 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt @@ -1,5 +1,3 @@ -shorthandPropertyAssignmentsInDestructuring.ts(14,9): error TS2339: Property 's1' does not exist on type '{}'. -shorthandPropertyAssignmentsInDestructuring.ts(20,9): error TS2339: Property 's1' does not exist on type '{}'. shorthandPropertyAssignmentsInDestructuring.ts(38,9): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring.ts(44,12): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring.ts(70,5): error TS2322: Type 'number' is not assignable to type 'string'. @@ -7,14 +5,11 @@ shorthandPropertyAssignmentsInDestructuring.ts(75,8): error TS2322: Type 'number shorthandPropertyAssignmentsInDestructuring.ts(80,5): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring.ts(80,20): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring.ts(85,8): error TS2322: Type 'number' is not assignable to type 'string'. -shorthandPropertyAssignmentsInDestructuring.ts(85,19): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. - Types of property 'x' are incompatible. - Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. -==== shorthandPropertyAssignmentsInDestructuring.ts (12 errors) ==== +==== shorthandPropertyAssignmentsInDestructuring.ts (9 errors) ==== (function() { var s0; for ({ s0 = 5 } of [{ s0: 1 }]) { @@ -29,16 +24,12 @@ shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you me (function() { var s1; for ({ s1 = 5 } of [{}]) { - ~~ -!!! error TS2339: Property 's1' does not exist on type '{}'. } }); (function() { var s1; for ({ s1:s1 = 5 } of [{}]) { - ~~ -!!! error TS2339: Property 's1' does not exist on type '{}'. } }); @@ -119,10 +110,6 @@ shorthandPropertyAssignmentsInDestructuring.ts(111,14): error TS1312: Did you me ({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) ~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. - ~~ -!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. ~ !!! error TS2322: Type 'number' is not assignable to type 'string'. !!! related TS6500 shorthandPropertyAssignmentsInDestructuring.ts:84:24: The expected type comes from property 'x' which is declared here on type '{ x: string; }' diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types index dfaaa2fe5c235..32af2c239484c 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.types @@ -371,18 +371,18 @@ > : ^^^^^^ ({ y1 = 5 } = {}) ->({ y1 = 5 } = {}) : { y1?: string; } -> : ^^^^^^^^^^^^^^^^ ->{ y1 = 5 } = {} : { y1?: string; } -> : ^^^^^^^^^^^^^^^^ +>({ y1 = 5 } = {}) : {} +> : ^^ +>{ y1 = 5 } = {} : {} +> : ^^ >{ y1 = 5 } : { y1?: string; } > : ^^^^^^^^^^^^^^^^ >y1 : string > : ^^^^^^ >5 : 5 > : ^ ->{} : { y1?: string; } -> : ^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ }); @@ -397,10 +397,10 @@ > : ^^^^^^ ({ y1:y1 = 5 } = {}) ->({ y1:y1 = 5 } = {}) : { y1?: number; } -> : ^^^^^^^^^^^^^^^^ ->{ y1:y1 = 5 } = {} : { y1?: number; } -> : ^^^^^^^^^^^^^^^^ +>({ y1:y1 = 5 } = {}) : {} +> : ^^ +>{ y1:y1 = 5 } = {} : {} +> : ^^ >{ y1:y1 = 5 } : { y1?: number; } > : ^^^^^^^^^^^^^^^^ >y1 : number @@ -411,8 +411,8 @@ > : ^^^^^^ >5 : 5 > : ^ ->{} : { y1?: number; } -> : ^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ }); @@ -431,10 +431,10 @@ > : ^^^^^^ ({ y2 = 5, y3 = { x: 1 } } = {}) ->({ y2 = 5, y3 = { x: 1 } } = {}) : { y2?: string; y3?: { x: string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ ->{ y2 = 5, y3 = { x: 1 } } = {} : { y2?: string; y3?: { x: string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>({ y2 = 5, y3 = { x: 1 } } = {}) : {} +> : ^^ +>{ y2 = 5, y3 = { x: 1 } } = {} : {} +> : ^^ >{ y2 = 5, y3 = { x: 1 } } : { y2?: string; y3?: { x: string; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ >y2 : string @@ -449,8 +449,8 @@ > : ^^^^^^ >1 : 1 > : ^ ->{} : { y2?: string; y3?: { x: string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>{} : {} +> : ^^ }); @@ -469,10 +469,10 @@ > : ^^^^^^ ({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) ->({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) : { y2?: number; y3?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ y2:y2 = 5, y3:y3 = { x: 1 } } = {} : { y2?: number; y3?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) : {} +> : ^^ +>{ y2:y2 = 5, y3:y3 = { x: 1 } } = {} : {} +> : ^^ >{ y2:y2 = 5, y3:y3 = { x: 1 } } : { y2?: number; y3?: { x: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >y2 : number @@ -495,8 +495,8 @@ > : ^^^^^^ >1 : 1 > : ^ ->{} : { y2?: number; y3?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ }); @@ -515,10 +515,10 @@ > : ^^^^^^ ({ y4 = 5, y5 = { x: 1 } } = {}) ->({ y4 = 5, y5 = { x: 1 } } = {}) : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ ->{ y4 = 5, y5 = { x: 1 } } = {} : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>({ y4 = 5, y5 = { x: 1 } } = {}) : {} +> : ^^ +>{ y4 = 5, y5 = { x: 1 } } = {} : {} +> : ^^ >{ y4 = 5, y5 = { x: 1 } } : { y4?: number; y5?: { x: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ >y4 : number @@ -533,8 +533,8 @@ > : ^^^^^^ >1 : 1 > : ^ ->{} : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>{} : {} +> : ^^ }); @@ -553,10 +553,10 @@ > : ^^^^^^ ({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) ->({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ y4:y4 = 5, y5:y5 = { x: 1 } } = {} : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) : {} +> : ^^ +>{ y4:y4 = 5, y5:y5 = { x: 1 } } = {} : {} +> : ^^ >{ y4:y4 = 5, y5:y5 = { x: 1 } } : { y4?: number; y5?: { x: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >y4 : number @@ -579,8 +579,8 @@ > : ^^^^^^ >1 : 1 > : ^ ->{} : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ }); diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt index 4d3cc097116a4..cd0830e27c5cb 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt @@ -1,5 +1,3 @@ -shorthandPropertyAssignmentsInDestructuring_ES6.ts(14,9): error TS2339: Property 's1' does not exist on type '{}'. -shorthandPropertyAssignmentsInDestructuring_ES6.ts(20,9): error TS2339: Property 's1' does not exist on type '{}'. shorthandPropertyAssignmentsInDestructuring_ES6.ts(38,9): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring_ES6.ts(44,12): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring_ES6.ts(70,5): error TS2322: Type 'number' is not assignable to type 'string'. @@ -7,14 +5,11 @@ shorthandPropertyAssignmentsInDestructuring_ES6.ts(75,8): error TS2322: Type 'nu shorthandPropertyAssignmentsInDestructuring_ES6.ts(80,5): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring_ES6.ts(80,20): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,8): error TS2322: Type 'number' is not assignable to type 'string'. -shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,19): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. - Types of property 'x' are incompatible. - Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring_ES6.ts(85,26): error TS2322: Type 'number' is not assignable to type 'string'. shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did you mean to use a ':'? An '=' can only follow a property name when the containing object literal is part of a destructuring pattern. -==== shorthandPropertyAssignmentsInDestructuring_ES6.ts (12 errors) ==== +==== shorthandPropertyAssignmentsInDestructuring_ES6.ts (9 errors) ==== (function() { var s0; for ({ s0 = 5 } of [{ s0: 1 }]) { @@ -29,16 +24,12 @@ shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did yo (function() { var s1; for ({ s1 = 5 } of [{}]) { - ~~ -!!! error TS2339: Property 's1' does not exist on type '{}'. } }); (function() { var s1; for ({ s1:s1 = 5 } of [{}]) { - ~~ -!!! error TS2339: Property 's1' does not exist on type '{}'. } }); @@ -119,10 +110,6 @@ shorthandPropertyAssignmentsInDestructuring_ES6.ts(111,14): error TS1312: Did yo ({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) ~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. - ~~ -!!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. -!!! error TS2322: Types of property 'x' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. ~ !!! error TS2322: Type 'number' is not assignable to type 'string'. !!! related TS6500 shorthandPropertyAssignmentsInDestructuring_ES6.ts:84:24: The expected type comes from property 'x' which is declared here on type '{ x: string; }' diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types index b713ddd3e4de1..511d33c914ec4 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.types @@ -371,18 +371,18 @@ > : ^^^^^^ ({ y1 = 5 } = {}) ->({ y1 = 5 } = {}) : { y1?: string; } -> : ^^^^^^^^^^^^^^^^ ->{ y1 = 5 } = {} : { y1?: string; } -> : ^^^^^^^^^^^^^^^^ +>({ y1 = 5 } = {}) : {} +> : ^^ +>{ y1 = 5 } = {} : {} +> : ^^ >{ y1 = 5 } : { y1?: string; } > : ^^^^^^^^^^^^^^^^ >y1 : string > : ^^^^^^ >5 : 5 > : ^ ->{} : { y1?: string; } -> : ^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ }); @@ -397,10 +397,10 @@ > : ^^^^^^ ({ y1:y1 = 5 } = {}) ->({ y1:y1 = 5 } = {}) : { y1?: number; } -> : ^^^^^^^^^^^^^^^^ ->{ y1:y1 = 5 } = {} : { y1?: number; } -> : ^^^^^^^^^^^^^^^^ +>({ y1:y1 = 5 } = {}) : {} +> : ^^ +>{ y1:y1 = 5 } = {} : {} +> : ^^ >{ y1:y1 = 5 } : { y1?: number; } > : ^^^^^^^^^^^^^^^^ >y1 : number @@ -411,8 +411,8 @@ > : ^^^^^^ >5 : 5 > : ^ ->{} : { y1?: number; } -> : ^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ }); @@ -431,10 +431,10 @@ > : ^^^^^^ ({ y2 = 5, y3 = { x: 1 } } = {}) ->({ y2 = 5, y3 = { x: 1 } } = {}) : { y2?: string; y3?: { x: string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ ->{ y2 = 5, y3 = { x: 1 } } = {} : { y2?: string; y3?: { x: string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>({ y2 = 5, y3 = { x: 1 } } = {}) : {} +> : ^^ +>{ y2 = 5, y3 = { x: 1 } } = {} : {} +> : ^^ >{ y2 = 5, y3 = { x: 1 } } : { y2?: string; y3?: { x: string; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ >y2 : string @@ -449,8 +449,8 @@ > : ^^^^^^ >1 : 1 > : ^ ->{} : { y2?: string; y3?: { x: string; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>{} : {} +> : ^^ }); @@ -469,10 +469,10 @@ > : ^^^^^^ ({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) ->({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) : { y2?: number; y3?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ y2:y2 = 5, y3:y3 = { x: 1 } } = {} : { y2?: number; y3?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) : {} +> : ^^ +>{ y2:y2 = 5, y3:y3 = { x: 1 } } = {} : {} +> : ^^ >{ y2:y2 = 5, y3:y3 = { x: 1 } } : { y2?: number; y3?: { x: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >y2 : number @@ -495,8 +495,8 @@ > : ^^^^^^ >1 : 1 > : ^ ->{} : { y2?: number; y3?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ }); @@ -515,10 +515,10 @@ > : ^^^^^^ ({ y4 = 5, y5 = { x: 1 } } = {}) ->({ y4 = 5, y5 = { x: 1 } } = {}) : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ ->{ y4 = 5, y5 = { x: 1 } } = {} : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>({ y4 = 5, y5 = { x: 1 } } = {}) : {} +> : ^^ +>{ y4 = 5, y5 = { x: 1 } } = {} : {} +> : ^^ >{ y4 = 5, y5 = { x: 1 } } : { y4?: number; y5?: { x: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ >y4 : number @@ -533,8 +533,8 @@ > : ^^^^^^ >1 : 1 > : ^ ->{} : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^ +>{} : {} +> : ^^ }); @@ -553,10 +553,10 @@ > : ^^^^^^ ({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) ->({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ->{ y4:y4 = 5, y5:y5 = { x: 1 } } = {} : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ y4:y4 = 5, y5:y5 = { x: 1 } } = {}) : {} +> : ^^ +>{ y4:y4 = 5, y5:y5 = { x: 1 } } = {} : {} +> : ^^ >{ y4:y4 = 5, y5:y5 = { x: 1 } } : { y4?: number; y5?: { x: number; }; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >y4 : number @@ -579,8 +579,8 @@ > : ^^^^^^ >1 : 1 > : ^ ->{} : { y4?: number; y5?: { x: number; }; } -> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>{} : {} +> : ^^ }); From 1c45b7f0021a30cd842ecc204878072cc927ba92 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Jul 2024 12:17:24 -0700 Subject: [PATCH 5/9] Intra-binding-pattern references have type 'any' in contextual types --- src/compiler/checker.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d92f8f03fe08a..6950703124bf3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2282,6 +2282,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var contextualTypes: (Type | undefined)[] = []; var contextualIsCache: boolean[] = []; var contextualTypeCount = 0; + var contextualBindingPatterns: BindingPattern[] = []; var inferenceContextNodes: Node[] = []; var inferenceContexts: (InferenceContext | undefined)[] = []; @@ -11885,9 +11886,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType = false, reportErrors = false): Type { - return pattern.kind === SyntaxKind.ObjectBindingPattern + if (includePatternInType) contextualBindingPatterns.push(pattern); + const result = pattern.kind === SyntaxKind.ObjectBindingPattern ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); + if (includePatternInType) contextualBindingPatterns.pop(); + return result; } // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type @@ -30239,6 +30243,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); let declaration = localOrExportSymbol.valueDeclaration; + // If the identifier is declared in a binding pattern for which we're currently computing the implied type and the + // reference occurs with the same binding pattern, return the non-inferrable any type. This for example occurs in + // 'const [a, b = a + 1] = [2]' when we're computing the contextual type for the array literal '[2]'. + if (declaration && declaration.kind === SyntaxKind.BindingElement && contains(contextualBindingPatterns, declaration.parent) && findAncestor(node, parent => parent === declaration!.parent)) { + return nonInferrableAnyType; + } + let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node); const assignmentKind = getAssignmentTargetKind(node); From 215ba5b97cc6aa900f9950fabfa4f4bbc08fb84b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Jul 2024 12:17:50 -0700 Subject: [PATCH 6/9] Accept new baselines --- ...ingArrayBindingPatternAndAssignment3.types | 52 ++++++------ ...ndAssignment5SiblingInitializer.errors.txt | 49 ------------ ...ternAndAssignment5SiblingInitializer.types | 72 ++++++++--------- ...ndAssignment9SiblingInitializer.errors.txt | 49 ------------ ...ternAndAssignment9SiblingInitializer.types | 80 +++++++++---------- .../useBeforeDeclaration_destructuring.types | 20 ++--- 6 files changed, 112 insertions(+), 210 deletions(-) delete mode 100644 tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.errors.txt delete mode 100644 tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.errors.txt diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types index e8922db8ba9a7..e5da561f97979 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment3.types @@ -2,24 +2,24 @@ === destructuringArrayBindingPatternAndAssignment3.ts === const [a, b = a] = [1]; // ok ->a : any -> : ^^^ ->b : any -> : ^^^ ->a : any -> : ^^^ +>a : number +> : ^^^^^^ +>b : number +> : ^^^^^^ +>a : number +> : ^^^^^^ >[1] : [number] > : ^^^^^^^^ >1 : 1 > : ^ const [c, d = c, e = e] = [1]; // error for e = e ->c : any -> : ^^^ ->d : any -> : ^^^ ->c : any -> : ^^^ +>c : number +> : ^^^^^^ +>d : number +> : ^^^^^^ +>c : number +> : ^^^^^^ >e : any > : ^^^ >e : any @@ -30,20 +30,20 @@ const [c, d = c, e = e] = [1]; // error for e = e > : ^ const [f, g = f, h = i, i = f] = [1]; // error for h = i ->f : any -> : ^^^ ->g : any -> : ^^^ ->f : any -> : ^^^ ->h : any -> : ^^^ ->i : any -> : ^^^ ->i : any -> : ^^^ ->f : any -> : ^^^ +>f : number +> : ^^^^^^ +>g : number +> : ^^^^^^ +>f : number +> : ^^^^^^ +>h : number +> : ^^^^^^ +>i : number +> : ^^^^^^ +>i : number +> : ^^^^^^ +>f : number +> : ^^^^^^ >[1] : [number] > : ^^^^^^^^ >1 : 1 diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.errors.txt deleted file mode 100644 index aa9bfae11e314..0000000000000 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.errors.txt +++ /dev/null @@ -1,49 +0,0 @@ -destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(3,12): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(4,12): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(9,12): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(10,12): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(15,12): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(16,12): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts(23,13): error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - - -==== destructuringArrayBindingPatternAndAssignment5SiblingInitializer.ts (7 errors) ==== - // To be inferred as `number` - function f1() { - const [a1, b1 = a1] = [1]; - ~~ -!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - const [a2, b2 = 1 + a2] = [1]; - ~~ -!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - } - - // To be inferred as `string` - function f2() { - const [a1, b1 = a1] = ['hi']; - ~~ -!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - const [a2, b2 = a2 + '!'] = ['hi']; - ~~ -!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - } - - // To be inferred as `string | number` - function f3() { - const [a1, b1 = a1] = ['hi', 1]; - ~~ -!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - const [a2, b2 = a2 + '!'] = ['hi', 1]; - ~~ -!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - } - - // Based on comment: - // - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 - declare const yadda: [number, number] | undefined - function f4() { - const [ a, b = a ] = yadda ?? []; - ~ -!!! error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - } - \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types index 692a90d250ee2..f97afc115f46c 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment5SiblingInitializer.types @@ -7,28 +7,28 @@ function f1() { > : ^^^^^^^^^^ const [a1, b1 = a1] = [1]; ->a1 : any -> : ^^^ ->b1 : any -> : ^^^ ->a1 : any -> : ^^^ +>a1 : number +> : ^^^^^^ +>b1 : number +> : ^^^^^^ +>a1 : number +> : ^^^^^^ >[1] : [number] > : ^^^^^^^^ >1 : 1 > : ^ const [a2, b2 = 1 + a2] = [1]; ->a2 : any -> : ^^^ ->b2 : any -> : ^^^ ->1 + a2 : any -> : ^^^ +>a2 : number +> : ^^^^^^ +>b2 : number +> : ^^^^^^ +>1 + a2 : number +> : ^^^^^^ >1 : 1 > : ^ ->a2 : any -> : ^^^ +>a2 : number +> : ^^^^^^ >[1] : [number] > : ^^^^^^^^ >1 : 1 @@ -41,26 +41,26 @@ function f2() { > : ^^^^^^^^^^ const [a1, b1 = a1] = ['hi']; ->a1 : any -> : ^^^ ->b1 : any -> : ^^^ ->a1 : any -> : ^^^ +>a1 : string +> : ^^^^^^ +>b1 : string +> : ^^^^^^ +>a1 : string +> : ^^^^^^ >['hi'] : [string] > : ^^^^^^^^ >'hi' : "hi" > : ^^^^ const [a2, b2 = a2 + '!'] = ['hi']; ->a2 : any -> : ^^^ +>a2 : string +> : ^^^^^^ >b2 : string > : ^^^^^^ >a2 + '!' : string > : ^^^^^^ ->a2 : any -> : ^^^ +>a2 : string +> : ^^^^^^ >'!' : "!" > : ^^^ >['hi'] : [string] @@ -75,12 +75,12 @@ function f3() { > : ^^^^^^^^^^ const [a1, b1 = a1] = ['hi', 1]; ->a1 : any -> : ^^^ ->b1 : any -> : ^^^ ->a1 : any -> : ^^^ +>a1 : string +> : ^^^^^^ +>b1 : string | number +> : ^^^^^^^^^^^^^^^ +>a1 : string +> : ^^^^^^ >['hi', 1] : [string, number] > : ^^^^^^^^^^^^^^^^ >'hi' : "hi" @@ -89,14 +89,14 @@ function f3() { > : ^ const [a2, b2 = a2 + '!'] = ['hi', 1]; ->a2 : any -> : ^^^ +>a2 : string +> : ^^^^^^ >b2 : string | number > : ^^^^^^^^^^^^^^^ >a2 + '!' : string > : ^^^^^^ ->a2 : any -> : ^^^ +>a2 : string +> : ^^^^^^ >'!' : "!" > : ^^^ >['hi', 1] : [string, number] @@ -118,8 +118,8 @@ function f4() { > : ^^^^^^^^^^ const [ a, b = a ] = yadda ?? []; ->a : any -> : ^^^ +>a : number +> : ^^^^^^ >b : number > : ^^^^^^ >a : number diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.errors.txt b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.errors.txt deleted file mode 100644 index 506000005bbff..0000000000000 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.errors.txt +++ /dev/null @@ -1,49 +0,0 @@ -destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(3,13): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(4,13): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(9,13): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(10,13): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(15,13): error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(16,13): error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. -destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts(23,13): error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - - -==== destructuringObjectBindingPatternAndAssignment9SiblingInitializer.ts (7 errors) ==== - // To be inferred as `number` - function f1() { - const { a1, b1 = a1 } = { a1: 1 }; - ~~ -!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - const { a2, b2 = 1 + a2 } = { a2: 1 }; - ~~ -!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - } - - // To be inferred as `string` - function f2() { - const { a1, b1 = a1 } = { a1: 'hi' }; - ~~ -!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - const { a2, b2 = a2 + '!' } = { a2: 'hi' }; - ~~ -!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - } - - // To be inferred as `string | number` - function f3() { - const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; - ~~ -!!! error TS7022: 'a1' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; - ~~ -!!! error TS7022: 'a2' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - } - - // Based on comment: - // - https://github.com/microsoft/TypeScript/issues/49989#issuecomment-1852694486 - declare const yadda: { a?: number, b?: number } | undefined - function f4() { - const { a, b = a } = yadda ?? {}; - ~ -!!! error TS7022: 'a' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer. - } - \ No newline at end of file diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types index a08c84f3ed1a5..9366b5542651f 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment9SiblingInitializer.types @@ -7,12 +7,12 @@ function f1() { > : ^^^^^^^^^^ const { a1, b1 = a1 } = { a1: 1 }; ->a1 : any -> : ^^^ ->b1 : any -> : ^^^ ->a1 : any -> : ^^^ +>a1 : number +> : ^^^^^^ +>b1 : number +> : ^^^^^^ +>a1 : number +> : ^^^^^^ >{ a1: 1 } : { a1: number; } > : ^^^^^^^^^^^^^^^ >a1 : number @@ -21,16 +21,16 @@ function f1() { > : ^ const { a2, b2 = 1 + a2 } = { a2: 1 }; ->a2 : any -> : ^^^ ->b2 : any -> : ^^^ ->1 + a2 : any -> : ^^^ +>a2 : number +> : ^^^^^^ +>b2 : number +> : ^^^^^^ +>1 + a2 : number +> : ^^^^^^ >1 : 1 > : ^ ->a2 : any -> : ^^^ +>a2 : number +> : ^^^^^^ >{ a2: 1 } : { a2: number; } > : ^^^^^^^^^^^^^^^ >a2 : number @@ -45,12 +45,12 @@ function f2() { > : ^^^^^^^^^^ const { a1, b1 = a1 } = { a1: 'hi' }; ->a1 : any -> : ^^^ ->b1 : any -> : ^^^ ->a1 : any -> : ^^^ +>a1 : string +> : ^^^^^^ +>b1 : string +> : ^^^^^^ +>a1 : string +> : ^^^^^^ >{ a1: 'hi' } : { a1: string; } > : ^^^^^^^^^^^^^^^ >a1 : string @@ -59,14 +59,14 @@ function f2() { > : ^^^^ const { a2, b2 = a2 + '!' } = { a2: 'hi' }; ->a2 : any -> : ^^^ +>a2 : string +> : ^^^^^^ >b2 : string > : ^^^^^^ >a2 + '!' : string > : ^^^^^^ ->a2 : any -> : ^^^ +>a2 : string +> : ^^^^^^ >'!' : "!" > : ^^^ >{ a2: 'hi' } : { a2: string; } @@ -83,12 +83,12 @@ function f3() { > : ^^^^^^^^^^ const { a1, b1 = a1 } = { a1: 'hi', b1: 1 }; ->a1 : any -> : ^^^ ->b1 : any -> : ^^^ ->a1 : any -> : ^^^ +>a1 : string +> : ^^^^^^ +>b1 : string | number +> : ^^^^^^^^^^^^^^^ +>a1 : string +> : ^^^^^^ >{ a1: 'hi', b1: 1 } : { a1: string; b1?: number; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >a1 : string @@ -101,14 +101,14 @@ function f3() { > : ^ const { a2, b2 = a2 + '!' } = { a2: 'hi', b2: 1 }; ->a2 : any -> : ^^^ +>a2 : string +> : ^^^^^^ >b2 : string | number > : ^^^^^^^^^^^^^^^ >a2 + '!' : string > : ^^^^^^ ->a2 : any -> : ^^^ +>a2 : string +> : ^^^^^^ >'!' : "!" > : ^^^ >{ a2: 'hi', b2: 1 } : { a2: string; b2?: number; } @@ -138,12 +138,12 @@ function f4() { > : ^^^^^^^^^^ const { a, b = a } = yadda ?? {}; ->a : any -> : ^^^ ->b : any -> : ^^^ ->a : any -> : ^^^ +>a : number +> : ^^^^^^ +>b : number +> : ^^^^^^ +>a : number +> : ^^^^^^ >yadda ?? {} : { a?: number; b?: number; } > : ^^^^^^ ^^^^^^ ^^^ >yadda : { a?: number; b?: number; } diff --git a/tests/baselines/reference/useBeforeDeclaration_destructuring.types b/tests/baselines/reference/useBeforeDeclaration_destructuring.types index fbe75b58947bf..545a6c4df1011 100644 --- a/tests/baselines/reference/useBeforeDeclaration_destructuring.types +++ b/tests/baselines/reference/useBeforeDeclaration_destructuring.types @@ -2,16 +2,16 @@ === useBeforeDeclaration_destructuring.ts === a; ->a : any -> : ^^^ +>a : string +> : ^^^^^^ let {a, b = a} = {a: '', b: 1}; ->a : any -> : ^^^ ->b : any -> : ^^^ ->a : any -> : ^^^ +>a : string +> : ^^^^^^ +>b : string | number +> : ^^^^^^^^^^^^^^^ +>a : string +> : ^^^^^^ >{a: '', b: 1} : { a: string; b?: number; } > : ^^^^^^^^^^^^^^^^^^^^^^^^^^ >a : string @@ -24,8 +24,8 @@ let {a, b = a} = {a: '', b: 1}; > : ^ b; ->b : any -> : ^^^ +>b : string | number +> : ^^^^^^^^^^^^^^^ function test({c, d = c}: Record) {} >test : ({ c, d }: Record) => void From aecda54eb3d19292053b0dad92241b7aacbd0009 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Jul 2024 17:37:35 -0700 Subject: [PATCH 7/9] Pad elements of destructured parameters --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6950703124bf3..5537f700b59c6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -40126,7 +40126,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const type = getQuickTypeOfExpression(initializer) || (contextualType ? checkExpressionWithContextualType(initializer, contextualType, /*inferenceContext*/ undefined, checkMode || CheckMode.Normal) : checkExpressionCached(initializer, checkMode)); - if (isParameter(declaration)) { + if (isParameter(isBindingElement(declaration) ? walkUpBindingElementsAndPatterns(declaration) : declaration)) { if (declaration.name.kind === SyntaxKind.ObjectBindingPattern && isObjectLiteralType(type)) { return padObjectLiteralType(type as ObjectType, declaration.name); } From e23ad6194fa9b98484e212e964d2b76e5eb6091b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 9 Jul 2024 06:31:38 -0700 Subject: [PATCH 8/9] Add tests --- .../intraBindingPatternReferences.errors.txt | 25 +++ .../intraBindingPatternReferences.symbols | 60 ++++++++ .../intraBindingPatternReferences.types | 144 ++++++++++++++++++ .../compiler/intraBindingPatternReferences.ts | 21 +++ 4 files changed, 250 insertions(+) create mode 100644 tests/baselines/reference/intraBindingPatternReferences.errors.txt create mode 100644 tests/baselines/reference/intraBindingPatternReferences.symbols create mode 100644 tests/baselines/reference/intraBindingPatternReferences.types create mode 100644 tests/cases/compiler/intraBindingPatternReferences.ts diff --git a/tests/baselines/reference/intraBindingPatternReferences.errors.txt b/tests/baselines/reference/intraBindingPatternReferences.errors.txt new file mode 100644 index 0000000000000..11cbe9cf5bcb7 --- /dev/null +++ b/tests/baselines/reference/intraBindingPatternReferences.errors.txt @@ -0,0 +1,25 @@ +intraBindingPatternReferences.ts(18,71): error TS7006: Parameter 'x' implicitly has an 'any' type. + + +==== intraBindingPatternReferences.ts (1 errors) ==== + // https://github.com/microsoft/TypeScript/issues/59177 + + function foo() { return a } + + const [a, b = a + 1] = [42]; + + const [c1, c2 = c1] = [123]; + const [d1, d2 = d1, d3 = d2] = [123]; + + const { e1, e2 = e1 } = { e1: 1 }; + const { f1, f2 = f1, f3 = f2 } = { f1: 1 }; + + // Example that requires padding of object literal types at depth + const mockCallback = ({ event: { params = {} } = {} }) => {}; + + // The contextual type for the second lambda in the object literal is 'any' because of the + // intra-binding-pattern reference in the initializer for fn2 + const { fn1 = (x: number) => 0, fn2 = fn1 } = { fn1: x => x + 1, fn2: x => x + 2 }; + ~ +!!! error TS7006: Parameter 'x' implicitly has an 'any' type. + \ No newline at end of file diff --git a/tests/baselines/reference/intraBindingPatternReferences.symbols b/tests/baselines/reference/intraBindingPatternReferences.symbols new file mode 100644 index 0000000000000..8d7008be269be --- /dev/null +++ b/tests/baselines/reference/intraBindingPatternReferences.symbols @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/intraBindingPatternReferences.ts] //// + +=== intraBindingPatternReferences.ts === +// https://github.com/microsoft/TypeScript/issues/59177 + +function foo() { return a } +>foo : Symbol(foo, Decl(intraBindingPatternReferences.ts, 0, 0)) +>a : Symbol(a, Decl(intraBindingPatternReferences.ts, 4, 7)) + +const [a, b = a + 1] = [42]; +>a : Symbol(a, Decl(intraBindingPatternReferences.ts, 4, 7)) +>b : Symbol(b, Decl(intraBindingPatternReferences.ts, 4, 9)) +>a : Symbol(a, Decl(intraBindingPatternReferences.ts, 4, 7)) + +const [c1, c2 = c1] = [123]; +>c1 : Symbol(c1, Decl(intraBindingPatternReferences.ts, 6, 7)) +>c2 : Symbol(c2, Decl(intraBindingPatternReferences.ts, 6, 10)) +>c1 : Symbol(c1, Decl(intraBindingPatternReferences.ts, 6, 7)) + +const [d1, d2 = d1, d3 = d2] = [123]; +>d1 : Symbol(d1, Decl(intraBindingPatternReferences.ts, 7, 7)) +>d2 : Symbol(d2, Decl(intraBindingPatternReferences.ts, 7, 10)) +>d1 : Symbol(d1, Decl(intraBindingPatternReferences.ts, 7, 7)) +>d3 : Symbol(d3, Decl(intraBindingPatternReferences.ts, 7, 19)) +>d2 : Symbol(d2, Decl(intraBindingPatternReferences.ts, 7, 10)) + +const { e1, e2 = e1 } = { e1: 1 }; +>e1 : Symbol(e1, Decl(intraBindingPatternReferences.ts, 9, 7)) +>e2 : Symbol(e2, Decl(intraBindingPatternReferences.ts, 9, 11)) +>e1 : Symbol(e1, Decl(intraBindingPatternReferences.ts, 9, 7)) +>e1 : Symbol(e1, Decl(intraBindingPatternReferences.ts, 9, 25)) + +const { f1, f2 = f1, f3 = f2 } = { f1: 1 }; +>f1 : Symbol(f1, Decl(intraBindingPatternReferences.ts, 10, 7)) +>f2 : Symbol(f2, Decl(intraBindingPatternReferences.ts, 10, 11)) +>f1 : Symbol(f1, Decl(intraBindingPatternReferences.ts, 10, 7)) +>f3 : Symbol(f3, Decl(intraBindingPatternReferences.ts, 10, 20)) +>f2 : Symbol(f2, Decl(intraBindingPatternReferences.ts, 10, 11)) +>f1 : Symbol(f1, Decl(intraBindingPatternReferences.ts, 10, 34)) + +// Example that requires padding of object literal types at depth +const mockCallback = ({ event: { params = {} } = {} }) => {}; +>mockCallback : Symbol(mockCallback, Decl(intraBindingPatternReferences.ts, 13, 5)) +>event : Symbol(event) +>params : Symbol(params, Decl(intraBindingPatternReferences.ts, 13, 32)) + +// The contextual type for the second lambda in the object literal is 'any' because of the +// intra-binding-pattern reference in the initializer for fn2 +const { fn1 = (x: number) => 0, fn2 = fn1 } = { fn1: x => x + 1, fn2: x => x + 2 }; +>fn1 : Symbol(fn1, Decl(intraBindingPatternReferences.ts, 17, 7)) +>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 15)) +>fn2 : Symbol(fn2, Decl(intraBindingPatternReferences.ts, 17, 31)) +>fn1 : Symbol(fn1, Decl(intraBindingPatternReferences.ts, 17, 7)) +>fn1 : Symbol(fn1, Decl(intraBindingPatternReferences.ts, 17, 47)) +>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 52)) +>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 52)) +>fn2 : Symbol(fn2, Decl(intraBindingPatternReferences.ts, 17, 64)) +>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 69)) +>x : Symbol(x, Decl(intraBindingPatternReferences.ts, 17, 69)) + diff --git a/tests/baselines/reference/intraBindingPatternReferences.types b/tests/baselines/reference/intraBindingPatternReferences.types new file mode 100644 index 0000000000000..ef877b74a888b --- /dev/null +++ b/tests/baselines/reference/intraBindingPatternReferences.types @@ -0,0 +1,144 @@ +//// [tests/cases/compiler/intraBindingPatternReferences.ts] //// + +=== intraBindingPatternReferences.ts === +// https://github.com/microsoft/TypeScript/issues/59177 + +function foo() { return a } +>foo : () => number +> : ^^^^^^^^^^^^ +>a : number +> : ^^^^^^ + +const [a, b = a + 1] = [42]; +>a : number +> : ^^^^^^ +>b : number +> : ^^^^^^ +>a + 1 : number +> : ^^^^^^ +>a : number +> : ^^^^^^ +>1 : 1 +> : ^ +>[42] : [number] +> : ^^^^^^^^ +>42 : 42 +> : ^^ + +const [c1, c2 = c1] = [123]; +>c1 : number +> : ^^^^^^ +>c2 : number +> : ^^^^^^ +>c1 : number +> : ^^^^^^ +>[123] : [number] +> : ^^^^^^^^ +>123 : 123 +> : ^^^ + +const [d1, d2 = d1, d3 = d2] = [123]; +>d1 : number +> : ^^^^^^ +>d2 : number +> : ^^^^^^ +>d1 : number +> : ^^^^^^ +>d3 : number +> : ^^^^^^ +>d2 : number +> : ^^^^^^ +>[123] : [number] +> : ^^^^^^^^ +>123 : 123 +> : ^^^ + +const { e1, e2 = e1 } = { e1: 1 }; +>e1 : number +> : ^^^^^^ +>e2 : number +> : ^^^^^^ +>e1 : number +> : ^^^^^^ +>{ e1: 1 } : { e1: number; } +> : ^^^^^^^^^^^^^^^ +>e1 : number +> : ^^^^^^ +>1 : 1 +> : ^ + +const { f1, f2 = f1, f3 = f2 } = { f1: 1 }; +>f1 : number +> : ^^^^^^ +>f2 : number +> : ^^^^^^ +>f1 : number +> : ^^^^^^ +>f3 : number +> : ^^^^^^ +>f2 : number +> : ^^^^^^ +>{ f1: 1 } : { f1: number; } +> : ^^^^^^^^^^^^^^^ +>f1 : number +> : ^^^^^^ +>1 : 1 +> : ^ + +// Example that requires padding of object literal types at depth +const mockCallback = ({ event: { params = {} } = {} }) => {}; +>mockCallback : ({ event: { params } }: { event?: { params?: {} | undefined; } | undefined; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>({ event: { params = {} } = {} }) => {} : ({ event: { params } }: { event?: { params?: {} | undefined; } | undefined; }) => void +> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>event : any +> : ^^^ +>params : {} +> : ^^ +>{} : {} +> : ^^ +>{} : {} +> : ^^ + +// The contextual type for the second lambda in the object literal is 'any' because of the +// intra-binding-pattern reference in the initializer for fn2 +const { fn1 = (x: number) => 0, fn2 = fn1 } = { fn1: x => x + 1, fn2: x => x + 2 }; +>fn1 : (x: number) => number +> : ^ ^^ ^^^^^^^^^^^ +>(x: number) => 0 : (x: number) => number +> : ^ ^^ ^^^^^^^^^^^ +>x : number +> : ^^^^^^ +>0 : 0 +> : ^ +>fn2 : ((x: number) => number) | ((x: any) => any) +> : ^^ ^^ ^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ +>fn1 : (x: number) => number +> : ^ ^^ ^^^^^^^^^^^ +>{ fn1: x => x + 1, fn2: x => x + 2 } : { fn1?: (x: number) => number; fn2?: (x: any) => any; } +> : ^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ +>fn1 : (x: number) => number +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x => x + 1 : (x: number) => number +> : ^ ^^^^^^^^^^^^^^^^^^^ +>x : number +> : ^^^^^^ +>x + 1 : number +> : ^^^^^^ +>x : number +> : ^^^^^^ +>1 : 1 +> : ^ +>fn2 : (x: any) => any +> : ^ ^^^^^^^^^^^^^ +>x => x + 2 : (x: any) => any +> : ^ ^^^^^^^^^^^^^ +>x : any +> : ^^^ +>x + 2 : any +> : ^^^ +>x : any +> : ^^^ +>2 : 2 +> : ^ + diff --git a/tests/cases/compiler/intraBindingPatternReferences.ts b/tests/cases/compiler/intraBindingPatternReferences.ts new file mode 100644 index 0000000000000..4af5d7675ee72 --- /dev/null +++ b/tests/cases/compiler/intraBindingPatternReferences.ts @@ -0,0 +1,21 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/59177 + +function foo() { return a } + +const [a, b = a + 1] = [42]; + +const [c1, c2 = c1] = [123]; +const [d1, d2 = d1, d3 = d2] = [123]; + +const { e1, e2 = e1 } = { e1: 1 }; +const { f1, f2 = f1, f3 = f2 } = { f1: 1 }; + +// Example that requires padding of object literal types at depth +const mockCallback = ({ event: { params = {} } = {} }) => {}; + +// The contextual type for the second lambda in the object literal is 'any' because of the +// intra-binding-pattern reference in the initializer for fn2 +const { fn1 = (x: number) => 0, fn2 = fn1 } = { fn1: x => x + 1, fn2: x => x + 2 }; From d36e028769a51715bdc708887a17b85e214175b1 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 9 Jul 2024 06:46:56 -0700 Subject: [PATCH 9/9] Remove unused error message --- src/compiler/diagnosticMessages.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ee05ca893c7e6..3057d6c6d6ddb 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2680,10 +2680,6 @@ "category": "Error", "code": 2524 }, - "Initializer provides no value for this binding element and the binding element has no default value.": { - "category": "Error", - "code": 2525 - }, "A 'this' type is available only in a non-static member of a class or interface.": { "category": "Error", "code": 2526