From e425f573aaa3584b66c042fd7661feb6908c0090 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 1 Jun 2021 14:55:21 -0700 Subject: [PATCH 1/7] Fix unintended 'as const' name lookup error (#44311) (#44370) * Fix logic for methods in isTypeParameterPossiblyReferenced * Add regression tests Co-authored-by: Anders Hejlsberg --- src/compiler/checker.ts | 8 +- .../reference/noAsConstNameLookup.js | 70 ++++++++++++++++ .../reference/noAsConstNameLookup.symbols | 81 ++++++++++++++++++ .../reference/noAsConstNameLookup.types | 83 +++++++++++++++++++ tests/cases/compiler/noAsConstNameLookup.ts | 32 +++++++ 5 files changed, 271 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/noAsConstNameLookup.js create mode 100644 tests/baselines/reference/noAsConstNameLookup.symbols create mode 100644 tests/baselines/reference/noAsConstNameLookup.types create mode 100644 tests/cases/compiler/noAsConstNameLookup.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index eb8397a18b019..a822b1d6925f1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15941,8 +15941,7 @@ namespace ts { } function maybeTypeParameterReference(node: Node) { - return !(node.kind === SyntaxKind.QualifiedName || - node.parent.kind === SyntaxKind.TypeReference && (node.parent).typeArguments && node === (node.parent).typeName || + return !(node.parent.kind === SyntaxKind.TypeReference && (node.parent as TypeReferenceNode).typeArguments && node === (node.parent as TypeReferenceNode).typeName || node.parent.kind === SyntaxKind.ImportType && (node.parent as ImportTypeNode).typeArguments && node === (node.parent as ImportTypeNode).qualifier); } @@ -15971,7 +15970,10 @@ namespace ts { return true; case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: - return (!(node as FunctionLikeDeclaration).type && !!(node as FunctionLikeDeclaration).body) || !!forEachChild(node, containsReference); + return !(node as FunctionLikeDeclaration).type && !!(node as FunctionLikeDeclaration).body || + some((node as FunctionLikeDeclaration).typeParameters, containsReference) || + some((node as FunctionLikeDeclaration).parameters, containsReference) || + !!(node as FunctionLikeDeclaration).type && containsReference((node as FunctionLikeDeclaration).type!); } return !!forEachChild(node, containsReference); } diff --git a/tests/baselines/reference/noAsConstNameLookup.js b/tests/baselines/reference/noAsConstNameLookup.js new file mode 100644 index 0000000000000..4b81035daa5b9 --- /dev/null +++ b/tests/baselines/reference/noAsConstNameLookup.js @@ -0,0 +1,70 @@ +//// [noAsConstNameLookup.ts] +// Repros from #44292 + +type Store = { a: 123 } +export type Cleaner = (runner: FeatureRunner) => Promise + +export class FeatureRunner { + private readonly cleaners: Cleaner[] = [] + + async runFeature(): Promise { + const objectWhichShouldBeConst = { + flags: {}, + settings: {}, + } as const; + return objectWhichShouldBeConst + } + + async run(): Promise { + const result = {} + this.cleaners.forEach(c => c(this)) + return result + } +} + +export class C { + f(): void { + let one = 1 as const; + } +} +new C().f(); + + +//// [noAsConstNameLookup.js] +// Repros from #44292 +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +export class FeatureRunner { + constructor() { + this.cleaners = []; + } + runFeature() { + return __awaiter(this, void 0, void 0, function* () { + const objectWhichShouldBeConst = { + flags: {}, + settings: {}, + }; + return objectWhichShouldBeConst; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + const result = {}; + this.cleaners.forEach(c => c(this)); + return result; + }); + } +} +export class C { + f() { + let one = 1; + } +} +new C().f(); diff --git a/tests/baselines/reference/noAsConstNameLookup.symbols b/tests/baselines/reference/noAsConstNameLookup.symbols new file mode 100644 index 0000000000000..e2d0a965da48a --- /dev/null +++ b/tests/baselines/reference/noAsConstNameLookup.symbols @@ -0,0 +1,81 @@ +=== tests/cases/compiler/noAsConstNameLookup.ts === +// Repros from #44292 + +type Store = { a: 123 } +>Store : Symbol(Store, Decl(noAsConstNameLookup.ts, 0, 0)) +>a : Symbol(a, Decl(noAsConstNameLookup.ts, 2, 14)) + +export type Cleaner = (runner: FeatureRunner) => Promise +>Cleaner : Symbol(Cleaner, Decl(noAsConstNameLookup.ts, 2, 23)) +>W : Symbol(W, Decl(noAsConstNameLookup.ts, 3, 23)) +>Store : Symbol(Store, Decl(noAsConstNameLookup.ts, 0, 0)) +>runner : Symbol(runner, Decl(noAsConstNameLookup.ts, 3, 40)) +>FeatureRunner : Symbol(FeatureRunner, Decl(noAsConstNameLookup.ts, 3, 81)) +>W : Symbol(W, Decl(noAsConstNameLookup.ts, 3, 23)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +export class FeatureRunner { +>FeatureRunner : Symbol(FeatureRunner, Decl(noAsConstNameLookup.ts, 3, 81)) +>W : Symbol(W, Decl(noAsConstNameLookup.ts, 5, 27)) +>Store : Symbol(Store, Decl(noAsConstNameLookup.ts, 0, 0)) + + private readonly cleaners: Cleaner[] = [] +>cleaners : Symbol(FeatureRunner.cleaners, Decl(noAsConstNameLookup.ts, 5, 45)) +>Cleaner : Symbol(Cleaner, Decl(noAsConstNameLookup.ts, 2, 23)) + + async runFeature(): Promise { +>runFeature : Symbol(FeatureRunner.runFeature, Decl(noAsConstNameLookup.ts, 6, 45)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + const objectWhichShouldBeConst = { +>objectWhichShouldBeConst : Symbol(objectWhichShouldBeConst, Decl(noAsConstNameLookup.ts, 9, 13)) + + flags: {}, +>flags : Symbol(flags, Decl(noAsConstNameLookup.ts, 9, 42)) + + settings: {}, +>settings : Symbol(settings, Decl(noAsConstNameLookup.ts, 10, 22)) + + } as const; + return objectWhichShouldBeConst +>objectWhichShouldBeConst : Symbol(objectWhichShouldBeConst, Decl(noAsConstNameLookup.ts, 9, 13)) + } + + async run(): Promise { +>run : Symbol(FeatureRunner.run, Decl(noAsConstNameLookup.ts, 14, 5)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + const result = {} +>result : Symbol(result, Decl(noAsConstNameLookup.ts, 17, 13)) + + this.cleaners.forEach(c => c(this)) +>this.cleaners.forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>this.cleaners : Symbol(FeatureRunner.cleaners, Decl(noAsConstNameLookup.ts, 5, 45)) +>this : Symbol(FeatureRunner, Decl(noAsConstNameLookup.ts, 3, 81)) +>cleaners : Symbol(FeatureRunner.cleaners, Decl(noAsConstNameLookup.ts, 5, 45)) +>forEach : Symbol(Array.forEach, Decl(lib.es5.d.ts, --, --)) +>c : Symbol(c, Decl(noAsConstNameLookup.ts, 18, 30)) +>c : Symbol(c, Decl(noAsConstNameLookup.ts, 18, 30)) +>this : Symbol(FeatureRunner, Decl(noAsConstNameLookup.ts, 3, 81)) + + return result +>result : Symbol(result, Decl(noAsConstNameLookup.ts, 17, 13)) + } +} + +export class C { +>C : Symbol(C, Decl(noAsConstNameLookup.ts, 21, 1)) +>T : Symbol(T, Decl(noAsConstNameLookup.ts, 23, 15)) + + f(): void { +>f : Symbol(C.f, Decl(noAsConstNameLookup.ts, 23, 19)) + + let one = 1 as const; +>one : Symbol(one, Decl(noAsConstNameLookup.ts, 25, 11)) + } +} +new C().f(); +>new C().f : Symbol(C.f, Decl(noAsConstNameLookup.ts, 23, 19)) +>C : Symbol(C, Decl(noAsConstNameLookup.ts, 21, 1)) +>f : Symbol(C.f, Decl(noAsConstNameLookup.ts, 23, 19)) + diff --git a/tests/baselines/reference/noAsConstNameLookup.types b/tests/baselines/reference/noAsConstNameLookup.types new file mode 100644 index 0000000000000..42a06c8530fb2 --- /dev/null +++ b/tests/baselines/reference/noAsConstNameLookup.types @@ -0,0 +1,83 @@ +=== tests/cases/compiler/noAsConstNameLookup.ts === +// Repros from #44292 + +type Store = { a: 123 } +>Store : Store +>a : 123 + +export type Cleaner = (runner: FeatureRunner) => Promise +>Cleaner : Cleaner +>runner : FeatureRunner + +export class FeatureRunner { +>FeatureRunner : FeatureRunner + + private readonly cleaners: Cleaner[] = [] +>cleaners : Cleaner[] +>[] : never[] + + async runFeature(): Promise { +>runFeature : () => Promise + + const objectWhichShouldBeConst = { +>objectWhichShouldBeConst : { readonly flags: {}; readonly settings: {}; } +>{ flags: {}, settings: {}, } as const : { readonly flags: {}; readonly settings: {}; } +>{ flags: {}, settings: {}, } : { readonly flags: {}; readonly settings: {}; } + + flags: {}, +>flags : {} +>{} : {} + + settings: {}, +>settings : {} +>{} : {} + + } as const; + return objectWhichShouldBeConst +>objectWhichShouldBeConst : { readonly flags: {}; readonly settings: {}; } + } + + async run(): Promise { +>run : () => Promise + + const result = {} +>result : {} +>{} : {} + + this.cleaners.forEach(c => c(this)) +>this.cleaners.forEach(c => c(this)) : void +>this.cleaners.forEach : (callbackfn: (value: Cleaner, index: number, array: Cleaner[]) => void, thisArg?: any) => void +>this.cleaners : Cleaner[] +>this : this +>cleaners : Cleaner[] +>forEach : (callbackfn: (value: Cleaner, index: number, array: Cleaner[]) => void, thisArg?: any) => void +>c => c(this) : (c: Cleaner) => Promise +>c : Cleaner +>c(this) : Promise +>c : Cleaner +>this : this + + return result +>result : {} + } +} + +export class C { +>C : C + + f(): void { +>f : () => void + + let one = 1 as const; +>one : 1 +>1 as const : 1 +>1 : 1 + } +} +new C().f(); +>new C().f() : void +>new C().f : () => void +>new C() : C +>C : typeof C +>f : () => void + diff --git a/tests/cases/compiler/noAsConstNameLookup.ts b/tests/cases/compiler/noAsConstNameLookup.ts new file mode 100644 index 0000000000000..62cc8975dc2bc --- /dev/null +++ b/tests/cases/compiler/noAsConstNameLookup.ts @@ -0,0 +1,32 @@ +// @strict: true +// @target: es2015 + +// Repros from #44292 + +type Store = { a: 123 } +export type Cleaner = (runner: FeatureRunner) => Promise + +export class FeatureRunner { + private readonly cleaners: Cleaner[] = [] + + async runFeature(): Promise { + const objectWhichShouldBeConst = { + flags: {}, + settings: {}, + } as const; + return objectWhichShouldBeConst + } + + async run(): Promise { + const result = {} + this.cleaners.forEach(c => c(this)) + return result + } +} + +export class C { + f(): void { + let one = 1 as const; + } +} +new C().f(); From 4f7fe4a1de6277b2bdc6d164513c0a6cbdeae0cd Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Thu, 3 Jun 2021 16:35:21 -0700 Subject: [PATCH 2/7] Cherry-pick PR #44290 into release-4.3 (#44425) Component commits: f3bf29a71c fix(44273): preserves 'override' modifier in JavaScript output Co-authored-by: Oleksandr T --- src/compiler/transformers/ts.ts | 1 + .../reference/override16(target=es2015).js | 19 ++++++++ .../override16(target=es2015).symbols | 16 +++++++ .../reference/override16(target=es2015).types | 17 +++++++ .../reference/override16(target=esnext).js | 17 +++++++ .../override16(target=esnext).symbols | 16 +++++++ .../reference/override16(target=esnext).types | 17 +++++++ tests/baselines/reference/override16.js | 17 +++++++ tests/baselines/reference/override16.symbols | 16 +++++++ tests/baselines/reference/override16.types | 17 +++++++ .../reference/override17(target=es2015).js | 45 +++++++++++++++++++ .../override17(target=es2015).symbols | 40 +++++++++++++++++ .../reference/override17(target=es2015).types | 44 ++++++++++++++++++ .../reference/override17(target=esnext).js | 45 +++++++++++++++++++ .../override17(target=esnext).symbols | 40 +++++++++++++++++ .../reference/override17(target=esnext).types | 44 ++++++++++++++++++ .../reference/override18(target=es2015).js | 32 +++++++++++++ .../override18(target=es2015).symbols | 16 +++++++ .../reference/override18(target=es2015).types | 17 +++++++ .../reference/override18(target=esnext).js | 17 +++++++ .../override18(target=esnext).symbols | 16 +++++++ .../reference/override18(target=esnext).types | 17 +++++++ .../cases/conformance/override/override16.ts | 10 +++++ .../cases/conformance/override/override17.ts | 27 +++++++++++ .../cases/conformance/override/override18.ts | 11 +++++ 25 files changed, 574 insertions(+) create mode 100644 tests/baselines/reference/override16(target=es2015).js create mode 100644 tests/baselines/reference/override16(target=es2015).symbols create mode 100644 tests/baselines/reference/override16(target=es2015).types create mode 100644 tests/baselines/reference/override16(target=esnext).js create mode 100644 tests/baselines/reference/override16(target=esnext).symbols create mode 100644 tests/baselines/reference/override16(target=esnext).types create mode 100644 tests/baselines/reference/override16.js create mode 100644 tests/baselines/reference/override16.symbols create mode 100644 tests/baselines/reference/override16.types create mode 100644 tests/baselines/reference/override17(target=es2015).js create mode 100644 tests/baselines/reference/override17(target=es2015).symbols create mode 100644 tests/baselines/reference/override17(target=es2015).types create mode 100644 tests/baselines/reference/override17(target=esnext).js create mode 100644 tests/baselines/reference/override17(target=esnext).symbols create mode 100644 tests/baselines/reference/override17(target=esnext).types create mode 100644 tests/baselines/reference/override18(target=es2015).js create mode 100644 tests/baselines/reference/override18(target=es2015).symbols create mode 100644 tests/baselines/reference/override18(target=es2015).types create mode 100644 tests/baselines/reference/override18(target=esnext).js create mode 100644 tests/baselines/reference/override18(target=esnext).symbols create mode 100644 tests/baselines/reference/override18(target=esnext).types create mode 100644 tests/cases/conformance/override/override16.ts create mode 100644 tests/cases/conformance/override/override17.ts create mode 100644 tests/cases/conformance/override/override18.ts diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 0d24f332c15bd..4be9876203669 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -368,6 +368,7 @@ namespace ts { case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: case SyntaxKind.AbstractKeyword: + case SyntaxKind.OverrideKeyword: case SyntaxKind.ConstKeyword: case SyntaxKind.DeclareKeyword: case SyntaxKind.ReadonlyKeyword: diff --git a/tests/baselines/reference/override16(target=es2015).js b/tests/baselines/reference/override16(target=es2015).js new file mode 100644 index 0000000000000..1cd40ba69bb39 --- /dev/null +++ b/tests/baselines/reference/override16(target=es2015).js @@ -0,0 +1,19 @@ +//// [override16.ts] +class A { + foo?: string; +} + +class B extends A { + override foo = "string"; +} + + +//// [override16.js] +class A { +} +class B extends A { + constructor() { + super(...arguments); + this.foo = "string"; + } +} diff --git a/tests/baselines/reference/override16(target=es2015).symbols b/tests/baselines/reference/override16(target=es2015).symbols new file mode 100644 index 0000000000000..d07d776e938cb --- /dev/null +++ b/tests/baselines/reference/override16(target=es2015).symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/override/override16.ts === +class A { +>A : Symbol(A, Decl(override16.ts, 0, 0)) + + foo?: string; +>foo : Symbol(A.foo, Decl(override16.ts, 0, 9)) +} + +class B extends A { +>B : Symbol(B, Decl(override16.ts, 2, 1)) +>A : Symbol(A, Decl(override16.ts, 0, 0)) + + override foo = "string"; +>foo : Symbol(B.foo, Decl(override16.ts, 4, 19)) +} + diff --git a/tests/baselines/reference/override16(target=es2015).types b/tests/baselines/reference/override16(target=es2015).types new file mode 100644 index 0000000000000..565b7f9613d98 --- /dev/null +++ b/tests/baselines/reference/override16(target=es2015).types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/override/override16.ts === +class A { +>A : A + + foo?: string; +>foo : string +} + +class B extends A { +>B : B +>A : A + + override foo = "string"; +>foo : string +>"string" : "string" +} + diff --git a/tests/baselines/reference/override16(target=esnext).js b/tests/baselines/reference/override16(target=esnext).js new file mode 100644 index 0000000000000..6935dccb34bec --- /dev/null +++ b/tests/baselines/reference/override16(target=esnext).js @@ -0,0 +1,17 @@ +//// [override16.ts] +class A { + foo?: string; +} + +class B extends A { + override foo = "string"; +} + + +//// [override16.js] +class A { + foo; +} +class B extends A { + foo = "string"; +} diff --git a/tests/baselines/reference/override16(target=esnext).symbols b/tests/baselines/reference/override16(target=esnext).symbols new file mode 100644 index 0000000000000..d07d776e938cb --- /dev/null +++ b/tests/baselines/reference/override16(target=esnext).symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/override/override16.ts === +class A { +>A : Symbol(A, Decl(override16.ts, 0, 0)) + + foo?: string; +>foo : Symbol(A.foo, Decl(override16.ts, 0, 9)) +} + +class B extends A { +>B : Symbol(B, Decl(override16.ts, 2, 1)) +>A : Symbol(A, Decl(override16.ts, 0, 0)) + + override foo = "string"; +>foo : Symbol(B.foo, Decl(override16.ts, 4, 19)) +} + diff --git a/tests/baselines/reference/override16(target=esnext).types b/tests/baselines/reference/override16(target=esnext).types new file mode 100644 index 0000000000000..565b7f9613d98 --- /dev/null +++ b/tests/baselines/reference/override16(target=esnext).types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/override/override16.ts === +class A { +>A : A + + foo?: string; +>foo : string +} + +class B extends A { +>B : B +>A : A + + override foo = "string"; +>foo : string +>"string" : "string" +} + diff --git a/tests/baselines/reference/override16.js b/tests/baselines/reference/override16.js new file mode 100644 index 0000000000000..6935dccb34bec --- /dev/null +++ b/tests/baselines/reference/override16.js @@ -0,0 +1,17 @@ +//// [override16.ts] +class A { + foo?: string; +} + +class B extends A { + override foo = "string"; +} + + +//// [override16.js] +class A { + foo; +} +class B extends A { + foo = "string"; +} diff --git a/tests/baselines/reference/override16.symbols b/tests/baselines/reference/override16.symbols new file mode 100644 index 0000000000000..d07d776e938cb --- /dev/null +++ b/tests/baselines/reference/override16.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/override/override16.ts === +class A { +>A : Symbol(A, Decl(override16.ts, 0, 0)) + + foo?: string; +>foo : Symbol(A.foo, Decl(override16.ts, 0, 9)) +} + +class B extends A { +>B : Symbol(B, Decl(override16.ts, 2, 1)) +>A : Symbol(A, Decl(override16.ts, 0, 0)) + + override foo = "string"; +>foo : Symbol(B.foo, Decl(override16.ts, 4, 19)) +} + diff --git a/tests/baselines/reference/override16.types b/tests/baselines/reference/override16.types new file mode 100644 index 0000000000000..565b7f9613d98 --- /dev/null +++ b/tests/baselines/reference/override16.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/override/override16.ts === +class A { +>A : A + + foo?: string; +>foo : string +} + +class B extends A { +>B : B +>A : A + + override foo = "string"; +>foo : string +>"string" : "string" +} + diff --git a/tests/baselines/reference/override17(target=es2015).js b/tests/baselines/reference/override17(target=es2015).js new file mode 100644 index 0000000000000..8f9f5b0ac7982 --- /dev/null +++ b/tests/baselines/reference/override17(target=es2015).js @@ -0,0 +1,45 @@ +//// [override17.ts] +class A { + public m1(): number { + return 0; + } + + public m2(): number { + return 0; + } + + public m3(): void {} +} + +class B extends A { + override m1() { + return 10; + } + + override m2(): number { + return 30; + } + + override m3(): void {} +} + + +//// [override17.js] +class A { + m1() { + return 0; + } + m2() { + return 0; + } + m3() { } +} +class B extends A { + m1() { + return 10; + } + m2() { + return 30; + } + m3() { } +} diff --git a/tests/baselines/reference/override17(target=es2015).symbols b/tests/baselines/reference/override17(target=es2015).symbols new file mode 100644 index 0000000000000..13d9a6e6382aa --- /dev/null +++ b/tests/baselines/reference/override17(target=es2015).symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/override/override17.ts === +class A { +>A : Symbol(A, Decl(override17.ts, 0, 0)) + + public m1(): number { +>m1 : Symbol(A.m1, Decl(override17.ts, 0, 9)) + + return 0; + } + + public m2(): number { +>m2 : Symbol(A.m2, Decl(override17.ts, 3, 5)) + + return 0; + } + + public m3(): void {} +>m3 : Symbol(A.m3, Decl(override17.ts, 7, 5)) +} + +class B extends A { +>B : Symbol(B, Decl(override17.ts, 10, 1)) +>A : Symbol(A, Decl(override17.ts, 0, 0)) + + override m1() { +>m1 : Symbol(B.m1, Decl(override17.ts, 12, 19)) + + return 10; + } + + override m2(): number { +>m2 : Symbol(B.m2, Decl(override17.ts, 15, 5)) + + return 30; + } + + override m3(): void {} +>m3 : Symbol(B.m3, Decl(override17.ts, 19, 5)) +} + diff --git a/tests/baselines/reference/override17(target=es2015).types b/tests/baselines/reference/override17(target=es2015).types new file mode 100644 index 0000000000000..66ae416da9f85 --- /dev/null +++ b/tests/baselines/reference/override17(target=es2015).types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/override/override17.ts === +class A { +>A : A + + public m1(): number { +>m1 : () => number + + return 0; +>0 : 0 + } + + public m2(): number { +>m2 : () => number + + return 0; +>0 : 0 + } + + public m3(): void {} +>m3 : () => void +} + +class B extends A { +>B : B +>A : A + + override m1() { +>m1 : () => number + + return 10; +>10 : 10 + } + + override m2(): number { +>m2 : () => number + + return 30; +>30 : 30 + } + + override m3(): void {} +>m3 : () => void +} + diff --git a/tests/baselines/reference/override17(target=esnext).js b/tests/baselines/reference/override17(target=esnext).js new file mode 100644 index 0000000000000..8f9f5b0ac7982 --- /dev/null +++ b/tests/baselines/reference/override17(target=esnext).js @@ -0,0 +1,45 @@ +//// [override17.ts] +class A { + public m1(): number { + return 0; + } + + public m2(): number { + return 0; + } + + public m3(): void {} +} + +class B extends A { + override m1() { + return 10; + } + + override m2(): number { + return 30; + } + + override m3(): void {} +} + + +//// [override17.js] +class A { + m1() { + return 0; + } + m2() { + return 0; + } + m3() { } +} +class B extends A { + m1() { + return 10; + } + m2() { + return 30; + } + m3() { } +} diff --git a/tests/baselines/reference/override17(target=esnext).symbols b/tests/baselines/reference/override17(target=esnext).symbols new file mode 100644 index 0000000000000..13d9a6e6382aa --- /dev/null +++ b/tests/baselines/reference/override17(target=esnext).symbols @@ -0,0 +1,40 @@ +=== tests/cases/conformance/override/override17.ts === +class A { +>A : Symbol(A, Decl(override17.ts, 0, 0)) + + public m1(): number { +>m1 : Symbol(A.m1, Decl(override17.ts, 0, 9)) + + return 0; + } + + public m2(): number { +>m2 : Symbol(A.m2, Decl(override17.ts, 3, 5)) + + return 0; + } + + public m3(): void {} +>m3 : Symbol(A.m3, Decl(override17.ts, 7, 5)) +} + +class B extends A { +>B : Symbol(B, Decl(override17.ts, 10, 1)) +>A : Symbol(A, Decl(override17.ts, 0, 0)) + + override m1() { +>m1 : Symbol(B.m1, Decl(override17.ts, 12, 19)) + + return 10; + } + + override m2(): number { +>m2 : Symbol(B.m2, Decl(override17.ts, 15, 5)) + + return 30; + } + + override m3(): void {} +>m3 : Symbol(B.m3, Decl(override17.ts, 19, 5)) +} + diff --git a/tests/baselines/reference/override17(target=esnext).types b/tests/baselines/reference/override17(target=esnext).types new file mode 100644 index 0000000000000..66ae416da9f85 --- /dev/null +++ b/tests/baselines/reference/override17(target=esnext).types @@ -0,0 +1,44 @@ +=== tests/cases/conformance/override/override17.ts === +class A { +>A : A + + public m1(): number { +>m1 : () => number + + return 0; +>0 : 0 + } + + public m2(): number { +>m2 : () => number + + return 0; +>0 : 0 + } + + public m3(): void {} +>m3 : () => void +} + +class B extends A { +>B : B +>A : A + + override m1() { +>m1 : () => number + + return 10; +>10 : 10 + } + + override m2(): number { +>m2 : () => number + + return 30; +>30 : 30 + } + + override m3(): void {} +>m3 : () => void +} + diff --git a/tests/baselines/reference/override18(target=es2015).js b/tests/baselines/reference/override18(target=es2015).js new file mode 100644 index 0000000000000..12d862bcfc954 --- /dev/null +++ b/tests/baselines/reference/override18(target=es2015).js @@ -0,0 +1,32 @@ +//// [override18.ts] +class A { + foo?: string; +} + +class B extends A { + override foo = "string"; +} + + +//// [override18.js] +class A { + constructor() { + Object.defineProperty(this, "foo", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + } +} +class B extends A { + constructor() { + super(...arguments); + Object.defineProperty(this, "foo", { + enumerable: true, + configurable: true, + writable: true, + value: "string" + }); + } +} diff --git a/tests/baselines/reference/override18(target=es2015).symbols b/tests/baselines/reference/override18(target=es2015).symbols new file mode 100644 index 0000000000000..c41c766ebcc5d --- /dev/null +++ b/tests/baselines/reference/override18(target=es2015).symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/override/override18.ts === +class A { +>A : Symbol(A, Decl(override18.ts, 0, 0)) + + foo?: string; +>foo : Symbol(A.foo, Decl(override18.ts, 0, 9)) +} + +class B extends A { +>B : Symbol(B, Decl(override18.ts, 2, 1)) +>A : Symbol(A, Decl(override18.ts, 0, 0)) + + override foo = "string"; +>foo : Symbol(B.foo, Decl(override18.ts, 4, 19)) +} + diff --git a/tests/baselines/reference/override18(target=es2015).types b/tests/baselines/reference/override18(target=es2015).types new file mode 100644 index 0000000000000..ff1e2320ec6b3 --- /dev/null +++ b/tests/baselines/reference/override18(target=es2015).types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/override/override18.ts === +class A { +>A : A + + foo?: string; +>foo : string +} + +class B extends A { +>B : B +>A : A + + override foo = "string"; +>foo : string +>"string" : "string" +} + diff --git a/tests/baselines/reference/override18(target=esnext).js b/tests/baselines/reference/override18(target=esnext).js new file mode 100644 index 0000000000000..660b2f1f0ea73 --- /dev/null +++ b/tests/baselines/reference/override18(target=esnext).js @@ -0,0 +1,17 @@ +//// [override18.ts] +class A { + foo?: string; +} + +class B extends A { + override foo = "string"; +} + + +//// [override18.js] +class A { + foo; +} +class B extends A { + foo = "string"; +} diff --git a/tests/baselines/reference/override18(target=esnext).symbols b/tests/baselines/reference/override18(target=esnext).symbols new file mode 100644 index 0000000000000..c41c766ebcc5d --- /dev/null +++ b/tests/baselines/reference/override18(target=esnext).symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/override/override18.ts === +class A { +>A : Symbol(A, Decl(override18.ts, 0, 0)) + + foo?: string; +>foo : Symbol(A.foo, Decl(override18.ts, 0, 9)) +} + +class B extends A { +>B : Symbol(B, Decl(override18.ts, 2, 1)) +>A : Symbol(A, Decl(override18.ts, 0, 0)) + + override foo = "string"; +>foo : Symbol(B.foo, Decl(override18.ts, 4, 19)) +} + diff --git a/tests/baselines/reference/override18(target=esnext).types b/tests/baselines/reference/override18(target=esnext).types new file mode 100644 index 0000000000000..ff1e2320ec6b3 --- /dev/null +++ b/tests/baselines/reference/override18(target=esnext).types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/override/override18.ts === +class A { +>A : A + + foo?: string; +>foo : string +} + +class B extends A { +>B : B +>A : A + + override foo = "string"; +>foo : string +>"string" : "string" +} + diff --git a/tests/cases/conformance/override/override16.ts b/tests/cases/conformance/override/override16.ts new file mode 100644 index 0000000000000..4468edfdc4251 --- /dev/null +++ b/tests/cases/conformance/override/override16.ts @@ -0,0 +1,10 @@ +// @target: esnext,es2015 +// @noImplicitOverride: true + +class A { + foo?: string; +} + +class B extends A { + override foo = "string"; +} diff --git a/tests/cases/conformance/override/override17.ts b/tests/cases/conformance/override/override17.ts new file mode 100644 index 0000000000000..edabe9816d05b --- /dev/null +++ b/tests/cases/conformance/override/override17.ts @@ -0,0 +1,27 @@ +// @noImplicitOverride: true +// @useDefineForClassFields: true +// @target: es2015,esnext + +class A { + public m1(): number { + return 0; + } + + public m2(): number { + return 0; + } + + public m3(): void {} +} + +class B extends A { + override m1() { + return 10; + } + + override m2(): number { + return 30; + } + + override m3(): void {} +} diff --git a/tests/cases/conformance/override/override18.ts b/tests/cases/conformance/override/override18.ts new file mode 100644 index 0000000000000..2527449e7499b --- /dev/null +++ b/tests/cases/conformance/override/override18.ts @@ -0,0 +1,11 @@ +// @target: esnext,es2015 +// @noImplicitOverride: true +// @useDefineForClassFields: true + +class A { + foo?: string; +} + +class B extends A { + override foo = "string"; +} From b60901da4f381f3cb13322ef426e992a22073855 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 4 Jun 2021 14:05:55 -0700 Subject: [PATCH 3/7] Fix duplicate visit of param tag comments (#44443) (#44444) Fixes #44422 Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> --- src/compiler/parser.ts | 10 +++++----- src/testRunner/unittests/publicApi.ts | 22 ++++++++++++++++++++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a8f917d325b11..826afeb0673bf 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -493,12 +493,12 @@ namespace ts { case SyntaxKind.JSDocPropertyTag: return visitNode(cbNode, (node as JSDocTag).tagName) || ((node as JSDocPropertyLikeTag).isNameFirst - ? visitNode(cbNode, (node).name) || - visitNode(cbNode, (node).typeExpression) || + ? visitNode(cbNode, (node as JSDocPropertyLikeTag).name) || + visitNode(cbNode, (node as JSDocPropertyLikeTag).typeExpression) || (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray | undefined)) - : visitNode(cbNode, (node).typeExpression) || - visitNode(cbNode, (node).name)) || - (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray | undefined)); + : visitNode(cbNode, (node as JSDocPropertyLikeTag).typeExpression) || + visitNode(cbNode, (node as JSDocPropertyLikeTag).name) || + (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray | undefined))); case SyntaxKind.JSDocAuthorTag: return visitNode(cbNode, (node as JSDocTag).tagName) || (typeof (node as JSDoc).comment === "string" ? undefined : visitNodes(cbNode, cbNodes, (node as JSDoc).comment as NodeArray | undefined)); diff --git a/src/testRunner/unittests/publicApi.ts b/src/testRunner/unittests/publicApi.ts index e299f0c339da5..e1400a9992c9e 100644 --- a/src/testRunner/unittests/publicApi.ts +++ b/src/testRunner/unittests/publicApi.ts @@ -150,6 +150,24 @@ describe("unittests:: Public APIs:: validateLocaleAndSetLanguage", () => { }, errors); }); } - ts.supportedLocaleDirectories.forEach(locale => verifyValidateLocale(locale, /*expctedToReadFile*/ true)); - ["en", "en-us"].forEach(locale => verifyValidateLocale(locale, /*expctedToReadFile*/ false)); + ts.supportedLocaleDirectories.forEach(locale => verifyValidateLocale(locale, /*expectedToReadFile*/ true)); + ["en", "en-us"].forEach(locale => verifyValidateLocale(locale, /*expectedToReadFile*/ false)); +}); + +describe("unittests:: Public APIs :: forEachChild of @param comments in JSDoc", () => { + const content = ` +/** + * @param The {@link TypeReferencesInAedoc}. + */ +var x +`; + const sourceFile = ts.createSourceFile("/file.ts", content, ts.ScriptTarget.ESNext, /*setParentNodes*/ true); + const paramTag = sourceFile.getChildren()[0].getChildren()[0].getChildren()[0].getChildren()[0]; + const kids = paramTag.getChildren(); + const seen: Set = new Set(); + ts.forEachChild(paramTag, n => { + assert.strictEqual(/*actual*/ false, seen.has(n), "Found a duplicate-added child"); + seen.add(n); + }); + assert.equal(5, kids.length); }); From 60f6d7bb3436c33e3df94112904cd89671ef7b57 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Fri, 4 Jun 2021 15:26:37 -0700 Subject: [PATCH 4/7] Cherry-pick PR #44394 into release-4.3 (#44431) Component commits: b6754e401b Add test showing how setting strict is not preserved in tsbuildinfo Test for #44305 d3b479e5ba Handle strict flag when writing tsbuildinfo Fixes #44305 cee9f40fd9 Apply suggestions from code review Co-authored-by: Daniel Rosenwasser Co-authored-by: Sheetal Nandi --- src/compiler/builder.ts | 10 +- src/compiler/commandLineParser.ts | 2 + src/testRunner/unittests/tsc/incremental.ts | 18 ++++ ...s-not-in-rootDir-at-the-import-location.js | 5 +- ...ng-setup-correctly-and-reports-no-error.js | 15 +-- ...-emitDeclarationOnly-and-declarationMap.js | 10 +- ...import-project-with-emitDeclarationOnly.js | 10 +- ...mports-project-with-emitDeclarationOnly.js | 15 +-- .../non-module-projects-without-prepend.js | 15 +-- ...ting-json-module-from-project-reference.js | 10 +- .../demo/updates-with-bad-reference.js | 10 +- .../demo/updates-with-circular-reference.js | 15 +-- .../when-project-has-strict-true.js | 99 +++++++++++++++++++ ...ypes-found-doesn't-crash-under---strict.js | 7 +- 14 files changed, 194 insertions(+), 47 deletions(-) create mode 100644 tests/baselines/reference/tsc/incremental/initial-build/when-project-has-strict-true.js diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 1b6bdf5eecb4e..46c2ed553aa02 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -851,8 +851,14 @@ namespace ts { const { optionsNameMap } = getOptionsNameMap(); for (const name of getOwnKeys(options).sort(compareStringsCaseSensitive)) { - const optionInfo = optionsNameMap.get(name.toLowerCase()); - if (optionInfo?.affectsEmit || optionInfo?.affectsSemanticDiagnostics || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + const optionKey = name.toLowerCase(); + const optionInfo = optionsNameMap.get(optionKey); + if (optionInfo?.affectsEmit || optionInfo?.affectsSemanticDiagnostics || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result ||= {})[name] = convertToReusableCompilerOptionValue( optionInfo, options[name] as CompilerOptionsValue, diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 253e38a5295b5..375048baec269 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -564,6 +564,8 @@ namespace ts { { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: Diagnostics.Strict_Type_Checking_Options, description: Diagnostics.Enable_all_strict_type_checking_options diff --git a/src/testRunner/unittests/tsc/incremental.ts b/src/testRunner/unittests/tsc/incremental.ts index 7e975b89ce6b2..a8fe334de7c7f 100644 --- a/src/testRunner/unittests/tsc/incremental.ts +++ b/src/testRunner/unittests/tsc/incremental.ts @@ -400,5 +400,23 @@ declare global { }, ] }); + + + verifyTscSerializedIncrementalEdits({ + scenario: "incremental", + subScenario: "when project has strict true", + commandLineArgs: ["-noEmit", "-p", `src/project`], + fs: () => loadProjectFromFiles({ + "/src/project/tsconfig.json": JSON.stringify({ + compilerOptions: { + incremental: true, + strict: true, + }, + }), + "/src/project/class1.ts": `export class class1 {}`, + }), + incrementalScenarios: noChangeOnlyRuns, + baselinePrograms: true + }); }); } diff --git a/tests/baselines/reference/tsbuild/demo/initial-build/in-bad-ref-branch-reports-the-error-about-files-not-in-rootDir-at-the-import-location.js b/tests/baselines/reference/tsbuild/demo/initial-build/in-bad-ref-branch-reports-the-error-about-files-not-in-rootDir-at-the-import-location.js index 04e7963ce5c38..6b617709cce6b 100644 --- a/tests/baselines/reference/tsbuild/demo/initial-build/in-bad-ref-branch-reports-the-error-about-files-not-in-rootDir-at-the-import-location.js +++ b/tests/baselines/reference/tsbuild/demo/initial-build/in-bad-ref-branch-reports-the-error-about-files-not-in-rootDir-at-the-import-location.js @@ -214,7 +214,7 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped //// [/src/lib/core/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n","-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","-15713992787-import * as A from '../animals';\n\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"exportedModulesMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":0,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[[2,1],[3,1],[4,1],[5,1]]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n","-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","-15713992787-import * as A from '../animals';\n\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"exportedModulesMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":0,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[[2,1],[3,1],[4,1],[5,1]]},"version":"FakeTSVersion"} //// [/src/lib/core/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -272,6 +272,7 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped "noUnusedParameters": true, "outDir": "./", "rootDir": "../../core", + "strict": true, "target": 1 }, "referencedMap": { @@ -340,6 +341,6 @@ exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped ] }, "version": "FakeTSVersion", - "size": 2273 + "size": 2287 } diff --git a/tests/baselines/reference/tsbuild/demo/initial-build/in-master-branch-with-everything-setup-correctly-and-reports-no-error.js b/tests/baselines/reference/tsbuild/demo/initial-build/in-master-branch-with-everything-setup-correctly-and-reports-no-error.js index 52b58e76138d3..c7ff594029ab7 100644 --- a/tests/baselines/reference/tsbuild/demo/initial-build/in-master-branch-with-everything-setup-correctly-and-reports-no-error.js +++ b/tests/baselines/reference/tsbuild/demo/initial-build/in-master-branch-with-everything-setup-correctly-and-reports-no-error.js @@ -220,7 +220,7 @@ Object.defineProperty(exports, "createDog", { enumerable: true, get: function () //// [/src/lib/animals/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../lib/lib.d.ts","../../animals/animal.ts","../../animals/index.ts","../core/utilities.d.ts","../../animals/dog.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","-8177343116-export declare function makeRandomName(): string;\r\nexport declare function lastElementOf(arr: T[]): T | undefined;\r\n","-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../animals","target":1},"fileIdsList":[[3,4],[2,5]],"referencedMap":[[5,1],[3,2]],"exportedModulesMap":[[5,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,5,3,4]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../lib/lib.d.ts","../../animals/animal.ts","../../animals/index.ts","../core/utilities.d.ts","../../animals/dog.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","-8177343116-export declare function makeRandomName(): string;\r\nexport declare function lastElementOf(arr: T[]): T | undefined;\r\n","-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../animals","strict":true,"target":1},"fileIdsList":[[3,4],[2,5]],"referencedMap":[[5,1],[3,2]],"exportedModulesMap":[[5,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,5,3,4]},"version":"FakeTSVersion"} //// [/src/lib/animals/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -275,6 +275,7 @@ Object.defineProperty(exports, "createDog", { enumerable: true, get: function () "noUnusedParameters": true, "outDir": "./", "rootDir": "../../animals", + "strict": true, "target": 1 }, "referencedMap": { @@ -306,11 +307,11 @@ Object.defineProperty(exports, "createDog", { enumerable: true, get: function () ] }, "version": "FakeTSVersion", - "size": 1889 + "size": 1903 } //// [/src/lib/core/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../lib/lib.d.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"25274411612-\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../lib/lib.d.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"25274411612-\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"} //// [/src/lib/core/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -340,6 +341,7 @@ Object.defineProperty(exports, "createDog", { enumerable: true, get: function () "noUnusedParameters": true, "outDir": "./", "rootDir": "../../core", + "strict": true, "target": 1 }, "referencedMap": {}, @@ -350,7 +352,7 @@ Object.defineProperty(exports, "createDog", { enumerable: true, get: function () ] }, "version": "FakeTSVersion", - "size": 1135 + "size": 1149 } //// [/src/lib/core/utilities.d.ts] @@ -375,7 +377,7 @@ exports.lastElementOf = lastElementOf; //// [/src/lib/zoo/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../lib/lib.d.ts","../animals/animal.d.ts","../animals/dog.d.ts","../animals/index.d.ts","../../zoo/zoo.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"13427676350-export declare type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","10854678623-import Animal from '.';\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\nexport declare function createDog(): Dog;\r\n","4477582546-import Animal from './animal';\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","8797123924-import { Dog, createDog } from '../animals/index';\r\n\r\nexport function createZoo(): Array {\r\n return [\r\n createDog()\r\n ];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../zoo","target":1},"fileIdsList":[[4],[2,3]],"referencedMap":[[3,1],[4,2],[5,1]],"exportedModulesMap":[[3,1],[4,2],[5,1]],"semanticDiagnosticsPerFile":[1,2,3,4,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../lib/lib.d.ts","../animals/animal.d.ts","../animals/dog.d.ts","../animals/index.d.ts","../../zoo/zoo.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"13427676350-export declare type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","10854678623-import Animal from '.';\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\nexport declare function createDog(): Dog;\r\n","4477582546-import Animal from './animal';\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","8797123924-import { Dog, createDog } from '../animals/index';\r\n\r\nexport function createZoo(): Array {\r\n return [\r\n createDog()\r\n ];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../zoo","strict":true,"target":1},"fileIdsList":[[4],[2,3]],"referencedMap":[[3,1],[4,2],[5,1]],"exportedModulesMap":[[3,1],[4,2],[5,1]],"semanticDiagnosticsPerFile":[1,2,3,4,5]},"version":"FakeTSVersion"} //// [/src/lib/zoo/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -429,6 +431,7 @@ exports.lastElementOf = lastElementOf; "noUnusedParameters": true, "outDir": "./", "rootDir": "../../zoo", + "strict": true, "target": 1 }, "referencedMap": { @@ -464,7 +467,7 @@ exports.lastElementOf = lastElementOf; ] }, "version": "FakeTSVersion", - "size": 1656 + "size": 1670 } //// [/src/lib/zoo/zoo.d.ts] diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js index 7296fd3bb7581..85cba94d561ba 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly-and-declarationMap.js @@ -120,7 +120,7 @@ export { C } from "./c"; {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC"} //// [/src/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../lib/lib.d.ts","./src/c.ts","./src/b.ts","./src/a.ts","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","-15463561693-import { B } from \"./b\";\n\nexport interface A {\n b: B;\n}\n","1286756397-export { A } from \"./a\";\nexport { B } from \"./b\";\nexport { C } from \"./c\";\n"],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"target":1},"fileIdsList":[[3],[2],[4],[2,3,4]],"referencedMap":[[4,1],[3,2],[2,3],[5,4]],"exportedModulesMap":[[4,1],[3,2],[2,3],[5,4]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../lib/lib.d.ts","./src/c.ts","./src/b.ts","./src/a.ts","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","-15463561693-import { B } from \"./b\";\n\nexport interface A {\n b: B;\n}\n","1286756397-export { A } from \"./a\";\nexport { B } from \"./b\";\nexport { C } from \"./c\";\n"],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"strict":true,"target":1},"fileIdsList":[[3],[2],[4],[2,3,4]],"referencedMap":[[4,1],[3,2],[2,3],[5,4]],"exportedModulesMap":[[4,1],[3,2],[2,3],[5,4]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} //// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -181,6 +181,7 @@ export { C } from "./c"; "outDir": "./lib", "rootDir": "./src", "sourceMap": true, + "strict": true, "target": 1 }, "referencedMap": { @@ -224,7 +225,7 @@ export { C } from "./c"; ] }, "version": "FakeTSVersion", - "size": 1314 + "size": 1328 } @@ -271,7 +272,7 @@ export interface A { //// [/src/lib/index.d.ts] file written with same contents //// [/src/lib/index.d.ts.map] file written with same contents //// [/src/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../lib/lib.d.ts","./src/c.ts","./src/b.ts","./src/a.ts","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"},{"version":"-14761736732-import { B } from \"./b\";\n\nexport interface A {\n b: B; foo: any;\n}\n","signature":"-7639584379-import { B } from \"./b\";\r\nexport interface A {\r\n b: B;\r\n foo: any;\r\n}\r\n"},{"version":"1286756397-export { A } from \"./a\";\nexport { B } from \"./b\";\nexport { C } from \"./c\";\n","signature":"-6009477228-export { A } from \"./a\";\r\nexport { B } from \"./b\";\r\nexport { C } from \"./c\";\r\n"}],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"target":1},"fileIdsList":[[3],[2],[4],[2,3,4]],"referencedMap":[[4,1],[3,2],[2,3],[5,4]],"exportedModulesMap":[[4,1],[3,2],[2,3],[5,4]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../lib/lib.d.ts","./src/c.ts","./src/b.ts","./src/a.ts","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"},{"version":"-14761736732-import { B } from \"./b\";\n\nexport interface A {\n b: B; foo: any;\n}\n","signature":"-7639584379-import { B } from \"./b\";\r\nexport interface A {\r\n b: B;\r\n foo: any;\r\n}\r\n"},{"version":"1286756397-export { A } from \"./a\";\nexport { B } from \"./b\";\nexport { C } from \"./c\";\n","signature":"-6009477228-export { A } from \"./a\";\r\nexport { B } from \"./b\";\r\nexport { C } from \"./c\";\r\n"}],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"strict":true,"target":1},"fileIdsList":[[3],[2],[4],[2,3,4]],"referencedMap":[[4,1],[3,2],[2,3],[5,4]],"exportedModulesMap":[[4,1],[3,2],[2,3],[5,4]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} //// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -332,6 +333,7 @@ export interface A { "outDir": "./lib", "rootDir": "./src", "sourceMap": true, + "strict": true, "target": 1 }, "referencedMap": { @@ -375,6 +377,6 @@ export interface A { ] }, "version": "FakeTSVersion", - "size": 1803 + "size": 1817 } diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js index d86178c9644c3..4ff553ac46c38 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-circular-import-project-with-emitDeclarationOnly.js @@ -108,7 +108,7 @@ export { C } from "./c"; //// [/src/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../lib/lib.d.ts","./src/c.ts","./src/b.ts","./src/a.ts","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","-15463561693-import { B } from \"./b\";\n\nexport interface A {\n b: B;\n}\n","1286756397-export { A } from \"./a\";\nexport { B } from \"./b\";\nexport { C } from \"./c\";\n"],"options":{"composite":true,"declaration":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"target":1},"fileIdsList":[[3],[2],[4],[2,3,4]],"referencedMap":[[4,1],[3,2],[2,3],[5,4]],"exportedModulesMap":[[4,1],[3,2],[2,3],[5,4]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../lib/lib.d.ts","./src/c.ts","./src/b.ts","./src/a.ts","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","-15463561693-import { B } from \"./b\";\n\nexport interface A {\n b: B;\n}\n","1286756397-export { A } from \"./a\";\nexport { B } from \"./b\";\nexport { C } from \"./c\";\n"],"options":{"composite":true,"declaration":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"strict":true,"target":1},"fileIdsList":[[3],[2],[4],[2,3,4]],"referencedMap":[[4,1],[3,2],[2,3],[5,4]],"exportedModulesMap":[[4,1],[3,2],[2,3],[5,4]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} //// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -168,6 +168,7 @@ export { C } from "./c"; "outDir": "./lib", "rootDir": "./src", "sourceMap": true, + "strict": true, "target": 1 }, "referencedMap": { @@ -211,7 +212,7 @@ export { C } from "./c"; ] }, "version": "FakeTSVersion", - "size": 1292 + "size": 1306 } @@ -252,7 +253,7 @@ export interface A { //// [/src/lib/c.d.ts] file written with same contents //// [/src/lib/index.d.ts] file written with same contents //// [/src/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../lib/lib.d.ts","./src/c.ts","./src/b.ts","./src/a.ts","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"},{"version":"-14761736732-import { B } from \"./b\";\n\nexport interface A {\n b: B; foo: any;\n}\n","signature":"-7639584379-import { B } from \"./b\";\r\nexport interface A {\r\n b: B;\r\n foo: any;\r\n}\r\n"},{"version":"1286756397-export { A } from \"./a\";\nexport { B } from \"./b\";\nexport { C } from \"./c\";\n","signature":"-6009477228-export { A } from \"./a\";\r\nexport { B } from \"./b\";\r\nexport { C } from \"./c\";\r\n"}],"options":{"composite":true,"declaration":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"target":1},"fileIdsList":[[3],[2],[4],[2,3,4]],"referencedMap":[[4,1],[3,2],[2,3],[5,4]],"exportedModulesMap":[[4,1],[3,2],[2,3],[5,4]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../lib/lib.d.ts","./src/c.ts","./src/b.ts","./src/a.ts","./src/index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"},{"version":"-14761736732-import { B } from \"./b\";\n\nexport interface A {\n b: B; foo: any;\n}\n","signature":"-7639584379-import { B } from \"./b\";\r\nexport interface A {\r\n b: B;\r\n foo: any;\r\n}\r\n"},{"version":"1286756397-export { A } from \"./a\";\nexport { B } from \"./b\";\nexport { C } from \"./c\";\n","signature":"-6009477228-export { A } from \"./a\";\r\nexport { B } from \"./b\";\r\nexport { C } from \"./c\";\r\n"}],"options":{"composite":true,"declaration":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"strict":true,"target":1},"fileIdsList":[[3],[2],[4],[2,3,4]],"referencedMap":[[4,1],[3,2],[2,3],[5,4]],"exportedModulesMap":[[4,1],[3,2],[2,3],[5,4]],"semanticDiagnosticsPerFile":[1,4,3,2,5]},"version":"FakeTSVersion"} //// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -312,6 +313,7 @@ export interface A { "outDir": "./lib", "rootDir": "./src", "sourceMap": true, + "strict": true, "target": 1 }, "referencedMap": { @@ -355,6 +357,6 @@ export interface A { ] }, "version": "FakeTSVersion", - "size": 1781 + "size": 1795 } diff --git a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js index 7eac017ad9602..68b5890d8723d 100644 --- a/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js +++ b/tests/baselines/reference/tsbuild/emitDeclarationOnly/initial-build/only-dts-output-in-non-circular-imports-project-with-emitDeclarationOnly.js @@ -107,7 +107,7 @@ export interface C { {"version":3,"file":"c.d.ts","sourceRoot":"","sources":["../src/c.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,CAAC;IAChB,CAAC,EAAE,CAAC,CAAC;CACN"} //// [/src/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../lib/lib.d.ts","./src/a.ts","./src/c.ts","./src/b.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"11179224639-export class B { prop = \"hello\"; }\n\nexport interface A {\n b: B;\n}\n","429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n"],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"target":1},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"exportedModulesMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../lib/lib.d.ts","./src/a.ts","./src/c.ts","./src/b.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"11179224639-export class B { prop = \"hello\"; }\n\nexport interface A {\n b: B;\n}\n","429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n"],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"strict":true,"target":1},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"exportedModulesMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"} //// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -155,6 +155,7 @@ export interface C { "outDir": "./lib", "rootDir": "./src", "sourceMap": true, + "strict": true, "target": 1 }, "referencedMap": { @@ -181,7 +182,7 @@ export interface C { ] }, "version": "FakeTSVersion", - "size": 1170 + "size": 1184 } @@ -220,7 +221,7 @@ exitCode:: ExitStatus.Success //// [/src/lib/c.d.ts] file written with same contents //// [/src/lib/c.d.ts.map] file written with same contents //// [/src/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../lib/lib.d.ts","./src/a.ts","./src/c.ts","./src/b.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"6651905050-export class B { prop = \"hello\"; }\n\nclass C { }\nexport interface A {\n b: B;\n}\n","signature":"-4181862109-export declare class B {\r\n prop: string;\r\n}\r\nexport interface A {\r\n b: B;\r\n}\r\n"},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"}],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"target":1},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"exportedModulesMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../lib/lib.d.ts","./src/a.ts","./src/c.ts","./src/b.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"6651905050-export class B { prop = \"hello\"; }\n\nclass C { }\nexport interface A {\n b: B;\n}\n","signature":"-4181862109-export declare class B {\r\n prop: string;\r\n}\r\nexport interface A {\r\n b: B;\r\n}\r\n"},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"}],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"strict":true,"target":1},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"exportedModulesMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"} //// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -268,6 +269,7 @@ exitCode:: ExitStatus.Success "outDir": "./lib", "rootDir": "./src", "sourceMap": true, + "strict": true, "target": 1 }, "referencedMap": { @@ -294,7 +296,7 @@ exitCode:: ExitStatus.Success ] }, "version": "FakeTSVersion", - "size": 1539 + "size": 1553 } @@ -342,7 +344,7 @@ export interface A { //// [/src/lib/c.d.ts] file written with same contents //// [/src/lib/c.d.ts.map] file written with same contents //// [/src/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../lib/lib.d.ts","./src/a.ts","./src/c.ts","./src/b.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"5380514971-export class B { prop = \"hello\"; }\n\nclass C { }\nexport interface A {\n b: B; foo: any;\n}\n","signature":"-6995298949-export declare class B {\r\n prop: string;\r\n}\r\nexport interface A {\r\n b: B;\r\n foo: any;\r\n}\r\n"},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"}],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"target":1},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"exportedModulesMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../lib/lib.d.ts","./src/a.ts","./src/c.ts","./src/b.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"5380514971-export class B { prop = \"hello\"; }\n\nclass C { }\nexport interface A {\n b: B; foo: any;\n}\n","signature":"-6995298949-export declare class B {\r\n prop: string;\r\n}\r\nexport interface A {\r\n b: B;\r\n foo: any;\r\n}\r\n"},{"version":"429593025-import { A } from \"./a\";\n\nexport interface C {\n a: A;\n}\n","signature":"-2697851509-import { A } from \"./a\";\r\nexport interface C {\r\n a: A;\r\n}\r\n"},{"version":"-2273488249-import { C } from \"./c\";\n\nexport interface B {\n b: C;\n}\n","signature":"20298635505-import { C } from \"./c\";\r\nexport interface B {\r\n b: C;\r\n}\r\n"}],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":1,"outDir":"./lib","rootDir":"./src","sourceMap":true,"strict":true,"target":1},"fileIdsList":[[3],[2]],"referencedMap":[[4,1],[3,2]],"exportedModulesMap":[[4,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,4,3]},"version":"FakeTSVersion"} //// [/src/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -390,6 +392,7 @@ export interface A { "outDir": "./lib", "rootDir": "./src", "sourceMap": true, + "strict": true, "target": 1 }, "referencedMap": { @@ -416,6 +419,6 @@ export interface A { ] }, "version": "FakeTSVersion", - "size": 1566 + "size": 1580 } diff --git a/tests/baselines/reference/tsbuild/outFile/initial-build/non-module-projects-without-prepend.js b/tests/baselines/reference/tsbuild/outFile/initial-build/non-module-projects-without-prepend.js index 9d3d2d5bb88b6..e4f98012bfa0e 100644 --- a/tests/baselines/reference/tsbuild/outFile/initial-build/non-module-projects-without-prepend.js +++ b/tests/baselines/reference/tsbuild/outFile/initial-build/non-module-projects-without-prepend.js @@ -202,7 +202,7 @@ function f() { {"version":3,"file":"first_part3.js","sourceRoot":"","sources":["first_part3.ts"],"names":[],"mappings":"AAAA,SAAS,CAAC;IACN,OAAO,gBAAgB,CAAC;AAC5B,CAAC"} //// [/src/first/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./first_part1.ts","./first_part2.ts","./first_part3.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-17207381411-interface TheFirst {\r\n none: any;\r\n}\r\n\r\nconst s = \"Hello, world\";\r\n\r\ninterface NoJsForHereEither {\r\n none: any;\r\n}\r\n\r\nconsole.log(s);\r\n","affectsGlobalScope":true},{"version":"4973778178-console.log(f());\r\n","affectsGlobalScope":true},{"version":"6202806249-function f() {\r\n return \"JS does hoists\";\r\n}","affectsGlobalScope":true}],"options":{"composite":true,"declarationMap":true,"module":0,"removeComments":true,"skipDefaultLibCheck":true,"sourceMap":true,"target":1},"semanticDiagnosticsPerFile":[1,2,3,4]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./first_part1.ts","./first_part2.ts","./first_part3.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-17207381411-interface TheFirst {\r\n none: any;\r\n}\r\n\r\nconst s = \"Hello, world\";\r\n\r\ninterface NoJsForHereEither {\r\n none: any;\r\n}\r\n\r\nconsole.log(s);\r\n","affectsGlobalScope":true},{"version":"4973778178-console.log(f());\r\n","affectsGlobalScope":true},{"version":"6202806249-function f() {\r\n return \"JS does hoists\";\r\n}","affectsGlobalScope":true}],"options":{"composite":true,"declarationMap":true,"module":0,"removeComments":true,"skipDefaultLibCheck":true,"sourceMap":true,"strict":false,"target":1},"semanticDiagnosticsPerFile":[1,2,3,4]},"version":"FakeTSVersion"} //// [/src/first/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -242,6 +242,7 @@ function f() { "removeComments": true, "skipDefaultLibCheck": true, "sourceMap": true, + "strict": false, "target": 1 }, "semanticDiagnosticsPerFile": [ @@ -252,7 +253,7 @@ function f() { ] }, "version": "FakeTSVersion", - "size": 1199 + "size": 1214 } //// [/src/second/second_part1.d.ts] @@ -302,7 +303,7 @@ var C = (function () { {"version":3,"file":"second_part2.js","sourceRoot":"","sources":["second_part2.ts"],"names":[],"mappings":"AAAA;IAAA;IAIA,CAAC;IAHG,uBAAW,GAAX;QACI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IACtC,CAAC;IACL,QAAC;AAAD,CAAC,AAJD,IAIC"} //// [/src/second/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./second_part1.ts","./second_part2.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-21603042336-namespace N {\r\n // Comment text\r\n}\r\n\r\nnamespace N {\r\n function f() {\r\n console.log('testing');\r\n }\r\n\r\n f();\r\n}\r\n","affectsGlobalScope":true},{"version":"9339262372-class C {\r\n doSomething() {\r\n console.log(\"something got done\");\r\n }\r\n}\r\n","affectsGlobalScope":true}],"options":{"composite":true,"declaration":true,"declarationMap":true,"module":0,"removeComments":true,"skipDefaultLibCheck":true,"sourceMap":true,"target":1},"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./second_part1.ts","./second_part2.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-21603042336-namespace N {\r\n // Comment text\r\n}\r\n\r\nnamespace N {\r\n function f() {\r\n console.log('testing');\r\n }\r\n\r\n f();\r\n}\r\n","affectsGlobalScope":true},{"version":"9339262372-class C {\r\n doSomething() {\r\n console.log(\"something got done\");\r\n }\r\n}\r\n","affectsGlobalScope":true}],"options":{"composite":true,"declaration":true,"declarationMap":true,"module":0,"removeComments":true,"skipDefaultLibCheck":true,"sourceMap":true,"strict":false,"target":1},"semanticDiagnosticsPerFile":[1,2,3]},"version":"FakeTSVersion"} //// [/src/second/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -337,6 +338,7 @@ var C = (function () { "removeComments": true, "skipDefaultLibCheck": true, "sourceMap": true, + "strict": false, "target": 1 }, "semanticDiagnosticsPerFile": [ @@ -346,7 +348,7 @@ var C = (function () { ] }, "version": "FakeTSVersion", - "size": 1159 + "size": 1174 } //// [/src/third/third_part1.d.ts] @@ -365,7 +367,7 @@ c.doSomething(); {"version":3,"file":"third_part1.js","sourceRoot":"","sources":["third_part1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC,CAAC,WAAW,EAAE,CAAC"} //// [/src/third/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../first/first_part1.d.ts","../first/first_part2.d.ts","../first/first_part3.d.ts","../second/second_part1.d.ts","../second/second_part2.d.ts","./third_part1.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-17939996161-interface TheFirst {\r\n none: any;\r\n}\r\ndeclare const s = \"Hello, world\";\r\ninterface NoJsForHereEither {\r\n none: any;\r\n}\r\n//# sourceMappingURL=first_PART1.d.ts.map","affectsGlobalScope":true},"-2054710634-//# sourceMappingURL=first_part2.d.ts.map",{"version":"-4577888121-declare function f(): string;\r\n//# sourceMappingURL=first_part3.d.ts.map","affectsGlobalScope":true},{"version":"-3134340341-declare namespace N {\r\n}\r\ndeclare namespace N {\r\n}\r\n//# sourceMappingURL=second_part1.d.ts.map","affectsGlobalScope":true},{"version":"6579734441-declare class C {\r\n doSomething(): void;\r\n}\r\n//# sourceMappingURL=second_part2.d.ts.map","affectsGlobalScope":true},{"version":"10470273651-var c = new C();\r\nc.doSomething();\r\n","affectsGlobalScope":true}],"options":{"composite":true,"declaration":true,"declarationMap":true,"module":0,"removeComments":true,"skipDefaultLibCheck":true,"sourceMap":true,"target":1},"semanticDiagnosticsPerFile":[1,2,3,4,5,6,7]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","../first/first_part1.d.ts","../first/first_part2.d.ts","../first/first_part3.d.ts","../second/second_part1.d.ts","../second/second_part2.d.ts","./third_part1.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"-17939996161-interface TheFirst {\r\n none: any;\r\n}\r\ndeclare const s = \"Hello, world\";\r\ninterface NoJsForHereEither {\r\n none: any;\r\n}\r\n//# sourceMappingURL=first_PART1.d.ts.map","affectsGlobalScope":true},"-2054710634-//# sourceMappingURL=first_part2.d.ts.map",{"version":"-4577888121-declare function f(): string;\r\n//# sourceMappingURL=first_part3.d.ts.map","affectsGlobalScope":true},{"version":"-3134340341-declare namespace N {\r\n}\r\ndeclare namespace N {\r\n}\r\n//# sourceMappingURL=second_part1.d.ts.map","affectsGlobalScope":true},{"version":"6579734441-declare class C {\r\n doSomething(): void;\r\n}\r\n//# sourceMappingURL=second_part2.d.ts.map","affectsGlobalScope":true},{"version":"10470273651-var c = new C();\r\nc.doSomething();\r\n","affectsGlobalScope":true}],"options":{"composite":true,"declaration":true,"declarationMap":true,"module":0,"removeComments":true,"skipDefaultLibCheck":true,"sourceMap":true,"strict":false,"target":1},"semanticDiagnosticsPerFile":[1,2,3,4,5,6,7]},"version":"FakeTSVersion"} //// [/src/third/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -423,6 +425,7 @@ c.doSomething(); "removeComments": true, "skipDefaultLibCheck": true, "sourceMap": true, + "strict": false, "target": 1 }, "semanticDiagnosticsPerFile": [ @@ -436,6 +439,6 @@ c.doSomething(); ] }, "version": "FakeTSVersion", - "size": 1749 + "size": 1764 } diff --git a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/importing-json-module-from-project-reference.js b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/importing-json-module-from-project-reference.js index e0e4855cda72a..f28e95fcce9c3 100644 --- a/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/importing-json-module-from-project-reference.js +++ b/tests/baselines/reference/tsbuild/resolveJsonModule/initial-build/importing-json-module-from-project-reference.js @@ -109,7 +109,7 @@ console.log(foo_json_1.foo); //// [/src/main/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","../strings/foo.json","./index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4395333385-{\n \"foo\": \"bar baz\"\n}","affectsGlobalScope":true},"-4651661680-import { foo } from '../strings/foo.json';\n\nconsole.log(foo);"],"options":{"composite":true,"esModuleInterop":true,"module":1,"rootDir":"..","target":1},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,3,2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","../strings/foo.json","./index.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4395333385-{\n \"foo\": \"bar baz\"\n}","affectsGlobalScope":true},"-4651661680-import { foo } from '../strings/foo.json';\n\nconsole.log(foo);"],"options":{"composite":true,"esModuleInterop":true,"module":1,"rootDir":"..","strict":true,"target":1},"fileIdsList":[[2]],"referencedMap":[[3,1]],"exportedModulesMap":[[3,1]],"semanticDiagnosticsPerFile":[1,3,2]},"version":"FakeTSVersion"} //// [/src/main/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -145,6 +145,7 @@ console.log(foo_json_1.foo); "esModuleInterop": true, "module": 1, "rootDir": "..", + "strict": true, "target": 1 }, "referencedMap": { @@ -164,11 +165,11 @@ console.log(foo_json_1.foo); ] }, "version": "FakeTSVersion", - "size": 961 + "size": 975 } //// [/src/strings/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./foo.json"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4395333385-{\n \"foo\": \"bar baz\"\n}","affectsGlobalScope":true}],"options":{"composite":true,"esModuleInterop":true,"module":1,"rootDir":"..","target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./foo.json"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},{"version":"4395333385-{\n \"foo\": \"bar baz\"\n}","affectsGlobalScope":true}],"options":{"composite":true,"esModuleInterop":true,"module":1,"rootDir":"..","strict":true,"target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"} //// [/src/strings/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -194,6 +195,7 @@ console.log(foo_json_1.foo); "esModuleInterop": true, "module": 1, "rootDir": "..", + "strict": true, "target": 1 }, "referencedMap": {}, @@ -204,7 +206,7 @@ console.log(foo_json_1.foo); ] }, "version": "FakeTSVersion", - "size": 829 + "size": 843 } diff --git a/tests/baselines/reference/tsbuild/watchMode/demo/updates-with-bad-reference.js b/tests/baselines/reference/tsbuild/watchMode/demo/updates-with-bad-reference.js index a50d1cc619046..9c5d48c153c5f 100644 --- a/tests/baselines/reference/tsbuild/watchMode/demo/updates-with-bad-reference.js +++ b/tests/baselines/reference/tsbuild/watchMode/demo/updates-with-bad-reference.js @@ -273,7 +273,7 @@ FsWatchesRecursive:: exitCode:: ExitStatus.undefined //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n","-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","-15713992787-import * as A from '../animals';\n\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"exportedModulesMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":0,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[[2,1],[3,1],[4,1],[5,1]]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n","-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","-15713992787-import * as A from '../animals';\n\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"exportedModulesMap":[[3,1],[4,2],[5,3]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":0,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[[2,1],[3,1],[4,1],[5,1]]},"version":"FakeTSVersion"} //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -331,6 +331,7 @@ exitCode:: ExitStatus.undefined "noUnusedParameters": true, "outDir": "./", "rootDir": "../../core", + "strict": true, "target": 1 }, "referencedMap": { @@ -399,7 +400,7 @@ exitCode:: ExitStatus.undefined ] }, "version": "FakeTSVersion", - "size": 2284 + "size": 2298 } @@ -535,7 +536,7 @@ FsWatchesRecursive:: exitCode:: ExitStatus.undefined //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n",{"version":"-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n","signature":"6032048049-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n"},{"version":"-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","signature":"1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n"},{"version":"-10926881769-\nimport * as A from '../animals';\n\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n","signature":"-11345568166-export declare function makeRandomName(): string;\nexport declare function lastElementOf(arr: T[]): T | undefined;\n"}],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"exportedModulesMap":[[3,3],[4,2]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":1,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[[2,1],[3,1],[4,1],[5,1]]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/dog.ts","../../animals/index.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n",{"version":"-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n","signature":"6032048049-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n"},{"version":"-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","signature":"1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n"},{"version":"-10926881769-\nimport * as A from '../animals';\n\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n","signature":"-11345568166-export declare function makeRandomName(): string;\nexport declare function lastElementOf(arr: T[]): T | undefined;\n"}],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"fileIdsList":[[4,5],[2,3],[4]],"referencedMap":[[3,1],[4,2],[5,3]],"exportedModulesMap":[[3,3],[4,2]],"semanticDiagnosticsPerFile":[1,2,3,4,[5,[{"file":"../../core/utilities.ts","start":1,"length":32,"messageText":"'A' is declared but its value is never read.","category":1,"code":6133,"reportsUnnecessary":true}]]],"affectedFilesPendingEmit":[[2,1],[3,1],[4,1],[5,1]]},"version":"FakeTSVersion"} //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -593,6 +594,7 @@ exitCode:: ExitStatus.undefined "noUnusedParameters": true, "outDir": "./", "rootDir": "../../core", + "strict": true, "target": 1 }, "referencedMap": { @@ -657,6 +659,6 @@ exitCode:: ExitStatus.undefined ] }, "version": "FakeTSVersion", - "size": 2788 + "size": 2802 } diff --git a/tests/baselines/reference/tsbuild/watchMode/demo/updates-with-circular-reference.js b/tests/baselines/reference/tsbuild/watchMode/demo/updates-with-circular-reference.js index fe40c2956235b..275d53c37cbc2 100644 --- a/tests/baselines/reference/tsbuild/watchMode/demo/updates-with-circular-reference.js +++ b/tests/baselines/reference/tsbuild/watchMode/demo/updates-with-circular-reference.js @@ -336,7 +336,7 @@ export declare function lastElementOf(arr: T[]): T | undefined; //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"25274411612-\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../core/utilities.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"25274411612-\r\nexport function makeRandomName() {\r\n return \"Bob!?! \";\r\n}\r\n\r\nexport function lastElementOf(arr: T[]): T | undefined {\r\n if (arr.length === 0) return undefined;\r\n return arr[arr.length - 1];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../core","strict":true,"target":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2]},"version":"FakeTSVersion"} //// [/user/username/projects/demo/lib/core/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -366,6 +366,7 @@ export declare function lastElementOf(arr: T[]): T | undefined; "noUnusedParameters": true, "outDir": "./", "rootDir": "../../core", + "strict": true, "target": 1 }, "referencedMap": {}, @@ -376,7 +377,7 @@ export declare function lastElementOf(arr: T[]): T | undefined; ] }, "version": "FakeTSVersion", - "size": 1146 + "size": 1160 } //// [/user/username/projects/demo/lib/animals/animal.js] @@ -433,7 +434,7 @@ export declare function createDog(): Dog; //// [/user/username/projects/demo/lib/animals/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/index.ts","../core/utilities.d.ts","../../animals/dog.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","-11345568166-export declare function makeRandomName(): string;\nexport declare function lastElementOf(arr: T[]): T | undefined;\n","-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../animals","target":1},"fileIdsList":[[3,4],[2,5]],"referencedMap":[[5,1],[3,2]],"exportedModulesMap":[[5,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,5,3,4]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../../animals/animal.ts","../../animals/index.ts","../core/utilities.d.ts","../../animals/dog.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14984181202-export type Size = \"small\" | \"medium\" | \"large\";\r\nexport default interface Animal {\r\n size: Size;\r\n}\r\n","-5382672599-import Animal from './animal';\r\n\r\nexport default Animal;\r\nimport { createDog, Dog } from './dog';\r\nexport { createDog, Dog };\r\n","-11345568166-export declare function makeRandomName(): string;\nexport declare function lastElementOf(arr: T[]): T | undefined;\n","-10991948013-import Animal from '.';\r\nimport { makeRandomName } from '../core/utilities';\r\n\r\nexport interface Dog extends Animal {\r\n woof(): void;\r\n name: string;\r\n}\r\n\r\nexport function createDog(): Dog {\r\n return ({\r\n size: \"medium\",\r\n woof: function(this: Dog) {\r\n console.log(`${this.name} says \"Woof\"!`);\r\n },\r\n name: makeRandomName()\r\n });\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../animals","strict":true,"target":1},"fileIdsList":[[3,4],[2,5]],"referencedMap":[[5,1],[3,2]],"exportedModulesMap":[[5,1],[3,2]],"semanticDiagnosticsPerFile":[1,2,5,3,4]},"version":"FakeTSVersion"} //// [/user/username/projects/demo/lib/animals/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -488,6 +489,7 @@ export declare function createDog(): Dog; "noUnusedParameters": true, "outDir": "./", "rootDir": "../../animals", + "strict": true, "target": 1 }, "referencedMap": { @@ -519,7 +521,7 @@ export declare function createDog(): Dog; ] }, "version": "FakeTSVersion", - "size": 1897 + "size": 1911 } //// [/user/username/projects/demo/lib/zoo/zoo.js] @@ -541,7 +543,7 @@ export declare function createZoo(): Array; //// [/user/username/projects/demo/lib/zoo/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../animals/animal.d.ts","../animals/dog.d.ts","../animals/index.d.ts","../../zoo/zoo.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-10510161654-export declare type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}\n","6032048049-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n","1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","8797123924-import { Dog, createDog } from '../animals/index';\r\n\r\nexport function createZoo(): Array {\r\n return [\r\n createDog()\r\n ];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../zoo","target":1},"fileIdsList":[[4],[2,3]],"referencedMap":[[3,1],[4,2],[5,1]],"exportedModulesMap":[[3,1],[4,2],[5,1]],"semanticDiagnosticsPerFile":[1,2,3,4,5]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../../../../../a/lib/lib.d.ts","../animals/animal.d.ts","../animals/dog.d.ts","../animals/index.d.ts","../../zoo/zoo.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-10510161654-export declare type Size = \"small\" | \"medium\" | \"large\";\nexport default interface Animal {\n size: Size;\n}\n","6032048049-import Animal from '.';\nexport interface Dog extends Animal {\n woof(): void;\n name: string;\n}\nexport declare function createDog(): Dog;\n","1096904574-import Animal from './animal';\nexport default Animal;\nimport { createDog, Dog } from './dog';\nexport { createDog, Dog };\n","8797123924-import { Dog, createDog } from '../animals/index';\r\n\r\nexport function createZoo(): Array {\r\n return [\r\n createDog()\r\n ];\r\n}\r\n\r\n"],"options":{"composite":true,"declaration":true,"module":1,"noFallthroughCasesInSwitch":true,"noImplicitReturns":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../../zoo","strict":true,"target":1},"fileIdsList":[[4],[2,3]],"referencedMap":[[3,1],[4,2],[5,1]],"exportedModulesMap":[[3,1],[4,2],[5,1]],"semanticDiagnosticsPerFile":[1,2,3,4,5]},"version":"FakeTSVersion"} //// [/user/username/projects/demo/lib/zoo/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -595,6 +597,7 @@ export declare function createZoo(): Array; "noUnusedParameters": true, "outDir": "./", "rootDir": "../../zoo", + "strict": true, "target": 1 }, "referencedMap": { @@ -630,6 +633,6 @@ export declare function createZoo(): Array; ] }, "version": "FakeTSVersion", - "size": 1639 + "size": 1653 } diff --git a/tests/baselines/reference/tsc/incremental/initial-build/when-project-has-strict-true.js b/tests/baselines/reference/tsc/incremental/initial-build/when-project-has-strict-true.js new file mode 100644 index 0000000000000..3a5f635071b44 --- /dev/null +++ b/tests/baselines/reference/tsc/incremental/initial-build/when-project-has-strict-true.js @@ -0,0 +1,99 @@ +Input:: +//// [/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } +interface ReadonlyArray {} +declare const console: { log(msg: any): void; }; + +//// [/src/project/class1.ts] +export class class1 {} + +//// [/src/project/tsconfig.json] +{"compilerOptions":{"incremental":true,"strict":true}} + + + +Output:: +/lib/tsc -noEmit -p src/project +exitCode:: ExitStatus.Success +Program root files: ["/src/project/class1.ts"] +Program options: {"incremental":true,"strict":true,"noEmit":true,"project":"/src/project","configFilePath":"/src/project/tsconfig.json"} +Program structureReused: Not +Program files:: +/lib/lib.d.ts +/src/project/class1.ts + +Semantic diagnostics in builder refreshed for:: +/lib/lib.d.ts +/src/project/class1.ts + + +//// [/src/project/tsconfig.tsbuildinfo] +{"program":{"fileNames":["../../lib/lib.d.ts","./class1.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-7660182596-export class class1 {}"],"options":{"strict":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,2],"affectedFilesPendingEmit":[[2,1]]},"version":"FakeTSVersion"} + +//// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt] +{ + "program": { + "fileNames": [ + "../../lib/lib.d.ts", + "./class1.ts" + ], + "fileInfos": { + "../../lib/lib.d.ts": { + "version": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "signature": "3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };", + "affectsGlobalScope": true + }, + "./class1.ts": { + "version": "-7660182596-export class class1 {}", + "signature": "-7660182596-export class class1 {}" + } + }, + "options": { + "strict": true + }, + "referencedMap": {}, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "../../lib/lib.d.ts", + "./class1.ts" + ], + "affectedFilesPendingEmit": [ + [ + "./class1.ts", + "Full" + ] + ] + }, + "version": "FakeTSVersion", + "size": 757 +} + + + +Change:: no-change-run +Input:: + + +Output:: +/lib/tsc -noEmit -p src/project +exitCode:: ExitStatus.Success +Program root files: ["/src/project/class1.ts"] +Program options: {"incremental":true,"strict":true,"noEmit":true,"project":"/src/project","configFilePath":"/src/project/tsconfig.json"} +Program structureReused: Not +Program files:: +/lib/lib.d.ts +/src/project/class1.ts + +Semantic diagnostics in builder refreshed for:: + + diff --git a/tests/baselines/reference/tsc/react-jsx-emit-mode/initial-build/with-no-backing-types-found-doesn't-crash-under---strict.js b/tests/baselines/reference/tsc/react-jsx-emit-mode/initial-build/with-no-backing-types-found-doesn't-crash-under---strict.js index fd5f7b98935c6..f9618768b4635 100644 --- a/tests/baselines/reference/tsc/react-jsx-emit-mode/initial-build/with-no-backing-types-found-doesn't-crash-under---strict.js +++ b/tests/baselines/reference/tsc/react-jsx-emit-mode/initial-build/with-no-backing-types-found-doesn't-crash-under---strict.js @@ -62,7 +62,7 @@ exports.App = App; //// [/src/project/tsconfig.tsbuildinfo] -{"program":{"fileNames":["../../lib/lib.d.ts","./src/index.tsx","./node_modules/@types/react/index.d.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14760199789-export const App = () =>
;",{"version":"-16587767667-\nexport {};\ndeclare global {\n namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propA?: boolean;\n };\n }\n }\n}","affectsGlobalScope":true}],"options":{"jsx":4,"jsxImportSource":"react","module":1},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,[2,[{"file":"./src/index.tsx","start":25,"length":24,"code":7016,"category":1,"messageText":"Could not find a declaration file for module 'react/jsx-runtime'. '/src/project/node_modules/react/jsx-runtime.js' implicitly has an 'any' type."}]]]},"version":"FakeTSVersion"} +{"program":{"fileNames":["../../lib/lib.d.ts","./src/index.tsx","./node_modules/@types/react/index.d.ts"],"fileInfos":[{"version":"3858781397-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true},"-14760199789-export const App = () =>
;",{"version":"-16587767667-\nexport {};\ndeclare global {\n namespace JSX {\n interface Element {}\n interface IntrinsicElements {\n div: {\n propA?: boolean;\n };\n }\n }\n}","affectsGlobalScope":true}],"options":{"jsx":4,"jsxImportSource":"react","module":1,"strict":true},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[1,3,[2,[{"file":"./src/index.tsx","start":25,"length":24,"code":7016,"category":1,"messageText":"Could not find a declaration file for module 'react/jsx-runtime'. '/src/project/node_modules/react/jsx-runtime.js' implicitly has an 'any' type."}]]]},"version":"FakeTSVersion"} //// [/src/project/tsconfig.tsbuildinfo.readable.baseline.txt] { @@ -91,7 +91,8 @@ exports.App = App; "options": { "jsx": 4, "jsxImportSource": "react", - "module": 1 + "module": 1, + "strict": true }, "referencedMap": {}, "exportedModulesMap": {}, @@ -114,6 +115,6 @@ exports.App = App; ] }, "version": "FakeTSVersion", - "size": 1334 + "size": 1348 } From 419f1e7fe8c270d1f57d8358a0b30e1eadf5c5ce Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 16 Jun 2021 15:28:44 -0700 Subject: [PATCH 5/7] Cherry-pick PR #44070 into release-4.3 (#44187) Component commits: d1920805b0 Do not incorrectly add line separators for non-synthetic nodes when emitting node list As of 3c32f6e154ead6749b76ec9c19cbfdd2acad97d6, a line separator is added between nodes if the nodes are not synthetic and on separate lines. This it push s wrong and previously only happened if the non-synthetic nodes were on different lines but had the same parent. Fixes #44068. Co-authored-by: Paul Gschwendtner --- src/compiler/emitter.ts | 41 ++++++++++++------- src/testRunner/unittests/transform.ts | 20 +++++++++ .../decoratorOnClassMethodThisParameter.js | 3 +- ...rmNestedSelfClosingChild(jsx=react-jsx).js | 3 +- ...estedSelfClosingChild(jsx=react-jsxdev).js | 3 +- ...ndPropertiesErrorFromNotUsingIdentifier.js | 3 +- ...teralShorthandPropertiesErrorWithModule.js | 3 +- .../objectTypesWithOptionalProperties2.js | 3 +- .../parserErrorRecovery_ObjectLiteral2.js | 3 +- .../transformsCorrectly.issue44068.js | 3 ++ 10 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 tests/baselines/reference/transformApi/transformsCorrectly.issue44068.js diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index a3007559f0dd9..11ef21f1be751 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -4564,16 +4564,26 @@ namespace ts { // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines( - includeComments => getLinesBetweenRangeEndAndRangeStart( - previousNode, - nextNode, - currentSourceFile!, - includeComments)); - } - else if (!preserveSourceNewlines && !nodeIsSynthesized(previousNode) && !nodeIsSynthesized(nextNode)) { - return rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile!) ? 0 : 1; + else if (!nodeIsSynthesized(previousNode) && !nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines( + includeComments => getLinesBetweenRangeEndAndRangeStart( + previousNode, + nextNode, + currentSourceFile!, + includeComments)); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile!) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & ListFormat.PreferNewLine ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -5300,11 +5310,14 @@ namespace ts { } - function siblingNodePositionsAreComparable(previousNode: Node, nextNode: Node) { - if (nodeIsSynthesized(previousNode) || nodeIsSynthesized(nextNode)) { - return false; - } + function originalNodesHaveSameParent(nodeA: Node, nodeB: Node) { + nodeA = getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === getOriginalNode(nodeB).parent; + } + function siblingNodePositionsAreComparable(previousNode: Node, nextNode: Node) { if (nextNode.pos < previousNode.end) { return false; } diff --git a/src/testRunner/unittests/transform.ts b/src/testRunner/unittests/transform.ts index 470366d39098d..13de003fd31ca 100644 --- a/src/testRunner/unittests/transform.ts +++ b/src/testRunner/unittests/transform.ts @@ -154,6 +154,26 @@ namespace ts { }).outputText; }); + testBaseline("issue44068", () => { + return transformSourceFile(` + const FirstVar = null; + const SecondVar = null; + `, [ + context => file => { + const firstVarName = (file.statements[0] as VariableStatement) + .declarationList.declarations[0].name as Identifier; + const secondVarName = (file.statements[0] as VariableStatement) + .declarationList.declarations[0].name as Identifier; + + return context.factory.updateSourceFile(file, file.statements.concat([ + context.factory.createExpressionStatement( + context.factory.createArrayLiteralExpression([firstVarName, secondVarName]) + ), + ])); + } + ]); + }); + testBaseline("rewrittenNamespace", () => { return transpileModule(`namespace Reflect { const x = 1; }`, { transformers: { diff --git a/tests/baselines/reference/decoratorOnClassMethodThisParameter.js b/tests/baselines/reference/decoratorOnClassMethodThisParameter.js index 5feeb0ef90e36..0938ccbc4438b 100644 --- a/tests/baselines/reference/decoratorOnClassMethodThisParameter.js +++ b/tests/baselines/reference/decoratorOnClassMethodThisParameter.js @@ -30,7 +30,8 @@ var C2 = /** @class */ (function () { } C2.prototype.method = function (allowed) { }; __decorate([ - __param(0, dec), __param(1, dec) + __param(0, dec), + __param(1, dec) ], C2.prototype, "method", null); return C2; }()); diff --git a/tests/baselines/reference/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).js b/tests/baselines/reference/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).js index b7d0e0d6a9493..db697c30671d8 100644 --- a/tests/baselines/reference/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).js +++ b/tests/baselines/reference/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsx).js @@ -26,6 +26,5 @@ console.log( exports.__esModule = true; var jsx_runtime_1 = require("react/jsx-runtime"); console.log(jsx_runtime_1.jsx("div", { children: jsx_runtime_1.jsx("div", {}, void 0) }, void 0)); -console.log(jsx_runtime_1.jsxs("div", { children: [jsx_runtime_1.jsx("div", {}, void 0), - jsx_runtime_1.jsx("div", {}, void 0)] }, void 0)); +console.log(jsx_runtime_1.jsxs("div", { children: [jsx_runtime_1.jsx("div", {}, void 0), jsx_runtime_1.jsx("div", {}, void 0)] }, void 0)); console.log(jsx_runtime_1.jsx("div", { children: [1, 2].map(function (i) { return jsx_runtime_1.jsx("div", { children: i }, i); }) }, void 0)); diff --git a/tests/baselines/reference/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).js b/tests/baselines/reference/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).js index 6ddbbb35817ab..670a68b264336 100644 --- a/tests/baselines/reference/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).js +++ b/tests/baselines/reference/jsxJsxsCjsTransformNestedSelfClosingChild(jsx=react-jsxdev).js @@ -28,6 +28,5 @@ exports.__esModule = true; var jsx_dev_runtime_1 = require("react/jsx-dev-runtime"); var _jsxFileName = "tests/cases/conformance/jsx/jsxs/jsxJsxsCjsTransformNestedSelfClosingChild.tsx"; console.log(jsx_dev_runtime_1.jsxDEV("div", { children: jsx_dev_runtime_1.jsxDEV("div", {}, void 0, false, { fileName: _jsxFileName, lineNumber: 6, columnNumber: 5 }, this) }, void 0, false, { fileName: _jsxFileName, lineNumber: 4, columnNumber: 13 }, this)); -console.log(jsx_dev_runtime_1.jsxDEV("div", { children: [jsx_dev_runtime_1.jsxDEV("div", {}, void 0, false, { fileName: _jsxFileName, lineNumber: 12, columnNumber: 5 }, this), - jsx_dev_runtime_1.jsxDEV("div", {}, void 0, false, { fileName: _jsxFileName, lineNumber: 13, columnNumber: 5 }, this)] }, void 0, true, { fileName: _jsxFileName, lineNumber: 10, columnNumber: 13 }, this)); +console.log(jsx_dev_runtime_1.jsxDEV("div", { children: [jsx_dev_runtime_1.jsxDEV("div", {}, void 0, false, { fileName: _jsxFileName, lineNumber: 12, columnNumber: 5 }, this), jsx_dev_runtime_1.jsxDEV("div", {}, void 0, false, { fileName: _jsxFileName, lineNumber: 13, columnNumber: 5 }, this)] }, void 0, true, { fileName: _jsxFileName, lineNumber: 10, columnNumber: 13 }, this)); console.log(jsx_dev_runtime_1.jsxDEV("div", { children: [1, 2].map(function (i) { return jsx_dev_runtime_1.jsxDEV("div", { children: i }, i, false, { fileName: _jsxFileName, lineNumber: 19, columnNumber: 21 }, _this); }) }, void 0, false, { fileName: _jsxFileName, lineNumber: 17, columnNumber: 13 }, this)); diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.js b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.js index e0aecb5f18814..33ae1f6c8f0ee 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.js +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorFromNotUsingIdentifier.js @@ -35,7 +35,8 @@ var y = { "typeof": }; var x = (_a = { - a: a, : .b, + a: a, + : .b, a: a }, _a["ss"] = , diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorWithModule.js b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorWithModule.js index ee46d4741dd15..f48a6c3a4e5d6 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesErrorWithModule.js +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesErrorWithModule.js @@ -25,7 +25,8 @@ var n; (function (n) { var z = 10000; n.y = { - m: m, : .x // error + m: m, + : .x // error }; })(n || (n = {})); m.y.x; diff --git a/tests/baselines/reference/objectTypesWithOptionalProperties2.js b/tests/baselines/reference/objectTypesWithOptionalProperties2.js index 03d2b162847ea..284ecdea92ca7 100644 --- a/tests/baselines/reference/objectTypesWithOptionalProperties2.js +++ b/tests/baselines/reference/objectTypesWithOptionalProperties2.js @@ -42,5 +42,6 @@ var C2 = /** @class */ (function () { return C2; }()); var b = { - x: function () { }, 1: // error + x: function () { }, + 1: // error }; diff --git a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.js b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.js index 1cdf73ddadcb3..6d723a00d4a9d 100644 --- a/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.js +++ b/tests/baselines/reference/parserErrorRecovery_ObjectLiteral2.js @@ -3,5 +3,4 @@ var v = { a return; //// [parserErrorRecovery_ObjectLiteral2.js] -var v = { a: a, - "return": }; +var v = { a: a, "return": }; diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.issue44068.js b/tests/baselines/reference/transformApi/transformsCorrectly.issue44068.js new file mode 100644 index 0000000000000..493a92a6c8c40 --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.issue44068.js @@ -0,0 +1,3 @@ +const FirstVar = null; +const SecondVar = null; +[FirstVar, FirstVar]; From 89a171e3081baabd2068ecf4b059047489892a4e Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 16 Jun 2021 15:45:46 -0700 Subject: [PATCH 6/7] Cherry-pick PR #44126 into release-4.3 (#44189) Component commits: 99110e9d9d Consider inferences between mapped type templates lower priority Co-authored-by: Wesley Wigham --- src/compiler/checker.ts | 6 +- .../localTypeParameterInferencePriority.js | 58 ++++++++++++++++ ...ocalTypeParameterInferencePriority.symbols | 69 +++++++++++++++++++ .../localTypeParameterInferencePriority.types | 40 +++++++++++ .../localTypeParameterInferencePriority.ts | 20 ++++++ 5 files changed, 191 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/localTypeParameterInferencePriority.js create mode 100644 tests/baselines/reference/localTypeParameterInferencePriority.symbols create mode 100644 tests/baselines/reference/localTypeParameterInferencePriority.types create mode 100644 tests/cases/compiler/localTypeParameterInferencePriority.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a822b1d6925f1..f2571a2ca0eb1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21641,12 +21641,14 @@ namespace ts { } function inferFromIndexTypes(source: Type, target: Type) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + const priority = (getObjectFlags(source) & getObjectFlags(target) & ObjectFlags.Mapped) ? InferencePriority.HomomorphicMappedType : 0; const targetStringIndexType = getIndexTypeOfType(target, IndexKind.String); if (targetStringIndexType) { const sourceIndexType = getIndexTypeOfType(source, IndexKind.String) || getImplicitIndexTypeOfType(source, IndexKind.String); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } const targetNumberIndexType = getIndexTypeOfType(target, IndexKind.Number); @@ -21655,7 +21657,7 @@ namespace ts { getIndexTypeOfType(source, IndexKind.String) || getImplicitIndexTypeOfType(source, IndexKind.Number); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } diff --git a/tests/baselines/reference/localTypeParameterInferencePriority.js b/tests/baselines/reference/localTypeParameterInferencePriority.js new file mode 100644 index 0000000000000..5376908b924ac --- /dev/null +++ b/tests/baselines/reference/localTypeParameterInferencePriority.js @@ -0,0 +1,58 @@ +//// [localTypeParameterInferencePriority.ts] +export type UnrollOnHover = O extends object ? + { [K in keyof O]: O[K]; } : + never; + + +export type Schema = Record; +class Table { + __schema!: S; + + // Removing this line, removes the error + getRows(): Array>> { + return null! + } +} + +class ColumnSelectViewImp extends Table { } + + +const ColumnSelectView1: new () => Table> = ColumnSelectViewImp; +const ColumnSelectView2: new () => Table> = Table; + +//// [localTypeParameterInferencePriority.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var Table = /** @class */ (function () { + function Table() { + } + // Removing this line, removes the error + Table.prototype.getRows = function () { + return null; + }; + return Table; +}()); +var ColumnSelectViewImp = /** @class */ (function (_super) { + __extends(ColumnSelectViewImp, _super); + function ColumnSelectViewImp() { + return _super !== null && _super.apply(this, arguments) || this; + } + return ColumnSelectViewImp; +}(Table)); +var ColumnSelectView1 = ColumnSelectViewImp; +var ColumnSelectView2 = Table; diff --git a/tests/baselines/reference/localTypeParameterInferencePriority.symbols b/tests/baselines/reference/localTypeParameterInferencePriority.symbols new file mode 100644 index 0000000000000..aee3c8bbcc68c --- /dev/null +++ b/tests/baselines/reference/localTypeParameterInferencePriority.symbols @@ -0,0 +1,69 @@ +=== tests/cases/compiler/localTypeParameterInferencePriority.ts === +export type UnrollOnHover = O extends object ? +>UnrollOnHover : Symbol(UnrollOnHover, Decl(localTypeParameterInferencePriority.ts, 0, 0)) +>O : Symbol(O, Decl(localTypeParameterInferencePriority.ts, 0, 26)) +>O : Symbol(O, Decl(localTypeParameterInferencePriority.ts, 0, 26)) + + { [K in keyof O]: O[K]; } : +>K : Symbol(K, Decl(localTypeParameterInferencePriority.ts, 1, 7)) +>O : Symbol(O, Decl(localTypeParameterInferencePriority.ts, 0, 26)) +>O : Symbol(O, Decl(localTypeParameterInferencePriority.ts, 0, 26)) +>K : Symbol(K, Decl(localTypeParameterInferencePriority.ts, 1, 7)) + + never; + + +export type Schema = Record; +>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) + +class Table { +>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 6, 12)) +>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) + + __schema!: S; +>__schema : Symbol(Table.__schema, Decl(localTypeParameterInferencePriority.ts, 6, 32)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 6, 12)) + + // Removing this line, removes the error + getRows(): Array>> { +>getRows : Symbol(Table.getRows, Decl(localTypeParameterInferencePriority.ts, 7, 17)) +>C : Symbol(C, Decl(localTypeParameterInferencePriority.ts, 10, 12)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 6, 12)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>UnrollOnHover : Symbol(UnrollOnHover, Decl(localTypeParameterInferencePriority.ts, 0, 0)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 6, 12)) +>C : Symbol(C, Decl(localTypeParameterInferencePriority.ts, 10, 12)) + + return null! + } +} + +class ColumnSelectViewImp extends Table { } +>ColumnSelectViewImp : Symbol(ColumnSelectViewImp, Decl(localTypeParameterInferencePriority.ts, 13, 1)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 15, 26)) +>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) +>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 15, 26)) + + +const ColumnSelectView1: new () => Table> = ColumnSelectViewImp; +>ColumnSelectView1 : Symbol(ColumnSelectView1, Decl(localTypeParameterInferencePriority.ts, 18, 5)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 18, 30)) +>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) +>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) +>UnrollOnHover : Symbol(UnrollOnHover, Decl(localTypeParameterInferencePriority.ts, 0, 0)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 18, 30)) +>ColumnSelectViewImp : Symbol(ColumnSelectViewImp, Decl(localTypeParameterInferencePriority.ts, 13, 1)) + +const ColumnSelectView2: new () => Table> = Table; +>ColumnSelectView2 : Symbol(ColumnSelectView2, Decl(localTypeParameterInferencePriority.ts, 19, 5)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 19, 30)) +>Schema : Symbol(Schema, Decl(localTypeParameterInferencePriority.ts, 2, 10)) +>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) +>UnrollOnHover : Symbol(UnrollOnHover, Decl(localTypeParameterInferencePriority.ts, 0, 0)) +>S : Symbol(S, Decl(localTypeParameterInferencePriority.ts, 19, 30)) +>Table : Symbol(Table, Decl(localTypeParameterInferencePriority.ts, 5, 45)) + diff --git a/tests/baselines/reference/localTypeParameterInferencePriority.types b/tests/baselines/reference/localTypeParameterInferencePriority.types new file mode 100644 index 0000000000000..3297fc40a6f1f --- /dev/null +++ b/tests/baselines/reference/localTypeParameterInferencePriority.types @@ -0,0 +1,40 @@ +=== tests/cases/compiler/localTypeParameterInferencePriority.ts === +export type UnrollOnHover = O extends object ? +>UnrollOnHover : UnrollOnHover + + { [K in keyof O]: O[K]; } : + never; + + +export type Schema = Record; +>Schema : Schema + +class Table { +>Table : Table + + __schema!: S; +>__schema : S + + // Removing this line, removes the error + getRows(): Array>> { +>getRows : () => Array>> + + return null! +>null! : null +>null : null + } +} + +class ColumnSelectViewImp extends Table { } +>ColumnSelectViewImp : ColumnSelectViewImp +>Table : Table + + +const ColumnSelectView1: new () => Table> = ColumnSelectViewImp; +>ColumnSelectView1 : new () => Table> +>ColumnSelectViewImp : typeof ColumnSelectViewImp + +const ColumnSelectView2: new () => Table> = Table; +>ColumnSelectView2 : new () => Table> +>Table : typeof Table + diff --git a/tests/cases/compiler/localTypeParameterInferencePriority.ts b/tests/cases/compiler/localTypeParameterInferencePriority.ts new file mode 100644 index 0000000000000..c20508cc92ccb --- /dev/null +++ b/tests/cases/compiler/localTypeParameterInferencePriority.ts @@ -0,0 +1,20 @@ +export type UnrollOnHover = O extends object ? + { [K in keyof O]: O[K]; } : + never; + + +export type Schema = Record; +class Table { + __schema!: S; + + // Removing this line, removes the error + getRows(): Array>> { + return null! + } +} + +class ColumnSelectViewImp extends Table { } + + +const ColumnSelectView1: new () => Table> = ColumnSelectViewImp; +const ColumnSelectView2: new () => Table> = Table; \ No newline at end of file From 14231aff092bbdda0396654c56e84a1a2dcfd691 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Wed, 16 Jun 2021 22:59:02 +0000 Subject: [PATCH 7/7] Bump version to 4.3.3 and LKG --- lib/tsc.js | 47 ++++++++++++++++++----------- lib/tsserver.js | 62 +++++++++++++++++++++++++++----------- lib/tsserverlibrary.js | 62 +++++++++++++++++++++++++++----------- lib/typescript.js | 62 +++++++++++++++++++++++++++----------- lib/typescriptServices.js | 62 +++++++++++++++++++++++++++----------- lib/typingsInstaller.js | 62 +++++++++++++++++++++++++++----------- package.json | 2 +- src/compiler/corePublic.ts | 2 +- 8 files changed, 251 insertions(+), 110 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index 83f54758acd6c..676a6234c8d91 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -65,7 +65,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.3"; - ts.version = "4.3.2"; + ts.version = "4.3.3"; var NativeCollections; (function (NativeCollections) { function tryGetNativeMap() { @@ -23614,8 +23614,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -49122,8 +49122,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 || - node.parent.kind === 174 && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -49148,7 +49147,10 @@ var ts; return true; case 166: case 165: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -53779,12 +53781,13 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32) ? 8 : 0; var targetStringIndexType = getIndexTypeOfType(target, 0); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0) || getImplicitIndexTypeOfType(source, 0); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1); @@ -53793,7 +53796,7 @@ var ts; getIndexTypeOfType(source, 0) || getImplicitIndexTypeOfType(source, 1); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -72176,6 +72179,7 @@ var ts; case 120: case 121: case 125: + case 156: case 84: case 133: case 142: @@ -87991,11 +87995,14 @@ var ts; if (nextNode.kind === 11) { return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + return format & 65536 ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -88541,10 +88548,11 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -93180,8 +93188,11 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + optionKey === "strict" || + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/tsserver.js b/lib/tsserver.js index 58028943d1d1f..6ff08da17dfb1 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -96,7 +96,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29268,8 +29268,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37382,6 +37382,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59168,8 +59170,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59197,7 +59198,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64580,12 +64584,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64594,7 +64600,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -85910,6 +85916,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107102,11 +107109,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107746,10 +107763,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113122,8 +113142,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index ee78ce982fd11..f4f612b263875 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -290,7 +290,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29462,8 +29462,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37576,6 +37576,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59362,8 +59364,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59391,7 +59392,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64774,12 +64778,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64788,7 +64794,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -86104,6 +86110,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107296,11 +107303,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107940,10 +107957,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113316,8 +113336,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/typescript.js b/lib/typescript.js index 615ad27f3f7d9..b3f80f1a315b2 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -290,7 +290,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29462,8 +29462,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37576,6 +37576,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59362,8 +59364,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59391,7 +59392,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64774,12 +64778,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64788,7 +64794,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -86104,6 +86110,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107296,11 +107303,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107940,10 +107957,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113316,8 +113336,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 59f7d01b56ae8..78539cc744019 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -290,7 +290,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29462,8 +29462,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37576,6 +37576,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59362,8 +59364,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59391,7 +59392,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64774,12 +64778,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64788,7 +64794,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -86104,6 +86110,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107296,11 +107303,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107940,10 +107957,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113316,8 +113336,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 6810860b9c4b6..859392ce380af 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -85,7 +85,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "4.3.2"; + ts.version = "4.3.3"; /* @internal */ var Comparison; (function (Comparison) { @@ -29257,8 +29257,8 @@ var ts; visitNode(cbNode, node.typeExpression) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)) : visitNode(cbNode, node.typeExpression) || - visitNode(cbNode, node.name)) || - (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); + visitNode(cbNode, node.name) || + (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment))); case 320 /* JSDocAuthorTag */: return visitNode(cbNode, node.tagName) || (typeof node.comment === "string" ? undefined : visitNodes(cbNode, cbNodes, node.comment)); @@ -37371,6 +37371,8 @@ var ts; { name: "strict", type: "boolean", + // Though this affects semantic diagnostics, affectsSemanticDiagnostics is not set here + // The value of each strictFlag depends on own strictFlag value or this and never accessed directly. showInSimplifiedHelpView: true, category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Enable_all_strict_type_checking_options @@ -59157,8 +59159,7 @@ var ts; return type; } function maybeTypeParameterReference(node) { - return !(node.kind === 158 /* QualifiedName */ || - node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || + return !(node.parent.kind === 174 /* TypeReference */ && node.parent.typeArguments && node === node.parent.typeName || node.parent.kind === 196 /* ImportType */ && node.parent.typeArguments && node === node.parent.qualifier); } function isTypeParameterPossiblyReferenced(tp, node) { @@ -59186,7 +59187,10 @@ var ts; return true; case 166 /* MethodDeclaration */: case 165 /* MethodSignature */: - return (!node.type && !!node.body) || !!ts.forEachChild(node, containsReference); + return !node.type && !!node.body || + ts.some(node.typeParameters, containsReference) || + ts.some(node.parameters, containsReference) || + !!node.type && containsReference(node.type); } return !!ts.forEachChild(node, containsReference); } @@ -64569,12 +64573,14 @@ var ts; applyToReturnTypes(source, target, inferFromTypes); } function inferFromIndexTypes(source, target) { + // Inferences across mapped type index signatures are pretty much the same a inferences to homomorphic variables + var priority = (ts.getObjectFlags(source) & ts.getObjectFlags(target) & 32 /* Mapped */) ? 8 /* HomomorphicMappedType */ : 0; var targetStringIndexType = getIndexTypeOfType(target, 0 /* String */); if (targetStringIndexType) { var sourceIndexType = getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 0 /* String */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetStringIndexType); + inferWithPriority(sourceIndexType, targetStringIndexType, priority); } } var targetNumberIndexType = getIndexTypeOfType(target, 1 /* Number */); @@ -64583,7 +64589,7 @@ var ts; getIndexTypeOfType(source, 0 /* String */) || getImplicitIndexTypeOfType(source, 1 /* Number */); if (sourceIndexType) { - inferFromTypes(sourceIndexType, targetNumberIndexType); + inferWithPriority(sourceIndexType, targetNumberIndexType, priority); } } } @@ -85899,6 +85905,7 @@ var ts; case 120 /* PrivateKeyword */: case 121 /* ProtectedKeyword */: case 125 /* AbstractKeyword */: + case 156 /* OverrideKeyword */: case 84 /* ConstKeyword */: case 133 /* DeclareKeyword */: case 142 /* ReadonlyKeyword */: @@ -107091,11 +107098,21 @@ var ts; // JsxText will be written with its leading whitespace, so don't add more manually. return 0; } - else if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { - return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); - } - else if (!preserveSourceNewlines && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { - return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) { + if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) { + return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); }); + } + // If `preserveSourceNewlines` is `false` we do not intend to preserve the effective lines between the + // previous and next node. Instead we naively check whether nodes are on separate lines within the + // same node parent. If so, we intend to preserve a single line terminator. This is less precise and + // expensive than checking with `preserveSourceNewlines` as above, but the goal is not to preserve the + // effective source lines between two sibling nodes. + else if (!preserveSourceNewlines && originalNodesHaveSameParent(previousNode, nextNode)) { + return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1; + } + // If the two nodes are not comparable, add a line terminator based on the format that can indicate + // whether new lines are preferred or not. + return format & 65536 /* PreferNewLine */ ? 1 : 0; } else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) { return 1; @@ -107735,10 +107752,13 @@ var ts; } exitComment(); } + function originalNodesHaveSameParent(nodeA, nodeB) { + nodeA = ts.getOriginalNode(nodeA); + // For performance, do not call `getOriginalNode` for `nodeB` if `nodeA` doesn't even + // have a parent node. + return nodeA.parent && nodeA.parent === ts.getOriginalNode(nodeB).parent; + } function siblingNodePositionsAreComparable(previousNode, nextNode) { - if (ts.nodeIsSynthesized(previousNode) || ts.nodeIsSynthesized(nextNode)) { - return false; - } if (nextNode.pos < previousNode.end) { return false; } @@ -113111,8 +113131,14 @@ var ts; var optionsNameMap = ts.getOptionsNameMap().optionsNameMap; for (var _i = 0, _a = ts.getOwnKeys(options).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) { var name = _a[_i]; - var optionInfo = optionsNameMap.get(name.toLowerCase()); - if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || name === "skipLibCheck" || name === "skipDefaultLibCheck") { + var optionKey = name.toLowerCase(); + var optionInfo = optionsNameMap.get(optionKey); + if ((optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsEmit) || (optionInfo === null || optionInfo === void 0 ? void 0 : optionInfo.affectsSemanticDiagnostics) || + // We need to store `strict`, even though it won't be examined directly, so that the + // flags it controls (e.g. `strictNullChecks`) will be retrieved correctly from the buildinfo + optionKey === "strict" || + // We need to store these to determine whether `lib` files need to be rechecked. + optionKey === "skiplibcheck" || optionKey === "skipdefaultlibcheck") { (result || (result = {}))[name] = convertToReusableCompilerOptionValue(optionInfo, options[name], relativeToBuildInfo); } } diff --git a/package.json b/package.json index 2f3518663a299..0f515e9766e5d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.3.2", + "version": "4.3.3", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index ec1ec375ff1d3..8d3e8d5c8a4d7 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -5,7 +5,7 @@ namespace ts { // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - export const version = "4.3.2" as string; + export const version = "4.3.3" as string; /** * Type of objects whose values are all of the same type.