From b45165d24eebf504bfe6c0f23ee92fd31305d1be Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 24 Aug 2022 10:48:23 -0700 Subject: [PATCH] strictNullChecks pragma tests, including cross-file type behavior --- .../strictNullChecksPragma1.errors.txt | 197 +++++++++ .../reference/strictNullChecksPragma1.js | 196 +++++++++ .../reference/strictNullChecksPragma1.symbols | 346 ++++++++++++++++ .../reference/strictNullChecksPragma1.types | 382 +++++++++++++++++ .../strictNullChecksPragma2.errors.txt | 195 +++++++++ .../reference/strictNullChecksPragma2.js | 194 +++++++++ .../reference/strictNullChecksPragma2.symbols | 344 ++++++++++++++++ .../reference/strictNullChecksPragma2.types | 380 +++++++++++++++++ .../strictNullChecksPragma3.errors.txt | 235 +++++++++++ .../reference/strictNullChecksPragma3.js | 198 +++++++++ .../reference/strictNullChecksPragma3.symbols | 350 ++++++++++++++++ .../reference/strictNullChecksPragma3.types | 388 ++++++++++++++++++ .../strictNullChecksPragma4.errors.txt | 233 +++++++++++ .../reference/strictNullChecksPragma4.js | 196 +++++++++ .../reference/strictNullChecksPragma4.symbols | 348 ++++++++++++++++ .../reference/strictNullChecksPragma4.types | 386 +++++++++++++++++ .../strictNullChecksPragma5.errors.txt | 207 ++++++++++ .../reference/strictNullChecksPragma5.js | 196 +++++++++ .../reference/strictNullChecksPragma5.symbols | 346 ++++++++++++++++ .../reference/strictNullChecksPragma5.types | 382 +++++++++++++++++ .../strictNullChecksPragma6.errors.txt | 205 +++++++++ .../reference/strictNullChecksPragma6.js | 194 +++++++++ .../reference/strictNullChecksPragma6.symbols | 344 ++++++++++++++++ .../reference/strictNullChecksPragma6.types | 380 +++++++++++++++++ .../strictNullChecksPragma1.ts | 122 ++++++ .../strictNullChecksPragma2.ts | 120 ++++++ .../strictNullChecksPragma3.ts | 122 ++++++ .../strictNullChecksPragma4.ts | 120 ++++++ .../strictNullChecksPragma5.ts | 122 ++++++ .../strictNullChecksPragma6.ts | 120 ++++++ 30 files changed, 7548 insertions(+) create mode 100644 tests/baselines/reference/strictNullChecksPragma1.errors.txt create mode 100644 tests/baselines/reference/strictNullChecksPragma1.js create mode 100644 tests/baselines/reference/strictNullChecksPragma1.symbols create mode 100644 tests/baselines/reference/strictNullChecksPragma1.types create mode 100644 tests/baselines/reference/strictNullChecksPragma2.errors.txt create mode 100644 tests/baselines/reference/strictNullChecksPragma2.js create mode 100644 tests/baselines/reference/strictNullChecksPragma2.symbols create mode 100644 tests/baselines/reference/strictNullChecksPragma2.types create mode 100644 tests/baselines/reference/strictNullChecksPragma3.errors.txt create mode 100644 tests/baselines/reference/strictNullChecksPragma3.js create mode 100644 tests/baselines/reference/strictNullChecksPragma3.symbols create mode 100644 tests/baselines/reference/strictNullChecksPragma3.types create mode 100644 tests/baselines/reference/strictNullChecksPragma4.errors.txt create mode 100644 tests/baselines/reference/strictNullChecksPragma4.js create mode 100644 tests/baselines/reference/strictNullChecksPragma4.symbols create mode 100644 tests/baselines/reference/strictNullChecksPragma4.types create mode 100644 tests/baselines/reference/strictNullChecksPragma5.errors.txt create mode 100644 tests/baselines/reference/strictNullChecksPragma5.js create mode 100644 tests/baselines/reference/strictNullChecksPragma5.symbols create mode 100644 tests/baselines/reference/strictNullChecksPragma5.types create mode 100644 tests/baselines/reference/strictNullChecksPragma6.errors.txt create mode 100644 tests/baselines/reference/strictNullChecksPragma6.js create mode 100644 tests/baselines/reference/strictNullChecksPragma6.symbols create mode 100644 tests/baselines/reference/strictNullChecksPragma6.types create mode 100644 tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma1.ts create mode 100644 tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma2.ts create mode 100644 tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma3.ts create mode 100644 tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma4.ts create mode 100644 tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma5.ts create mode 100644 tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma6.ts diff --git a/tests/baselines/reference/strictNullChecksPragma1.errors.txt b/tests/baselines/reference/strictNullChecksPragma1.errors.txt new file mode 100644 index 0000000000000..460e6d54d858b --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma1.errors.txt @@ -0,0 +1,197 @@ +tests/cases/conformance/pragma/strictNullChecks/file1.ts(9,14): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(11,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(16,20): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(25,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(31,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(18,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(24,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(27,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(5,14): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(7,16): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(8,16): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(10,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(20,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(10,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(20,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. + + +==== tests/cases/conformance/pragma/strictNullChecks/file1.ts (5 errors) ==== + // @ts-strictNullChecks + export interface A { + member: string; + } + export interface B { + member: string | undefined; + } + + let a: A = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/pragma/strictNullChecks/file1.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + declare var b: B; + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + + import {A as OtherA, B as OtherB} from "./file2"; + + let a2: OtherA = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + declare var b2: OtherB; + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file2.ts (3 errors) ==== + // loose + export interface A { + member: string; + } + export interface B { + member: string | undefined; + } + + let a: A = { member: undefined }; + declare var b: B; + a = b; + b = a; + + import {A as OtherA, B as OtherB} from "./file1"; + + let a2: OtherA = { member: undefined }; + declare var b2: OtherB; + a2 = b2; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = a2; + + a = a2; + a2 = a; + + b = b2; + ~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = b; + + a = b2; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = a; + + b = a2; + a2 = b; + +==== tests/cases/conformance/pragma/strictNullChecks/file3.ts (6 errors) ==== + // @ts-strictNullChecks + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/pragma/strictNullChecks/file1.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b2: B2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:6:5: The expected type comes from property 'member' which is declared here on type 'B' + + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file4.ts (3 errors) ==== + // loose + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + let b2: B2 = { member: undefined }; + + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/strictNullChecksPragma1.js b/tests/baselines/reference/strictNullChecksPragma1.js new file mode 100644 index 0000000000000..db7aedabdce21 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma1.js @@ -0,0 +1,196 @@ +//// [tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma1.ts] //// + +//// [file1.ts] +// @ts-strictNullChecks +export interface A { + member: string; +} +export interface B { + member: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.ts] +// loose +export interface A { + member: string; +} +export interface B { + member: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file3.ts] +// @ts-strictNullChecks +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file4.ts] +// loose +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file1.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file3.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file4.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; diff --git a/tests/baselines/reference/strictNullChecksPragma1.symbols b/tests/baselines/reference/strictNullChecksPragma1.symbols new file mode 100644 index 0000000000000..7b233d617d11b --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma1.symbols @@ -0,0 +1,346 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +// @ts-strictNullChecks +export interface A { +>A : Symbol(A, Decl(file1.ts, 0, 0)) + + member: string; +>member : Symbol(A.member, Decl(file1.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file1.ts, 3, 1)) + + member: string | undefined; +>member : Symbol(B.member, Decl(file1.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>A : Symbol(A, Decl(file1.ts, 0, 0)) +>member : Symbol(member, Decl(file1.ts, 8, 12)) +>undefined : Symbol(undefined) + +declare var b: B; +>b : Symbol(b, Decl(file1.ts, 9, 11)) +>B : Symbol(B, Decl(file1.ts, 3, 1)) + +a = b; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>b : Symbol(b, Decl(file1.ts, 9, 11)) + +b = a; +>b : Symbol(b, Decl(file1.ts, 9, 11)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file2"; +>A : Symbol(OtherA, Decl(file2.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file2.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 13, 8)) +>member : Symbol(member, Decl(file1.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file1.ts, 9, 11)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>b : Symbol(b, Decl(file1.ts, 9, 11)) + +a = b2; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file1.ts, 9, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>b : Symbol(b, Decl(file1.ts, 9, 11)) + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// loose +export interface A { +>A : Symbol(A, Decl(file2.ts, 0, 0)) + + member: string; +>member : Symbol(A.member, Decl(file2.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file2.ts, 3, 1)) + + member: string | undefined; +>member : Symbol(B.member, Decl(file2.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>member : Symbol(member, Decl(file2.ts, 8, 12)) +>undefined : Symbol(undefined) + +declare var b: B; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>B : Symbol(B, Decl(file2.ts, 3, 1)) + +a = b; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +b = a; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file1"; +>A : Symbol(OtherA, Decl(file1.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file1.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>member : Symbol(member, Decl(file2.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +a = b2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +// @ts-strictNullChecks +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file3.ts, 1, 8)) +>B : Symbol(B, Decl(file3.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file3.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file3.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>A : Symbol(A, Decl(file3.ts, 1, 8)) +>member : Symbol(member, Decl(file3.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>B : Symbol(B, Decl(file3.ts, 1, 10)) +>member : Symbol(member, Decl(file3.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file3.ts, 2, 8)) +>member : Symbol(member, Decl(file3.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file3.ts, 2, 16)) +>member : Symbol(member, Decl(file3.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// loose +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>member : Symbol(member, Decl(file4.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) +>member : Symbol(member, Decl(file4.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>member : Symbol(member, Decl(file4.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) +>member : Symbol(member, Decl(file4.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + diff --git a/tests/baselines/reference/strictNullChecksPragma1.types b/tests/baselines/reference/strictNullChecksPragma1.types new file mode 100644 index 0000000000000..f3024ac3034a9 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma1.types @@ -0,0 +1,382 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +// @ts-strictNullChecks +export interface A { + member: string; +>member : string +} +export interface B { + member: string | undefined; +>member : string | undefined +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b: B; +>b : B + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file2"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// loose +export interface A { + member: string; +>member : string +} +export interface B { + member: string | undefined; +>member : string +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b: B; +>b : B + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file1"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +// @ts-strictNullChecks +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// loose +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + diff --git a/tests/baselines/reference/strictNullChecksPragma2.errors.txt b/tests/baselines/reference/strictNullChecksPragma2.errors.txt new file mode 100644 index 0000000000000..4706a4b4f9c34 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma2.errors.txt @@ -0,0 +1,195 @@ +tests/cases/conformance/pragma/strictNullChecks/file1.ts(8,14): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(10,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(15,20): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(24,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(30,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(18,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(24,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(27,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(4,14): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(6,16): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(7,16): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(9,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(19,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(25,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(10,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(20,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. + + +==== tests/cases/conformance/pragma/strictNullChecks/file1.ts (5 errors) ==== + export interface A { + member: string; + } + export interface B { + member: string | undefined; + } + + let a: A = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/pragma/strictNullChecks/file1.ts:2:5: The expected type comes from property 'member' which is declared here on type 'A' + declare var b: B; + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + + import {A as OtherA, B as OtherB} from "./file2"; + + let a2: OtherA = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + declare var b2: OtherB; + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file2.ts (3 errors) ==== + // @ts-strictNullChecks false + export interface A { + member: string; + } + export interface B { + member: string | undefined; + } + + let a: A = { member: undefined }; + declare var b: B; + a = b; + b = a; + + import {A as OtherA, B as OtherB} from "./file1"; + + let a2: OtherA = { member: undefined }; + declare var b2: OtherB; + a2 = b2; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = a2; + + a = a2; + a2 = a; + + b = b2; + ~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = b; + + a = b2; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = a; + + b = a2; + a2 = b; + +==== tests/cases/conformance/pragma/strictNullChecks/file3.ts (6 errors) ==== + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 tests/cases/conformance/pragma/strictNullChecks/file1.ts:2:5: The expected type comes from property 'member' which is declared here on type 'A' + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b2: B2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:6:5: The expected type comes from property 'member' which is declared here on type 'B' + + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file4.ts (3 errors) ==== + // @ts-strictNullChecks false + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + let b2: B2 = { member: undefined }; + + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/strictNullChecksPragma2.js b/tests/baselines/reference/strictNullChecksPragma2.js new file mode 100644 index 0000000000000..86551ff590c7a --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma2.js @@ -0,0 +1,194 @@ +//// [tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma2.ts] //// + +//// [file1.ts] +export interface A { + member: string; +} +export interface B { + member: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.ts] +// @ts-strictNullChecks false +export interface A { + member: string; +} +export interface B { + member: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file3.ts] +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file4.ts] +// @ts-strictNullChecks false +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file1.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file3.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file4.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; diff --git a/tests/baselines/reference/strictNullChecksPragma2.symbols b/tests/baselines/reference/strictNullChecksPragma2.symbols new file mode 100644 index 0000000000000..4dfacc433151f --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma2.symbols @@ -0,0 +1,344 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +export interface A { +>A : Symbol(A, Decl(file1.ts, 0, 0)) + + member: string; +>member : Symbol(A.member, Decl(file1.ts, 0, 20)) +} +export interface B { +>B : Symbol(B, Decl(file1.ts, 2, 1)) + + member: string | undefined; +>member : Symbol(B.member, Decl(file1.ts, 3, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>A : Symbol(A, Decl(file1.ts, 0, 0)) +>member : Symbol(member, Decl(file1.ts, 7, 12)) +>undefined : Symbol(undefined) + +declare var b: B; +>b : Symbol(b, Decl(file1.ts, 8, 11)) +>B : Symbol(B, Decl(file1.ts, 2, 1)) + +a = b; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>b : Symbol(b, Decl(file1.ts, 8, 11)) + +b = a; +>b : Symbol(b, Decl(file1.ts, 8, 11)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +import {A as OtherA, B as OtherB} from "./file2"; +>A : Symbol(OtherA, Decl(file2.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 12, 8)) +>B : Symbol(OtherB, Decl(file2.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 12, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 12, 8)) +>member : Symbol(member, Decl(file1.ts, 14, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 12, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a = a2; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +b = b2; +>b : Symbol(b, Decl(file1.ts, 8, 11)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>b : Symbol(b, Decl(file1.ts, 8, 11)) + +a = b2; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +b = a2; +>b : Symbol(b, Decl(file1.ts, 8, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>b : Symbol(b, Decl(file1.ts, 8, 11)) + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// @ts-strictNullChecks false +export interface A { +>A : Symbol(A, Decl(file2.ts, 0, 0)) + + member: string; +>member : Symbol(A.member, Decl(file2.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file2.ts, 3, 1)) + + member: string | undefined; +>member : Symbol(B.member, Decl(file2.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>member : Symbol(member, Decl(file2.ts, 8, 12)) +>undefined : Symbol(undefined) + +declare var b: B; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>B : Symbol(B, Decl(file2.ts, 3, 1)) + +a = b; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +b = a; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file1"; +>A : Symbol(OtherA, Decl(file1.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file1.ts, 2, 1)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>member : Symbol(member, Decl(file2.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +a = b2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file3.ts, 0, 8)) +>B : Symbol(B, Decl(file3.ts, 0, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file3.ts, 1, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file3.ts, 1, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>A : Symbol(A, Decl(file3.ts, 0, 8)) +>member : Symbol(member, Decl(file3.ts, 3, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>B : Symbol(B, Decl(file3.ts, 0, 10)) +>member : Symbol(member, Decl(file3.ts, 4, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>A2 : Symbol(A2, Decl(file3.ts, 1, 8)) +>member : Symbol(member, Decl(file3.ts, 5, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>B2 : Symbol(B2, Decl(file3.ts, 1, 16)) +>member : Symbol(member, Decl(file3.ts, 6, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +b = a; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a = a2; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +b = b2; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +a = b2; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +b = a2; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// @ts-strictNullChecks false +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>member : Symbol(member, Decl(file4.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) +>member : Symbol(member, Decl(file4.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>member : Symbol(member, Decl(file4.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) +>member : Symbol(member, Decl(file4.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + diff --git a/tests/baselines/reference/strictNullChecksPragma2.types b/tests/baselines/reference/strictNullChecksPragma2.types new file mode 100644 index 0000000000000..d2fa7821a1a1c --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma2.types @@ -0,0 +1,380 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +export interface A { + member: string; +>member : string +} +export interface B { + member: string | undefined; +>member : string | undefined +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b: B; +>b : B + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file2"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// @ts-strictNullChecks false +export interface A { + member: string; +>member : string +} +export interface B { + member: string | undefined; +>member : string +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b: B; +>b : B + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file1"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// @ts-strictNullChecks false +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + diff --git a/tests/baselines/reference/strictNullChecksPragma3.errors.txt b/tests/baselines/reference/strictNullChecksPragma3.errors.txt new file mode 100644 index 0000000000000..00d2b880bb977 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma3.errors.txt @@ -0,0 +1,235 @@ +tests/cases/conformance/pragma/strictNullChecks/file1.ts(9,14): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(11,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(12,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(16,20): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(19,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(28,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(30,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(31,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(12,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'number' is not assignable to type 'undefined'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(18,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(19,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'number' is not assignable to type 'undefined'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(27,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(28,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'number' is not assignable to type 'undefined'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(30,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'number' is not assignable to type 'undefined'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(5,14): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(7,16): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(10,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(11,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(14,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(23,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(25,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(10,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(11,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(14,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(23,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(25,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. + + +==== tests/cases/conformance/pragma/strictNullChecks/file1.ts (8 errors) ==== + // @ts-strictNullChecks + export interface A { + member: number; + } + export interface B { + member: undefined; + } + + let a: A = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/pragma/strictNullChecks/file1.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b: B = { member: undefined }; + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + import {A as OtherA, B as OtherB} from "./file2"; + + let a2: OtherA = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + declare var b2: OtherB; + a2 = b2; + b2 = a2; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a = a2; + a2 = a; + + b = b2; + b2 = b; + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file2.ts (6 errors) ==== + // loose + export interface A { + member: number; + } + export interface B { + member: undefined; + } + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + a = b; + b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'undefined'. + + import {A as OtherA, B as OtherB} from "./file1"; + + let a2: OtherA = { member: undefined }; + declare var b2: OtherB; + a2 = b2; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. + b2 = a2; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'undefined'. + + a = a2; + a2 = a; + + b = b2; + b2 = b; + + a = b2; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'undefined'. + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'undefined'. + a2 = b; + +==== tests/cases/conformance/pragma/strictNullChecks/file3.ts (8 errors) ==== + // @ts-strictNullChecks + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/pragma/strictNullChecks/file1.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b2: B2 = { member: undefined }; + + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a2 = b2; + b2 = a2; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a = a2; + a2 = a; + + b = b2; + b2 = b; + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file4.ts (6 errors) ==== + // loose + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + let b2: B2 = { member: undefined }; + + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a2 = b2; + b2 = a2; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a = a2; + a2 = a; + + b = b2; + b2 = b; + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/strictNullChecksPragma3.js b/tests/baselines/reference/strictNullChecksPragma3.js new file mode 100644 index 0000000000000..704c3cc5fa806 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma3.js @@ -0,0 +1,198 @@ +//// [tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma3.ts] //// + +//// [file1.ts] +// @ts-strictNullChecks +export interface A { + member: number; +} +export interface B { + member: undefined; +} + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.ts] +// loose +export interface A { + member: number; +} +export interface B { + member: undefined; +} + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +a = b; +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file3.ts] +// @ts-strictNullChecks +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file4.ts] +// loose +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +a = b; +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file1.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file3.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file4.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; diff --git a/tests/baselines/reference/strictNullChecksPragma3.symbols b/tests/baselines/reference/strictNullChecksPragma3.symbols new file mode 100644 index 0000000000000..e6b9a8cefce35 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma3.symbols @@ -0,0 +1,350 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +// @ts-strictNullChecks +export interface A { +>A : Symbol(A, Decl(file1.ts, 0, 0)) + + member: number; +>member : Symbol(A.member, Decl(file1.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file1.ts, 3, 1)) + + member: undefined; +>member : Symbol(B.member, Decl(file1.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>A : Symbol(A, Decl(file1.ts, 0, 0)) +>member : Symbol(member, Decl(file1.ts, 8, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file1.ts, 9, 3)) +>B : Symbol(B, Decl(file1.ts, 3, 1)) +>member : Symbol(member, Decl(file1.ts, 9, 12)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>b : Symbol(b, Decl(file1.ts, 9, 3)) + +b = a; +>b : Symbol(b, Decl(file1.ts, 9, 3)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file2"; +>A : Symbol(OtherA, Decl(file2.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file2.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 13, 8)) +>member : Symbol(member, Decl(file1.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file1.ts, 9, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>b : Symbol(b, Decl(file1.ts, 9, 3)) + +a = b2; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file1.ts, 9, 3)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>b : Symbol(b, Decl(file1.ts, 9, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// loose +export interface A { +>A : Symbol(A, Decl(file2.ts, 0, 0)) + + member: number; +>member : Symbol(A.member, Decl(file2.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file2.ts, 3, 1)) + + member: undefined; +>member : Symbol(B.member, Decl(file2.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>member : Symbol(member, Decl(file2.ts, 8, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file2.ts, 9, 3)) +>B : Symbol(B, Decl(file2.ts, 3, 1)) +>member : Symbol(member, Decl(file2.ts, 9, 12)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 3)) + +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. +>b : Symbol(b, Decl(file2.ts, 9, 3)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file1"; +>A : Symbol(OtherA, Decl(file1.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file1.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>member : Symbol(member, Decl(file2.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file2.ts, 9, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>b : Symbol(b, Decl(file2.ts, 9, 3)) + +a = b2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file2.ts, 9, 3)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +// @ts-strictNullChecks +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file3.ts, 1, 8)) +>B : Symbol(B, Decl(file3.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file3.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file3.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>A : Symbol(A, Decl(file3.ts, 1, 8)) +>member : Symbol(member, Decl(file3.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>B : Symbol(B, Decl(file3.ts, 1, 10)) +>member : Symbol(member, Decl(file3.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file3.ts, 2, 8)) +>member : Symbol(member, Decl(file3.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file3.ts, 2, 16)) +>member : Symbol(member, Decl(file3.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// loose +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>member : Symbol(member, Decl(file4.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) +>member : Symbol(member, Decl(file4.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>member : Symbol(member, Decl(file4.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) +>member : Symbol(member, Decl(file4.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + diff --git a/tests/baselines/reference/strictNullChecksPragma3.types b/tests/baselines/reference/strictNullChecksPragma3.types new file mode 100644 index 0000000000000..6fae0363f85f2 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma3.types @@ -0,0 +1,388 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +// @ts-strictNullChecks +export interface A { + member: number; +>member : number +} +export interface B { + member: undefined; +>member : undefined +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file2"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// loose +export interface A { + member: number; +>member : number +} +export interface B { + member: undefined; +>member : undefined +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file1"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +// @ts-strictNullChecks +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// loose +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + diff --git a/tests/baselines/reference/strictNullChecksPragma4.errors.txt b/tests/baselines/reference/strictNullChecksPragma4.errors.txt new file mode 100644 index 0000000000000..b9ba10ac52325 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma4.errors.txt @@ -0,0 +1,233 @@ +tests/cases/conformance/pragma/strictNullChecks/file1.ts(8,14): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(10,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(11,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(15,20): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(18,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(27,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(29,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(30,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(12,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'number' is not assignable to type 'undefined'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(18,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(19,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'number' is not assignable to type 'undefined'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(27,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(28,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'number' is not assignable to type 'undefined'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(30,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'number' is not assignable to type 'undefined'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(4,14): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(6,16): error TS2322: Type 'undefined' is not assignable to type 'number'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(9,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(10,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(13,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(22,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(24,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(25,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(10,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(11,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(14,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(23,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(25,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. + + +==== tests/cases/conformance/pragma/strictNullChecks/file1.ts (8 errors) ==== + export interface A { + member: number; + } + export interface B { + member: undefined; + } + + let a: A = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/pragma/strictNullChecks/file1.ts:2:5: The expected type comes from property 'member' which is declared here on type 'A' + let b: B = { member: undefined }; + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + import {A as OtherA, B as OtherB} from "./file2"; + + let a2: OtherA = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + declare var b2: OtherB; + a2 = b2; + b2 = a2; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a = a2; + a2 = a; + + b = b2; + b2 = b; + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file2.ts (6 errors) ==== + // @ts-strictNullChecks false + export interface A { + member: number; + } + export interface B { + member: undefined; + } + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + a = b; + b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'undefined'. + + import {A as OtherA, B as OtherB} from "./file1"; + + let a2: OtherA = { member: undefined }; + declare var b2: OtherB; + a2 = b2; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. + b2 = a2; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'undefined'. + + a = a2; + a2 = a; + + b = b2; + b2 = b; + + a = b2; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'undefined'. + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'undefined'. + a2 = b; + +==== tests/cases/conformance/pragma/strictNullChecks/file3.ts (8 errors) ==== + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. +!!! related TS6500 tests/cases/conformance/pragma/strictNullChecks/file1.ts:2:5: The expected type comes from property 'member' which is declared here on type 'A' + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'number'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b2: B2 = { member: undefined }; + + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a2 = b2; + b2 = a2; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a = a2; + a2 = a; + + b = b2; + b2 = b; + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file4.ts (6 errors) ==== + // @ts-strictNullChecks false + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + let b2: B2 = { member: undefined }; + + a = b; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + b = a; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a2 = b2; + b2 = a2; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + a = a2; + a2 = a; + + b = b2; + b2 = b; + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/strictNullChecksPragma4.js b/tests/baselines/reference/strictNullChecksPragma4.js new file mode 100644 index 0000000000000..386b6baebe75c --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma4.js @@ -0,0 +1,196 @@ +//// [tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma4.ts] //// + +//// [file1.ts] +export interface A { + member: number; +} +export interface B { + member: undefined; +} + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.ts] +// @ts-strictNullChecks false +export interface A { + member: number; +} +export interface B { + member: undefined; +} + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +a = b; +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file3.ts] +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file4.ts] +// @ts-strictNullChecks false +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +a = b; +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file1.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file3.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file4.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; diff --git a/tests/baselines/reference/strictNullChecksPragma4.symbols b/tests/baselines/reference/strictNullChecksPragma4.symbols new file mode 100644 index 0000000000000..497527c109735 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma4.symbols @@ -0,0 +1,348 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +export interface A { +>A : Symbol(A, Decl(file1.ts, 0, 0)) + + member: number; +>member : Symbol(A.member, Decl(file1.ts, 0, 20)) +} +export interface B { +>B : Symbol(B, Decl(file1.ts, 2, 1)) + + member: undefined; +>member : Symbol(B.member, Decl(file1.ts, 3, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>A : Symbol(A, Decl(file1.ts, 0, 0)) +>member : Symbol(member, Decl(file1.ts, 7, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file1.ts, 8, 3)) +>B : Symbol(B, Decl(file1.ts, 2, 1)) +>member : Symbol(member, Decl(file1.ts, 8, 12)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>b : Symbol(b, Decl(file1.ts, 8, 3)) + +b = a; +>b : Symbol(b, Decl(file1.ts, 8, 3)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +import {A as OtherA, B as OtherB} from "./file2"; +>A : Symbol(OtherA, Decl(file2.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 12, 8)) +>B : Symbol(OtherB, Decl(file2.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 12, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 12, 8)) +>member : Symbol(member, Decl(file1.ts, 14, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 12, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a = a2; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +b = b2; +>b : Symbol(b, Decl(file1.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>b : Symbol(b, Decl(file1.ts, 8, 3)) + +a = b2; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +b = a2; +>b : Symbol(b, Decl(file1.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>b : Symbol(b, Decl(file1.ts, 8, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// @ts-strictNullChecks false +export interface A { +>A : Symbol(A, Decl(file2.ts, 0, 0)) + + member: number; +>member : Symbol(A.member, Decl(file2.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file2.ts, 3, 1)) + + member: undefined; +>member : Symbol(B.member, Decl(file2.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>member : Symbol(member, Decl(file2.ts, 8, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file2.ts, 9, 3)) +>B : Symbol(B, Decl(file2.ts, 3, 1)) +>member : Symbol(member, Decl(file2.ts, 9, 12)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 3)) + +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. +>b : Symbol(b, Decl(file2.ts, 9, 3)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file1"; +>A : Symbol(OtherA, Decl(file1.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file1.ts, 2, 1)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>member : Symbol(member, Decl(file2.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file2.ts, 9, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>b : Symbol(b, Decl(file2.ts, 9, 3)) + +a = b2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file2.ts, 9, 3)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file3.ts, 0, 8)) +>B : Symbol(B, Decl(file3.ts, 0, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file3.ts, 1, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file3.ts, 1, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>A : Symbol(A, Decl(file3.ts, 0, 8)) +>member : Symbol(member, Decl(file3.ts, 3, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>B : Symbol(B, Decl(file3.ts, 0, 10)) +>member : Symbol(member, Decl(file3.ts, 4, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>A2 : Symbol(A2, Decl(file3.ts, 1, 8)) +>member : Symbol(member, Decl(file3.ts, 5, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>B2 : Symbol(B2, Decl(file3.ts, 1, 16)) +>member : Symbol(member, Decl(file3.ts, 6, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +b = a; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a = a2; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +b = b2; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +a = b2; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +b = a2; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// @ts-strictNullChecks false +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>member : Symbol(member, Decl(file4.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) +>member : Symbol(member, Decl(file4.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>member : Symbol(member, Decl(file4.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) +>member : Symbol(member, Decl(file4.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + diff --git a/tests/baselines/reference/strictNullChecksPragma4.types b/tests/baselines/reference/strictNullChecksPragma4.types new file mode 100644 index 0000000000000..377185aee8383 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma4.types @@ -0,0 +1,386 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +export interface A { + member: number; +>member : number +} +export interface B { + member: undefined; +>member : undefined +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file2"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// @ts-strictNullChecks false +export interface A { + member: number; +>member : number +} +export interface B { + member: undefined; +>member : undefined +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file1"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// @ts-strictNullChecks false +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + diff --git a/tests/baselines/reference/strictNullChecksPragma5.errors.txt b/tests/baselines/reference/strictNullChecksPragma5.errors.txt new file mode 100644 index 0000000000000..6aede13b519d3 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma5.errors.txt @@ -0,0 +1,207 @@ +tests/cases/conformance/pragma/strictNullChecks/file1.ts(16,20): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(22,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(25,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(28,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(31,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(21,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(24,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(27,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(30,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(7,16): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(8,16): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(17,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(20,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(23,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(17,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(20,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(23,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. + + +==== tests/cases/conformance/pragma/strictNullChecks/file1.ts (5 errors) ==== + // @ts-strictNullChecks + export interface A { + member?: string; + } + export interface B { + member?: string | undefined; + } + + let a: A = { member: undefined }; + declare var b: B; + a = b; + b = a; + + import {A as OtherA, B as OtherB} from "./file2"; + + let a2: OtherA = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + declare var b2: OtherB; + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file2.ts (4 errors) ==== + // loose + export interface A { + member?: string; + } + export interface B { + member?: string | undefined; + } + + let a: A = { member: undefined }; + declare var b: B; + a = b; + b = a; + + import {A as OtherA, B as OtherB} from "./file1"; + + let a2: OtherA = { member: undefined }; + declare var b2: OtherB; + a2 = b2; + b2 = a2; + + a = a2; + ~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + a2 = a; + + b = b2; + ~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = b; + + a = b2; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = a; + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + a2 = b; + +==== tests/cases/conformance/pragma/strictNullChecks/file3.ts (6 errors) ==== + // @ts-strictNullChecks + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b2: B2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:6:5: The expected type comes from property 'member' which is declared here on type 'B' + + a = b; + b = a; + + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file4.ts (4 errors) ==== + // loose + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + let b2: B2 = { member: undefined }; + + a = b; + b = a; + + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/strictNullChecksPragma5.js b/tests/baselines/reference/strictNullChecksPragma5.js new file mode 100644 index 0000000000000..10f744e8b013b --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma5.js @@ -0,0 +1,196 @@ +//// [tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma5.ts] //// + +//// [file1.ts] +// @ts-strictNullChecks +export interface A { + member?: string; +} +export interface B { + member?: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.ts] +// loose +export interface A { + member?: string; +} +export interface B { + member?: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file3.ts] +// @ts-strictNullChecks +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file4.ts] +// loose +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file1.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file3.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file4.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; diff --git a/tests/baselines/reference/strictNullChecksPragma5.symbols b/tests/baselines/reference/strictNullChecksPragma5.symbols new file mode 100644 index 0000000000000..e3c487c46fc66 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma5.symbols @@ -0,0 +1,346 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +// @ts-strictNullChecks +export interface A { +>A : Symbol(A, Decl(file1.ts, 0, 0)) + + member?: string; +>member : Symbol(A.member, Decl(file1.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file1.ts, 3, 1)) + + member?: string | undefined; +>member : Symbol(B.member, Decl(file1.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>A : Symbol(A, Decl(file1.ts, 0, 0)) +>member : Symbol(member, Decl(file1.ts, 8, 12)) +>undefined : Symbol(undefined) + +declare var b: B; +>b : Symbol(b, Decl(file1.ts, 9, 11)) +>B : Symbol(B, Decl(file1.ts, 3, 1)) + +a = b; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>b : Symbol(b, Decl(file1.ts, 9, 11)) + +b = a; +>b : Symbol(b, Decl(file1.ts, 9, 11)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file2"; +>A : Symbol(OtherA, Decl(file2.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file2.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 13, 8)) +>member : Symbol(member, Decl(file1.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file1.ts, 9, 11)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>b : Symbol(b, Decl(file1.ts, 9, 11)) + +a = b2; +>a : Symbol(a, Decl(file1.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file1.ts, 16, 11)) +>a : Symbol(a, Decl(file1.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file1.ts, 9, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file1.ts, 15, 3)) +>b : Symbol(b, Decl(file1.ts, 9, 11)) + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// loose +export interface A { +>A : Symbol(A, Decl(file2.ts, 0, 0)) + + member?: string; +>member : Symbol(A.member, Decl(file2.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file2.ts, 3, 1)) + + member?: string | undefined; +>member : Symbol(B.member, Decl(file2.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>member : Symbol(member, Decl(file2.ts, 8, 12)) +>undefined : Symbol(undefined) + +declare var b: B; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>B : Symbol(B, Decl(file2.ts, 3, 1)) + +a = b; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +b = a; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file1"; +>A : Symbol(OtherA, Decl(file1.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file1.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>member : Symbol(member, Decl(file2.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +a = b2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +// @ts-strictNullChecks +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file3.ts, 1, 8)) +>B : Symbol(B, Decl(file3.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file3.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file3.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>A : Symbol(A, Decl(file3.ts, 1, 8)) +>member : Symbol(member, Decl(file3.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>B : Symbol(B, Decl(file3.ts, 1, 10)) +>member : Symbol(member, Decl(file3.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file3.ts, 2, 8)) +>member : Symbol(member, Decl(file3.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file3.ts, 2, 16)) +>member : Symbol(member, Decl(file3.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file3.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file3.ts, 7, 3)) +>a : Symbol(a, Decl(file3.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file3.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file3.ts, 6, 3)) +>b : Symbol(b, Decl(file3.ts, 5, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// loose +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>member : Symbol(member, Decl(file4.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) +>member : Symbol(member, Decl(file4.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>member : Symbol(member, Decl(file4.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) +>member : Symbol(member, Decl(file4.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + diff --git a/tests/baselines/reference/strictNullChecksPragma5.types b/tests/baselines/reference/strictNullChecksPragma5.types new file mode 100644 index 0000000000000..4de7640ed50ff --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma5.types @@ -0,0 +1,382 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +// @ts-strictNullChecks +export interface A { + member?: string; +>member : string | undefined +} +export interface B { + member?: string | undefined; +>member : string | undefined +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b: B; +>b : B + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file2"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// loose +export interface A { + member?: string; +>member : string +} +export interface B { + member?: string | undefined; +>member : string +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b: B; +>b : B + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file1"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +// @ts-strictNullChecks +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// loose +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + diff --git a/tests/baselines/reference/strictNullChecksPragma6.errors.txt b/tests/baselines/reference/strictNullChecksPragma6.errors.txt new file mode 100644 index 0000000000000..8fcdb47dc7cb1 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma6.errors.txt @@ -0,0 +1,205 @@ +tests/cases/conformance/pragma/strictNullChecks/file1.ts(15,20): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(21,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(24,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(27,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file1.ts(30,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(21,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(24,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(27,1): error TS2322: Type 'B' is not assignable to type 'A'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file2.ts(30,1): error TS2322: Type 'A' is not assignable to type 'B'. + Types of property 'member' are incompatible. + Type 'string | undefined' is not assignable to type 'string'. + Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(6,16): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(7,16): error TS2322: Type 'undefined' is not assignable to type 'string'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(16,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(19,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(22,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file3.ts(25,1): error TS2322: Type 'B' is not assignable to type 'A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(17,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(20,1): error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(23,1): error TS2322: Type 'A' is not assignable to type 'B'. +tests/cases/conformance/pragma/strictNullChecks/file4.ts(26,1): error TS2322: Type 'B' is not assignable to type 'A'. + + +==== tests/cases/conformance/pragma/strictNullChecks/file1.ts (5 errors) ==== + export interface A { + member?: string; + } + export interface B { + member?: string | undefined; + } + + let a: A = { member: undefined }; + declare var b: B; + a = b; + b = a; + + import {A as OtherA, B as OtherB} from "./file2"; + + let a2: OtherA = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + declare var b2: OtherB; + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file2.ts (4 errors) ==== + // @ts-strictNullChecks false + export interface A { + member?: string; + } + export interface B { + member?: string | undefined; + } + + let a: A = { member: undefined }; + declare var b: B; + a = b; + b = a; + + import {A as OtherA, B as OtherB} from "./file1"; + + let a2: OtherA = { member: undefined }; + declare var b2: OtherB; + a2 = b2; + b2 = a2; + + a = a2; + ~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + a2 = a; + + b = b2; + ~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = b; + + a = b2; + ~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + b2 = a; + + b = a2; + ~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'member' are incompatible. +!!! error TS2322: Type 'string | undefined' is not assignable to type 'string'. +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. + a2 = b; + +==== tests/cases/conformance/pragma/strictNullChecks/file3.ts (6 errors) ==== + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:3:5: The expected type comes from property 'member' which is declared here on type 'A' + let b2: B2 = { member: undefined }; + ~~~~~~ +!!! error TS2322: Type 'undefined' is not assignable to type 'string'. +!!! related TS6500 /.src/tests/cases/conformance/pragma/strictNullChecks/file2.ts:6:5: The expected type comes from property 'member' which is declared here on type 'B' + + a = b; + b = a; + + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. + +==== tests/cases/conformance/pragma/strictNullChecks/file4.ts (4 errors) ==== + // @ts-strictNullChecks false + import {A, B} from "./file1"; + import {A as A2, B as B2} from "./file2"; + + let a: A = { member: undefined }; + let b: B = { member: undefined }; + let a2: A2 = { member: undefined }; + let b2: B2 = { member: undefined }; + + a = b; + b = a; + + a2 = b2; + b2 = a2; + + a = a2; + a2 = a; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").A' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").A'. + + b = b2; + b2 = b; + ~~ +!!! error TS2322: Type 'import("tests/cases/conformance/pragma/strictNullChecks/file1").B' is not assignable to type 'import("tests/cases/conformance/pragma/strictNullChecks/file2").B'. + + a = b2; + b2 = a; + ~~ +!!! error TS2322: Type 'A' is not assignable to type 'B'. + + b = a2; + a2 = b; + ~~ +!!! error TS2322: Type 'B' is not assignable to type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/strictNullChecksPragma6.js b/tests/baselines/reference/strictNullChecksPragma6.js new file mode 100644 index 0000000000000..5d06eb2def00c --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma6.js @@ -0,0 +1,194 @@ +//// [tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma6.ts] //// + +//// [file1.ts] +export interface A { + member?: string; +} +export interface B { + member?: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.ts] +// @ts-strictNullChecks false +export interface A { + member?: string; +} +export interface B { + member?: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file3.ts] +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file4.ts] +// @ts-strictNullChecks false +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +//// [file2.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file1.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +a = b; +b = a; +var a2 = { member: undefined }; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file3.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; +//// [file4.js] +"use strict"; +exports.__esModule = true; +var a = { member: undefined }; +var b = { member: undefined }; +var a2 = { member: undefined }; +var b2 = { member: undefined }; +a = b; +b = a; +a2 = b2; +b2 = a2; +a = a2; +a2 = a; +b = b2; +b2 = b; +a = b2; +b2 = a; +b = a2; +a2 = b; diff --git a/tests/baselines/reference/strictNullChecksPragma6.symbols b/tests/baselines/reference/strictNullChecksPragma6.symbols new file mode 100644 index 0000000000000..7997849a8fa95 --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma6.symbols @@ -0,0 +1,344 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +export interface A { +>A : Symbol(A, Decl(file1.ts, 0, 0)) + + member?: string; +>member : Symbol(A.member, Decl(file1.ts, 0, 20)) +} +export interface B { +>B : Symbol(B, Decl(file1.ts, 2, 1)) + + member?: string | undefined; +>member : Symbol(B.member, Decl(file1.ts, 3, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>A : Symbol(A, Decl(file1.ts, 0, 0)) +>member : Symbol(member, Decl(file1.ts, 7, 12)) +>undefined : Symbol(undefined) + +declare var b: B; +>b : Symbol(b, Decl(file1.ts, 8, 11)) +>B : Symbol(B, Decl(file1.ts, 2, 1)) + +a = b; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>b : Symbol(b, Decl(file1.ts, 8, 11)) + +b = a; +>b : Symbol(b, Decl(file1.ts, 8, 11)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +import {A as OtherA, B as OtherB} from "./file2"; +>A : Symbol(OtherA, Decl(file2.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 12, 8)) +>B : Symbol(OtherB, Decl(file2.ts, 3, 1)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 12, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>OtherA : Symbol(OtherA, Decl(file1.ts, 12, 8)) +>member : Symbol(member, Decl(file1.ts, 14, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>OtherB : Symbol(OtherB, Decl(file1.ts, 12, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a = a2; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +b = b2; +>b : Symbol(b, Decl(file1.ts, 8, 11)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>b : Symbol(b, Decl(file1.ts, 8, 11)) + +a = b2; +>a : Symbol(a, Decl(file1.ts, 7, 3)) +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file1.ts, 15, 11)) +>a : Symbol(a, Decl(file1.ts, 7, 3)) + +b = a2; +>b : Symbol(b, Decl(file1.ts, 8, 11)) +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file1.ts, 14, 3)) +>b : Symbol(b, Decl(file1.ts, 8, 11)) + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// @ts-strictNullChecks false +export interface A { +>A : Symbol(A, Decl(file2.ts, 0, 0)) + + member?: string; +>member : Symbol(A.member, Decl(file2.ts, 1, 20)) +} +export interface B { +>B : Symbol(B, Decl(file2.ts, 3, 1)) + + member?: string | undefined; +>member : Symbol(B.member, Decl(file2.ts, 4, 20)) +} + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>A : Symbol(A, Decl(file2.ts, 0, 0)) +>member : Symbol(member, Decl(file2.ts, 8, 12)) +>undefined : Symbol(undefined) + +declare var b: B; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>B : Symbol(B, Decl(file2.ts, 3, 1)) + +a = b; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +b = a; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +import {A as OtherA, B as OtherB} from "./file1"; +>A : Symbol(OtherA, Decl(file1.ts, 0, 0)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>B : Symbol(OtherB, Decl(file1.ts, 2, 1)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +let a2: OtherA = { member: undefined }; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>OtherA : Symbol(OtherA, Decl(file2.ts, 13, 8)) +>member : Symbol(member, Decl(file2.ts, 15, 18)) +>undefined : Symbol(undefined) + +declare var b2: OtherB; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>OtherB : Symbol(OtherB, Decl(file2.ts, 13, 20)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a = a2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = b2; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = b; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +a = b2; +>a : Symbol(a, Decl(file2.ts, 8, 3)) +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) + +b2 = a; +>b2 : Symbol(b2, Decl(file2.ts, 16, 11)) +>a : Symbol(a, Decl(file2.ts, 8, 3)) + +b = a2; +>b : Symbol(b, Decl(file2.ts, 9, 11)) +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file2.ts, 15, 3)) +>b : Symbol(b, Decl(file2.ts, 9, 11)) + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file3.ts, 0, 8)) +>B : Symbol(B, Decl(file3.ts, 0, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file3.ts, 1, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file3.ts, 1, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>A : Symbol(A, Decl(file3.ts, 0, 8)) +>member : Symbol(member, Decl(file3.ts, 3, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>B : Symbol(B, Decl(file3.ts, 0, 10)) +>member : Symbol(member, Decl(file3.ts, 4, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>A2 : Symbol(A2, Decl(file3.ts, 1, 8)) +>member : Symbol(member, Decl(file3.ts, 5, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>B2 : Symbol(B2, Decl(file3.ts, 1, 16)) +>member : Symbol(member, Decl(file3.ts, 6, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +b = a; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a = a2; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +b = b2; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +a = b2; +>a : Symbol(a, Decl(file3.ts, 3, 3)) +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file3.ts, 6, 3)) +>a : Symbol(a, Decl(file3.ts, 3, 3)) + +b = a2; +>b : Symbol(b, Decl(file3.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file3.ts, 5, 3)) +>b : Symbol(b, Decl(file3.ts, 4, 3)) + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// @ts-strictNullChecks false +import {A, B} from "./file1"; +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) + +import {A as A2, B as B2} from "./file2"; +>A : Symbol(A2, Decl(file2.ts, 0, 0)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>B : Symbol(B2, Decl(file2.ts, 3, 1)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) + +let a: A = { member: undefined }; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>A : Symbol(A, Decl(file4.ts, 1, 8)) +>member : Symbol(member, Decl(file4.ts, 4, 12)) +>undefined : Symbol(undefined) + +let b: B = { member: undefined }; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>B : Symbol(B, Decl(file4.ts, 1, 10)) +>member : Symbol(member, Decl(file4.ts, 5, 12)) +>undefined : Symbol(undefined) + +let a2: A2 = { member: undefined }; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>A2 : Symbol(A2, Decl(file4.ts, 2, 8)) +>member : Symbol(member, Decl(file4.ts, 6, 14)) +>undefined : Symbol(undefined) + +let b2: B2 = { member: undefined }; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>B2 : Symbol(B2, Decl(file4.ts, 2, 16)) +>member : Symbol(member, Decl(file4.ts, 7, 14)) +>undefined : Symbol(undefined) + +a = b; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +b = a; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +a2 = b2; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a2; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a = a2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = a; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = b2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = b; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + +a = b2; +>a : Symbol(a, Decl(file4.ts, 4, 3)) +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) + +b2 = a; +>b2 : Symbol(b2, Decl(file4.ts, 7, 3)) +>a : Symbol(a, Decl(file4.ts, 4, 3)) + +b = a2; +>b : Symbol(b, Decl(file4.ts, 5, 3)) +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) + +a2 = b; +>a2 : Symbol(a2, Decl(file4.ts, 6, 3)) +>b : Symbol(b, Decl(file4.ts, 5, 3)) + diff --git a/tests/baselines/reference/strictNullChecksPragma6.types b/tests/baselines/reference/strictNullChecksPragma6.types new file mode 100644 index 0000000000000..802d83f155afe --- /dev/null +++ b/tests/baselines/reference/strictNullChecksPragma6.types @@ -0,0 +1,380 @@ +=== tests/cases/conformance/pragma/strictNullChecks/file1.ts === +export interface A { + member?: string; +>member : string | undefined +} +export interface B { + member?: string | undefined; +>member : string | undefined +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b: B; +>b : B + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file2"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file2.ts === +// @ts-strictNullChecks false +export interface A { + member?: string; +>member : string +} +export interface B { + member?: string | undefined; +>member : string +} + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b: B; +>b : B + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +import {A as OtherA, B as OtherB} from "./file1"; +>A : any +>OtherA : any +>B : any +>OtherB : any + +let a2: OtherA = { member: undefined }; +>a2 : OtherA +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +declare var b2: OtherB; +>b2 : OtherB + +a2 = b2; +>a2 = b2 : OtherB +>a2 : OtherA +>b2 : OtherB + +b2 = a2; +>b2 = a2 : OtherA +>b2 : OtherB +>a2 : OtherA + +a = a2; +>a = a2 : OtherA +>a : A +>a2 : OtherA + +a2 = a; +>a2 = a : A +>a2 : OtherA +>a : A + +b = b2; +>b = b2 : OtherB +>b : B +>b2 : OtherB + +b2 = b; +>b2 = b : B +>b2 : OtherB +>b : B + +a = b2; +>a = b2 : OtherB +>a : A +>b2 : OtherB + +b2 = a; +>b2 = a : A +>b2 : OtherB +>a : A + +b = a2; +>b = a2 : OtherA +>b : B +>a2 : OtherA + +a2 = b; +>a2 = b : B +>a2 : OtherA +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file3.ts === +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + +=== tests/cases/conformance/pragma/strictNullChecks/file4.ts === +// @ts-strictNullChecks false +import {A, B} from "./file1"; +>A : any +>B : any + +import {A as A2, B as B2} from "./file2"; +>A : any +>A2 : any +>B : any +>B2 : any + +let a: A = { member: undefined }; +>a : A +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b: B = { member: undefined }; +>b : B +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let a2: A2 = { member: undefined }; +>a2 : A2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +let b2: B2 = { member: undefined }; +>b2 : B2 +>{ member: undefined } : { member: undefined; } +>member : undefined +>undefined : undefined + +a = b; +>a = b : B +>a : A +>b : B + +b = a; +>b = a : A +>b : B +>a : A + +a2 = b2; +>a2 = b2 : B2 +>a2 : A2 +>b2 : B2 + +b2 = a2; +>b2 = a2 : A2 +>b2 : B2 +>a2 : A2 + +a = a2; +>a = a2 : A2 +>a : A +>a2 : A2 + +a2 = a; +>a2 = a : A +>a2 : A2 +>a : A + +b = b2; +>b = b2 : B2 +>b : B +>b2 : B2 + +b2 = b; +>b2 = b : B +>b2 : B2 +>b : B + +a = b2; +>a = b2 : B2 +>a : A +>b2 : B2 + +b2 = a; +>b2 = a : A +>b2 : B2 +>a : A + +b = a2; +>b = a2 : A2 +>b : B +>a2 : A2 + +a2 = b; +>a2 = b : B +>a2 : A2 +>b : B + diff --git a/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma1.ts b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma1.ts new file mode 100644 index 0000000000000..25436e9e7458c --- /dev/null +++ b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma1.ts @@ -0,0 +1,122 @@ +// @strict: false +// @filename: file1.ts +// @ts-strictNullChecks +export interface A { + member: string; +} +export interface B { + member: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file2.ts +// loose +export interface A { + member: string; +} +export interface B { + member: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file3.ts +// @ts-strictNullChecks +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file4.ts +// loose +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; \ No newline at end of file diff --git a/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma2.ts b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma2.ts new file mode 100644 index 0000000000000..9a9e6e0b3bfdd --- /dev/null +++ b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma2.ts @@ -0,0 +1,120 @@ +// @strict: true +// @filename: file1.ts +export interface A { + member: string; +} +export interface B { + member: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file2.ts +// @ts-strictNullChecks false +export interface A { + member: string; +} +export interface B { + member: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file3.ts +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file4.ts +// @ts-strictNullChecks false +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; \ No newline at end of file diff --git a/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma3.ts b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma3.ts new file mode 100644 index 0000000000000..a6507cefa2bfb --- /dev/null +++ b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma3.ts @@ -0,0 +1,122 @@ +// @strict: false +// @filename: file1.ts +// @ts-strictNullChecks +export interface A { + member: number; +} +export interface B { + member: undefined; +} + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file2.ts +// loose +export interface A { + member: number; +} +export interface B { + member: undefined; +} + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +a = b; +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file3.ts +// @ts-strictNullChecks +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file4.ts +// loose +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; \ No newline at end of file diff --git a/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma4.ts b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma4.ts new file mode 100644 index 0000000000000..16875c70c1ee1 --- /dev/null +++ b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma4.ts @@ -0,0 +1,120 @@ +// @strict: true +// @filename: file1.ts +export interface A { + member: number; +} +export interface B { + member: undefined; +} + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file2.ts +// @ts-strictNullChecks false +export interface A { + member: number; +} +export interface B { + member: undefined; +} + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +a = b; +b = a; // Historic behavior is that most things aren't assignable to `undefined` when it doesn't evaporate, even outside `strict` mode - making it more like a special `never` than an `any`. + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file3.ts +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file4.ts +// @ts-strictNullChecks false +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; \ No newline at end of file diff --git a/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma5.ts b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma5.ts new file mode 100644 index 0000000000000..141e9dc10d7ff --- /dev/null +++ b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma5.ts @@ -0,0 +1,122 @@ +// @strict: false +// @filename: file1.ts +// @ts-strictNullChecks +export interface A { + member?: string; +} +export interface B { + member?: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file2.ts +// loose +export interface A { + member?: string; +} +export interface B { + member?: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file3.ts +// @ts-strictNullChecks +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file4.ts +// loose +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; \ No newline at end of file diff --git a/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma6.ts b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma6.ts new file mode 100644 index 0000000000000..680bf72c1816b --- /dev/null +++ b/tests/cases/conformance/pragma/strictNullChecks/strictNullChecksPragma6.ts @@ -0,0 +1,120 @@ +// @strict: true +// @filename: file1.ts +export interface A { + member?: string; +} +export interface B { + member?: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file2"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file2.ts +// @ts-strictNullChecks false +export interface A { + member?: string; +} +export interface B { + member?: string | undefined; +} + +let a: A = { member: undefined }; +declare var b: B; +a = b; +b = a; + +import {A as OtherA, B as OtherB} from "./file1"; + +let a2: OtherA = { member: undefined }; +declare var b2: OtherB; +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file3.ts +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; + +// @filename: file4.ts +// @ts-strictNullChecks false +import {A, B} from "./file1"; +import {A as A2, B as B2} from "./file2"; + +let a: A = { member: undefined }; +let b: B = { member: undefined }; +let a2: A2 = { member: undefined }; +let b2: B2 = { member: undefined }; + +a = b; +b = a; + +a2 = b2; +b2 = a2; + +a = a2; +a2 = a; + +b = b2; +b2 = b; + +a = b2; +b2 = a; + +b = a2; +a2 = b; \ No newline at end of file