From f89e69581e4c792fcda3fa302def3f69481843e3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 8 Jan 2026 01:33:50 +0000 Subject: [PATCH] Correct some incorrectly-added `declare` in functions. --- ...llSignaturesShouldBeResolvedBeforeSpecialization.ts | 2 +- ...ithTypeParameterConstrainedToOtherTypeParameter2.ts | 10 +++++----- tests/cases/compiler/exportSpecifierForAGlobal.ts | 2 +- tests/cases/compiler/genericConstructorFunction1.ts | 4 ++-- .../assignmentCompatWithNumericIndexer2.ts | 8 ++++---- .../assignmentCompatWithNumericIndexer3.ts | 6 +++--- .../assignmentCompatWithStringIndexer2.ts | 6 +++--- .../assignmentCompatWithStringIndexer3.ts | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts b/tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts index 537719fb3b9..a373ec20ce3 100644 --- a/tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts +++ b/tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts @@ -4,7 +4,7 @@ interface I1 { } function foo() { - declare var test: I1; + var test!: I1; test("expects boolean instead of string"); // should not error - "test" should not expect a boolean test(true); // should error - string expected } \ No newline at end of file diff --git a/tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts b/tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts index da297c98805..a22bf10a38c 100644 --- a/tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts +++ b/tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts @@ -1,8 +1,8 @@ class Chain { constructor(public value: T) { } then(cb: (x: T) => S): Chain { - declare var t: T; - declare var s: S; + var t!: T; + var s!: S; // Ok to go down the chain, but error to climb up the chain (new Chain(t)).then(tt => s).then(ss => t); @@ -24,9 +24,9 @@ interface I { class Chain2 { constructor(public value: T) { } then(cb: (x: T) => S): Chain2 { - declare var i: I; - declare var t: T; - declare var s: S; + var i!: I; + var t!: T; + var s!: S; // Ok to go down the chain, check the constraint at the end. // Should get an error that we are assigning a string to a number (new Chain2(i)).then(ii => t).then(tt => s).value.x = ""; diff --git a/tests/cases/compiler/exportSpecifierForAGlobal.ts b/tests/cases/compiler/exportSpecifierForAGlobal.ts index 85c8f0e9d58..058648090da 100644 --- a/tests/cases/compiler/exportSpecifierForAGlobal.ts +++ b/tests/cases/compiler/exportSpecifierForAGlobal.ts @@ -7,6 +7,6 @@ declare class X { } // @filename: b.ts export {X}; export function f() { - declare var x: X; + var x!: X; return x; } diff --git a/tests/cases/compiler/genericConstructorFunction1.ts b/tests/cases/compiler/genericConstructorFunction1.ts index 948740ea342..cb1efab977a 100644 --- a/tests/cases/compiler/genericConstructorFunction1.ts +++ b/tests/cases/compiler/genericConstructorFunction1.ts @@ -1,5 +1,5 @@ function f1(args: T) { - declare var v1: { [index: string]: new (arg: T) => Date }; + var v1!: { [index: string]: new (arg: T) => Date }; var v2 = v1['test']; v2(args); return new v2(args); // used to give error @@ -8,7 +8,7 @@ function f1(args: T) { interface I1 { new (arg: T): Date }; function f2(args: T) { - declare var v1: { [index: string]: I1 }; + var v1!: { [index: string]: I1 }; var v2 = v1['test']; var y = v2(args); return new v2(args); // used to give error diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts index acb38a2cba9..51a9a569803 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts @@ -27,16 +27,16 @@ namespace Generics { } function foo() { - declare var a: A; - declare var b: { [x: number]: Derived; } + var a!: A; + var b!: { [x: number]: Derived; } a = b; // error b = a; // error - declare var b2: { [x: number]: Derived2; } + var b2!: { [x: number]: Derived2; } a = b2; // error b2 = a; // error - declare var b3: { [x: number]: T; } + var b3!: { [x: number]: T; } a = b3; // ok b3 = a; // ok } diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts index 7dd33eefe3d..304f5ca3c89 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts @@ -28,12 +28,12 @@ namespace Generics { } function foo() { - declare var a: A; - declare var b: { [x: number]: Derived; }; + var a!: A; + var b!: { [x: number]: Derived; }; a = b; // error b = a; // ok - declare var b2: { [x: number]: T; }; + var b2!: { [x: number]: T; }; a = b2; // ok b2 = a; // ok } diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts index 8b5c2eb273e..830ea07c75e 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts @@ -41,12 +41,12 @@ namespace Generics { b2 = a1; // error function foo() { - declare var b3: { [x: string]: Derived; }; - declare var a3: A; + var b3!: { [x: string]: Derived; }; + var a3!: A; a3 = b3; // error b3 = a3; // error - declare var b4: { [x: string]: Derived2; }; + var b4!: { [x: string]: Derived2; }; a3 = b4; // error b4 = a3; // error } diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts index ab93e183940..6ede9b50046 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts @@ -15,8 +15,8 @@ namespace Generics { } function foo() { - declare var a: A; - declare var b: { [x: string]: string; }; + var a!: A; + var b!: { [x: string]: string; }; a = b; // error b = a; // error }