From 177d13db2eacc64e3d79a7d1fa92aeaf62ee7f7e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 19:28:48 +0000 Subject: [PATCH 01/10] Update tests sensitive to CFA. --- .../stringLiteralTypesWithVariousOperators01.ts | 8 ++++---- .../stringLiteralTypesWithVariousOperators02.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts index 28c34d3c74a99..83855b9d2dfcd 100644 --- a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts @@ -1,9 +1,9 @@ // @declaration: true -let abc: "ABC" = "ABC"; -let xyz: "XYZ" = "XYZ"; -let abcOrXyz: "ABC" | "XYZ" = abc || xyz; -let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; +declare let abc: "ABC"; +declare let xyz: "XYZ"; +declare let abcOrXyz: "ABC" | "XYZ"; +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; let a = "" + abc; let b = abc + ""; diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts index cf66f66e47c30..75b04b2b9daf4 100644 --- a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts @@ -1,9 +1,9 @@ // @declaration: true -let abc: "ABC" = "ABC"; -let xyz: "XYZ" = "XYZ"; -let abcOrXyz: "ABC" | "XYZ" = abc || xyz; -let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; +declare let abc: "ABC"; +declare let xyz: "XYZ"; +declare let abcOrXyz: "ABC" | "XYZ"; +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; let a = abcOrXyzOrNumber + 100; let b = 100 + abcOrXyzOrNumber; From 8d4d9c908df59558eb9556dc0bac85127599be3c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 19:29:00 +0000 Subject: [PATCH 02/10] Turn strict off in widening tests. --- tests/cases/conformance/types/tuple/wideningTuples1.ts | 1 + tests/cases/conformance/types/tuple/wideningTuples2.ts | 1 + tests/cases/conformance/types/tuple/wideningTuples3.ts | 1 + tests/cases/conformance/types/tuple/wideningTuples4.ts | 1 + tests/cases/conformance/types/tuple/wideningTuples5.ts | 1 + tests/cases/conformance/types/tuple/wideningTuples6.ts | 1 + tests/cases/conformance/types/tuple/wideningTuples7.ts | 1 + 7 files changed, 7 insertions(+) diff --git a/tests/cases/conformance/types/tuple/wideningTuples1.ts b/tests/cases/conformance/types/tuple/wideningTuples1.ts index f4885435dcfab..7cd9551fd9d4d 100644 --- a/tests/cases/conformance/types/tuple/wideningTuples1.ts +++ b/tests/cases/conformance/types/tuple/wideningTuples1.ts @@ -1,3 +1,4 @@ +//@strict: false //@noImplicitAny: true declare function foo(x: T): T; diff --git a/tests/cases/conformance/types/tuple/wideningTuples2.ts b/tests/cases/conformance/types/tuple/wideningTuples2.ts index d8bf124854663..5a69be75de73e 100644 --- a/tests/cases/conformance/types/tuple/wideningTuples2.ts +++ b/tests/cases/conformance/types/tuple/wideningTuples2.ts @@ -1,3 +1,4 @@ +//@strict: false //@noImplicitAny: true var foo: () => [any] = function bar() { let intermediate = bar(); diff --git a/tests/cases/conformance/types/tuple/wideningTuples3.ts b/tests/cases/conformance/types/tuple/wideningTuples3.ts index a6837be2a0fac..5a140bbefdfdf 100644 --- a/tests/cases/conformance/types/tuple/wideningTuples3.ts +++ b/tests/cases/conformance/types/tuple/wideningTuples3.ts @@ -1,3 +1,4 @@ +//@strict: false //@noImplicitAny: true var a: [any]; diff --git a/tests/cases/conformance/types/tuple/wideningTuples4.ts b/tests/cases/conformance/types/tuple/wideningTuples4.ts index 550ba07f60012..2583e194495e9 100644 --- a/tests/cases/conformance/types/tuple/wideningTuples4.ts +++ b/tests/cases/conformance/types/tuple/wideningTuples4.ts @@ -1,3 +1,4 @@ +//@strict: false var a: [any]; var b = a = [undefined, null]; diff --git a/tests/cases/conformance/types/tuple/wideningTuples5.ts b/tests/cases/conformance/types/tuple/wideningTuples5.ts index 36434c6eafe22..67ec7f31c85bb 100644 --- a/tests/cases/conformance/types/tuple/wideningTuples5.ts +++ b/tests/cases/conformance/types/tuple/wideningTuples5.ts @@ -1,2 +1,3 @@ +//@strict: false //@noImplicitAny: true var [a, b] = [undefined, null]; \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples6.ts b/tests/cases/conformance/types/tuple/wideningTuples6.ts index cac228ecb4d02..be2bd335c6aa3 100644 --- a/tests/cases/conformance/types/tuple/wideningTuples6.ts +++ b/tests/cases/conformance/types/tuple/wideningTuples6.ts @@ -1,3 +1,4 @@ +//@strict: false var [a, b] = [undefined, null]; a = ""; b = ""; \ No newline at end of file diff --git a/tests/cases/conformance/types/tuple/wideningTuples7.ts b/tests/cases/conformance/types/tuple/wideningTuples7.ts index 1a4d212d3622d..3091df5b3cb87 100644 --- a/tests/cases/conformance/types/tuple/wideningTuples7.ts +++ b/tests/cases/conformance/types/tuple/wideningTuples7.ts @@ -1,3 +1,4 @@ +//@strict: false //@noImplicitAny: true var foo = function bar() { let intermediate: [string]; From 390058959625ef887d98df20e49e431a616eddaf Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 19:30:05 +0000 Subject: [PATCH 03/10] Update tests with output sensitive to `strictNullChecks`. --- .../cases/compiler/metadataOfClassFromAlias.ts | 18 ++++++++++++++---- .../cases/compiler/metadataOfUnionWithNull.ts | 1 + .../metadataReferencedWithinFilteredUnion.ts | 8 +++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tests/cases/compiler/metadataOfClassFromAlias.ts b/tests/cases/compiler/metadataOfClassFromAlias.ts index c7407c8d76603..7de4777970e15 100644 --- a/tests/cases/compiler/metadataOfClassFromAlias.ts +++ b/tests/cases/compiler/metadataOfClassFromAlias.ts @@ -2,17 +2,27 @@ // @emitDecoratorMetadata: true // @target: es5 // @module: commonjs +// @strict: true, false -// @filename: auxiliry.ts +// @filename: auxiliary.ts export class SomeClass { field: string; } -//@filename: test.ts -import { SomeClass } from './auxiliry'; +//@filename: testA.ts +import { SomeClass } from './auxiliary'; function annotation(): PropertyDecorator { return (target: any): void => { }; } export class ClassA { - @annotation() array: SomeClass | null; + @annotation() aaa: SomeClass; +} + +//@filename: testB.ts +import { SomeClass } from './auxiliary'; +function annotation(): PropertyDecorator { + return (target: any): void => { }; +} +export class ClassB { + @annotation() bbb: SomeClass | null; } \ No newline at end of file diff --git a/tests/cases/compiler/metadataOfUnionWithNull.ts b/tests/cases/compiler/metadataOfUnionWithNull.ts index bb4d93189fc66..46ac77877e718 100644 --- a/tests/cases/compiler/metadataOfUnionWithNull.ts +++ b/tests/cases/compiler/metadataOfUnionWithNull.ts @@ -1,5 +1,6 @@ // @experimentalDecorators: true // @emitDecoratorMetadata: true +// @strict: true, false function PropDeco(target: Object, propKey: string | symbol) { } class A { diff --git a/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts b/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts index 6fd19622f8803..3b83b52dd6f97 100644 --- a/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts +++ b/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts @@ -2,6 +2,8 @@ // @emitDecoratorMetadata: true // @target: es5 // @filename: Class1.ts +// @strict: true, false + export class Class1 { } // @filename: Class2.ts @@ -12,7 +14,11 @@ function decorate(target: any, propertyKey: string) { export class Class2 { @decorate - get prop(): Class1 | undefined { + get maybeProp(): Class1 | undefined { + return undefined; + } + @decorate + get prop(): Class1 { return undefined; } } \ No newline at end of file From 419e1e0f1eda503086231c1acd485fb6bd9a8dc6 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 19:30:52 +0000 Subject: [PATCH 04/10] Some strictPropertyInitialization updates. --- tests/cases/compiler/2dArrays.ts | 6 +++--- tests/cases/compiler/abstractPropertyBasics.ts | 2 +- tests/cases/compiler/metadataOfUnion.ts | 1 + tests/cases/compiler/metadataOfUnionWithNull.ts | 3 ++- .../cases/compiler/metadataReferencedWithinFilteredUnion.ts | 3 ++- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/cases/compiler/2dArrays.ts b/tests/cases/compiler/2dArrays.ts index 5a3dac3fff60e..7fe0cb43a27a3 100644 --- a/tests/cases/compiler/2dArrays.ts +++ b/tests/cases/compiler/2dArrays.ts @@ -2,12 +2,12 @@ class Cell { } class Ship { - isSunk: boolean; + isSunk: boolean = false; } class Board { - ships: Ship[]; - cells: Cell[]; + ships: Ship[] = []; + cells: Cell[] = []; private allShipsSunk() { return this.ships.every(function (val) { return val.isSunk; }); diff --git a/tests/cases/compiler/abstractPropertyBasics.ts b/tests/cases/compiler/abstractPropertyBasics.ts index c0b76057a6b08..c8fd32b52b902 100644 --- a/tests/cases/compiler/abstractPropertyBasics.ts +++ b/tests/cases/compiler/abstractPropertyBasics.ts @@ -17,6 +17,6 @@ class C extends B { set prop(v) { } raw = "edge"; readonly ro = "readonly please"; - readonlyProp: string; // don't have to give a value, in fact + readonlyProp!: string; m() { } } \ No newline at end of file diff --git a/tests/cases/compiler/metadataOfUnion.ts b/tests/cases/compiler/metadataOfUnion.ts index 2093357cb31e0..a398cfb4a3fe0 100644 --- a/tests/cases/compiler/metadataOfUnion.ts +++ b/tests/cases/compiler/metadataOfUnion.ts @@ -1,5 +1,6 @@ // @experimentalDecorators: true // @emitDecoratorMetadata: true +// @strictPropertyInitialization: false function PropDeco(target: Object, propKey: string | symbol) { } class A { diff --git a/tests/cases/compiler/metadataOfUnionWithNull.ts b/tests/cases/compiler/metadataOfUnionWithNull.ts index 46ac77877e718..066fdfde19c21 100644 --- a/tests/cases/compiler/metadataOfUnionWithNull.ts +++ b/tests/cases/compiler/metadataOfUnionWithNull.ts @@ -1,6 +1,7 @@ // @experimentalDecorators: true // @emitDecoratorMetadata: true -// @strict: true, false +// @strictNullChecks: true, false +// @strictPropertyInitialization: false function PropDeco(target: Object, propKey: string | symbol) { } class A { diff --git a/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts b/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts index 3b83b52dd6f97..1ccb6ff5e1fcf 100644 --- a/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts +++ b/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts @@ -2,7 +2,8 @@ // @emitDecoratorMetadata: true // @target: es5 // @filename: Class1.ts -// @strict: true, false +// @strictNullChecks: true, false +// @strictPropertyInitialization: false export class Class1 { } From c1dcad5eff5b03a5cadf6a49fef723f8db3ee7af Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 19:31:24 +0000 Subject: [PATCH 05/10] strictNullChecks updates. --- tests/cases/compiler/APISample_Watch.ts | 2 +- .../typeArgumentLists/wrappedAndRecursiveConstraints.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cases/compiler/APISample_Watch.ts b/tests/cases/compiler/APISample_Watch.ts index 42b1fef4c4a0b..ae56cf6987dca 100644 --- a/tests/cases/compiler/APISample_Watch.ts +++ b/tests/cases/compiler/APISample_Watch.ts @@ -55,7 +55,7 @@ function watchMain() { // You can technically override any given hook on the host, though you probably don't need to. // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all. const origCreateProgram = host.createProgram; - host.createProgram = (rootNames: ReadonlyArray, options, host, oldProgram) => { + host.createProgram = (rootNames: ReadonlyArray | undefined, options, host, oldProgram) => { console.log("** We're about to create the program! **"); return origCreateProgram(rootNames, options, host, oldProgram); } diff --git a/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints.ts b/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints.ts index b731d8da42a72..3bc94dd5fe4b3 100644 --- a/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints.ts +++ b/tests/cases/conformance/types/typeParameters/typeArgumentLists/wrappedAndRecursiveConstraints.ts @@ -11,6 +11,6 @@ interface Foo extends Date { foo: string; } -var y: Foo = null; +var y: Foo = {} as Foo; var c = new C(y); var r = c.foo(y); \ No newline at end of file From 43d470e1293edcc14450de6eeef90a679d380684 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 19:52:51 +0000 Subject: [PATCH 06/10] Update baselines. --- tests/baselines/reference/2dArrays.js | 9 +- tests/baselines/reference/2dArrays.symbols | 10 +- tests/baselines/reference/2dArrays.types | 12 +- tests/baselines/reference/APISample_Watch.js | 2 +- .../reference/abstractPropertyBasics.js | 2 +- .../reference/abstractPropertyBasics.symbols | 4 +- .../reference/abstractPropertyBasics.types | 2 +- .../metadataOfClassFromAlias(strict=false).js | 89 +++++++++++++ ...dataOfClassFromAlias(strict=false).symbols | 49 ++++++++ ...tadataOfClassFromAlias(strict=false).types | 65 ++++++++++ ...taOfClassFromAlias(strict=true).errors.txt | 33 +++++ .../metadataOfClassFromAlias(strict=true).js | 88 +++++++++++++ ...adataOfClassFromAlias(strict=true).symbols | 49 ++++++++ ...etadataOfClassFromAlias(strict=true).types | 67 ++++++++++ .../reference/metadataOfClassFromAlias.js | 53 -------- .../metadataOfClassFromAlias.symbols | 29 ----- .../reference/metadataOfClassFromAlias.types | 38 ------ ...fUnionWithNull(strictnullchecks=false).js} | 0 ...nWithNull(strictnullchecks=false).symbols} | 0 ...ionWithNull(strictnullchecks=false).types} | 0 ...aOfUnionWithNull(strictnullchecks=true).js | 115 +++++++++++++++++ ...ionWithNull(strictnullchecks=true).symbols | 91 ++++++++++++++ ...UnionWithNull(strictnullchecks=true).types | 118 ++++++++++++++++++ ...inFilteredUnion(strictnullchecks=false).js | 78 ++++++++++++ ...eredUnion(strictnullchecks=false).symbols} | 14 ++- ...lteredUnion(strictnullchecks=false).types} | 14 ++- ...redUnion(strictnullchecks=true).errors.txt | 24 ++++ ...inFilteredUnion(strictnullchecks=true).js} | 18 ++- ...lteredUnion(strictnullchecks=true).symbols | 40 ++++++ ...FilteredUnion(strictnullchecks=true).types | 50 ++++++++ ...tringLiteralTypesWithVariousOperators01.js | 12 +- ...LiteralTypesWithVariousOperators01.symbols | 85 ++++++------- ...ngLiteralTypesWithVariousOperators01.types | 24 +--- ...eralTypesWithVariousOperators02.errors.txt | 8 +- ...tringLiteralTypesWithVariousOperators02.js | 12 +- ...LiteralTypesWithVariousOperators02.symbols | 51 ++++---- ...ngLiteralTypesWithVariousOperators02.types | 24 +--- .../wrappedAndRecursiveConstraints.js | 4 +- .../wrappedAndRecursiveConstraints.symbols | 3 +- .../wrappedAndRecursiveConstraints.types | 6 +- 40 files changed, 1117 insertions(+), 275 deletions(-) create mode 100644 tests/baselines/reference/metadataOfClassFromAlias(strict=false).js create mode 100644 tests/baselines/reference/metadataOfClassFromAlias(strict=false).symbols create mode 100644 tests/baselines/reference/metadataOfClassFromAlias(strict=false).types create mode 100644 tests/baselines/reference/metadataOfClassFromAlias(strict=true).errors.txt create mode 100644 tests/baselines/reference/metadataOfClassFromAlias(strict=true).js create mode 100644 tests/baselines/reference/metadataOfClassFromAlias(strict=true).symbols create mode 100644 tests/baselines/reference/metadataOfClassFromAlias(strict=true).types delete mode 100644 tests/baselines/reference/metadataOfClassFromAlias.js delete mode 100644 tests/baselines/reference/metadataOfClassFromAlias.symbols delete mode 100644 tests/baselines/reference/metadataOfClassFromAlias.types rename tests/baselines/reference/{metadataOfUnionWithNull.js => metadataOfUnionWithNull(strictnullchecks=false).js} (100%) rename tests/baselines/reference/{metadataOfUnionWithNull.symbols => metadataOfUnionWithNull(strictnullchecks=false).symbols} (100%) rename tests/baselines/reference/{metadataOfUnionWithNull.types => metadataOfUnionWithNull(strictnullchecks=false).types} (100%) create mode 100644 tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).js create mode 100644 tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).symbols create mode 100644 tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).types create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).js rename tests/baselines/reference/{metadataReferencedWithinFilteredUnion.symbols => metadataReferencedWithinFilteredUnion(strictnullchecks=false).symbols} (64%) rename tests/baselines/reference/{metadataReferencedWithinFilteredUnion.types => metadataReferencedWithinFilteredUnion(strictnullchecks=false).types} (68%) create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).errors.txt rename tests/baselines/reference/{metadataReferencedWithinFilteredUnion.js => metadataReferencedWithinFilteredUnion(strictnullchecks=true).js} (78%) create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).symbols create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).types diff --git a/tests/baselines/reference/2dArrays.js b/tests/baselines/reference/2dArrays.js index 67ca55be5f1e1..3c12da4a25ef8 100644 --- a/tests/baselines/reference/2dArrays.js +++ b/tests/baselines/reference/2dArrays.js @@ -5,12 +5,12 @@ class Cell { } class Ship { - isSunk: boolean; + isSunk: boolean = false; } class Board { - ships: Ship[]; - cells: Cell[]; + ships: Ship[] = []; + cells: Cell[] = []; private allShipsSunk() { return this.ships.every(function (val) { return val.isSunk; }); @@ -25,11 +25,14 @@ var Cell = /** @class */ (function () { }()); var Ship = /** @class */ (function () { function Ship() { + this.isSunk = false; } return Ship; }()); var Board = /** @class */ (function () { function Board() { + this.ships = []; + this.cells = []; } Board.prototype.allShipsSunk = function () { return this.ships.every(function (val) { return val.isSunk; }); diff --git a/tests/baselines/reference/2dArrays.symbols b/tests/baselines/reference/2dArrays.symbols index 3974e5e803d82..109c8307ff9fc 100644 --- a/tests/baselines/reference/2dArrays.symbols +++ b/tests/baselines/reference/2dArrays.symbols @@ -8,23 +8,23 @@ class Cell { class Ship { >Ship : Symbol(Ship, Decl(2dArrays.ts, 1, 1)) - isSunk: boolean; + isSunk: boolean = false; >isSunk : Symbol(Ship.isSunk, Decl(2dArrays.ts, 3, 12)) } class Board { >Board : Symbol(Board, Decl(2dArrays.ts, 5, 1)) - ships: Ship[]; + ships: Ship[] = []; >ships : Symbol(Board.ships, Decl(2dArrays.ts, 7, 13)) >Ship : Symbol(Ship, Decl(2dArrays.ts, 1, 1)) - cells: Cell[]; ->cells : Symbol(Board.cells, Decl(2dArrays.ts, 8, 18)) + cells: Cell[] = []; +>cells : Symbol(Board.cells, Decl(2dArrays.ts, 8, 23)) >Cell : Symbol(Cell, Decl(2dArrays.ts, 0, 0)) private allShipsSunk() { ->allShipsSunk : Symbol(Board.allShipsSunk, Decl(2dArrays.ts, 9, 18)) +>allShipsSunk : Symbol(Board.allShipsSunk, Decl(2dArrays.ts, 9, 23)) return this.ships.every(function (val) { return val.isSunk; }); >this.ships.every : Symbol(Array.every, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) diff --git a/tests/baselines/reference/2dArrays.types b/tests/baselines/reference/2dArrays.types index 74a962fff0424..3ad88ae6b15dc 100644 --- a/tests/baselines/reference/2dArrays.types +++ b/tests/baselines/reference/2dArrays.types @@ -10,22 +10,28 @@ class Ship { >Ship : Ship > : ^^^^ - isSunk: boolean; + isSunk: boolean = false; >isSunk : boolean > : ^^^^^^^ +>false : false +> : ^^^^^ } class Board { >Board : Board > : ^^^^^ - ships: Ship[]; + ships: Ship[] = []; >ships : Ship[] > : ^^^^^^ +>[] : undefined[] +> : ^^^^^^^^^^^ - cells: Cell[]; + cells: Cell[] = []; >cells : Cell[] > : ^^^^^^ +>[] : undefined[] +> : ^^^^^^^^^^^ private allShipsSunk() { >allShipsSunk : () => boolean diff --git a/tests/baselines/reference/APISample_Watch.js b/tests/baselines/reference/APISample_Watch.js index 8659e969ffb66..608d0e00a1dda 100644 --- a/tests/baselines/reference/APISample_Watch.js +++ b/tests/baselines/reference/APISample_Watch.js @@ -51,7 +51,7 @@ function watchMain() { // You can technically override any given hook on the host, though you probably don't need to. // Note that we're assuming `origCreateProgram` and `origPostProgramCreate` doesn't use `this` at all. const origCreateProgram = host.createProgram; - host.createProgram = (rootNames: ReadonlyArray, options, host, oldProgram) => { + host.createProgram = (rootNames: ReadonlyArray | undefined, options, host, oldProgram) => { console.log("** We're about to create the program! **"); return origCreateProgram(rootNames, options, host, oldProgram); } diff --git a/tests/baselines/reference/abstractPropertyBasics.js b/tests/baselines/reference/abstractPropertyBasics.js index c9026e5f3424d..c20a295242ff3 100644 --- a/tests/baselines/reference/abstractPropertyBasics.js +++ b/tests/baselines/reference/abstractPropertyBasics.js @@ -19,7 +19,7 @@ class C extends B { set prop(v) { } raw = "edge"; readonly ro = "readonly please"; - readonlyProp: string; // don't have to give a value, in fact + readonlyProp!: string; m() { } } diff --git a/tests/baselines/reference/abstractPropertyBasics.symbols b/tests/baselines/reference/abstractPropertyBasics.symbols index b7c7a74483d02..b251e283c2965 100644 --- a/tests/baselines/reference/abstractPropertyBasics.symbols +++ b/tests/baselines/reference/abstractPropertyBasics.symbols @@ -53,9 +53,9 @@ class C extends B { readonly ro = "readonly please"; >ro : Symbol(C.ro, Decl(abstractPropertyBasics.ts, 16, 17)) - readonlyProp: string; // don't have to give a value, in fact + readonlyProp!: string; >readonlyProp : Symbol(C.readonlyProp, Decl(abstractPropertyBasics.ts, 17, 36)) m() { } ->m : Symbol(C.m, Decl(abstractPropertyBasics.ts, 18, 25)) +>m : Symbol(C.m, Decl(abstractPropertyBasics.ts, 18, 26)) } diff --git a/tests/baselines/reference/abstractPropertyBasics.types b/tests/baselines/reference/abstractPropertyBasics.types index e578dfc1a3d83..c62b71a86e149 100644 --- a/tests/baselines/reference/abstractPropertyBasics.types +++ b/tests/baselines/reference/abstractPropertyBasics.types @@ -74,7 +74,7 @@ class C extends B { >"readonly please" : "readonly please" > : ^^^^^^^^^^^^^^^^^ - readonlyProp: string; // don't have to give a value, in fact + readonlyProp!: string; >readonlyProp : string > : ^^^^^^ diff --git a/tests/baselines/reference/metadataOfClassFromAlias(strict=false).js b/tests/baselines/reference/metadataOfClassFromAlias(strict=false).js new file mode 100644 index 0000000000000..3caae58547030 --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromAlias(strict=false).js @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// + +//// [auxiliary.ts] +export class SomeClass { + field: string; +} + +//// [testA.ts] +import { SomeClass } from './auxiliary'; +function annotation(): PropertyDecorator { + return (target: any): void => { }; +} +export class ClassA { + @annotation() aaa: SomeClass; +} + +//// [testB.ts] +import { SomeClass } from './auxiliary'; +function annotation(): PropertyDecorator { + return (target: any): void => { }; +} +export class ClassB { + @annotation() bbb: SomeClass | null; +} + +//// [auxiliary.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SomeClass = void 0; +var SomeClass = /** @class */ (function () { + function SomeClass() { + } + return SomeClass; +}()); +exports.SomeClass = SomeClass; +//// [testA.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ClassA = void 0; +var auxiliary_1 = require("./auxiliary"); +function annotation() { + return function (target) { }; +} +var ClassA = /** @class */ (function () { + function ClassA() { + } + __decorate([ + annotation(), + __metadata("design:type", auxiliary_1.SomeClass) + ], ClassA.prototype, "aaa", void 0); + return ClassA; +}()); +exports.ClassA = ClassA; +//// [testB.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ClassB = void 0; +var auxiliary_1 = require("./auxiliary"); +function annotation() { + return function (target) { }; +} +var ClassB = /** @class */ (function () { + function ClassB() { + } + __decorate([ + annotation(), + __metadata("design:type", auxiliary_1.SomeClass) + ], ClassB.prototype, "bbb", void 0); + return ClassB; +}()); +exports.ClassB = ClassB; diff --git a/tests/baselines/reference/metadataOfClassFromAlias(strict=false).symbols b/tests/baselines/reference/metadataOfClassFromAlias(strict=false).symbols new file mode 100644 index 0000000000000..11709d87afae1 --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromAlias(strict=false).symbols @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// + +=== auxiliary.ts === +export class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(auxiliary.ts, 0, 0)) + + field: string; +>field : Symbol(SomeClass.field, Decl(auxiliary.ts, 0, 24)) +} + +=== testA.ts === +import { SomeClass } from './auxiliary'; +>SomeClass : Symbol(SomeClass, Decl(testA.ts, 0, 8)) + +function annotation(): PropertyDecorator { +>annotation : Symbol(annotation, Decl(testA.ts, 0, 40)) +>PropertyDecorator : Symbol(PropertyDecorator, Decl(lib.decorators.legacy.d.ts, --, --)) + + return (target: any): void => { }; +>target : Symbol(target, Decl(testA.ts, 2, 12)) +} +export class ClassA { +>ClassA : Symbol(ClassA, Decl(testA.ts, 3, 1)) + + @annotation() aaa: SomeClass; +>annotation : Symbol(annotation, Decl(testA.ts, 0, 40)) +>aaa : Symbol(ClassA.aaa, Decl(testA.ts, 4, 21)) +>SomeClass : Symbol(SomeClass, Decl(testA.ts, 0, 8)) +} + +=== testB.ts === +import { SomeClass } from './auxiliary'; +>SomeClass : Symbol(SomeClass, Decl(testB.ts, 0, 8)) + +function annotation(): PropertyDecorator { +>annotation : Symbol(annotation, Decl(testB.ts, 0, 40)) +>PropertyDecorator : Symbol(PropertyDecorator, Decl(lib.decorators.legacy.d.ts, --, --)) + + return (target: any): void => { }; +>target : Symbol(target, Decl(testB.ts, 2, 12)) +} +export class ClassB { +>ClassB : Symbol(ClassB, Decl(testB.ts, 3, 1)) + + @annotation() bbb: SomeClass | null; +>annotation : Symbol(annotation, Decl(testB.ts, 0, 40)) +>bbb : Symbol(ClassB.bbb, Decl(testB.ts, 4, 21)) +>SomeClass : Symbol(SomeClass, Decl(testB.ts, 0, 8)) +} diff --git a/tests/baselines/reference/metadataOfClassFromAlias(strict=false).types b/tests/baselines/reference/metadataOfClassFromAlias(strict=false).types new file mode 100644 index 0000000000000..70c6e5161ba23 --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromAlias(strict=false).types @@ -0,0 +1,65 @@ +//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// + +=== auxiliary.ts === +export class SomeClass { +>SomeClass : SomeClass +> : ^^^^^^^^^ + + field: string; +>field : string +> : ^^^^^^ +} + +=== testA.ts === +import { SomeClass } from './auxiliary'; +>SomeClass : typeof SomeClass +> : ^^^^^^^^^^^^^^^^ + +function annotation(): PropertyDecorator { +>annotation : () => PropertyDecorator +> : ^^^^^^ + + return (target: any): void => { }; +>(target: any): void => { } : (target: any) => void +> : ^ ^^ ^^^^^ +>target : any +} +export class ClassA { +>ClassA : ClassA +> : ^^^^^^ + + @annotation() aaa: SomeClass; +>annotation() : PropertyDecorator +> : ^^^^^^^^^^^^^^^^^ +>annotation : () => PropertyDecorator +> : ^^^^^^ +>aaa : SomeClass +> : ^^^^^^^^^ +} + +=== testB.ts === +import { SomeClass } from './auxiliary'; +>SomeClass : typeof SomeClass +> : ^^^^^^^^^^^^^^^^ + +function annotation(): PropertyDecorator { +>annotation : () => PropertyDecorator +> : ^^^^^^ + + return (target: any): void => { }; +>(target: any): void => { } : (target: any) => void +> : ^ ^^ ^^^^^ +>target : any +} +export class ClassB { +>ClassB : ClassB +> : ^^^^^^ + + @annotation() bbb: SomeClass | null; +>annotation() : PropertyDecorator +> : ^^^^^^^^^^^^^^^^^ +>annotation : () => PropertyDecorator +> : ^^^^^^ +>bbb : SomeClass +> : ^^^^^^^^^ +} diff --git a/tests/baselines/reference/metadataOfClassFromAlias(strict=true).errors.txt b/tests/baselines/reference/metadataOfClassFromAlias(strict=true).errors.txt new file mode 100644 index 0000000000000..fa2ac7a8d184a --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromAlias(strict=true).errors.txt @@ -0,0 +1,33 @@ +auxiliary.ts(2,5): error TS2564: Property 'field' has no initializer and is not definitely assigned in the constructor. +testA.ts(6,19): error TS2564: Property 'aaa' has no initializer and is not definitely assigned in the constructor. +testB.ts(6,19): error TS2564: Property 'bbb' has no initializer and is not definitely assigned in the constructor. + + +==== auxiliary.ts (1 errors) ==== + export class SomeClass { + field: string; + ~~~~~ +!!! error TS2564: Property 'field' has no initializer and is not definitely assigned in the constructor. + } + +==== testA.ts (1 errors) ==== + import { SomeClass } from './auxiliary'; + function annotation(): PropertyDecorator { + return (target: any): void => { }; + } + export class ClassA { + @annotation() aaa: SomeClass; + ~~~ +!!! error TS2564: Property 'aaa' has no initializer and is not definitely assigned in the constructor. + } + +==== testB.ts (1 errors) ==== + import { SomeClass } from './auxiliary'; + function annotation(): PropertyDecorator { + return (target: any): void => { }; + } + export class ClassB { + @annotation() bbb: SomeClass | null; + ~~~ +!!! error TS2564: Property 'bbb' has no initializer and is not definitely assigned in the constructor. + } \ No newline at end of file diff --git a/tests/baselines/reference/metadataOfClassFromAlias(strict=true).js b/tests/baselines/reference/metadataOfClassFromAlias(strict=true).js new file mode 100644 index 0000000000000..9dd50e5eed290 --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromAlias(strict=true).js @@ -0,0 +1,88 @@ +//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// + +//// [auxiliary.ts] +export class SomeClass { + field: string; +} + +//// [testA.ts] +import { SomeClass } from './auxiliary'; +function annotation(): PropertyDecorator { + return (target: any): void => { }; +} +export class ClassA { + @annotation() aaa: SomeClass; +} + +//// [testB.ts] +import { SomeClass } from './auxiliary'; +function annotation(): PropertyDecorator { + return (target: any): void => { }; +} +export class ClassB { + @annotation() bbb: SomeClass | null; +} + +//// [auxiliary.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SomeClass = void 0; +var SomeClass = /** @class */ (function () { + function SomeClass() { + } + return SomeClass; +}()); +exports.SomeClass = SomeClass; +//// [testA.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ClassA = void 0; +var auxiliary_1 = require("./auxiliary"); +function annotation() { + return function (target) { }; +} +var ClassA = /** @class */ (function () { + function ClassA() { + } + __decorate([ + annotation(), + __metadata("design:type", auxiliary_1.SomeClass) + ], ClassA.prototype, "aaa", void 0); + return ClassA; +}()); +exports.ClassA = ClassA; +//// [testB.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ClassB = void 0; +function annotation() { + return function (target) { }; +} +var ClassB = /** @class */ (function () { + function ClassB() { + } + __decorate([ + annotation(), + __metadata("design:type", Object) + ], ClassB.prototype, "bbb", void 0); + return ClassB; +}()); +exports.ClassB = ClassB; diff --git a/tests/baselines/reference/metadataOfClassFromAlias(strict=true).symbols b/tests/baselines/reference/metadataOfClassFromAlias(strict=true).symbols new file mode 100644 index 0000000000000..11709d87afae1 --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromAlias(strict=true).symbols @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// + +=== auxiliary.ts === +export class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(auxiliary.ts, 0, 0)) + + field: string; +>field : Symbol(SomeClass.field, Decl(auxiliary.ts, 0, 24)) +} + +=== testA.ts === +import { SomeClass } from './auxiliary'; +>SomeClass : Symbol(SomeClass, Decl(testA.ts, 0, 8)) + +function annotation(): PropertyDecorator { +>annotation : Symbol(annotation, Decl(testA.ts, 0, 40)) +>PropertyDecorator : Symbol(PropertyDecorator, Decl(lib.decorators.legacy.d.ts, --, --)) + + return (target: any): void => { }; +>target : Symbol(target, Decl(testA.ts, 2, 12)) +} +export class ClassA { +>ClassA : Symbol(ClassA, Decl(testA.ts, 3, 1)) + + @annotation() aaa: SomeClass; +>annotation : Symbol(annotation, Decl(testA.ts, 0, 40)) +>aaa : Symbol(ClassA.aaa, Decl(testA.ts, 4, 21)) +>SomeClass : Symbol(SomeClass, Decl(testA.ts, 0, 8)) +} + +=== testB.ts === +import { SomeClass } from './auxiliary'; +>SomeClass : Symbol(SomeClass, Decl(testB.ts, 0, 8)) + +function annotation(): PropertyDecorator { +>annotation : Symbol(annotation, Decl(testB.ts, 0, 40)) +>PropertyDecorator : Symbol(PropertyDecorator, Decl(lib.decorators.legacy.d.ts, --, --)) + + return (target: any): void => { }; +>target : Symbol(target, Decl(testB.ts, 2, 12)) +} +export class ClassB { +>ClassB : Symbol(ClassB, Decl(testB.ts, 3, 1)) + + @annotation() bbb: SomeClass | null; +>annotation : Symbol(annotation, Decl(testB.ts, 0, 40)) +>bbb : Symbol(ClassB.bbb, Decl(testB.ts, 4, 21)) +>SomeClass : Symbol(SomeClass, Decl(testB.ts, 0, 8)) +} diff --git a/tests/baselines/reference/metadataOfClassFromAlias(strict=true).types b/tests/baselines/reference/metadataOfClassFromAlias(strict=true).types new file mode 100644 index 0000000000000..06e5367e6f358 --- /dev/null +++ b/tests/baselines/reference/metadataOfClassFromAlias(strict=true).types @@ -0,0 +1,67 @@ +//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// + +=== auxiliary.ts === +export class SomeClass { +>SomeClass : SomeClass +> : ^^^^^^^^^ + + field: string; +>field : string +> : ^^^^^^ +} + +=== testA.ts === +import { SomeClass } from './auxiliary'; +>SomeClass : typeof SomeClass +> : ^^^^^^^^^^^^^^^^ + +function annotation(): PropertyDecorator { +>annotation : () => PropertyDecorator +> : ^^^^^^ + + return (target: any): void => { }; +>(target: any): void => { } : (target: any) => void +> : ^ ^^ ^^^^^ +>target : any +> : ^^^ +} +export class ClassA { +>ClassA : ClassA +> : ^^^^^^ + + @annotation() aaa: SomeClass; +>annotation() : PropertyDecorator +> : ^^^^^^^^^^^^^^^^^ +>annotation : () => PropertyDecorator +> : ^^^^^^ +>aaa : SomeClass +> : ^^^^^^^^^ +} + +=== testB.ts === +import { SomeClass } from './auxiliary'; +>SomeClass : typeof SomeClass +> : ^^^^^^^^^^^^^^^^ + +function annotation(): PropertyDecorator { +>annotation : () => PropertyDecorator +> : ^^^^^^ + + return (target: any): void => { }; +>(target: any): void => { } : (target: any) => void +> : ^ ^^ ^^^^^ +>target : any +> : ^^^ +} +export class ClassB { +>ClassB : ClassB +> : ^^^^^^ + + @annotation() bbb: SomeClass | null; +>annotation() : PropertyDecorator +> : ^^^^^^^^^^^^^^^^^ +>annotation : () => PropertyDecorator +> : ^^^^^^ +>bbb : SomeClass | null +> : ^^^^^^^^^^^^^^^^ +} diff --git a/tests/baselines/reference/metadataOfClassFromAlias.js b/tests/baselines/reference/metadataOfClassFromAlias.js deleted file mode 100644 index 657cdf21f975f..0000000000000 --- a/tests/baselines/reference/metadataOfClassFromAlias.js +++ /dev/null @@ -1,53 +0,0 @@ -//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// - -//// [auxiliry.ts] -export class SomeClass { - field: string; -} - -//// [test.ts] -import { SomeClass } from './auxiliry'; -function annotation(): PropertyDecorator { - return (target: any): void => { }; -} -export class ClassA { - @annotation() array: SomeClass | null; -} - -//// [auxiliry.js] -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.SomeClass = void 0; -var SomeClass = /** @class */ (function () { - function SomeClass() { - } - return SomeClass; -}()); -exports.SomeClass = SomeClass; -//// [test.js] -"use strict"; -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.ClassA = void 0; -var auxiliry_1 = require("./auxiliry"); -function annotation() { - return function (target) { }; -} -var ClassA = /** @class */ (function () { - function ClassA() { - } - __decorate([ - annotation(), - __metadata("design:type", auxiliry_1.SomeClass) - ], ClassA.prototype, "array", void 0); - return ClassA; -}()); -exports.ClassA = ClassA; diff --git a/tests/baselines/reference/metadataOfClassFromAlias.symbols b/tests/baselines/reference/metadataOfClassFromAlias.symbols deleted file mode 100644 index b11225e880e93..0000000000000 --- a/tests/baselines/reference/metadataOfClassFromAlias.symbols +++ /dev/null @@ -1,29 +0,0 @@ -//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// - -=== auxiliry.ts === -export class SomeClass { ->SomeClass : Symbol(SomeClass, Decl(auxiliry.ts, 0, 0)) - - field: string; ->field : Symbol(SomeClass.field, Decl(auxiliry.ts, 0, 24)) -} - -=== test.ts === -import { SomeClass } from './auxiliry'; ->SomeClass : Symbol(SomeClass, Decl(test.ts, 0, 8)) - -function annotation(): PropertyDecorator { ->annotation : Symbol(annotation, Decl(test.ts, 0, 39)) ->PropertyDecorator : Symbol(PropertyDecorator, Decl(lib.decorators.legacy.d.ts, --, --)) - - return (target: any): void => { }; ->target : Symbol(target, Decl(test.ts, 2, 12)) -} -export class ClassA { ->ClassA : Symbol(ClassA, Decl(test.ts, 3, 1)) - - @annotation() array: SomeClass | null; ->annotation : Symbol(annotation, Decl(test.ts, 0, 39)) ->array : Symbol(ClassA.array, Decl(test.ts, 4, 21)) ->SomeClass : Symbol(SomeClass, Decl(test.ts, 0, 8)) -} diff --git a/tests/baselines/reference/metadataOfClassFromAlias.types b/tests/baselines/reference/metadataOfClassFromAlias.types deleted file mode 100644 index 4cb3f654a5c87..0000000000000 --- a/tests/baselines/reference/metadataOfClassFromAlias.types +++ /dev/null @@ -1,38 +0,0 @@ -//// [tests/cases/compiler/metadataOfClassFromAlias.ts] //// - -=== auxiliry.ts === -export class SomeClass { ->SomeClass : SomeClass -> : ^^^^^^^^^ - - field: string; ->field : string -> : ^^^^^^ -} - -=== test.ts === -import { SomeClass } from './auxiliry'; ->SomeClass : typeof SomeClass -> : ^^^^^^^^^^^^^^^^ - -function annotation(): PropertyDecorator { ->annotation : () => PropertyDecorator -> : ^^^^^^ - - return (target: any): void => { }; ->(target: any): void => { } : (target: any) => void -> : ^ ^^ ^^^^^ ->target : any -} -export class ClassA { ->ClassA : ClassA -> : ^^^^^^ - - @annotation() array: SomeClass | null; ->annotation() : PropertyDecorator -> : ^^^^^^^^^^^^^^^^^ ->annotation : () => PropertyDecorator -> : ^^^^^^ ->array : SomeClass -> : ^^^^^^^^^ -} diff --git a/tests/baselines/reference/metadataOfUnionWithNull.js b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=false).js similarity index 100% rename from tests/baselines/reference/metadataOfUnionWithNull.js rename to tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=false).js diff --git a/tests/baselines/reference/metadataOfUnionWithNull.symbols b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=false).symbols similarity index 100% rename from tests/baselines/reference/metadataOfUnionWithNull.symbols rename to tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=false).symbols diff --git a/tests/baselines/reference/metadataOfUnionWithNull.types b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=false).types similarity index 100% rename from tests/baselines/reference/metadataOfUnionWithNull.types rename to tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=false).types diff --git a/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).js b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).js new file mode 100644 index 0000000000000..877fcb4ae1dcf --- /dev/null +++ b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).js @@ -0,0 +1,115 @@ +//// [tests/cases/compiler/metadataOfUnionWithNull.ts] //// + +//// [metadataOfUnionWithNull.ts] +function PropDeco(target: Object, propKey: string | symbol) { } + +class A { +} + +class B { + @PropDeco + x: "foo" | null; + + @PropDeco + y: true | never; + + @PropDeco + z: "foo" | undefined; + + @PropDeco + a: null; + + @PropDeco + b: never; + + @PropDeco + c: undefined; + + @PropDeco + d: undefined | null; + + @PropDeco + e: symbol | null; + + @PropDeco + f: symbol | A; + + @PropDeco + g: A | null; + + @PropDeco + h: null | B; + + @PropDeco + j: null | symbol; +} + +//// [metadataOfUnionWithNull.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +function PropDeco(target, propKey) { } +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +var B = /** @class */ (function () { + function B() { + } + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "x", void 0); + __decorate([ + PropDeco, + __metadata("design:type", Boolean) + ], B.prototype, "y", void 0); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "z", void 0); + __decorate([ + PropDeco, + __metadata("design:type", void 0) + ], B.prototype, "a", void 0); + __decorate([ + PropDeco, + __metadata("design:type", void 0) + ], B.prototype, "b", void 0); + __decorate([ + PropDeco, + __metadata("design:type", void 0) + ], B.prototype, "c", void 0); + __decorate([ + PropDeco, + __metadata("design:type", void 0) + ], B.prototype, "d", void 0); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "e", void 0); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "f", void 0); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "g", void 0); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "h", void 0); + __decorate([ + PropDeco, + __metadata("design:type", Object) + ], B.prototype, "j", void 0); + return B; +}()); diff --git a/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).symbols b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).symbols new file mode 100644 index 0000000000000..8405164fbabfa --- /dev/null +++ b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).symbols @@ -0,0 +1,91 @@ +//// [tests/cases/compiler/metadataOfUnionWithNull.ts] //// + +=== metadataOfUnionWithNull.ts === +function PropDeco(target: Object, propKey: string | symbol) { } +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) +>target : Symbol(target, Decl(metadataOfUnionWithNull.ts, 0, 18)) +>Object : Symbol(Object, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>propKey : Symbol(propKey, Decl(metadataOfUnionWithNull.ts, 0, 33)) + +class A { +>A : Symbol(A, Decl(metadataOfUnionWithNull.ts, 0, 63)) +} + +class B { +>B : Symbol(B, Decl(metadataOfUnionWithNull.ts, 3, 1)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + x: "foo" | null; +>x : Symbol(B.x, Decl(metadataOfUnionWithNull.ts, 5, 9)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + y: true | never; +>y : Symbol(B.y, Decl(metadataOfUnionWithNull.ts, 7, 20)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + z: "foo" | undefined; +>z : Symbol(B.z, Decl(metadataOfUnionWithNull.ts, 10, 20)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + a: null; +>a : Symbol(B.a, Decl(metadataOfUnionWithNull.ts, 13, 25)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + b: never; +>b : Symbol(B.b, Decl(metadataOfUnionWithNull.ts, 16, 12)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + c: undefined; +>c : Symbol(B.c, Decl(metadataOfUnionWithNull.ts, 19, 13)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + d: undefined | null; +>d : Symbol(B.d, Decl(metadataOfUnionWithNull.ts, 22, 17)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + e: symbol | null; +>e : Symbol(B.e, Decl(metadataOfUnionWithNull.ts, 25, 24)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + f: symbol | A; +>f : Symbol(B.f, Decl(metadataOfUnionWithNull.ts, 28, 21)) +>A : Symbol(A, Decl(metadataOfUnionWithNull.ts, 0, 63)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + g: A | null; +>g : Symbol(B.g, Decl(metadataOfUnionWithNull.ts, 31, 18)) +>A : Symbol(A, Decl(metadataOfUnionWithNull.ts, 0, 63)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + h: null | B; +>h : Symbol(B.h, Decl(metadataOfUnionWithNull.ts, 34, 16)) +>B : Symbol(B, Decl(metadataOfUnionWithNull.ts, 3, 1)) + + @PropDeco +>PropDeco : Symbol(PropDeco, Decl(metadataOfUnionWithNull.ts, 0, 0)) + + j: null | symbol; +>j : Symbol(B.j, Decl(metadataOfUnionWithNull.ts, 37, 16)) +} diff --git a/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).types b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).types new file mode 100644 index 0000000000000..d175797d3c774 --- /dev/null +++ b/tests/baselines/reference/metadataOfUnionWithNull(strictnullchecks=true).types @@ -0,0 +1,118 @@ +//// [tests/cases/compiler/metadataOfUnionWithNull.ts] //// + +=== metadataOfUnionWithNull.ts === +function PropDeco(target: Object, propKey: string | symbol) { } +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>target : Object +> : ^^^^^^ +>propKey : string | symbol +> : ^^^^^^^^^^^^^^^ + +class A { +>A : A +> : ^ +} + +class B { +>B : B +> : ^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + x: "foo" | null; +>x : "foo" | null +> : ^^^^^^^^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + y: true | never; +>y : true +> : ^^^^ +>true : true +> : ^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + z: "foo" | undefined; +>z : "foo" | undefined +> : ^^^^^^^^^^^^^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + a: null; +>a : null +> : ^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + b: never; +>b : never +> : ^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + c: undefined; +>c : undefined +> : ^^^^^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + d: undefined | null; +>d : null | undefined +> : ^^^^^^^^^^^^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + e: symbol | null; +>e : symbol | null +> : ^^^^^^^^^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + f: symbol | A; +>f : symbol | A +> : ^^^^^^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + g: A | null; +>g : A | null +> : ^^^^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + h: null | B; +>h : B | null +> : ^^^^^^^^ + + @PropDeco +>PropDeco : (target: Object, propKey: string | symbol) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + j: null | symbol; +>j : symbol | null +> : ^^^^^^^^^^^^^ +} diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).js b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).js new file mode 100644 index 0000000000000..66e3281eefbfa --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).js @@ -0,0 +1,78 @@ +//// [tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts] //// + +//// [Class1.ts] +export class Class1 { +} +//// [Class2.ts] +import { Class1 } from './Class1'; + +function decorate(target: any, propertyKey: string) { +} + +export class Class2 { + @decorate + get maybeProp(): Class1 | undefined { + return undefined; + } + @decorate + get prop(): Class1 { + return undefined; + } +} + +//// [Class1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Class1 = void 0; +var Class1 = /** @class */ (function () { + function Class1() { + } + return Class1; +}()); +exports.Class1 = Class1; +//// [Class2.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Class2 = void 0; +var Class1_1 = require("./Class1"); +function decorate(target, propertyKey) { +} +var Class2 = /** @class */ (function () { + function Class2() { + } + Object.defineProperty(Class2.prototype, "maybeProp", { + get: function () { + return undefined; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(Class2.prototype, "prop", { + get: function () { + return undefined; + }, + enumerable: false, + configurable: true + }); + __decorate([ + decorate, + __metadata("design:type", Class1_1.Class1), + __metadata("design:paramtypes", []) + ], Class2.prototype, "maybeProp", null); + __decorate([ + decorate, + __metadata("design:type", Class1_1.Class1), + __metadata("design:paramtypes", []) + ], Class2.prototype, "prop", null); + return Class2; +}()); +exports.Class2 = Class2; diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).symbols similarity index 64% rename from tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols rename to tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).symbols index 2b764c948f624..cf34ba8b9fe0d 100644 --- a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).symbols @@ -20,8 +20,18 @@ export class Class2 { @decorate >decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) - get prop(): Class1 | undefined { ->prop : Symbol(Class2.prop, Decl(Class2.ts, 5, 21)) + get maybeProp(): Class1 | undefined { +>maybeProp : Symbol(Class2.maybeProp, Decl(Class2.ts, 5, 21)) +>Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) + + return undefined; +>undefined : Symbol(undefined) + } + @decorate +>decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) + + get prop(): Class1 { +>prop : Symbol(Class2.prop, Decl(Class2.ts, 9, 5)) >Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) return undefined; diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.types b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).types similarity index 68% rename from tests/baselines/reference/metadataReferencedWithinFilteredUnion.types rename to tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).types index 458131de33109..5a596676a3f05 100644 --- a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.types +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=false).types @@ -26,7 +26,19 @@ export class Class2 { >decorate : (target: any, propertyKey: string) => void > : ^ ^^ ^^ ^^ ^^^^^^^^^ - get prop(): Class1 | undefined { + get maybeProp(): Class1 | undefined { +>maybeProp : Class1 +> : ^^^^^^ + + return undefined; +>undefined : undefined +> : ^^^^^^^^^ + } + @decorate +>decorate : (target: any, propertyKey: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + get prop(): Class1 { >prop : Class1 > : ^^^^^^ diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).errors.txt b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).errors.txt new file mode 100644 index 0000000000000..4e39e852206b1 --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).errors.txt @@ -0,0 +1,24 @@ +Class2.ts(13,9): error TS2322: Type 'undefined' is not assignable to type 'Class1'. + + +==== Class1.ts (0 errors) ==== + export class Class1 { + } +==== Class2.ts (1 errors) ==== + import { Class1 } from './Class1'; + + function decorate(target: any, propertyKey: string) { + } + + export class Class2 { + @decorate + get maybeProp(): Class1 | undefined { + return undefined; + } + @decorate + get prop(): Class1 { + return undefined; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'Class1'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).js similarity index 78% rename from tests/baselines/reference/metadataReferencedWithinFilteredUnion.js rename to tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).js index 7c7d70c749b5a..809fb44c978ea 100644 --- a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).js @@ -11,7 +11,11 @@ function decorate(target: any, propertyKey: string) { export class Class2 { @decorate - get prop(): Class1 | undefined { + get maybeProp(): Class1 | undefined { + return undefined; + } + @decorate + get prop(): Class1 { return undefined; } } @@ -45,6 +49,13 @@ function decorate(target, propertyKey) { var Class2 = /** @class */ (function () { function Class2() { } + Object.defineProperty(Class2.prototype, "maybeProp", { + get: function () { + return undefined; + }, + enumerable: false, + configurable: true + }); Object.defineProperty(Class2.prototype, "prop", { get: function () { return undefined; @@ -52,6 +63,11 @@ var Class2 = /** @class */ (function () { enumerable: false, configurable: true }); + __decorate([ + decorate, + __metadata("design:type", Object), + __metadata("design:paramtypes", []) + ], Class2.prototype, "maybeProp", null); __decorate([ decorate, __metadata("design:type", Class1_1.Class1), diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).symbols b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).symbols new file mode 100644 index 0000000000000..cf34ba8b9fe0d --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).symbols @@ -0,0 +1,40 @@ +//// [tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts] //// + +=== Class1.ts === +export class Class1 { +>Class1 : Symbol(Class1, Decl(Class1.ts, 0, 0)) +} +=== Class2.ts === +import { Class1 } from './Class1'; +>Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) + +function decorate(target: any, propertyKey: string) { +>decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) +>target : Symbol(target, Decl(Class2.ts, 2, 18)) +>propertyKey : Symbol(propertyKey, Decl(Class2.ts, 2, 30)) +} + +export class Class2 { +>Class2 : Symbol(Class2, Decl(Class2.ts, 3, 1)) + + @decorate +>decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) + + get maybeProp(): Class1 | undefined { +>maybeProp : Symbol(Class2.maybeProp, Decl(Class2.ts, 5, 21)) +>Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) + + return undefined; +>undefined : Symbol(undefined) + } + @decorate +>decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) + + get prop(): Class1 { +>prop : Symbol(Class2.prop, Decl(Class2.ts, 9, 5)) +>Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) + + return undefined; +>undefined : Symbol(undefined) + } +} diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).types b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).types new file mode 100644 index 0000000000000..248837954bead --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion(strictnullchecks=true).types @@ -0,0 +1,50 @@ +//// [tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts] //// + +=== Class1.ts === +export class Class1 { +>Class1 : Class1 +> : ^^^^^^ +} +=== Class2.ts === +import { Class1 } from './Class1'; +>Class1 : typeof Class1 +> : ^^^^^^^^^^^^^ + +function decorate(target: any, propertyKey: string) { +>decorate : (target: any, propertyKey: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ +>target : any +> : ^^^ +>propertyKey : string +> : ^^^^^^ +} + +export class Class2 { +>Class2 : Class2 +> : ^^^^^^ + + @decorate +>decorate : (target: any, propertyKey: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + get maybeProp(): Class1 | undefined { +>maybeProp : Class1 | undefined +> : ^^^^^^^^^^^^^^^^^^ + + return undefined; +>undefined : undefined +> : ^^^^^^^^^ + } + @decorate +>decorate : (target: any, propertyKey: string) => void +> : ^ ^^ ^^ ^^ ^^^^^^^^^ + + get prop(): Class1 { +>prop : Class1 +> : ^^^^^^ + + return undefined; +>undefined : undefined +> : ^^^^^^^^^ + } +} diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.js b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.js index e59b01fe5942c..9b5358315fc09 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.js +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.js @@ -1,10 +1,10 @@ //// [tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts] //// //// [stringLiteralTypesWithVariousOperators01.ts] -let abc: "ABC" = "ABC"; -let xyz: "XYZ" = "XYZ"; -let abcOrXyz: "ABC" | "XYZ" = abc || xyz; -let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; +declare let abc: "ABC"; +declare let xyz: "XYZ"; +declare let abcOrXyz: "ABC" | "XYZ"; +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; let a = "" + abc; let b = abc + ""; @@ -30,10 +30,6 @@ let u = abc === abcOrXyz; let v = abcOrXyz === abcOrXyzOrNumber; //// [stringLiteralTypesWithVariousOperators01.js] -var abc = "ABC"; -var xyz = "XYZ"; -var abcOrXyz = abc || xyz; -var abcOrXyzOrNumber = abcOrXyz || 100; var a = "" + abc; var b = abc + ""; var c = 10 + abc; diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.symbols b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.symbols index 7b8bc0d327ee3..d0732c46c9983 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.symbols +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.symbols @@ -1,117 +1,114 @@ //// [tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts] //// === stringLiteralTypesWithVariousOperators01.ts === -let abc: "ABC" = "ABC"; ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) +declare let abc: "ABC"; +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) -let xyz: "XYZ" = "XYZ"; ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) +declare let xyz: "XYZ"; +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 11)) -let abcOrXyz: "ABC" | "XYZ" = abc || xyz; ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) +declare let abcOrXyz: "ABC" | "XYZ"; +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) -let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) let a = "" + abc; >a : Symbol(a, Decl(stringLiteralTypesWithVariousOperators01.ts, 5, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) let b = abc + ""; >b : Symbol(b, Decl(stringLiteralTypesWithVariousOperators01.ts, 6, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) let c = 10 + abc; >c : Symbol(c, Decl(stringLiteralTypesWithVariousOperators01.ts, 7, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) let d = abc + 10; >d : Symbol(d, Decl(stringLiteralTypesWithVariousOperators01.ts, 8, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) let e = xyz + abc; >e : Symbol(e, Decl(stringLiteralTypesWithVariousOperators01.ts, 9, 3)) ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 11)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) let f = abc + xyz; >f : Symbol(f, Decl(stringLiteralTypesWithVariousOperators01.ts, 10, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 11)) let g = true + abc; >g : Symbol(g, Decl(stringLiteralTypesWithVariousOperators01.ts, 11, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) let h = abc + true; >h : Symbol(h, Decl(stringLiteralTypesWithVariousOperators01.ts, 12, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) let i = abc + abcOrXyz + xyz; >i : Symbol(i, Decl(stringLiteralTypesWithVariousOperators01.ts, 13, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 1, 11)) let j = abcOrXyz + abcOrXyz; >j : Symbol(j, Decl(stringLiteralTypesWithVariousOperators01.ts, 14, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) let k = +abcOrXyz; >k : Symbol(k, Decl(stringLiteralTypesWithVariousOperators01.ts, 15, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) let l = -abcOrXyz; >l : Symbol(l, Decl(stringLiteralTypesWithVariousOperators01.ts, 16, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) let m = abcOrXyzOrNumber + ""; >m : Symbol(m, Decl(stringLiteralTypesWithVariousOperators01.ts, 17, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) let n = "" + abcOrXyzOrNumber; >n : Symbol(n, Decl(stringLiteralTypesWithVariousOperators01.ts, 18, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) let o = abcOrXyzOrNumber + abcOrXyz; >o : Symbol(o, Decl(stringLiteralTypesWithVariousOperators01.ts, 19, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) let p = abcOrXyz + abcOrXyzOrNumber; >p : Symbol(p, Decl(stringLiteralTypesWithVariousOperators01.ts, 20, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) let q = !abcOrXyzOrNumber; >q : Symbol(q, Decl(stringLiteralTypesWithVariousOperators01.ts, 21, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) let r = ~abcOrXyzOrNumber; >r : Symbol(r, Decl(stringLiteralTypesWithVariousOperators01.ts, 22, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) let s = abcOrXyzOrNumber < abcOrXyzOrNumber; >s : Symbol(s, Decl(stringLiteralTypesWithVariousOperators01.ts, 23, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) let t = abcOrXyzOrNumber >= abcOrXyz; >t : Symbol(t, Decl(stringLiteralTypesWithVariousOperators01.ts, 24, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) let u = abc === abcOrXyz; >u : Symbol(u, Decl(stringLiteralTypesWithVariousOperators01.ts, 25, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators01.ts, 0, 11)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) let v = abcOrXyz === abcOrXyzOrNumber; >v : Symbol(v, Decl(stringLiteralTypesWithVariousOperators01.ts, 26, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 3)) +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators01.ts, 2, 11)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators01.ts, 3, 11)) diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types index 8fce260189917..eef777c98e7ba 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types @@ -1,37 +1,21 @@ //// [tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators01.ts] //// === stringLiteralTypesWithVariousOperators01.ts === -let abc: "ABC" = "ABC"; +declare let abc: "ABC"; >abc : "ABC" > : ^^^^^ ->"ABC" : "ABC" -> : ^^^^^ -let xyz: "XYZ" = "XYZ"; +declare let xyz: "XYZ"; >xyz : "XYZ" > : ^^^^^ ->"XYZ" : "XYZ" -> : ^^^^^ -let abcOrXyz: "ABC" | "XYZ" = abc || xyz; +declare let abcOrXyz: "ABC" | "XYZ"; >abcOrXyz : "ABC" | "XYZ" > : ^^^^^^^^^^^^^ ->abc || xyz : "ABC" | "XYZ" -> : ^^^^^^^^^^^^^ ->abc : "ABC" -> : ^^^^^ ->xyz : "XYZ" -> : ^^^^^ -let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; >abcOrXyzOrNumber : number | "ABC" | "XYZ" > : ^^^^^^^^^^^^^^^^^^^^^^ ->abcOrXyz || 100 : "ABC" | "XYZ" | 100 -> : ^^^^^^^^^^^^^^^^^^^ ->abcOrXyz : "ABC" | "XYZ" -> : ^^^^^^^^^^^^^ ->100 : 100 -> : ^^^ let a = "" + abc; >a : string diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt index 0cb00b42c8def..7dc532acbbb4c 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt @@ -12,10 +12,10 @@ stringLiteralTypesWithVariousOperators02.ts(17,9): error TS2367: This comparison ==== stringLiteralTypesWithVariousOperators02.ts (11 errors) ==== - let abc: "ABC" = "ABC"; - let xyz: "XYZ" = "XYZ"; - let abcOrXyz: "ABC" | "XYZ" = abc || xyz; - let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; + declare let abc: "ABC"; + declare let xyz: "XYZ"; + declare let abcOrXyz: "ABC" | "XYZ"; + declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; let a = abcOrXyzOrNumber + 100; ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.js b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.js index bd7879c241983..6c1dd120c5ece 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.js +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.js @@ -1,10 +1,10 @@ //// [tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts] //// //// [stringLiteralTypesWithVariousOperators02.ts] -let abc: "ABC" = "ABC"; -let xyz: "XYZ" = "XYZ"; -let abcOrXyz: "ABC" | "XYZ" = abc || xyz; -let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; +declare let abc: "ABC"; +declare let xyz: "XYZ"; +declare let abcOrXyz: "ABC" | "XYZ"; +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; let a = abcOrXyzOrNumber + 100; let b = 100 + abcOrXyzOrNumber; @@ -20,10 +20,6 @@ let k = abc === xyz; let l = abc != xyz; //// [stringLiteralTypesWithVariousOperators02.js] -var abc = "ABC"; -var xyz = "XYZ"; -var abcOrXyz = abc || xyz; -var abcOrXyzOrNumber = abcOrXyz || 100; var a = abcOrXyzOrNumber + 100; var b = 100 + abcOrXyzOrNumber; var c = abcOrXyzOrNumber + abcOrXyzOrNumber; diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.symbols b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.symbols index 42e0524f2cf28..438da13b8bebe 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.symbols +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.symbols @@ -1,70 +1,67 @@ //// [tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts] //// === stringLiteralTypesWithVariousOperators02.ts === -let abc: "ABC" = "ABC"; ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 3)) +declare let abc: "ABC"; +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 11)) -let xyz: "XYZ" = "XYZ"; ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 3)) +declare let xyz: "XYZ"; +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 11)) -let abcOrXyz: "ABC" | "XYZ" = abc || xyz; ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 2, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 3)) ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 3)) +declare let abcOrXyz: "ABC" | "XYZ"; +>abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 2, 11)) -let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) ->abcOrXyz : Symbol(abcOrXyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 2, 3)) +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let a = abcOrXyzOrNumber + 100; >a : Symbol(a, Decl(stringLiteralTypesWithVariousOperators02.ts, 5, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let b = 100 + abcOrXyzOrNumber; >b : Symbol(b, Decl(stringLiteralTypesWithVariousOperators02.ts, 6, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let c = abcOrXyzOrNumber + abcOrXyzOrNumber; >c : Symbol(c, Decl(stringLiteralTypesWithVariousOperators02.ts, 7, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let d = abcOrXyzOrNumber + true; >d : Symbol(d, Decl(stringLiteralTypesWithVariousOperators02.ts, 8, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let e = false + abcOrXyzOrNumber; >e : Symbol(e, Decl(stringLiteralTypesWithVariousOperators02.ts, 9, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let f = abcOrXyzOrNumber++; >f : Symbol(f, Decl(stringLiteralTypesWithVariousOperators02.ts, 10, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let g = --abcOrXyzOrNumber; >g : Symbol(g, Decl(stringLiteralTypesWithVariousOperators02.ts, 11, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let h = abcOrXyzOrNumber ^ 10; >h : Symbol(h, Decl(stringLiteralTypesWithVariousOperators02.ts, 12, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let i = abcOrXyzOrNumber | 10; >i : Symbol(i, Decl(stringLiteralTypesWithVariousOperators02.ts, 13, 3)) ->abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 3)) +>abcOrXyzOrNumber : Symbol(abcOrXyzOrNumber, Decl(stringLiteralTypesWithVariousOperators02.ts, 3, 11)) let j = abc < xyz; >j : Symbol(j, Decl(stringLiteralTypesWithVariousOperators02.ts, 14, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 3)) ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 11)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 11)) let k = abc === xyz; >k : Symbol(k, Decl(stringLiteralTypesWithVariousOperators02.ts, 15, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 3)) ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 11)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 11)) let l = abc != xyz; >l : Symbol(l, Decl(stringLiteralTypesWithVariousOperators02.ts, 16, 3)) ->abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 3)) ->xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 3)) +>abc : Symbol(abc, Decl(stringLiteralTypesWithVariousOperators02.ts, 0, 11)) +>xyz : Symbol(xyz, Decl(stringLiteralTypesWithVariousOperators02.ts, 1, 11)) diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.types b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.types index 4e2a7456fa6c5..bb2a0477239ce 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.types +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.types @@ -1,37 +1,21 @@ //// [tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts] //// === stringLiteralTypesWithVariousOperators02.ts === -let abc: "ABC" = "ABC"; +declare let abc: "ABC"; >abc : "ABC" > : ^^^^^ ->"ABC" : "ABC" -> : ^^^^^ -let xyz: "XYZ" = "XYZ"; +declare let xyz: "XYZ"; >xyz : "XYZ" > : ^^^^^ ->"XYZ" : "XYZ" -> : ^^^^^ -let abcOrXyz: "ABC" | "XYZ" = abc || xyz; +declare let abcOrXyz: "ABC" | "XYZ"; >abcOrXyz : "ABC" | "XYZ" > : ^^^^^^^^^^^^^ ->abc || xyz : "ABC" | "XYZ" -> : ^^^^^^^^^^^^^ ->abc : "ABC" -> : ^^^^^ ->xyz : "XYZ" -> : ^^^^^ -let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; +declare let abcOrXyzOrNumber: "ABC" | "XYZ" | number; >abcOrXyzOrNumber : number | "ABC" | "XYZ" > : ^^^^^^^^^^^^^^^^^^^^^^ ->abcOrXyz || 100 : "ABC" | "XYZ" | 100 -> : ^^^^^^^^^^^^^^^^^^^ ->abcOrXyz : "ABC" | "XYZ" -> : ^^^^^^^^^^^^^ ->100 : 100 -> : ^^^ let a = abcOrXyzOrNumber + 100; >a : any diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints.js b/tests/baselines/reference/wrappedAndRecursiveConstraints.js index e22561c786a2a..38c71f63f058f 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints.js +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints.js @@ -14,7 +14,7 @@ interface Foo extends Date { foo: string; } -var y: Foo = null; +var y: Foo = {} as Foo; var c = new C(y); var r = c.foo(y); @@ -29,6 +29,6 @@ var C = /** @class */ (function () { }; return C; }()); -var y = null; +var y = {}; var c = new C(y); var r = c.foo(y); diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints.symbols b/tests/baselines/reference/wrappedAndRecursiveConstraints.symbols index cc9d5b42eaa2d..83ac314e1d969 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints.symbols +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints.symbols @@ -32,9 +32,10 @@ interface Foo extends Date { >foo : Symbol(Foo.foo, Decl(wrappedAndRecursiveConstraints.ts, 9, 28)) } -var y: Foo = null; +var y: Foo = {} as Foo; >y : Symbol(y, Decl(wrappedAndRecursiveConstraints.ts, 13, 3)) >Foo : Symbol(Foo, Decl(wrappedAndRecursiveConstraints.ts, 7, 1)) +>Foo : Symbol(Foo, Decl(wrappedAndRecursiveConstraints.ts, 7, 1)) var c = new C(y); >c : Symbol(c, Decl(wrappedAndRecursiveConstraints.ts, 14, 3)) diff --git a/tests/baselines/reference/wrappedAndRecursiveConstraints.types b/tests/baselines/reference/wrappedAndRecursiveConstraints.types index 37050946dee1d..76a5f7fc3f595 100644 --- a/tests/baselines/reference/wrappedAndRecursiveConstraints.types +++ b/tests/baselines/reference/wrappedAndRecursiveConstraints.types @@ -29,9 +29,13 @@ interface Foo extends Date { > : ^^^^^^ } -var y: Foo = null; +var y: Foo = {} as Foo; >y : Foo > : ^^^ +>{} as Foo : Foo +> : ^^^ +>{} : {} +> : ^^ var c = new C(y); >c : C From 1da4ff1a69a7f72c73fff786ca4deec4a3db935c Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 20:07:43 +0000 Subject: [PATCH 07/10] Adjust tests for `strictPropertyInitialization`. --- tests/cases/compiler/controlFlowInstanceof.ts | 15 +++++++++------ .../controlFlowInstanceofWithSymbolHasInstance.ts | 8 ++++---- tests/cases/compiler/optionalParameterProperty.ts | 2 +- .../compiler/strictNullNotNullIndexTypeNoLib.ts | 1 + .../strictNullNotNullIndexTypeShouldWork.ts | 1 + .../controlFlow/typeGuardsNestedAssignments.ts | 2 +- .../controlFlow/typeGuardsTypeParameters.ts | 2 +- .../interfaceExtendsObjectIntersection.ts | 1 + .../types/keyof/keyofAndIndexedAccess.ts | 1 + .../conformance/types/mapped/mappedTypeErrors.ts | 5 ++++- .../types/namedTypes/optionalMethods.ts | 2 +- .../types/spread/objectSpreadNegative.ts | 2 +- 12 files changed, 26 insertions(+), 16 deletions(-) diff --git a/tests/cases/compiler/controlFlowInstanceof.ts b/tests/cases/compiler/controlFlowInstanceof.ts index b032fb708dc58..ec8588675d4b5 100644 --- a/tests/cases/compiler/controlFlowInstanceof.ts +++ b/tests/cases/compiler/controlFlowInstanceof.ts @@ -50,9 +50,9 @@ function f4(s: Set | Set) { // More tests -class A { a: string } -class B extends A { b: string } -class C extends A { c: string } +class A { a: string = "" } +class B extends A { b: string = "" } +class C extends A { c: string = "" } function foo(x: A | undefined) { x; // A | undefined @@ -88,11 +88,11 @@ function foo(x: A | undefined) { // Y is assignable to X, but not a subtype of X interface X { - x?: string; + x?: string } class Y { - y: string; + y: string = ""; } function goo(x: X) { @@ -114,7 +114,10 @@ if (x instanceof ctor) { // Repro from #27550 (based on uglify code) // @Filename: uglify.js -/** @constructor */ +/** + * @constructor + * @param {any} val + */ function AtTop(val) { this.val = val } /** @type {*} */ var v = 1; diff --git a/tests/cases/compiler/controlFlowInstanceofWithSymbolHasInstance.ts b/tests/cases/compiler/controlFlowInstanceofWithSymbolHasInstance.ts index 83b38fce9df27..633d691c294ce 100644 --- a/tests/cases/compiler/controlFlowInstanceofWithSymbolHasInstance.ts +++ b/tests/cases/compiler/controlFlowInstanceofWithSymbolHasInstance.ts @@ -56,7 +56,7 @@ function f4(s: Set | Set) { // More tests class A { - a: string; + a: string = ""; static [Symbol.hasInstance](this: T, value: unknown): value is ( T extends (abstract new (...args: any) => infer U) ? U : never @@ -64,8 +64,8 @@ class A { return Function.prototype[Symbol.hasInstance].call(this, value); } } -class B extends A { b: string } -class C extends A { c: string } +class B extends A { b: string = ""; } +class C extends A { c: string = ""; } function foo(x: A | undefined) { x; // A | undefined @@ -105,7 +105,7 @@ interface X { } class Y { - y: string; + y: string = ""; } function goo(x: X) { diff --git a/tests/cases/compiler/optionalParameterProperty.ts b/tests/cases/compiler/optionalParameterProperty.ts index 1f547d4af26a7..f398b526dcbb1 100644 --- a/tests/cases/compiler/optionalParameterProperty.ts +++ b/tests/cases/compiler/optionalParameterProperty.ts @@ -1,7 +1,7 @@ // @strictNullChecks: true class C { - p: number; + p: number = 0; } class D extends C { diff --git a/tests/cases/compiler/strictNullNotNullIndexTypeNoLib.ts b/tests/cases/compiler/strictNullNotNullIndexTypeNoLib.ts index f5df0e2be8b72..bb63ebd45a3f2 100644 --- a/tests/cases/compiler/strictNullNotNullIndexTypeNoLib.ts +++ b/tests/cases/compiler/strictNullNotNullIndexTypeNoLib.ts @@ -1,4 +1,5 @@ // @strictNullChecks: true +// @strictPropertyInitialization: false // @noLib: true type Readonly = {readonly [K in keyof T]: T[K]} interface A { diff --git a/tests/cases/compiler/strictNullNotNullIndexTypeShouldWork.ts b/tests/cases/compiler/strictNullNotNullIndexTypeShouldWork.ts index 954eaee454b6f..3cd2eccef4100 100644 --- a/tests/cases/compiler/strictNullNotNullIndexTypeShouldWork.ts +++ b/tests/cases/compiler/strictNullNotNullIndexTypeShouldWork.ts @@ -1,4 +1,5 @@ // @strictNullChecks: true +// @strictPropertyInitialization: false interface A { params?: { name: string; }; } diff --git a/tests/cases/conformance/controlFlow/typeGuardsNestedAssignments.ts b/tests/cases/conformance/controlFlow/typeGuardsNestedAssignments.ts index 41e3ffe572e60..9b031015193e7 100644 --- a/tests/cases/conformance/controlFlow/typeGuardsNestedAssignments.ts +++ b/tests/cases/conformance/controlFlow/typeGuardsNestedAssignments.ts @@ -1,7 +1,7 @@ // @strictNullChecks: true class Foo { - x: string; + x: string = ""; } declare function getFooOrNull(): Foo | null; diff --git a/tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts b/tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts index 169dbc7a7c8a2..a2bd6ba38a385 100644 --- a/tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts +++ b/tests/cases/conformance/controlFlow/typeGuardsTypeParameters.ts @@ -3,7 +3,7 @@ // Type guards involving type parameters produce intersection types class C { - prop: string; + prop: string = ""; } function f1(x: T) { diff --git a/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts b/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts index 003976a2b27c8..c6a49f8f8521f 100644 --- a/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts +++ b/tests/cases/conformance/interfaces/interfaceDeclarations/interfaceExtendsObjectIntersection.ts @@ -1,4 +1,5 @@ // @strictNullChecks: true +// @strictPropertyInitialization: false type T1 = { a: number }; type T2 = T1 & { b: number }; diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts index 56ff157a67fd0..35123a89fb35d 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts @@ -1,4 +1,5 @@ // @strictNullChecks: true +// @strictPropertyInitialization: false // @declaration: true class Shape { diff --git a/tests/cases/conformance/types/mapped/mappedTypeErrors.ts b/tests/cases/conformance/types/mapped/mappedTypeErrors.ts index a38979054ecff..f3a6cf2d36854 100644 --- a/tests/cases/conformance/types/mapped/mappedTypeErrors.ts +++ b/tests/cases/conformance/types/mapped/mappedTypeErrors.ts @@ -110,6 +110,9 @@ setState(foo, { c: true }); // Error class C { state: T; + constructor(initialState: T) { + this.state = initialState; + } setState(props: Pick) { for (let k in props) { this.state[k] = props[k]; @@ -117,7 +120,7 @@ class C { } } -let c = new C(); +let c = new C({ a: "hello", b: 42 }); c.setState({ a: "test", b: 43 }); c.setState({ a: "hi" }); c.setState({ b: undefined }); diff --git a/tests/cases/conformance/types/namedTypes/optionalMethods.ts b/tests/cases/conformance/types/namedTypes/optionalMethods.ts index 932521425f9f6..4691a850693ac 100644 --- a/tests/cases/conformance/types/namedTypes/optionalMethods.ts +++ b/tests/cases/conformance/types/namedTypes/optionalMethods.ts @@ -19,7 +19,7 @@ function test1(x: Foo) { } class Bar { - a: number; + a: number = 0; b?: number; c? = 2; constructor(public d?: number, public e = 10) {} diff --git a/tests/cases/conformance/types/spread/objectSpreadNegative.ts b/tests/cases/conformance/types/spread/objectSpreadNegative.ts index 00dfd440667b3..28936bbdeb127 100644 --- a/tests/cases/conformance/types/spread/objectSpreadNegative.ts +++ b/tests/cases/conformance/types/spread/objectSpreadNegative.ts @@ -7,7 +7,7 @@ class PrivateOptionalX { private x?: number; } class PublicX { - public x: number; + public x: number = 42; } declare let publicX: PublicX; declare let privateOptionalX: PrivateOptionalX; From 337bdfd9d07bf3da3e7a5dd91d8c195d0ae53851 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 20:16:18 +0000 Subject: [PATCH 08/10] Accepted baselines. --- .../reference/controlFlowInstanceof.symbols | 51 +++-- .../reference/controlFlowInstanceof.types | 23 +- ...lowInstanceofWithSymbolHasInstance.symbols | 20 +- ...lFlowInstanceofWithSymbolHasInstance.types | 16 +- .../reference/mappedTypeErrors.errors.txt | 31 +-- tests/baselines/reference/mappedTypeErrors.js | 11 +- .../reference/mappedTypeErrors.symbols | 210 +++++++++--------- .../reference/mappedTypeErrors.types | 32 ++- .../reference/objectSpreadNegative.errors.txt | 2 +- .../reference/objectSpreadNegative.js | 3 +- .../reference/objectSpreadNegative.symbols | 2 +- .../reference/objectSpreadNegative.types | 4 +- tests/baselines/reference/optionalMethods.js | 3 +- .../reference/optionalMethods.symbols | 8 +- .../baselines/reference/optionalMethods.types | 4 +- .../optionalParameterProperty.errors.txt | 2 +- .../reference/optionalParameterProperty.js | 3 +- .../optionalParameterProperty.symbols | 2 +- .../reference/optionalParameterProperty.types | 4 +- .../reference/typeGuardsNestedAssignments.js | 3 +- .../typeGuardsNestedAssignments.symbols | 2 +- .../typeGuardsNestedAssignments.types | 4 +- .../reference/typeGuardsTypeParameters.js | 3 +- .../typeGuardsTypeParameters.symbols | 2 +- .../reference/typeGuardsTypeParameters.types | 4 +- 25 files changed, 266 insertions(+), 183 deletions(-) diff --git a/tests/baselines/reference/controlFlowInstanceof.symbols b/tests/baselines/reference/controlFlowInstanceof.symbols index c464fc7cd252c..b19da2dcaf525 100644 --- a/tests/baselines/reference/controlFlowInstanceof.symbols +++ b/tests/baselines/reference/controlFlowInstanceof.symbols @@ -111,22 +111,22 @@ function f4(s: Set | Set) { // More tests -class A { a: string } +class A { a: string = "" } >A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) >a : Symbol(A.a, Decl(controlFlowInstanceof.ts, 45, 9)) -class B extends A { b: string } ->B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) +class B extends A { b: string = "" } +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 26)) >A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) >b : Symbol(B.b, Decl(controlFlowInstanceof.ts, 46, 19)) -class C extends A { c: string } ->C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) +class C extends A { c: string = "" } +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 36)) >A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) >c : Symbol(C.c, Decl(controlFlowInstanceof.ts, 47, 19)) function foo(x: A | undefined) { ->foo : Symbol(foo, Decl(controlFlowInstanceof.ts, 47, 31)) +>foo : Symbol(foo, Decl(controlFlowInstanceof.ts, 47, 36)) >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) >A : Symbol(A, Decl(controlFlowInstanceof.ts, 41, 1)) @@ -135,9 +135,9 @@ function foo(x: A | undefined) { if (x instanceof B || x instanceof C) { >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 26)) >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 36)) x; // B | C >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) @@ -147,9 +147,9 @@ function foo(x: A | undefined) { if (x instanceof B && x instanceof C) { >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 26)) >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 36)) x; // B & C >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) @@ -167,14 +167,14 @@ function foo(x: A | undefined) { if (x instanceof B) { >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 21)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 45, 26)) x; // B >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) if (x instanceof C) { >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) ->C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 31)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 46, 36)) x; // B & C >x : Symbol(x, Decl(controlFlowInstanceof.ts, 49, 13)) @@ -200,14 +200,14 @@ function foo(x: A | undefined) { interface X { >X : Symbol(X, Decl(controlFlowInstanceof.ts, 77, 1)) - x?: string; + x?: string >x : Symbol(X.x, Decl(controlFlowInstanceof.ts, 82, 13)) } class Y { >Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 84, 1)) - y: string; + y: string = ""; >y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 86, 9)) } @@ -251,26 +251,29 @@ if (x instanceof ctor) { // Repro from #27550 (based on uglify code) === uglify.js === -/** @constructor */ +/** + * @constructor + * @param {any} val + */ function AtTop(val) { this.val = val } >AtTop : Symbol(AtTop, Decl(uglify.js, 0, 0)) ->val : Symbol(val, Decl(uglify.js, 1, 15)) ->this.val : Symbol(AtTop.val, Decl(uglify.js, 1, 21)) +>val : Symbol(val, Decl(uglify.js, 4, 15)) +>this.val : Symbol(AtTop.val, Decl(uglify.js, 4, 21)) >this : Symbol(AtTop, Decl(uglify.js, 0, 0)) ->val : Symbol(AtTop.val, Decl(uglify.js, 1, 21)) ->val : Symbol(val, Decl(uglify.js, 1, 15)) +>val : Symbol(AtTop.val, Decl(uglify.js, 4, 21)) +>val : Symbol(val, Decl(uglify.js, 4, 15)) /** @type {*} */ var v = 1; ->v : Symbol(v, Decl(uglify.js, 3, 3)) +>v : Symbol(v, Decl(uglify.js, 6, 3)) if (v instanceof AtTop) { ->v : Symbol(v, Decl(uglify.js, 3, 3)) +>v : Symbol(v, Decl(uglify.js, 6, 3)) >AtTop : Symbol(AtTop, Decl(uglify.js, 0, 0)) v.val ->v.val : Symbol(AtTop.val, Decl(uglify.js, 1, 21)) ->v : Symbol(v, Decl(uglify.js, 3, 3)) ->val : Symbol(AtTop.val, Decl(uglify.js, 1, 21)) +>v.val : Symbol(AtTop.val, Decl(uglify.js, 4, 21)) +>v : Symbol(v, Decl(uglify.js, 6, 3)) +>val : Symbol(AtTop.val, Decl(uglify.js, 4, 21)) } diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types index fc2fe6c36b20b..6d2417a6fb839 100644 --- a/tests/baselines/reference/controlFlowInstanceof.types +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -171,27 +171,33 @@ function f4(s: Set | Set) { // More tests -class A { a: string } +class A { a: string = "" } >A : A > : ^ >a : string > : ^^^^^^ +>"" : "" +> : ^^ -class B extends A { b: string } +class B extends A { b: string = "" } >B : B > : ^ >A : A > : ^ >b : string > : ^^^^^^ +>"" : "" +> : ^^ -class C extends A { c: string } +class C extends A { c: string = "" } >C : C > : ^ >A : A > : ^ >c : string > : ^^^^^^ +>"" : "" +> : ^^ function foo(x: A | undefined) { >foo : (x: A | undefined) => void @@ -310,7 +316,7 @@ function foo(x: A | undefined) { // Y is assignable to X, but not a subtype of X interface X { - x?: string; + x?: string >x : string | undefined > : ^^^^^^^^^^^^^^^^^^ } @@ -319,9 +325,11 @@ class Y { >Y : Y > : ^ - y: string; + y: string = ""; >y : string > : ^^^^^^ +>"" : "" +> : ^^ } function goo(x: X) { @@ -382,7 +390,10 @@ if (x instanceof ctor) { // Repro from #27550 (based on uglify code) === uglify.js === -/** @constructor */ +/** + * @constructor + * @param {any} val + */ function AtTop(val) { this.val = val } >AtTop : typeof AtTop > : ^^^^^^^^^^^^ diff --git a/tests/baselines/reference/controlFlowInstanceofWithSymbolHasInstance.symbols b/tests/baselines/reference/controlFlowInstanceofWithSymbolHasInstance.symbols index 4c19470419e35..a2bfbc3676c8e 100644 --- a/tests/baselines/reference/controlFlowInstanceofWithSymbolHasInstance.symbols +++ b/tests/baselines/reference/controlFlowInstanceofWithSymbolHasInstance.symbols @@ -138,11 +138,11 @@ function f4(s: Set | Set) { class A { >A : Symbol(A, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 47, 1)) - a: string; + a: string = ""; >a : Symbol(A.a, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 51, 9)) static [Symbol.hasInstance](this: T, value: unknown): value is ( ->[Symbol.hasInstance] : Symbol(A[Symbol.hasInstance], Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 52, 14)) +>[Symbol.hasInstance] : Symbol(A[Symbol.hasInstance], Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 52, 19)) >Symbol.hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >hasInstance : Symbol(SymbolConstructor.hasInstance, Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) @@ -173,18 +173,18 @@ class A { >value : Symbol(value, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 53, 43)) } } -class B extends A { b: string } +class B extends A { b: string = ""; } >B : Symbol(B, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 59, 1)) >A : Symbol(A, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 47, 1)) >b : Symbol(B.b, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 19)) -class C extends A { c: string } ->C : Symbol(C, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 31)) +class C extends A { c: string = ""; } +>C : Symbol(C, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 37)) >A : Symbol(A, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 47, 1)) >c : Symbol(C.c, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 61, 19)) function foo(x: A | undefined) { ->foo : Symbol(foo, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 61, 31)) +>foo : Symbol(foo, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 61, 37)) >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) >A : Symbol(A, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 47, 1)) @@ -195,7 +195,7 @@ function foo(x: A | undefined) { >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) >B : Symbol(B, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 59, 1)) >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) ->C : Symbol(C, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 31)) +>C : Symbol(C, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 37)) x; // B | C >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) @@ -207,7 +207,7 @@ function foo(x: A | undefined) { >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) >B : Symbol(B, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 59, 1)) >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) ->C : Symbol(C, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 31)) +>C : Symbol(C, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 37)) x; // B & C >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) @@ -232,7 +232,7 @@ function foo(x: A | undefined) { if (x instanceof C) { >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) ->C : Symbol(C, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 31)) +>C : Symbol(C, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 60, 37)) x; // B & C >x : Symbol(x, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 63, 13)) @@ -265,7 +265,7 @@ interface X { class Y { >Y : Symbol(Y, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 98, 1)) - y: string; + y: string = ""; >y : Symbol(Y.y, Decl(controlFlowInstanceofWithSymbolHasInstance.ts, 100, 9)) } diff --git a/tests/baselines/reference/controlFlowInstanceofWithSymbolHasInstance.types b/tests/baselines/reference/controlFlowInstanceofWithSymbolHasInstance.types index d980a88e871a9..949d9c5798bed 100644 --- a/tests/baselines/reference/controlFlowInstanceofWithSymbolHasInstance.types +++ b/tests/baselines/reference/controlFlowInstanceofWithSymbolHasInstance.types @@ -199,9 +199,11 @@ class A { >A : A > : ^ - a: string; + a: string = ""; >a : string > : ^^^^^^ +>"" : "" +> : ^^ static [Symbol.hasInstance](this: T, value: unknown): value is ( >[Symbol.hasInstance] : (this: T, value: unknown) => value is (T extends (abstract new (...args: any) => infer U) ? U : never) @@ -248,21 +250,25 @@ class A { > : ^^^^^^^ } } -class B extends A { b: string } +class B extends A { b: string = ""; } >B : B > : ^ >A : A > : ^ >b : string > : ^^^^^^ +>"" : "" +> : ^^ -class C extends A { c: string } +class C extends A { c: string = ""; } >C : C > : ^ >A : A > : ^ >c : string > : ^^^^^^ +>"" : "" +> : ^^ function foo(x: A | undefined) { >foo : (x: A | undefined) => void @@ -390,9 +396,11 @@ class Y { >Y : Y > : ^ - y: string; + y: string = ""; >y : string > : ^^^^^^ +>"" : "" +> : ^^ } function goo(x: X) { diff --git a/tests/baselines/reference/mappedTypeErrors.errors.txt b/tests/baselines/reference/mappedTypeErrors.errors.txt index e03c20d64bff7..f05b82726619c 100644 --- a/tests/baselines/reference/mappedTypeErrors.errors.txt +++ b/tests/baselines/reference/mappedTypeErrors.errors.txt @@ -21,15 +21,15 @@ mappedTypeErrors.ts(77,59): error TS2353: Object literal may only specify known mappedTypeErrors.ts(83,58): error TS2353: Object literal may only specify known properties, and 'z' does not exist in type 'Partial<{ x: number; y: number; }>'. mappedTypeErrors.ts(105,17): error TS2322: Type 'undefined' is not assignable to type 'string'. mappedTypeErrors.ts(106,17): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. -mappedTypeErrors.ts(123,14): error TS2322: Type 'undefined' is not assignable to type 'string'. -mappedTypeErrors.ts(124,14): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. -mappedTypeErrors.ts(128,16): error TS2322: Type 'string' is not assignable to type 'number'. -mappedTypeErrors.ts(129,25): error TS2322: Type 'string' is not assignable to type 'number'. -mappedTypeErrors.ts(130,39): error TS2322: Type 'string' is not assignable to type 'number'. -mappedTypeErrors.ts(136,16): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'. -mappedTypeErrors.ts(136,21): error TS2536: Type 'P' cannot be used to index type 'T'. -mappedTypeErrors.ts(148,17): error TS2339: Property 'foo' does not exist on type 'Pick'. -mappedTypeErrors.ts(152,17): error TS2339: Property 'foo' does not exist on type 'Record'. +mappedTypeErrors.ts(126,14): error TS2322: Type 'undefined' is not assignable to type 'string'. +mappedTypeErrors.ts(127,14): error TS2353: Object literal may only specify known properties, and 'c' does not exist in type 'Pick'. +mappedTypeErrors.ts(131,16): error TS2322: Type 'string' is not assignable to type 'number'. +mappedTypeErrors.ts(132,25): error TS2322: Type 'string' is not assignable to type 'number'. +mappedTypeErrors.ts(133,39): error TS2322: Type 'string' is not assignable to type 'number'. +mappedTypeErrors.ts(139,16): error TS2322: Type 'T' is not assignable to type 'string | number | symbol'. +mappedTypeErrors.ts(139,21): error TS2536: Type 'P' cannot be used to index type 'T'. +mappedTypeErrors.ts(151,17): error TS2339: Property 'foo' does not exist on type 'Pick'. +mappedTypeErrors.ts(155,17): error TS2339: Property 'foo' does not exist on type 'Record'. ==== mappedTypeErrors.ts (27 errors) ==== @@ -190,6 +190,9 @@ mappedTypeErrors.ts(152,17): error TS2339: Property 'foo' does not exist on type class C { state: T; + constructor(initialState: T) { + this.state = initialState; + } setState(props: Pick) { for (let k in props) { this.state[k] = props[k]; @@ -197,7 +200,7 @@ mappedTypeErrors.ts(152,17): error TS2339: Property 'foo' does not exist on type } } - let c = new C(); + let c = new C({ a: "hello", b: 42 }); c.setState({ a: "test", b: 43 }); c.setState({ a: "hi" }); c.setState({ b: undefined }); @@ -216,15 +219,15 @@ mappedTypeErrors.ts(152,17): error TS2339: Property 'foo' does not exist on type let x1: T2 = { a: 'no' }; // Error ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. -!!! related TS6500 mappedTypeErrors.ts:126:13: The expected type comes from property 'a' which is declared here on type 'T2' +!!! related TS6500 mappedTypeErrors.ts:129:13: The expected type comes from property 'a' which is declared here on type 'T2' let x2: Partial = { a: 'no' }; // Error ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. -!!! related TS6500 mappedTypeErrors.ts:126:13: The expected type comes from property 'a' which is declared here on type 'Partial' +!!! related TS6500 mappedTypeErrors.ts:129:13: The expected type comes from property 'a' which is declared here on type 'Partial' let x3: { [P in keyof T2]: T2[P]} = { a: 'no' }; // Error ~ !!! error TS2322: Type 'string' is not assignable to type 'number'. -!!! related TS6500 mappedTypeErrors.ts:126:13: The expected type comes from property 'a' which is declared here on type '{ [x: string]: any; a?: number | undefined; }' +!!! related TS6500 mappedTypeErrors.ts:129:13: The expected type comes from property 'a' which is declared here on type '{ [x: string]: any; a?: number | undefined; }' // Repro from #13044 @@ -233,7 +236,7 @@ mappedTypeErrors.ts(152,17): error TS2339: Property 'foo' does not exist on type pt: {[P in T]?: T[P]}, // note: should be in keyof T ~ !!! error TS2322: Type 'T' is not assignable to type 'string | number | symbol'. -!!! related TS2208 mappedTypeErrors.ts:134:11: This type parameter might need an `extends string | number | symbol` constraint. +!!! related TS2208 mappedTypeErrors.ts:137:11: This type parameter might need an `extends string | number | symbol` constraint. ~~~~ !!! error TS2536: Type 'P' cannot be used to index type 'T'. }; diff --git a/tests/baselines/reference/mappedTypeErrors.js b/tests/baselines/reference/mappedTypeErrors.js index 81d183c94831a..39018b0e2874c 100644 --- a/tests/baselines/reference/mappedTypeErrors.js +++ b/tests/baselines/reference/mappedTypeErrors.js @@ -110,6 +110,9 @@ setState(foo, { c: true }); // Error class C { state: T; + constructor(initialState: T) { + this.state = initialState; + } setState(props: Pick) { for (let k in props) { this.state[k] = props[k]; @@ -117,7 +120,7 @@ class C { } } -let c = new C(); +let c = new C({ a: "hello", b: 42 }); c.setState({ a: "test", b: 43 }); c.setState({ a: "hi" }); c.setState({ b: undefined }); @@ -209,7 +212,8 @@ setState(foo, foo); setState(foo, { a: undefined }); // Error setState(foo, { c: true }); // Error var C = /** @class */ (function () { - function C() { + function C(initialState) { + this.state = initialState; } C.prototype.setState = function (props) { for (var k in props) { @@ -218,7 +222,7 @@ var C = /** @class */ (function () { }; return C; }()); -var c = new C(); +var c = new C({ a: "hello", b: 42 }); c.setState({ a: "test", b: 43 }); c.setState({ a: "hi" }); c.setState({ b: undefined }); @@ -293,6 +297,7 @@ declare function setState(obj: T, props: Pick): void declare let foo: Foo; declare class C { state: T; + constructor(initialState: T); setState(props: Pick): void; } declare let c: C; diff --git a/tests/baselines/reference/mappedTypeErrors.symbols b/tests/baselines/reference/mappedTypeErrors.symbols index 092881722f5b1..62a33c71c7aa2 100644 --- a/tests/baselines/reference/mappedTypeErrors.symbols +++ b/tests/baselines/reference/mappedTypeErrors.symbols @@ -395,181 +395,193 @@ class C { >state : Symbol(C.state, Decl(mappedTypeErrors.ts, 107, 12)) >T : Symbol(T, Decl(mappedTypeErrors.ts, 107, 8)) + constructor(initialState: T) { +>initialState : Symbol(initialState, Decl(mappedTypeErrors.ts, 109, 16)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 107, 8)) + + this.state = initialState; +>this.state : Symbol(C.state, Decl(mappedTypeErrors.ts, 107, 12)) +>this : Symbol(C, Decl(mappedTypeErrors.ts, 105, 27)) +>state : Symbol(C.state, Decl(mappedTypeErrors.ts, 107, 12)) +>initialState : Symbol(initialState, Decl(mappedTypeErrors.ts, 109, 16)) + } setState(props: Pick) { ->setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->K : Symbol(K, Decl(mappedTypeErrors.ts, 109, 13)) +>setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>K : Symbol(K, Decl(mappedTypeErrors.ts, 112, 13)) >T : Symbol(T, Decl(mappedTypeErrors.ts, 107, 8)) ->props : Symbol(props, Decl(mappedTypeErrors.ts, 109, 32)) +>props : Symbol(props, Decl(mappedTypeErrors.ts, 112, 32)) >Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) >T : Symbol(T, Decl(mappedTypeErrors.ts, 107, 8)) ->K : Symbol(K, Decl(mappedTypeErrors.ts, 109, 13)) +>K : Symbol(K, Decl(mappedTypeErrors.ts, 112, 13)) for (let k in props) { ->k : Symbol(k, Decl(mappedTypeErrors.ts, 110, 16)) ->props : Symbol(props, Decl(mappedTypeErrors.ts, 109, 32)) +>k : Symbol(k, Decl(mappedTypeErrors.ts, 113, 16)) +>props : Symbol(props, Decl(mappedTypeErrors.ts, 112, 32)) this.state[k] = props[k]; >this.state : Symbol(C.state, Decl(mappedTypeErrors.ts, 107, 12)) >this : Symbol(C, Decl(mappedTypeErrors.ts, 105, 27)) >state : Symbol(C.state, Decl(mappedTypeErrors.ts, 107, 12)) ->k : Symbol(k, Decl(mappedTypeErrors.ts, 110, 16)) ->props : Symbol(props, Decl(mappedTypeErrors.ts, 109, 32)) ->k : Symbol(k, Decl(mappedTypeErrors.ts, 110, 16)) +>k : Symbol(k, Decl(mappedTypeErrors.ts, 113, 16)) +>props : Symbol(props, Decl(mappedTypeErrors.ts, 112, 32)) +>k : Symbol(k, Decl(mappedTypeErrors.ts, 113, 16)) } } } -let c = new C(); ->c : Symbol(c, Decl(mappedTypeErrors.ts, 116, 3)) +let c = new C({ a: "hello", b: 42 }); +>c : Symbol(c, Decl(mappedTypeErrors.ts, 119, 3)) >C : Symbol(C, Decl(mappedTypeErrors.ts, 105, 27)) >Foo : Symbol(Foo, Decl(mappedTypeErrors.ts, 83, 1)) +>a : Symbol(a, Decl(mappedTypeErrors.ts, 119, 20)) +>b : Symbol(b, Decl(mappedTypeErrors.ts, 119, 32)) c.setState({ a: "test", b: 43 }); ->c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->c : Symbol(c, Decl(mappedTypeErrors.ts, 116, 3)) ->setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->a : Symbol(a, Decl(mappedTypeErrors.ts, 117, 12)) ->b : Symbol(b, Decl(mappedTypeErrors.ts, 117, 23)) +>c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>c : Symbol(c, Decl(mappedTypeErrors.ts, 119, 3)) +>setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>a : Symbol(a, Decl(mappedTypeErrors.ts, 120, 12)) +>b : Symbol(b, Decl(mappedTypeErrors.ts, 120, 23)) c.setState({ a: "hi" }); ->c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->c : Symbol(c, Decl(mappedTypeErrors.ts, 116, 3)) ->setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->a : Symbol(a, Decl(mappedTypeErrors.ts, 118, 12)) +>c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>c : Symbol(c, Decl(mappedTypeErrors.ts, 119, 3)) +>setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>a : Symbol(a, Decl(mappedTypeErrors.ts, 121, 12)) c.setState({ b: undefined }); ->c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->c : Symbol(c, Decl(mappedTypeErrors.ts, 116, 3)) ->setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->b : Symbol(b, Decl(mappedTypeErrors.ts, 119, 12)) +>c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>c : Symbol(c, Decl(mappedTypeErrors.ts, 119, 3)) +>setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>b : Symbol(b, Decl(mappedTypeErrors.ts, 122, 12)) >undefined : Symbol(undefined) c.setState({ }); ->c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->c : Symbol(c, Decl(mappedTypeErrors.ts, 116, 3)) ->setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) +>c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>c : Symbol(c, Decl(mappedTypeErrors.ts, 119, 3)) +>setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) c.setState(foo); ->c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->c : Symbol(c, Decl(mappedTypeErrors.ts, 116, 3)) ->setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) +>c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>c : Symbol(c, Decl(mappedTypeErrors.ts, 119, 3)) +>setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) >foo : Symbol(foo, Decl(mappedTypeErrors.ts, 98, 3)) c.setState({ a: undefined }); // Error ->c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->c : Symbol(c, Decl(mappedTypeErrors.ts, 116, 3)) ->setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->a : Symbol(a, Decl(mappedTypeErrors.ts, 122, 12)) +>c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>c : Symbol(c, Decl(mappedTypeErrors.ts, 119, 3)) +>setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>a : Symbol(a, Decl(mappedTypeErrors.ts, 125, 12)) >undefined : Symbol(undefined) c.setState({ c: true }); // Error ->c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->c : Symbol(c, Decl(mappedTypeErrors.ts, 116, 3)) ->setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 108, 13)) ->c : Symbol(c, Decl(mappedTypeErrors.ts, 123, 12)) +>c.setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>c : Symbol(c, Decl(mappedTypeErrors.ts, 119, 3)) +>setState : Symbol(C.setState, Decl(mappedTypeErrors.ts, 111, 5)) +>c : Symbol(c, Decl(mappedTypeErrors.ts, 126, 12)) type T2 = { a?: number, [key: string]: any }; ->T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 123, 24)) ->a : Symbol(a, Decl(mappedTypeErrors.ts, 125, 11)) ->key : Symbol(key, Decl(mappedTypeErrors.ts, 125, 25)) +>T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 126, 24)) +>a : Symbol(a, Decl(mappedTypeErrors.ts, 128, 11)) +>key : Symbol(key, Decl(mappedTypeErrors.ts, 128, 25)) let x1: T2 = { a: 'no' }; // Error ->x1 : Symbol(x1, Decl(mappedTypeErrors.ts, 127, 3)) ->T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 123, 24)) ->a : Symbol(a, Decl(mappedTypeErrors.ts, 127, 14)) +>x1 : Symbol(x1, Decl(mappedTypeErrors.ts, 130, 3)) +>T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 126, 24)) +>a : Symbol(a, Decl(mappedTypeErrors.ts, 130, 14)) let x2: Partial = { a: 'no' }; // Error ->x2 : Symbol(x2, Decl(mappedTypeErrors.ts, 128, 3)) +>x2 : Symbol(x2, Decl(mappedTypeErrors.ts, 131, 3)) >Partial : Symbol(Partial, Decl(lib.es5.d.ts, --, --)) ->T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 123, 24)) ->a : Symbol(a, Decl(mappedTypeErrors.ts, 128, 23)) +>T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 126, 24)) +>a : Symbol(a, Decl(mappedTypeErrors.ts, 131, 23)) let x3: { [P in keyof T2]: T2[P]} = { a: 'no' }; // Error ->x3 : Symbol(x3, Decl(mappedTypeErrors.ts, 129, 3)) ->P : Symbol(P, Decl(mappedTypeErrors.ts, 129, 11)) ->T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 123, 24)) ->T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 123, 24)) ->P : Symbol(P, Decl(mappedTypeErrors.ts, 129, 11)) ->a : Symbol(a, Decl(mappedTypeErrors.ts, 129, 37)) +>x3 : Symbol(x3, Decl(mappedTypeErrors.ts, 132, 3)) +>P : Symbol(P, Decl(mappedTypeErrors.ts, 132, 11)) +>T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 126, 24)) +>T2 : Symbol(T2, Decl(mappedTypeErrors.ts, 126, 24)) +>P : Symbol(P, Decl(mappedTypeErrors.ts, 132, 11)) +>a : Symbol(a, Decl(mappedTypeErrors.ts, 132, 37)) // Repro from #13044 type Foo2 = { ->Foo2 : Symbol(Foo2, Decl(mappedTypeErrors.ts, 129, 48)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 133, 10)) ->F : Symbol(F, Decl(mappedTypeErrors.ts, 133, 12)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 133, 10)) +>Foo2 : Symbol(Foo2, Decl(mappedTypeErrors.ts, 132, 48)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 136, 10)) +>F : Symbol(F, Decl(mappedTypeErrors.ts, 136, 12)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 136, 10)) pf: {[P in F]?: T[P]}, ->pf : Symbol(pf, Decl(mappedTypeErrors.ts, 133, 35)) ->P : Symbol(P, Decl(mappedTypeErrors.ts, 134, 10)) ->F : Symbol(F, Decl(mappedTypeErrors.ts, 133, 12)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 133, 10)) ->P : Symbol(P, Decl(mappedTypeErrors.ts, 134, 10)) +>pf : Symbol(pf, Decl(mappedTypeErrors.ts, 136, 35)) +>P : Symbol(P, Decl(mappedTypeErrors.ts, 137, 10)) +>F : Symbol(F, Decl(mappedTypeErrors.ts, 136, 12)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 136, 10)) +>P : Symbol(P, Decl(mappedTypeErrors.ts, 137, 10)) pt: {[P in T]?: T[P]}, // note: should be in keyof T ->pt : Symbol(pt, Decl(mappedTypeErrors.ts, 134, 26)) ->P : Symbol(P, Decl(mappedTypeErrors.ts, 135, 10)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 133, 10)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 133, 10)) ->P : Symbol(P, Decl(mappedTypeErrors.ts, 135, 10)) +>pt : Symbol(pt, Decl(mappedTypeErrors.ts, 137, 26)) +>P : Symbol(P, Decl(mappedTypeErrors.ts, 138, 10)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 136, 10)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 136, 10)) +>P : Symbol(P, Decl(mappedTypeErrors.ts, 138, 10)) }; type O = {x: number, y: boolean}; ->O : Symbol(O, Decl(mappedTypeErrors.ts, 136, 2)) ->x : Symbol(x, Decl(mappedTypeErrors.ts, 137, 10)) ->y : Symbol(y, Decl(mappedTypeErrors.ts, 137, 20)) +>O : Symbol(O, Decl(mappedTypeErrors.ts, 139, 2)) +>x : Symbol(x, Decl(mappedTypeErrors.ts, 140, 10)) +>y : Symbol(y, Decl(mappedTypeErrors.ts, 140, 20)) let o: O = {x: 5, y: false}; ->o : Symbol(o, Decl(mappedTypeErrors.ts, 138, 3)) ->O : Symbol(O, Decl(mappedTypeErrors.ts, 136, 2)) ->x : Symbol(x, Decl(mappedTypeErrors.ts, 138, 12)) ->y : Symbol(y, Decl(mappedTypeErrors.ts, 138, 17)) +>o : Symbol(o, Decl(mappedTypeErrors.ts, 141, 3)) +>O : Symbol(O, Decl(mappedTypeErrors.ts, 139, 2)) +>x : Symbol(x, Decl(mappedTypeErrors.ts, 141, 12)) +>y : Symbol(y, Decl(mappedTypeErrors.ts, 141, 17)) let f: Foo2 = { ->f : Symbol(f, Decl(mappedTypeErrors.ts, 139, 3)) ->Foo2 : Symbol(Foo2, Decl(mappedTypeErrors.ts, 129, 48)) ->O : Symbol(O, Decl(mappedTypeErrors.ts, 136, 2)) +>f : Symbol(f, Decl(mappedTypeErrors.ts, 142, 3)) +>Foo2 : Symbol(Foo2, Decl(mappedTypeErrors.ts, 132, 48)) +>O : Symbol(O, Decl(mappedTypeErrors.ts, 139, 2)) pf: {x: 7}, ->pf : Symbol(pf, Decl(mappedTypeErrors.ts, 139, 23)) ->x : Symbol(x, Decl(mappedTypeErrors.ts, 140, 9)) +>pf : Symbol(pf, Decl(mappedTypeErrors.ts, 142, 23)) +>x : Symbol(x, Decl(mappedTypeErrors.ts, 143, 9)) pt: {x: 7, y: false}, ->pt : Symbol(pt, Decl(mappedTypeErrors.ts, 140, 15)) ->x : Symbol(x, Decl(mappedTypeErrors.ts, 141, 9)) ->y : Symbol(y, Decl(mappedTypeErrors.ts, 141, 14)) +>pt : Symbol(pt, Decl(mappedTypeErrors.ts, 143, 15)) +>x : Symbol(x, Decl(mappedTypeErrors.ts, 144, 9)) +>y : Symbol(y, Decl(mappedTypeErrors.ts, 144, 14)) }; // Repro from #28170 function test1(obj: Pick) { ->test1 : Symbol(test1, Decl(mappedTypeErrors.ts, 142, 2)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 146, 15)) ->K : Symbol(K, Decl(mappedTypeErrors.ts, 146, 17)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 146, 15)) ->obj : Symbol(obj, Decl(mappedTypeErrors.ts, 146, 37)) +>test1 : Symbol(test1, Decl(mappedTypeErrors.ts, 145, 2)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 149, 15)) +>K : Symbol(K, Decl(mappedTypeErrors.ts, 149, 17)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 149, 15)) +>obj : Symbol(obj, Decl(mappedTypeErrors.ts, 149, 37)) >Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 146, 15)) ->K : Symbol(K, Decl(mappedTypeErrors.ts, 146, 17)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 149, 15)) +>K : Symbol(K, Decl(mappedTypeErrors.ts, 149, 17)) let x = obj.foo; // Error ->x : Symbol(x, Decl(mappedTypeErrors.ts, 147, 7)) ->obj : Symbol(obj, Decl(mappedTypeErrors.ts, 146, 37)) +>x : Symbol(x, Decl(mappedTypeErrors.ts, 150, 7)) +>obj : Symbol(obj, Decl(mappedTypeErrors.ts, 149, 37)) } function test2(obj: Record) { ->test2 : Symbol(test2, Decl(mappedTypeErrors.ts, 148, 1)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 150, 15)) ->K : Symbol(K, Decl(mappedTypeErrors.ts, 150, 17)) ->T : Symbol(T, Decl(mappedTypeErrors.ts, 150, 15)) ->obj : Symbol(obj, Decl(mappedTypeErrors.ts, 150, 37)) +>test2 : Symbol(test2, Decl(mappedTypeErrors.ts, 151, 1)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 153, 15)) +>K : Symbol(K, Decl(mappedTypeErrors.ts, 153, 17)) +>T : Symbol(T, Decl(mappedTypeErrors.ts, 153, 15)) +>obj : Symbol(obj, Decl(mappedTypeErrors.ts, 153, 37)) >Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) ->K : Symbol(K, Decl(mappedTypeErrors.ts, 150, 17)) +>K : Symbol(K, Decl(mappedTypeErrors.ts, 153, 17)) let x = obj.foo; // Error ->x : Symbol(x, Decl(mappedTypeErrors.ts, 151, 7)) ->obj : Symbol(obj, Decl(mappedTypeErrors.ts, 150, 37)) +>x : Symbol(x, Decl(mappedTypeErrors.ts, 154, 7)) +>obj : Symbol(obj, Decl(mappedTypeErrors.ts, 153, 37)) } diff --git a/tests/baselines/reference/mappedTypeErrors.types b/tests/baselines/reference/mappedTypeErrors.types index 32839343182fc..8e3cc57116da1 100644 --- a/tests/baselines/reference/mappedTypeErrors.types +++ b/tests/baselines/reference/mappedTypeErrors.types @@ -538,6 +538,22 @@ class C { >state : T > : ^ + constructor(initialState: T) { +>initialState : T +> : ^ + + this.state = initialState; +>this.state = initialState : T +> : ^ +>this.state : T +> : ^ +>this : this +> : ^^^^ +>state : T +> : ^ +>initialState : T +> : ^ + } setState(props: Pick) { >setState : (props: Pick) => void > : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ @@ -573,13 +589,23 @@ class C { } } -let c = new C(); +let c = new C({ a: "hello", b: 42 }); >c : C > : ^^^^^^ ->new C() : C -> : ^^^^^^ +>new C({ a: "hello", b: 42 }) : C +> : ^^^^^^ >C : typeof C > : ^^^^^^^^ +>{ a: "hello", b: 42 } : { a: string; b: number; } +> : ^^^^^^^^^^^^^^^^^^^^^^^^^ +>a : string +> : ^^^^^^ +>"hello" : "hello" +> : ^^^^^^^ +>b : number +> : ^^^^^^ +>42 : 42 +> : ^^ c.setState({ a: "test", b: 43 }); >c.setState({ a: "test", b: 43 }) : void diff --git a/tests/baselines/reference/objectSpreadNegative.errors.txt b/tests/baselines/reference/objectSpreadNegative.errors.txt index 860b430be4bd3..248cf36e66580 100644 --- a/tests/baselines/reference/objectSpreadNegative.errors.txt +++ b/tests/baselines/reference/objectSpreadNegative.errors.txt @@ -34,7 +34,7 @@ objectSpreadNegative.ts(74,11): error TS2339: Property 'a' does not exist on typ private x?: number; } class PublicX { - public x: number; + public x: number = 42; } declare let publicX: PublicX; declare let privateOptionalX: PrivateOptionalX; diff --git a/tests/baselines/reference/objectSpreadNegative.js b/tests/baselines/reference/objectSpreadNegative.js index 01c626ac93e03..474b76dd8cfc0 100644 --- a/tests/baselines/reference/objectSpreadNegative.js +++ b/tests/baselines/reference/objectSpreadNegative.js @@ -8,7 +8,7 @@ class PrivateOptionalX { private x?: number; } class PublicX { - public x: number; + public x: number = 42; } declare let publicX: PublicX; declare let privateOptionalX: PrivateOptionalX; @@ -99,6 +99,7 @@ var PrivateOptionalX = /** @class */ (function () { }()); var PublicX = /** @class */ (function () { function PublicX() { + this.x = 42; } return PublicX; }()); diff --git a/tests/baselines/reference/objectSpreadNegative.symbols b/tests/baselines/reference/objectSpreadNegative.symbols index 55bc35f60e197..2862a1b864548 100644 --- a/tests/baselines/reference/objectSpreadNegative.symbols +++ b/tests/baselines/reference/objectSpreadNegative.symbols @@ -16,7 +16,7 @@ class PrivateOptionalX { class PublicX { >PublicX : Symbol(PublicX, Decl(objectSpreadNegative.ts, 5, 1)) - public x: number; + public x: number = 42; >x : Symbol(PublicX.x, Decl(objectSpreadNegative.ts, 6, 15)) } declare let publicX: PublicX; diff --git a/tests/baselines/reference/objectSpreadNegative.types b/tests/baselines/reference/objectSpreadNegative.types index 5a228136893ef..0e1c4abe618c2 100644 --- a/tests/baselines/reference/objectSpreadNegative.types +++ b/tests/baselines/reference/objectSpreadNegative.types @@ -28,9 +28,11 @@ class PublicX { >PublicX : PublicX > : ^^^^^^^ - public x: number; + public x: number = 42; >x : number > : ^^^^^^ +>42 : 42 +> : ^^ } declare let publicX: PublicX; >publicX : PublicX diff --git a/tests/baselines/reference/optionalMethods.js b/tests/baselines/reference/optionalMethods.js index b82fed9387b8f..c621119f5a591 100644 --- a/tests/baselines/reference/optionalMethods.js +++ b/tests/baselines/reference/optionalMethods.js @@ -19,7 +19,7 @@ function test1(x: Foo) { } class Bar { - a: number; + a: number = 0; b?: number; c? = 2; constructor(public d?: number, public e = 10) {} @@ -88,6 +88,7 @@ var Bar = /** @class */ (function () { if (e === void 0) { e = 10; } this.d = d; this.e = e; + this.a = 0; this.c = 2; } Bar.prototype.f = function () { diff --git a/tests/baselines/reference/optionalMethods.symbols b/tests/baselines/reference/optionalMethods.symbols index 806d7d9043571..87e52a3b2a323 100644 --- a/tests/baselines/reference/optionalMethods.symbols +++ b/tests/baselines/reference/optionalMethods.symbols @@ -70,11 +70,11 @@ function test1(x: Foo) { class Bar { >Bar : Symbol(Bar, Decl(optionalMethods.ts, 15, 1)) - a: number; + a: number = 0; >a : Symbol(Bar.a, Decl(optionalMethods.ts, 17, 11)) b?: number; ->b : Symbol(Bar.b, Decl(optionalMethods.ts, 18, 14)) +>b : Symbol(Bar.b, Decl(optionalMethods.ts, 18, 18)) c? = 2; >c : Symbol(Bar.c, Decl(optionalMethods.ts, 19, 15)) @@ -109,9 +109,9 @@ function test2(x: Bar) { >a : Symbol(Bar.a, Decl(optionalMethods.ts, 17, 11)) x.b; ->x.b : Symbol(Bar.b, Decl(optionalMethods.ts, 18, 14)) +>x.b : Symbol(Bar.b, Decl(optionalMethods.ts, 18, 18)) >x : Symbol(x, Decl(optionalMethods.ts, 31, 15)) ->b : Symbol(Bar.b, Decl(optionalMethods.ts, 18, 14)) +>b : Symbol(Bar.b, Decl(optionalMethods.ts, 18, 18)) x.c; >x.c : Symbol(Bar.c, Decl(optionalMethods.ts, 19, 15)) diff --git a/tests/baselines/reference/optionalMethods.types b/tests/baselines/reference/optionalMethods.types index 7230b9e6cfb01..c76a6dae6a6ff 100644 --- a/tests/baselines/reference/optionalMethods.types +++ b/tests/baselines/reference/optionalMethods.types @@ -116,9 +116,11 @@ class Bar { >Bar : Bar > : ^^^ - a: number; + a: number = 0; >a : number > : ^^^^^^ +>0 : 0 +> : ^ b?: number; >b : number | undefined diff --git a/tests/baselines/reference/optionalParameterProperty.errors.txt b/tests/baselines/reference/optionalParameterProperty.errors.txt index 8d0418dc6208e..cd7fb6f9f6f4e 100644 --- a/tests/baselines/reference/optionalParameterProperty.errors.txt +++ b/tests/baselines/reference/optionalParameterProperty.errors.txt @@ -6,7 +6,7 @@ optionalParameterProperty.ts(5,7): error TS2415: Class 'D' incorrectly extends b ==== optionalParameterProperty.ts (1 errors) ==== class C { - p: number; + p: number = 0; } class D extends C { diff --git a/tests/baselines/reference/optionalParameterProperty.js b/tests/baselines/reference/optionalParameterProperty.js index 071841946d2a4..43589fcd22e86 100644 --- a/tests/baselines/reference/optionalParameterProperty.js +++ b/tests/baselines/reference/optionalParameterProperty.js @@ -2,7 +2,7 @@ //// [optionalParameterProperty.ts] class C { - p: number; + p: number = 0; } class D extends C { @@ -30,6 +30,7 @@ var __extends = (this && this.__extends) || (function () { })(); var C = /** @class */ (function () { function C() { + this.p = 0; } return C; }()); diff --git a/tests/baselines/reference/optionalParameterProperty.symbols b/tests/baselines/reference/optionalParameterProperty.symbols index fac6b778ef12e..ccbb8ec3ea740 100644 --- a/tests/baselines/reference/optionalParameterProperty.symbols +++ b/tests/baselines/reference/optionalParameterProperty.symbols @@ -4,7 +4,7 @@ class C { >C : Symbol(C, Decl(optionalParameterProperty.ts, 0, 0)) - p: number; + p: number = 0; >p : Symbol(C.p, Decl(optionalParameterProperty.ts, 0, 9)) } diff --git a/tests/baselines/reference/optionalParameterProperty.types b/tests/baselines/reference/optionalParameterProperty.types index febddfe677bc4..602be37c049e0 100644 --- a/tests/baselines/reference/optionalParameterProperty.types +++ b/tests/baselines/reference/optionalParameterProperty.types @@ -5,9 +5,11 @@ class C { >C : C > : ^ - p: number; + p: number = 0; >p : number > : ^^^^^^ +>0 : 0 +> : ^ } class D extends C { diff --git a/tests/baselines/reference/typeGuardsNestedAssignments.js b/tests/baselines/reference/typeGuardsNestedAssignments.js index e195cde18833c..8534f78d9d4f3 100644 --- a/tests/baselines/reference/typeGuardsNestedAssignments.js +++ b/tests/baselines/reference/typeGuardsNestedAssignments.js @@ -2,7 +2,7 @@ //// [typeGuardsNestedAssignments.ts] class Foo { - x: string; + x: string = ""; } declare function getFooOrNull(): Foo | null; @@ -50,6 +50,7 @@ while ((match = re.exec("xxx")) != null) { //// [typeGuardsNestedAssignments.js] var Foo = /** @class */ (function () { function Foo() { + this.x = ""; } return Foo; }()); diff --git a/tests/baselines/reference/typeGuardsNestedAssignments.symbols b/tests/baselines/reference/typeGuardsNestedAssignments.symbols index 49ccb47beb265..576f1a0a43277 100644 --- a/tests/baselines/reference/typeGuardsNestedAssignments.symbols +++ b/tests/baselines/reference/typeGuardsNestedAssignments.symbols @@ -4,7 +4,7 @@ class Foo { >Foo : Symbol(Foo, Decl(typeGuardsNestedAssignments.ts, 0, 0)) - x: string; + x: string = ""; >x : Symbol(Foo.x, Decl(typeGuardsNestedAssignments.ts, 0, 11)) } diff --git a/tests/baselines/reference/typeGuardsNestedAssignments.types b/tests/baselines/reference/typeGuardsNestedAssignments.types index 069a2e6612356..88d5c0d34fe86 100644 --- a/tests/baselines/reference/typeGuardsNestedAssignments.types +++ b/tests/baselines/reference/typeGuardsNestedAssignments.types @@ -5,9 +5,11 @@ class Foo { >Foo : Foo > : ^^^ - x: string; + x: string = ""; >x : string > : ^^^^^^ +>"" : "" +> : ^^ } declare function getFooOrNull(): Foo | null; diff --git a/tests/baselines/reference/typeGuardsTypeParameters.js b/tests/baselines/reference/typeGuardsTypeParameters.js index cde3d832ff343..273099ee99642 100644 --- a/tests/baselines/reference/typeGuardsTypeParameters.js +++ b/tests/baselines/reference/typeGuardsTypeParameters.js @@ -4,7 +4,7 @@ // Type guards involving type parameters produce intersection types class C { - prop: string; + prop: string = ""; } function f1(x: T) { @@ -40,6 +40,7 @@ function fun(item: { [P in keyof T]: T[P] }) { // Type guards involving type parameters produce intersection types var C = /** @class */ (function () { function C() { + this.prop = ""; } return C; }()); diff --git a/tests/baselines/reference/typeGuardsTypeParameters.symbols b/tests/baselines/reference/typeGuardsTypeParameters.symbols index 4aa4f9447773e..45879e84ea37d 100644 --- a/tests/baselines/reference/typeGuardsTypeParameters.symbols +++ b/tests/baselines/reference/typeGuardsTypeParameters.symbols @@ -6,7 +6,7 @@ class C { >C : Symbol(C, Decl(typeGuardsTypeParameters.ts, 0, 0)) - prop: string; + prop: string = ""; >prop : Symbol(C.prop, Decl(typeGuardsTypeParameters.ts, 2, 9)) } diff --git a/tests/baselines/reference/typeGuardsTypeParameters.types b/tests/baselines/reference/typeGuardsTypeParameters.types index 40614718b6193..174d6a4cc1593 100644 --- a/tests/baselines/reference/typeGuardsTypeParameters.types +++ b/tests/baselines/reference/typeGuardsTypeParameters.types @@ -7,9 +7,11 @@ class C { >C : C > : ^ - prop: string; + prop: string = ""; >prop : string > : ^^^^^^ +>"" : "" +> : ^^ } function f1(x: T) { From 0bdb9dbb865b084654544088fe3e46197c2acec1 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 20:29:18 +0000 Subject: [PATCH 09/10] Fix up any -> unknown in catch variables. --- tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts | 2 +- tests/cases/compiler/duplicateLocalVariable1.ts | 2 +- tests/cases/compiler/implicitAnyInCatch.ts | 1 + tests/cases/compiler/localVariablesReturnedFromCatchBlocks.ts | 1 + tests/cases/compiler/redeclareParameterInCatchBlock.ts | 1 + tests/cases/conformance/async/es6/asyncWithVarShadowing_es6.ts | 1 + .../cases/conformance/es6/destructuring/destructuringCatch.ts | 1 + .../conformance/jsdoc/jsdocCatchClauseWithTypeAnnotation.ts | 1 + .../conformance/parser/ecmascript5/RealWorld/parserharness.ts | 3 ++- .../statements/tryStatements/catchClauseWithTypeAnnotation.ts | 1 + tests/cases/conformance/types/rest/objectRestCatchES5.ts | 2 ++ 11 files changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts b/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts index 17568f48029a5..fe1ba0b8ef89c 100644 --- a/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts +++ b/tests/cases/compiler/defaultOfAnyInStrictNullChecks.ts @@ -1,5 +1,5 @@ // @strictNullChecks: true - +// @useUnknownInCatchVariables: false // Regression test for #8295 function foo() { diff --git a/tests/cases/compiler/duplicateLocalVariable1.ts b/tests/cases/compiler/duplicateLocalVariable1.ts index 10145aa87caed..ba9f302d34c8a 100644 --- a/tests/cases/compiler/duplicateLocalVariable1.ts +++ b/tests/cases/compiler/duplicateLocalVariable1.ts @@ -32,7 +32,7 @@ export class TestRunner { try { testResult = testcase.test(); } - catch (e) { + catch (e: any) { exception = true; testResult = false; if (typeof testcase.errorMessageRegEx === "string") { diff --git a/tests/cases/compiler/implicitAnyInCatch.ts b/tests/cases/compiler/implicitAnyInCatch.ts index 0f3129f5430d1..532f8c2b17821 100644 --- a/tests/cases/compiler/implicitAnyInCatch.ts +++ b/tests/cases/compiler/implicitAnyInCatch.ts @@ -1,4 +1,5 @@ // @noimplicitany: true +// @useUnknownInCatchVariables: false // this should not be an error try { } catch (error) { if (error.number === -2147024809) { } diff --git a/tests/cases/compiler/localVariablesReturnedFromCatchBlocks.ts b/tests/cases/compiler/localVariablesReturnedFromCatchBlocks.ts index ba277773dd8ea..d04ae1e5dad4c 100644 --- a/tests/cases/compiler/localVariablesReturnedFromCatchBlocks.ts +++ b/tests/cases/compiler/localVariablesReturnedFromCatchBlocks.ts @@ -1,3 +1,4 @@ +// @useUnknownInCatchVariables: false function f() { try { } catch (e) { diff --git a/tests/cases/compiler/redeclareParameterInCatchBlock.ts b/tests/cases/compiler/redeclareParameterInCatchBlock.ts index 7f98d68b29d13..bfadd6e378859 100644 --- a/tests/cases/compiler/redeclareParameterInCatchBlock.ts +++ b/tests/cases/compiler/redeclareParameterInCatchBlock.ts @@ -1,3 +1,4 @@ +// @useUnknownInCatchVariables: false // @target: es6 try { diff --git a/tests/cases/conformance/async/es6/asyncWithVarShadowing_es6.ts b/tests/cases/conformance/async/es6/asyncWithVarShadowing_es6.ts index 9083246dd181a..7b5ef4ac60b54 100644 --- a/tests/cases/conformance/async/es6/asyncWithVarShadowing_es6.ts +++ b/tests/cases/conformance/async/es6/asyncWithVarShadowing_es6.ts @@ -1,3 +1,4 @@ +// @useUnknownInCatchVariables: false // @target: es2015 // @noEmitHelpers: true // https://github.com/Microsoft/TypeScript/issues/20461 diff --git a/tests/cases/conformance/es6/destructuring/destructuringCatch.ts b/tests/cases/conformance/es6/destructuring/destructuringCatch.ts index 31afd672084d9..dc2b18e94a31a 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringCatch.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringCatch.ts @@ -1,4 +1,5 @@ // @noImplicitAny: true +// @useUnknownInCatchVariables: false try { throw [0, 1]; diff --git a/tests/cases/conformance/jsdoc/jsdocCatchClauseWithTypeAnnotation.ts b/tests/cases/conformance/jsdoc/jsdocCatchClauseWithTypeAnnotation.ts index b47776eb1d9c4..41049395a8908 100644 --- a/tests/cases/conformance/jsdoc/jsdocCatchClauseWithTypeAnnotation.ts +++ b/tests/cases/conformance/jsdoc/jsdocCatchClauseWithTypeAnnotation.ts @@ -2,6 +2,7 @@ // @checkJs: true // @target: esnext // @noImplicitAny: true +// @useUnknownInCatchVariables: false // @outDir: out // @Filename: foo.js diff --git a/tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts b/tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts index 5622ca5097594..99b4ad8a10b29 100644 --- a/tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts +++ b/tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts @@ -1,4 +1,5 @@ -// @lib: es5 +// @useUnknownInCatchVariables: false +// @lib: es5 // // Copyright (c) Microsoft Corporation. All rights reserved. // diff --git a/tests/cases/conformance/statements/tryStatements/catchClauseWithTypeAnnotation.ts b/tests/cases/conformance/statements/tryStatements/catchClauseWithTypeAnnotation.ts index 6f3bd6a4c15db..0a59dc34e2a81 100644 --- a/tests/cases/conformance/statements/tryStatements/catchClauseWithTypeAnnotation.ts +++ b/tests/cases/conformance/statements/tryStatements/catchClauseWithTypeAnnotation.ts @@ -1,3 +1,4 @@ +// @useUnknownInCatchVariables: false type any1 = any; type unknown1 = unknown; diff --git a/tests/cases/conformance/types/rest/objectRestCatchES5.ts b/tests/cases/conformance/types/rest/objectRestCatchES5.ts index 0e568d32b5863..ec7e5b950206f 100644 --- a/tests/cases/conformance/types/rest/objectRestCatchES5.ts +++ b/tests/cases/conformance/types/rest/objectRestCatchES5.ts @@ -1,2 +1,4 @@ +// @useUnknownInCatchVariables: false + let a = 1, b = 2; try {} catch ({ a, ...b }) {} \ No newline at end of file From fc4aa545d85a2f68f60647ba554203b62eacfd5f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 13 Jan 2026 20:33:38 +0000 Subject: [PATCH 10/10] Accepted baselines. --- tests/baselines/reference/duplicateLocalVariable1.errors.txt | 2 +- tests/baselines/reference/duplicateLocalVariable1.js | 2 +- tests/baselines/reference/duplicateLocalVariable1.symbols | 2 +- tests/baselines/reference/duplicateLocalVariable1.types | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/baselines/reference/duplicateLocalVariable1.errors.txt b/tests/baselines/reference/duplicateLocalVariable1.errors.txt index 649778dea5e20..5d0ced61fb776 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable1.errors.txt @@ -35,7 +35,7 @@ duplicateLocalVariable1.ts(184,37): error TS2356: An arithmetic operand must be try { testResult = testcase.test(); } - catch (e) { + catch (e: any) { exception = true; testResult = false; if (typeof testcase.errorMessageRegEx === "string") { diff --git a/tests/baselines/reference/duplicateLocalVariable1.js b/tests/baselines/reference/duplicateLocalVariable1.js index c72d618466d63..9dc20b390aeb9 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.js +++ b/tests/baselines/reference/duplicateLocalVariable1.js @@ -32,7 +32,7 @@ export class TestRunner { try { testResult = testcase.test(); } - catch (e) { + catch (e: any) { exception = true; testResult = false; if (typeof testcase.errorMessageRegEx === "string") { diff --git a/tests/baselines/reference/duplicateLocalVariable1.symbols b/tests/baselines/reference/duplicateLocalVariable1.symbols index 5d89389b1f8f2..974db0a732df0 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.symbols +++ b/tests/baselines/reference/duplicateLocalVariable1.symbols @@ -91,7 +91,7 @@ export class TestRunner { >testcase : Symbol(testcase, Decl(duplicateLocalVariable1.ts, 26, 15)) >test : Symbol(TestCase.test, Decl(duplicateLocalVariable1.ts, 9, 37)) } - catch (e) { + catch (e: any) { >e : Symbol(e, Decl(duplicateLocalVariable1.ts, 31, 19)) exception = true; diff --git a/tests/baselines/reference/duplicateLocalVariable1.types b/tests/baselines/reference/duplicateLocalVariable1.types index 30c540696609c..76e2c907796f8 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.types +++ b/tests/baselines/reference/duplicateLocalVariable1.types @@ -163,7 +163,7 @@ export class TestRunner { >test : () => boolean > : ^^^^^^ } - catch (e) { + catch (e: any) { >e : any > : ^^^