From 52a9cfb0a9de3f0c0f36a77bb976330a0a57f6df Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 6 Feb 2019 14:23:49 -0800 Subject: [PATCH 01/64] Infer to partially homomorphic mapped types (such as Pick) --- src/compiler/checker.ts | 45 ++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ce06e84b2fd26..aa5007065fc8e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14570,11 +14570,24 @@ namespace ts { return undefined; } - function inferFromMappedTypeConstraint(source: Type, target: Type, constraintType: Type): boolean { + function inferToHomomorphicMappedType(source: Type, target: MappedType, constraintType: IndexType) { + const inference = getInferenceInfoForType(constraintType.type); + if (inference && !inference.isFixed) { + const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + const savePriority = priority; + priority |= InferencePriority.HomomorphicMappedType; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } + } + + function inferToMappedType(source: Type, target: MappedType, constraintType: Type): boolean { if (constraintType.flags & TypeFlags.Union) { let result = false; for (const type of (constraintType as UnionType).types) { - result = inferFromMappedTypeConstraint(source, target, type) || result; + result = inferToMappedType(source, target, type) || result; } return result; } @@ -14583,31 +14596,31 @@ namespace ts { // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference // such that direct inferences to T get priority over inferences to Partial, for example. - const inference = getInferenceInfoForType((constraintType).type); - if (inference && !inference.isFixed) { - const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType as IndexType); - if (inferredType) { - const savePriority = priority; - priority |= InferencePriority.HomomorphicMappedType; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } + inferToHomomorphicMappedType(source, target, constraintType); return true; } if (constraintType.flags & TypeFlags.TypeParameter) { - // We're inferring from some source type S to a mapped type { [P in T]: X }, where T is a type - // parameter. Infer from 'keyof S' to T and infer from a union of each property type in S to X. + // We're inferring from some source type S to a mapped type { [P in K]: X }, where K is a type + // parameter. First infer from 'keyof S' to K. const savePriority = priority; priority |= InferencePriority.MappedTypeConstraint; inferFromTypes(getIndexType(source), constraintType); priority = savePriority; + // If K is constrained to an index type keyof T, where T is a type parameter, proceed to make + // the same inferences as we would for a homomorphic mapped type { [P in keyof T]: X } (this + // enables us to make meaningful inferences when the target is a Pick). Otherwise, infer + // from a union of the property types in the source to the template type X. + const extendedConstraint = getConstraintOfType(constraintType); + if (extendedConstraint && extendedConstraint.flags & TypeFlags.Index) { + inferToHomomorphicMappedType(source, target, extendedConstraint); + return true; + } const valueTypes = compact([ getIndexTypeOfType(source, IndexKind.String), getIndexTypeOfType(source, IndexKind.Number), ...map(getPropertiesOfType(source), getTypeOfSymbol) ]); - inferFromTypes(getUnionType(valueTypes), getTemplateTypeFromMappedType(target)); + inferFromTypes(getUnionType(valueTypes), getTemplateTypeFromMappedType(target)); return true; } return false; @@ -14622,7 +14635,7 @@ namespace ts { } if (getObjectFlags(target) & ObjectFlags.Mapped) { const constraintType = getConstraintTypeFromMappedType(target); - if (inferFromMappedTypeConstraint(source, target, constraintType)) { + if (inferToMappedType(source, target, constraintType)) { return; } } From 62c62f4f87bfcf96e3f0e0500b453187b39f3c89 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 6 Feb 2019 15:41:43 -0800 Subject: [PATCH 02/64] Add tests --- .../mapped/isomorphicMappedTypeInference.ts | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts b/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts index 14bb765a84011..534d50c367e12 100644 --- a/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts +++ b/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts @@ -152,4 +152,27 @@ var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } }); const foo = (object: T, partial: Partial) => object; let o = {a: 5, b: 7}; foo(o, {b: 9}); -o = foo(o, {b: 9}); \ No newline at end of file +o = foo(o, {b: 9}); + +// Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as +// inferring to { [P in keyof T]: X }. + +declare function f20(obj: Pick): T; +declare function f21(obj: Pick): K; +declare function f22(obj: Boxified>): T; + +let x0 = f20({ foo: 42, bar: "hello" }); +let x1 = f21({ foo: 42, bar: "hello" }); +let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); + +// Repro from #29765 + +function getProps(obj: T, list: K[]): Pick { + return {} as any; +} + +const myAny: any = {}; + +const o1 = getProps(myAny, ['foo', 'bar']); + +const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); From 262e3c1ae294cef6e1075fa53a4d60481c700494 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 6 Feb 2019 15:41:51 -0800 Subject: [PATCH 03/64] Accept new baselines --- .../isomorphicMappedTypeInference.js | 55 +++++++++++- .../isomorphicMappedTypeInference.symbols | 90 +++++++++++++++++++ .../isomorphicMappedTypeInference.types | 85 ++++++++++++++++++ 3 files changed, 229 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.js b/tests/baselines/reference/isomorphicMappedTypeInference.js index 589122444323a..6cfc2ec7350da 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.js +++ b/tests/baselines/reference/isomorphicMappedTypeInference.js @@ -149,7 +149,31 @@ var g2 = applySpec({ foo: { bar: { baz: (x: any) => true } } }); const foo = (object: T, partial: Partial) => object; let o = {a: 5, b: 7}; foo(o, {b: 9}); -o = foo(o, {b: 9}); +o = foo(o, {b: 9}); + +// Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as +// inferring to { [P in keyof T]: X }. + +declare function f20(obj: Pick): T; +declare function f21(obj: Pick): K; +declare function f22(obj: Boxified>): T; + +let x0 = f20({ foo: 42, bar: "hello" }); +let x1 = f21({ foo: 42, bar: "hello" }); +let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); + +// Repro from #29765 + +function getProps(obj: T, list: K[]): Pick { + return {} as any; +} + +const myAny: any = {}; + +const o1 = getProps(myAny, ['foo', 'bar']); + +const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); + //// [isomorphicMappedTypeInference.js] function box(x) { @@ -255,6 +279,16 @@ var foo = function (object, partial) { return object; }; var o = { a: 5, b: 7 }; foo(o, { b: 9 }); o = foo(o, { b: 9 }); +var x0 = f20({ foo: 42, bar: "hello" }); +var x1 = f21({ foo: 42, bar: "hello" }); +var x2 = f22({ foo: { value: 42 }, bar: { value: "hello" } }); +// Repro from #29765 +function getProps(obj, list) { + return {}; +} +var myAny = {}; +var o1 = getProps(myAny, ['foo', 'bar']); +var o2 = getProps(myAny, ['foo', 'bar']); //// [isomorphicMappedTypeInference.d.ts] @@ -323,3 +357,22 @@ declare let o: { a: number; b: number; }; +declare function f20(obj: Pick): T; +declare function f21(obj: Pick): K; +declare function f22(obj: Boxified>): T; +declare let x0: { + foo: number; + bar: string; +}; +declare let x1: "foo" | "bar"; +declare let x2: { + foo: number; + bar: string; +}; +declare function getProps(obj: T, list: K[]): Pick; +declare const myAny: any; +declare const o1: Pick; +declare const o2: { + foo: any; + bar: any; +}; diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.symbols b/tests/baselines/reference/isomorphicMappedTypeInference.symbols index d36ebc7a4a517..6f999f91dc439 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.symbols +++ b/tests/baselines/reference/isomorphicMappedTypeInference.symbols @@ -486,3 +486,93 @@ o = foo(o, {b: 9}); >o : Symbol(o, Decl(isomorphicMappedTypeInference.ts, 148, 3)) >b : Symbol(b, Decl(isomorphicMappedTypeInference.ts, 150, 12)) +// Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as +// inferring to { [P in keyof T]: X }. + +declare function f20(obj: Pick): T; +>f20 : Symbol(f20, Decl(isomorphicMappedTypeInference.ts, 150, 19)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 155, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 155, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 155, 21)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 155, 43)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 155, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 155, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 155, 21)) + +declare function f21(obj: Pick): K; +>f21 : Symbol(f21, Decl(isomorphicMappedTypeInference.ts, 155, 63)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 156, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 156, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 156, 21)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 156, 43)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 156, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 156, 23)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 156, 23)) + +declare function f22(obj: Boxified>): T; +>f22 : Symbol(f22, Decl(isomorphicMappedTypeInference.ts, 156, 63)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 157, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 157, 43)) +>Boxified : Symbol(Boxified, Decl(isomorphicMappedTypeInference.ts, 2, 1)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 157, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) + +let x0 = f20({ foo: 42, bar: "hello" }); +>x0 : Symbol(x0, Decl(isomorphicMappedTypeInference.ts, 159, 3)) +>f20 : Symbol(f20, Decl(isomorphicMappedTypeInference.ts, 150, 19)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 159, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 159, 23)) + +let x1 = f21({ foo: 42, bar: "hello" }); +>x1 : Symbol(x1, Decl(isomorphicMappedTypeInference.ts, 160, 3)) +>f21 : Symbol(f21, Decl(isomorphicMappedTypeInference.ts, 155, 63)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 160, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 160, 23)) + +let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); +>x2 : Symbol(x2, Decl(isomorphicMappedTypeInference.ts, 161, 3)) +>f22 : Symbol(f22, Decl(isomorphicMappedTypeInference.ts, 156, 63)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 161, 14)) +>value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 161, 21)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 161, 34)) +>value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 161, 41)) + +// Repro from #29765 + +function getProps(obj: T, list: K[]): Pick { +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 165, 40)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) +>list : Symbol(list, Decl(isomorphicMappedTypeInference.ts, 165, 47)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) + + return {} as any; +} + +const myAny: any = {}; +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) + +const o1 = getProps(myAny, ['foo', 'bar']); +>o1 : Symbol(o1, Decl(isomorphicMappedTypeInference.ts, 171, 5)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) + +const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); +>o2 : Symbol(o2, Decl(isomorphicMappedTypeInference.ts, 173, 5)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 173, 11)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 173, 21)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) + diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.types b/tests/baselines/reference/isomorphicMappedTypeInference.types index 4488fa27daf6c..b37175b5eed28 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.types +++ b/tests/baselines/reference/isomorphicMappedTypeInference.types @@ -507,3 +507,88 @@ o = foo(o, {b: 9}); >b : number >9 : 9 +// Inferring to { [P in K]: X }, where K extends keyof T, produces same inferences as +// inferring to { [P in keyof T]: X }. + +declare function f20(obj: Pick): T; +>f20 : (obj: Pick) => T +>obj : Pick + +declare function f21(obj: Pick): K; +>f21 : (obj: Pick) => K +>obj : Pick + +declare function f22(obj: Boxified>): T; +>f22 : (obj: Boxified>) => T +>obj : Boxified> + +let x0 = f20({ foo: 42, bar: "hello" }); +>x0 : { foo: number; bar: string; } +>f20({ foo: 42, bar: "hello" }) : { foo: number; bar: string; } +>f20 : (obj: Pick) => T +>{ foo: 42, bar: "hello" } : { foo: number; bar: string; } +>foo : number +>42 : 42 +>bar : string +>"hello" : "hello" + +let x1 = f21({ foo: 42, bar: "hello" }); +>x1 : "foo" | "bar" +>f21({ foo: 42, bar: "hello" }) : "foo" | "bar" +>f21 : (obj: Pick) => K +>{ foo: 42, bar: "hello" } : { foo: number; bar: string; } +>foo : number +>42 : 42 +>bar : string +>"hello" : "hello" + +let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); +>x2 : { foo: number; bar: string; } +>f22({ foo: { value: 42} , bar: { value: "hello" } }) : { foo: number; bar: string; } +>f22 : (obj: Boxified>) => T +>{ foo: { value: 42} , bar: { value: "hello" } } : { foo: { value: number; }; bar: { value: string; }; } +>foo : { value: number; } +>{ value: 42} : { value: number; } +>value : number +>42 : 42 +>bar : { value: string; } +>{ value: "hello" } : { value: string; } +>value : string +>"hello" : "hello" + +// Repro from #29765 + +function getProps(obj: T, list: K[]): Pick { +>getProps : (obj: T, list: K[]) => Pick +>obj : T +>list : K[] + + return {} as any; +>{} as any : any +>{} : {} +} + +const myAny: any = {}; +>myAny : any +>{} : {} + +const o1 = getProps(myAny, ['foo', 'bar']); +>o1 : Pick +>getProps(myAny, ['foo', 'bar']) : Pick +>getProps : (obj: T, list: K[]) => Pick +>myAny : any +>['foo', 'bar'] : ("foo" | "bar")[] +>'foo' : "foo" +>'bar' : "bar" + +const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); +>o2 : { foo: any; bar: any; } +>foo : any +>bar : any +>getProps(myAny, ['foo', 'bar']) : Pick +>getProps : (obj: T, list: K[]) => Pick +>myAny : any +>['foo', 'bar'] : ("foo" | "bar")[] +>'foo' : "foo" +>'bar' : "bar" + From bc386c11fd3f026ca84ec556b1b8fb4a2eee0038 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 7 Feb 2019 13:35:07 -0800 Subject: [PATCH 04/64] Use execFileSync in typing installer --- .../unittests/tsserver/typingsInstaller.ts | 12 ++++++------ src/typingsInstaller/nodeTypingsInstaller.ts | 16 ++++++++-------- src/typingsInstallerCore/typingsInstaller.ts | 17 ++++++++++++----- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/testRunner/unittests/tsserver/typingsInstaller.ts b/src/testRunner/unittests/tsserver/typingsInstaller.ts index 76df9934682fd..5d648ba23a20a 100644 --- a/src/testRunner/unittests/tsserver/typingsInstaller.ts +++ b/src/testRunner/unittests/tsserver/typingsInstaller.ts @@ -1684,9 +1684,9 @@ namespace ts.projectSystem { TI.getNpmCommandForInstallation(npmPath, tsVersion, packageNames, packageNames.length - Math.ceil(packageNames.length / 2)).command ]; it("works when the command is too long to install all packages at once", () => { - const commands: string[] = []; - const hasError = TI.installNpmPackages(npmPath, tsVersion, packageNames, command => { - commands.push(command); + const commands: [string, string[]][] = []; + const hasError = TI.installNpmPackages(npmPath, tsVersion, packageNames, (file, args) => { + commands.push([file, args]); return false; }); assert.isFalse(hasError); @@ -1694,9 +1694,9 @@ namespace ts.projectSystem { }); it("installs remaining packages when one of the partial command fails", () => { - const commands: string[] = []; - const hasError = TI.installNpmPackages(npmPath, tsVersion, packageNames, command => { - commands.push(command); + const commands: [string, string[]][] = []; + const hasError = TI.installNpmPackages(npmPath, tsVersion, packageNames, (file, args) => { + commands.push([file, args]); return commands.length === 1; }); assert.isTrue(hasError); diff --git a/src/typingsInstaller/nodeTypingsInstaller.ts b/src/typingsInstaller/nodeTypingsInstaller.ts index 62bdcfce2603b..1d75218c88323 100644 --- a/src/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/typingsInstaller/nodeTypingsInstaller.ts @@ -70,10 +70,10 @@ namespace ts.server.typingsInstaller { cwd: string; encoding: "utf-8"; } - type ExecSync = (command: string, options: ExecSyncOptions) => string; + type ExecFileSync = (file: string, args: string[], options: ExecSyncOptions) => string; export class NodeTypingsInstaller extends TypingsInstaller { - private readonly nodeExecSync: ExecSync; + private readonly nodeExecFileSync: ExecFileSync; private readonly npmPath: string; readonly typesRegistry: Map>; @@ -97,7 +97,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`Process id: ${process.pid}`); this.log.writeLine(`NPM location: ${this.npmPath} (explicit '${Arguments.NpmLocation}' ${npmLocation === undefined ? "not " : ""} provided)`); } - ({ execSync: this.nodeExecSync } = require("child_process")); + ({ execFileSync: this.nodeExecFileSync } = require("child_process")); this.ensurePackageDirectoryExists(globalTypingsCacheLocation); @@ -105,7 +105,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Updating ${typesRegistryPackageName} npm package...`); } - this.execSyncAndLog(`${this.npmPath} install --ignore-scripts ${typesRegistryPackageName}@${this.latestDistTag}`, { cwd: globalTypingsCacheLocation }); + this.execFileSyncAndLog(this.npmPath, ["install", "--ignore-scripts", `${typesRegistryPackageName}@${this.latestDistTag}`], { cwd: globalTypingsCacheLocation }); if (this.log.isEnabled()) { this.log.writeLine(`Updated ${typesRegistryPackageName} npm package`); } @@ -189,7 +189,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`#${requestId} with arguments'${JSON.stringify(packageNames)}'.`); } const start = Date.now(); - const hasError = installNpmPackages(this.npmPath, version, packageNames, command => this.execSyncAndLog(command, { cwd })); + const hasError = installNpmPackages(this.npmPath, version, packageNames, (file, args) => this.execFileSyncAndLog(file, args, { cwd })); if (this.log.isEnabled()) { this.log.writeLine(`npm install #${requestId} took: ${Date.now() - start} ms`); } @@ -197,12 +197,12 @@ namespace ts.server.typingsInstaller { } /** Returns 'true' in case of error. */ - private execSyncAndLog(command: string, options: Pick): boolean { + private execFileSyncAndLog(file: string, args: string[], options: Pick): boolean { if (this.log.isEnabled()) { - this.log.writeLine(`Exec: ${command}`); + this.log.writeLine(`Exec: ${file} ${args.join(" ")}`); } try { - const stdout = this.nodeExecSync(command, { ...options, encoding: "utf-8" }); + const stdout = this.nodeExecFileSync(file, args, { ...options, encoding: "utf-8" }); if (this.log.isEnabled()) { this.log.writeLine(` Succeeded. stdout:${indent(sys.newLine, stdout)}`); } diff --git a/src/typingsInstallerCore/typingsInstaller.ts b/src/typingsInstallerCore/typingsInstaller.ts index df83f1a677c39..3d0858d7dfe34 100644 --- a/src/typingsInstallerCore/typingsInstaller.ts +++ b/src/typingsInstallerCore/typingsInstaller.ts @@ -31,28 +31,35 @@ namespace ts.server.typingsInstaller { } /*@internal*/ - export function installNpmPackages(npmPath: string, tsVersion: string, packageNames: string[], install: (command: string) => boolean) { + export function installNpmPackages(npmPath: string, tsVersion: string, packageNames: string[], install: (file: string, args: string[]) => boolean) { let hasError = false; for (let remaining = packageNames.length; remaining > 0;) { const result = getNpmCommandForInstallation(npmPath, tsVersion, packageNames, remaining); remaining = result.remaining; - hasError = install(result.command) || hasError; + hasError = install(result.command[0], result.command[1]) || hasError; } return hasError; } + function getUserAgent(tsVersion: string) { + return `--user-agent="typesInstaller/${tsVersion}"`; + } + const npmInstall = "install", ignoreScripts = "--ignore-scripts", saveDev = "--save-dev"; + const commandBaseLength = npmInstall.length + ignoreScripts.length + saveDev.length + getUserAgent("").length + 5; /*@internal*/ export function getNpmCommandForInstallation(npmPath: string, tsVersion: string, packageNames: string[], remaining: number) { const sliceStart = packageNames.length - remaining; - let command: string, toSlice = remaining; + let packages: string[], toSlice = remaining; while (true) { - command = `${npmPath} install --ignore-scripts ${(toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" ")} --save-dev --user-agent="typesInstaller/${tsVersion}"`; - if (command.length < 8000) { + packages = toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice); + const commandLength = npmPath.length + commandBaseLength + packages.join(" ").length + tsVersion.length; + if (commandLength < 8000) { break; } toSlice = toSlice - Math.floor(toSlice / 2); } + const command: [string, string[]] = [npmPath, [npmInstall, ignoreScripts, ...packages, saveDev, getUserAgent(tsVersion)]]; return { command, remaining: remaining - toSlice }; } From f46c0a45979669daf2067c3990bf604a7d35dcaf Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Feb 2019 06:49:13 -0800 Subject: [PATCH 05/64] Process more complex constraints as per CR feedback --- src/compiler/checker.ts | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aa5007065fc8e..bdb645a00036a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14570,19 +14570,8 @@ namespace ts { return undefined; } - function inferToHomomorphicMappedType(source: Type, target: MappedType, constraintType: IndexType) { - const inference = getInferenceInfoForType(constraintType.type); - if (inference && !inference.isFixed) { - const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); - if (inferredType) { - const savePriority = priority; - priority |= InferencePriority.HomomorphicMappedType; - inferFromTypes(inferredType, inference.typeParameter); - priority = savePriority; - } - } - } - + // target: { [P in 'a' | 'b' | keyof T | keyof U]: XXX } + // source: { a: xxx, b: xxx, c: xxx, d: xxx } function inferToMappedType(source: Type, target: MappedType, constraintType: Type): boolean { if (constraintType.flags & TypeFlags.Union) { let result = false; @@ -14596,7 +14585,16 @@ namespace ts { // where T is a type variable. Use inferTypeForHomomorphicMappedType to infer a suitable source // type and then make a secondary inference from that type to T. We make a secondary inference // such that direct inferences to T get priority over inferences to Partial, for example. - inferToHomomorphicMappedType(source, target, constraintType); + const inference = getInferenceInfoForType((constraintType).type); + if (inference && !inference.isFixed) { + const inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType); + if (inferredType) { + const savePriority = priority; + priority |= InferencePriority.HomomorphicMappedType; + inferFromTypes(inferredType, inference.typeParameter); + priority = savePriority; + } + } return true; } if (constraintType.flags & TypeFlags.TypeParameter) { @@ -14606,15 +14604,16 @@ namespace ts { priority |= InferencePriority.MappedTypeConstraint; inferFromTypes(getIndexType(source), constraintType); priority = savePriority; - // If K is constrained to an index type keyof T, where T is a type parameter, proceed to make - // the same inferences as we would for a homomorphic mapped type { [P in keyof T]: X } (this - // enables us to make meaningful inferences when the target is a Pick). Otherwise, infer - // from a union of the property types in the source to the template type X. + // If K is constrained to a type C, also infer to C. Thus, for a mapped type { [P in K]: X }, + // where K extends keyof T, we make the same inferences as for a homomorphic mapped type + // { [P in keyof T]: X }. This enables us to make meaningful inferences when the target is a + // Pick. const extendedConstraint = getConstraintOfType(constraintType); - if (extendedConstraint && extendedConstraint.flags & TypeFlags.Index) { - inferToHomomorphicMappedType(source, target, extendedConstraint); + if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) { return true; } + // If no inferences can be made to K's constraint, infer from a union of the property types + // in the source to the template type X. const valueTypes = compact([ getIndexTypeOfType(source, IndexKind.String), getIndexTypeOfType(source, IndexKind.Number), From e49320d1db82ae4e281914ab3b6c4d101da4e16d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Feb 2019 06:49:26 -0800 Subject: [PATCH 06/64] Add more tests --- .../conformance/types/mapped/isomorphicMappedTypeInference.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts b/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts index 534d50c367e12..031cf840d33f4 100644 --- a/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts +++ b/tests/cases/conformance/types/mapped/isomorphicMappedTypeInference.ts @@ -160,10 +160,14 @@ o = foo(o, {b: 9}); declare function f20(obj: Pick): T; declare function f21(obj: Pick): K; declare function f22(obj: Boxified>): T; +declare function f23(obj: Pick): T; +declare function f24(obj: Pick): T & U; let x0 = f20({ foo: 42, bar: "hello" }); let x1 = f21({ foo: 42, bar: "hello" }); let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); +let x3 = f23({ foo: 42, bar: "hello" }); +let x4 = f24({ foo: 42, bar: "hello" }); // Repro from #29765 From 8652158ead4af506a604d70ad80becba7ddccea9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Feb 2019 06:49:33 -0800 Subject: [PATCH 07/64] Accept new baselines --- .../isomorphicMappedTypeInference.js | 19 ++++ .../isomorphicMappedTypeInference.symbols | 100 ++++++++++++------ .../isomorphicMappedTypeInference.types | 28 +++++ 3 files changed, 117 insertions(+), 30 deletions(-) diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.js b/tests/baselines/reference/isomorphicMappedTypeInference.js index 6cfc2ec7350da..aa904e9afa173 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.js +++ b/tests/baselines/reference/isomorphicMappedTypeInference.js @@ -157,10 +157,14 @@ o = foo(o, {b: 9}); declare function f20(obj: Pick): T; declare function f21(obj: Pick): K; declare function f22(obj: Boxified>): T; +declare function f23(obj: Pick): T; +declare function f24(obj: Pick): T & U; let x0 = f20({ foo: 42, bar: "hello" }); let x1 = f21({ foo: 42, bar: "hello" }); let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); +let x3 = f23({ foo: 42, bar: "hello" }); +let x4 = f24({ foo: 42, bar: "hello" }); // Repro from #29765 @@ -282,6 +286,8 @@ o = foo(o, { b: 9 }); var x0 = f20({ foo: 42, bar: "hello" }); var x1 = f21({ foo: 42, bar: "hello" }); var x2 = f22({ foo: { value: 42 }, bar: { value: "hello" } }); +var x3 = f23({ foo: 42, bar: "hello" }); +var x4 = f24({ foo: 42, bar: "hello" }); // Repro from #29765 function getProps(obj, list) { return {}; @@ -360,6 +366,8 @@ declare let o: { declare function f20(obj: Pick): T; declare function f21(obj: Pick): K; declare function f22(obj: Boxified>): T; +declare function f23(obj: Pick): T; +declare function f24(obj: Pick): T & U; declare let x0: { foo: number; bar: string; @@ -369,6 +377,17 @@ declare let x2: { foo: number; bar: string; }; +declare let x3: { + foo: number; + bar: string; +}; +declare let x4: { + foo: number; + bar: string; +} & { + foo: number; + bar: string; +}; declare function getProps(obj: T, list: K[]): Pick; declare const myAny: any; declare const o1: Pick; diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.symbols b/tests/baselines/reference/isomorphicMappedTypeInference.symbols index 6f999f91dc439..3192be13ff634 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.symbols +++ b/tests/baselines/reference/isomorphicMappedTypeInference.symbols @@ -523,56 +523,96 @@ declare function f22(obj: Boxified>): T; >K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 157, 23)) >T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 157, 21)) +declare function f23(obj: Pick): T; +>f23 : Symbol(f23, Decl(isomorphicMappedTypeInference.ts, 157, 73)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 158, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 158, 23)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 158, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 158, 42)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 158, 23)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 158, 56)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 158, 21)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 158, 42)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 158, 21)) + +declare function f24(obj: Pick): T & U; +>f24 : Symbol(f24, Decl(isomorphicMappedTypeInference.ts, 158, 76)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 159, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 159, 23)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 159, 26)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 159, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 159, 23)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 159, 56)) +>Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 159, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 159, 23)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 159, 26)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 159, 21)) +>U : Symbol(U, Decl(isomorphicMappedTypeInference.ts, 159, 23)) + let x0 = f20({ foo: 42, bar: "hello" }); ->x0 : Symbol(x0, Decl(isomorphicMappedTypeInference.ts, 159, 3)) +>x0 : Symbol(x0, Decl(isomorphicMappedTypeInference.ts, 161, 3)) >f20 : Symbol(f20, Decl(isomorphicMappedTypeInference.ts, 150, 19)) ->foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 159, 14)) ->bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 159, 23)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 161, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 161, 23)) let x1 = f21({ foo: 42, bar: "hello" }); ->x1 : Symbol(x1, Decl(isomorphicMappedTypeInference.ts, 160, 3)) +>x1 : Symbol(x1, Decl(isomorphicMappedTypeInference.ts, 162, 3)) >f21 : Symbol(f21, Decl(isomorphicMappedTypeInference.ts, 155, 63)) ->foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 160, 14)) ->bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 160, 23)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 162, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 162, 23)) let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); ->x2 : Symbol(x2, Decl(isomorphicMappedTypeInference.ts, 161, 3)) +>x2 : Symbol(x2, Decl(isomorphicMappedTypeInference.ts, 163, 3)) >f22 : Symbol(f22, Decl(isomorphicMappedTypeInference.ts, 156, 63)) ->foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 161, 14)) ->value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 161, 21)) ->bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 161, 34)) ->value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 161, 41)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 163, 14)) +>value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 163, 21)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 163, 34)) +>value : Symbol(value, Decl(isomorphicMappedTypeInference.ts, 163, 41)) + +let x3 = f23({ foo: 42, bar: "hello" }); +>x3 : Symbol(x3, Decl(isomorphicMappedTypeInference.ts, 164, 3)) +>f23 : Symbol(f23, Decl(isomorphicMappedTypeInference.ts, 157, 73)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 164, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 164, 23)) + +let x4 = f24({ foo: 42, bar: "hello" }); +>x4 : Symbol(x4, Decl(isomorphicMappedTypeInference.ts, 165, 3)) +>f24 : Symbol(f24, Decl(isomorphicMappedTypeInference.ts, 158, 76)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 165, 14)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 165, 23)) // Repro from #29765 function getProps(obj: T, list: K[]): Pick { ->getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) ->T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) ->K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) ->T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) ->obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 165, 40)) ->T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) ->list : Symbol(list, Decl(isomorphicMappedTypeInference.ts, 165, 47)) ->K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 165, 40)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 169, 18)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 169, 20)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 169, 18)) +>obj : Symbol(obj, Decl(isomorphicMappedTypeInference.ts, 169, 40)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 169, 18)) +>list : Symbol(list, Decl(isomorphicMappedTypeInference.ts, 169, 47)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 169, 20)) >Pick : Symbol(Pick, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 165, 18)) ->K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 165, 20)) +>T : Symbol(T, Decl(isomorphicMappedTypeInference.ts, 169, 18)) +>K : Symbol(K, Decl(isomorphicMappedTypeInference.ts, 169, 20)) return {} as any; } const myAny: any = {}; ->myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 173, 5)) const o1 = getProps(myAny, ['foo', 'bar']); ->o1 : Symbol(o1, Decl(isomorphicMappedTypeInference.ts, 171, 5)) ->getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) ->myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) +>o1 : Symbol(o1, Decl(isomorphicMappedTypeInference.ts, 175, 5)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 165, 40)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 173, 5)) const o2: { foo: any; bar: any } = getProps(myAny, ['foo', 'bar']); ->o2 : Symbol(o2, Decl(isomorphicMappedTypeInference.ts, 173, 5)) ->foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 173, 11)) ->bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 173, 21)) ->getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 161, 62)) ->myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 169, 5)) +>o2 : Symbol(o2, Decl(isomorphicMappedTypeInference.ts, 177, 5)) +>foo : Symbol(foo, Decl(isomorphicMappedTypeInference.ts, 177, 11)) +>bar : Symbol(bar, Decl(isomorphicMappedTypeInference.ts, 177, 21)) +>getProps : Symbol(getProps, Decl(isomorphicMappedTypeInference.ts, 165, 40)) +>myAny : Symbol(myAny, Decl(isomorphicMappedTypeInference.ts, 173, 5)) diff --git a/tests/baselines/reference/isomorphicMappedTypeInference.types b/tests/baselines/reference/isomorphicMappedTypeInference.types index b37175b5eed28..1f1fa0d200a0c 100644 --- a/tests/baselines/reference/isomorphicMappedTypeInference.types +++ b/tests/baselines/reference/isomorphicMappedTypeInference.types @@ -522,6 +522,14 @@ declare function f22(obj: Boxified>): T; >f22 : (obj: Boxified>) => T >obj : Boxified> +declare function f23(obj: Pick): T; +>f23 : (obj: Pick) => T +>obj : Pick + +declare function f24(obj: Pick): T & U; +>f24 : (obj: Pick) => T & U +>obj : Pick + let x0 = f20({ foo: 42, bar: "hello" }); >x0 : { foo: number; bar: string; } >f20({ foo: 42, bar: "hello" }) : { foo: number; bar: string; } @@ -556,6 +564,26 @@ let x2 = f22({ foo: { value: 42} , bar: { value: "hello" } }); >value : string >"hello" : "hello" +let x3 = f23({ foo: 42, bar: "hello" }); +>x3 : { foo: number; bar: string; } +>f23({ foo: 42, bar: "hello" }) : { foo: number; bar: string; } +>f23 : (obj: Pick) => T +>{ foo: 42, bar: "hello" } : { foo: number; bar: string; } +>foo : number +>42 : 42 +>bar : string +>"hello" : "hello" + +let x4 = f24({ foo: 42, bar: "hello" }); +>x4 : { foo: number; bar: string; } & { foo: number; bar: string; } +>f24({ foo: 42, bar: "hello" }) : { foo: number; bar: string; } & { foo: number; bar: string; } +>f24 : (obj: Pick) => T & U +>{ foo: 42, bar: "hello" } : { foo: number; bar: string; } +>foo : number +>42 : 42 +>bar : string +>"hello" : "hello" + // Repro from #29765 function getProps(obj: T, list: K[]): Pick { From 040401205ba51d036b9ec234ff2f2341ceac96b9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 8 Feb 2019 06:53:39 -0800 Subject: [PATCH 08/64] Delete wayward comment --- src/compiler/checker.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bdb645a00036a..b550710861c72 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14570,8 +14570,6 @@ namespace ts { return undefined; } - // target: { [P in 'a' | 'b' | keyof T | keyof U]: XXX } - // source: { a: xxx, b: xxx, c: xxx, d: xxx } function inferToMappedType(source: Type, target: MappedType, constraintType: Type): boolean { if (constraintType.flags & TypeFlags.Union) { let result = false; From 61a05018cba05d223aee07432a697fe316d5ed36 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Fri, 8 Feb 2019 10:49:28 -0800 Subject: [PATCH 09/64] Update user baselines (#29800) --- .../user/chrome-devtools-frontend.log | 274 +++++++++++++++--- tests/baselines/reference/user/npm.log | 4 +- 2 files changed, 232 insertions(+), 46 deletions(-) diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 7ae2531d38396..3c86f06756a2b 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -1,16 +1,16 @@ Exit Code: 1 Standard output: -../../../../built/local/lib.dom.d.ts(2388,11): error TS2300: Duplicate identifier 'CSSRule'. -../../../../built/local/lib.dom.d.ts(2407,13): error TS2300: Duplicate identifier 'CSSRule'. -../../../../built/local/lib.dom.d.ts(3267,11): error TS2300: Duplicate identifier 'Comment'. -../../../../built/local/lib.dom.d.ts(3270,13): error TS2300: Duplicate identifier 'Comment'. -../../../../built/local/lib.dom.d.ts(4963,11): error TS2300: Duplicate identifier 'Event'. -../../../../built/local/lib.dom.d.ts(5023,13): error TS2300: Duplicate identifier 'Event'. -../../../../built/local/lib.dom.d.ts(11214,11): error TS2300: Duplicate identifier 'Position'. -../../../../built/local/lib.dom.d.ts(11959,11): error TS2300: Duplicate identifier 'Request'. -../../../../built/local/lib.dom.d.ts(12039,13): error TS2300: Duplicate identifier 'Request'. -../../../../built/local/lib.dom.d.ts(16513,11): error TS2300: Duplicate identifier 'Window'. -../../../../built/local/lib.dom.d.ts(16644,13): error TS2300: Duplicate identifier 'Window'. +../../../../built/local/lib.dom.d.ts(2439,11): error TS2300: Duplicate identifier 'CSSRule'. +../../../../built/local/lib.dom.d.ts(2458,13): error TS2300: Duplicate identifier 'CSSRule'. +../../../../built/local/lib.dom.d.ts(3339,11): error TS2300: Duplicate identifier 'Comment'. +../../../../built/local/lib.dom.d.ts(3342,13): error TS2300: Duplicate identifier 'Comment'. +../../../../built/local/lib.dom.d.ts(5032,11): error TS2300: Duplicate identifier 'Event'. +../../../../built/local/lib.dom.d.ts(5092,13): error TS2300: Duplicate identifier 'Event'. +../../../../built/local/lib.dom.d.ts(11453,11): error TS2300: Duplicate identifier 'Position'. +../../../../built/local/lib.dom.d.ts(12214,11): error TS2300: Duplicate identifier 'Request'. +../../../../built/local/lib.dom.d.ts(12294,13): error TS2300: Duplicate identifier 'Request'. +../../../../built/local/lib.dom.d.ts(16941,11): error TS2300: Duplicate identifier 'Window'. +../../../../built/local/lib.dom.d.ts(17073,13): error TS2300: Duplicate identifier 'Window'. ../../../../built/local/lib.es5.d.ts(1416,11): error TS2300: Duplicate identifier 'ArrayLike'. ../../../../built/local/lib.es5.d.ts(1452,6): error TS2300: Duplicate identifier 'Record'. ../../../../node_modules/@types/node/index.d.ts(150,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'module' must be of type '{}', but here has type 'NodeModule'. @@ -158,7 +158,7 @@ node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(391,50): error TS2345: Argument of type '0' is not assignable to parameter of type 'string'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(393,50): error TS2345: Argument of type '-1' is not assignable to parameter of type 'string'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(396,27): error TS2339: Property 'focus' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(447,26): error TS2339: Property 'breadcrumb' does not exist on type 'Node'. +node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(447,26): error TS2339: Property 'breadcrumb' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(457,30): error TS2339: Property 'breadcrumb' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(473,24): error TS2694: Namespace 'Protocol' has no exported member 'Accessibility'. node_modules/chrome-devtools-frontend/front_end/accessibility/AXBreadcrumbsPane.js(481,17): error TS2339: Property 'setTextContentTruncatedIfNeeded' does not exist on type 'Element'. @@ -699,10 +699,6 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9093,1): error TS2554: Expected 0-2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9117,1): error TS2554: Expected 0-2 arguments, but got 3. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9467,15): error TS2339: Property 'axe' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9708,34): error TS2345: Argument of type 'any[][]' is not assignable to parameter of type 'readonly [any, any][]'. - Type 'any[]' is missing the following properties from type '[any, any]': 0, 1 -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9948,10): error TS2693: 'ShadowRoot' only refers to a type, but is being used as a value here. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(9969,4): error TS2693: 'ShadowRoot' only refers to a type, but is being used as a value here. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10092,16): error TS2304: Cannot find name 'd41d8cd98f00b204e9800998ecf8427e_LibraryDetectorTests'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10513,19): error TS2488: Type 'NodeListOf' must have a '[Symbol.iterator]()' method that returns an iterator. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(10811,19): error TS2304: Cannot find name 'getElementsInDocument'. @@ -3981,7 +3977,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(107,9) node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(111,9): error TS2339: Property 'ConsoleSidebar' does not exist on type '{ new (): Console; prototype: Console; }'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(119,47): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(122,25): error TS2345: Argument of type 'Element' is not assignable to parameter of type 'Icon'. - Type 'Element' is missing the following properties from type 'Icon': createdCallback, _descriptor, _spriteSheet, _iconType, and 116 more. + Type 'Element' is missing the following properties from type 'Icon': createdCallback, _descriptor, _spriteSheet, _iconType, and 117 more. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(133,9): error TS2339: Property 'ConsoleSidebar' does not exist on type '{ new (): Console; prototype: Console; }'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(147,27): error TS2322: Type 'Element' is not assignable to type 'Icon'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleSidebar.js(177,60): error TS2555: Expected at least 2 arguments, but got 1. @@ -5065,8 +5061,6 @@ node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(25 node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(253,61): error TS2339: Property 'host' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(254,17): error TS2339: Property 'host' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(261,16): error TS2339: Property 'getComponentSelection' does not exist on type 'Node'. -node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(265,28): error TS2693: 'ShadowRoot' only refers to a type, but is being used as a value here. -node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(265,48): error TS2339: Property 'getSelection' does not exist on type 'Node & ParentNode'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(265,70): error TS2339: Property 'window' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(271,16): error TS2339: Property 'hasSelection' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(273,23): error TS2339: Property 'querySelectorAll' does not exist on type 'Node'. @@ -5149,7 +5143,7 @@ node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(74 node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(745,48): error TS2339: Property 'pageX' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(745,60): error TS2339: Property 'pageY' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(753,20): error TS2339: Property 'deepElementFromPoint' does not exist on type 'Document'. -node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(761,5): error TS2740: Type 'ShadowRoot' is missing the following properties from type 'Document': URL, alinkColor, all, anchors, and 169 more. +node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(761,5): error TS2740: Type 'ShadowRoot' is missing the following properties from type 'Document': URL, alinkColor, all, anchors, and 174 more. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(766,28): error TS2339: Property 'deepElementFromPoint' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(766,70): error TS2339: Property 'deepElementFromPoint' does not exist on type 'Document'. node_modules/chrome-devtools-frontend/front_end/dom_extension/DOMExtension.js(771,20): error TS2339: Property 'deepActiveElement' does not exist on type 'Document'. @@ -5367,7 +5361,7 @@ node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js( node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(575,10): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(576,10): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(580,10): error TS2339: Property 'scrollIntoViewIfNeeded' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(592,20): error TS2339: Property 'classList' does not exist on type 'Node'. +node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(592,20): error TS2339: Property 'classList' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(600,41): error TS2339: Property 'isAncestor' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(632,27): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(655,26): error TS2339: Property 'getComponentSelection' does not exist on type 'Element'. @@ -5377,7 +5371,6 @@ node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js( node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(738,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(739,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(762,13): error TS2339: Property 'style' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(763,7): error TS2739: Type 'Node' is missing the following properties from type 'ChildNode': after, before, remove, replaceWith node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(767,32): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(772,10): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(796,24): error TS2339: Property 'setMultilineEditing' does not exist on type 'TreeOutline'. @@ -5385,7 +5378,6 @@ node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js( node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(803,60): error TS2339: Property 'visibleWidth' does not exist on type 'TreeOutline'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(828,34): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(832,15): error TS2339: Property 'style' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(833,9): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(837,26): error TS2339: Property 'setMultilineEditing' does not exist on type 'TreeOutline'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(851,18): error TS2339: Property 'altKey' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeElement.js(851,35): error TS2339: Property 'shiftKey' does not exist on type 'Event'. @@ -5466,7 +5458,7 @@ node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js( node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(755,33): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(758,36): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(813,22): error TS2339: Property 'index' does not exist on type 'DOMNode'. -node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(920,9): error TS2740: Type 'Node & ParentNode' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 63 more. +node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(920,9): error TS2740: Type 'Node & ParentNode' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 64 more. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(930,13): error TS2339: Property 'type' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(1010,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/elements/ElementsTreeOutline.js(1025,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -5658,14 +5650,13 @@ node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(10 node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1040,69): error TS2339: Property 'selectorText' does not exist on type 'CSSRule'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1055,24): error TS2339: Property '_section' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1056,29): error TS2339: Property '_section' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1057,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1073,24): error TS2339: Property '_section' does not exist on type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1074,29): error TS2339: Property '_section' does not exist on type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1075,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1087,7): error TS2740: Type 'Node' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 71 more. +node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1075,7): error TS2739: Type 'Node' is missing the following properties from type 'ChildNode': after, before, remove, replaceWith +node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1087,7): error TS2740: Type 'ChildNode' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 68 more. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1088,38): error TS2339: Property '_section' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1090,36): error TS2339: Property '_section' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1099,7): error TS2322: Type 'Node' is not assignable to type 'Element'. +node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1099,7): error TS2740: Type 'Node' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 72 more. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1100,38): error TS2339: Property '_section' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1102,36): error TS2339: Property '_section' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(1106,22): error TS2694: Namespace 'Common' has no exported member 'Event'. @@ -6143,7 +6134,6 @@ node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(13 node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(161,5): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(219,43): error TS2694: Namespace 'Protocol' has no exported member 'Network'. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(244,54): error TS2339: Property 'traverseNextNode' does not exist on type 'HTMLElement'. -node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(245,27): error TS2693: 'ShadowRoot' only refers to a type, but is being used as a value here. node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(463,53): error TS2345: Argument of type '{ url: string; type: string; }' is not assignable to parameter of type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }'. Type '{ url: string; type: string; }' is missing the following properties from type '{ contentURL(): string; contentType(): ResourceType; contentEncoded(): Promise; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }': contentURL, contentType, contentEncoded, requestContent, searchInContent node_modules/chrome-devtools-frontend/front_end/extensions/ExtensionServer.js(471,22): error TS2339: Property 'valuesArray' does not exist on type 'Map; requestContent(): Promise; searchInContent(query: string, caseSensitive: boolean, isRegex: boolean): Promise<...>; }>'. @@ -6927,7 +6917,6 @@ node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(852 node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(858,13): error TS2339: Property 'image' does not exist on type 'WebGLTexture'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(861,81): error TS2339: Property 'image' does not exist on type 'WebGLTexture'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(928,26): error TS2694: Namespace 'SDK' has no exported member 'SnapshotWithRect'. -node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(932,39): error TS2345: Argument of type 'any[][]' is not assignable to parameter of type 'readonly [any, any][]'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1080,24): error TS2694: Namespace 'Protocol' has no exported member 'DOM'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1098,15): error TS2304: Cannot find name 'CSSMatrix'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(1143,19): error TS2694: Namespace 'SDK' has no exported member 'SnapshotWithRect'. @@ -8059,8 +8048,8 @@ node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(189,25): node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(196,23): error TS2339: Property '_labelElement' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(199,15): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(200,23): error TS2339: Property 'style' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(210,7): error TS2322: Type 'Node' is not assignable to type 'Element'. -node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(215,7): error TS2322: Type 'Node' is not assignable to type 'Element'. +node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(210,7): error TS2322: Type 'ChildNode' is not assignable to type 'Element'. +node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(215,7): error TS2322: Type 'ChildNode' is not assignable to type 'Element'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(267,21): error TS2339: Property 'DividersData' does not exist on type 'typeof TimelineGrid'. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(277,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/perf_ui/TimelineGrid.js(284,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -8343,7 +8332,212 @@ node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(34,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(55,41): error TS2694: Namespace 'ProductRegistry.Registry' has no exported member 'ProductEntry'. node_modules/chrome-devtools-frontend/front_end/product_registry/ProductRegistry.js(72,26): error TS2339: Property 'ProductEntry' does not exist on type 'typeof Registry'. -node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1488,1): error TS2590: Expression produces a union type that is too complex to represent. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1559,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1563,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1604,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1605,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1606,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(1865,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2136,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2136,64): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2136,86): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2208,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2269,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2270,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2322,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2323,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2503,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2856,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2857,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2858,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2859,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2860,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2861,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2862,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2863,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2864,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(2865,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3126,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3572,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3573,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3574,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3575,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3576,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3747,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3748,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3770,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3771,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3772,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3773,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3774,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3775,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3776,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3780,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3819,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3826,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3873,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3874,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3957,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(3958,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4068,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4069,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4138,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4139,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4203,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4230,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4260,104): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4264,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4265,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4266,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4312,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4480,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4832,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4833,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4834,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(4835,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5127,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5137,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5159,70): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5175,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5186,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5202,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5249,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5522,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5523,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5524,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5525,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5539,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5565,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5612,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5613,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5614,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5615,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5616,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5617,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5618,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5619,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5684,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5789,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5820,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5852,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5858,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5859,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5860,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5970,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5971,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(5972,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6145,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6151,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6152,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6153,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6154,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6180,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6181,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6182,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6183,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6184,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6185,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6186,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6187,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6193,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6194,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6195,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6196,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6197,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6198,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6199,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6217,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6218,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6225,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6227,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6228,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6229,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6230,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6231,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6232,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6233,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6243,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6270,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6272,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6276,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6294,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6296,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6297,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6298,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6299,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6300,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6303,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6305,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6323,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6324,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6325,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6326,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6327,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6333,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6334,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6335,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6336,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6337,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6338,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6339,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6340,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6341,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6342,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6343,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6344,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6345,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6346,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6347,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6348,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6349,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6350,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6351,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6360,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6361,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6362,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6363,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6364,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6365,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6369,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6382,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6388,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6389,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6404,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6405,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6406,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6425,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6441,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6442,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6445,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6481,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6521,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6560,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6573,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6574,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6575,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6576,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6577,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6578,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6579,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6580,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6581,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6582,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6583,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6615,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6620,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6629,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6637,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6661,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6668,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6675,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6689,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6690,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6699,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6726,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6735,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6737,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6738,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. +node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryData.js(6741,42): error TS2741: Property 'type' is missing in type '{ "product": number; }' but required in type '{ product: number; type: number; }'. node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryImpl.js(27,41): error TS2694: Namespace 'ProductRegistry.Registry' has no exported member 'ProductEntry'. node_modules/chrome-devtools-frontend/front_end/product_registry_impl/ProductRegistryImpl.js(103,67): error TS2694: Namespace 'ProductRegistry.Registry' has no exported member 'ProductEntry'. node_modules/chrome-devtools-frontend/front_end/profiler/BottomUpProfileDataGrid.js(83,15): error TS2339: Property '_remainingNodeInfos' does not exist on type 'ProfileDataGridNode'. @@ -8772,8 +8966,6 @@ node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(57,23): node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(78,46): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(79,46): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(80,45): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(84,17): error TS2345: Argument of type '(string | Element)[][]' is not assignable to parameter of type 'readonly [any, any][]'. - Type '(string | Element)[]' is missing the following properties from type '[any, any]': 0, 1 node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(136,59): error TS2339: Property 'profile' does not exist on type 'ProfileView'. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(136,78): error TS2339: Property 'adjustedTotal' does not exist on type 'ProfileView'. node_modules/chrome-devtools-frontend/front_end/profiler/ProfileView.js(147,59): error TS2339: Property 'profile' does not exist on type 'ProfileView'. @@ -10730,7 +10922,6 @@ node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(54,59): node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(73,28): error TS2339: Property 'setSearchRegex' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(80,23): error TS2339: Property 'setSearchRegex' does not exist on type 'TreeElement'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(223,35): error TS2339: Property 'childElementCount' does not exist on type 'Node'. -node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(242,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(290,24): error TS2339: Property 'tagName' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(296,31): error TS2339: Property 'attributes' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/source_frame/XMLView.js(305,20): error TS2339: Property 'childElementCount' does not exist on type 'Node'. @@ -10860,8 +11051,6 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(80,71): error TS2339: Property 'uiLocation' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(81,60): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(82,62): error TS2339: Property 'breakpoint' does not exist on type 'V'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(87,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(92,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(119,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(141,29): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(156,33): error TS2339: Property 'checkboxElement' does not exist on type 'EventTarget'. @@ -11345,8 +11534,6 @@ node_modules/chrome-devtools-frontend/front_end/sources_test_runner/SourcesTestR node_modules/chrome-devtools-frontend/front_end/sources_test_runner/SourcesTestRunner.js(129,11): error TS2339: Property 'pushAll' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/terminal/TerminalWidget.js(29,54): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/terminal/TerminalWidget.js(30,65): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/terminal/TerminalWidget.js(139,9): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. -node_modules/chrome-devtools-frontend/front_end/terminal/TerminalWidget.js(146,7): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/addons/fit/fit.js(19,34): error TS2307: Cannot find module '../../xterm'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/addons/fit/fit.js(20,21): error TS2304: Cannot find name 'define'. node_modules/chrome-devtools-frontend/front_end/terminal/xterm.js/addons/fit/fit.js(24,5): error TS2304: Cannot find name 'define'. @@ -11500,7 +11687,6 @@ node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(683,28 node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(717,24): error TS2694: Namespace 'TestRunner' has no exported member 'CustomFormatters'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(748,24): error TS2694: Namespace 'TestRunner' has no exported member 'CustomFormatters'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(777,22): error TS2339: Property 'attributes' does not exist on type 'Node'. -node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(783,46): error TS2322: Type 'Node' is not assignable to type 'ChildNode'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(785,14): error TS2339: Property 'shadowRoot' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(786,39): error TS2339: Property 'shadowRoot' does not exist on type 'Node'. node_modules/chrome-devtools-frontend/front_end/test_runner/TestRunner.js(805,12): error TS2339: Property 'shadowRoot' does not exist on type 'Node'. @@ -11742,7 +11928,7 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.j node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(246,68): error TS2339: Property 'peekLast' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(248,81): error TS2339: Property '_overviewIndex' does not exist on type 'TimelineCategory'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(384,7): error TS2322: Type 'Promise HTMLImageElement>' is not assignable to type 'Promise'. - Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'HTMLImageElement': align, alt, border, complete, and 259 more. + Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'HTMLImageElement': align, alt, border, complete, and 261 more. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(457,17): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(483,24): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(524,28): error TS2339: Property 'peekLast' does not exist on type 'TimelineFrame[]'. @@ -12252,7 +12438,7 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1652 node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1657,64): error TS2345: Argument of type 'new (width?: number, height?: number) => HTMLImageElement' is not assignable to parameter of type 'Node'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1664,11): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1665,67): error TS2555: Expected at least 2 arguments, but got 1. -node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1675,5): error TS2740: Type 'DocumentFragment' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 63 more. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1675,5): error TS2740: Type 'DocumentFragment' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 64 more. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1684,30): error TS2339: Property 'millisToString' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1685,16): error TS2339: Property 'millisToString' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineUIUtils.js(1687,13): error TS2339: Property 'createTextChild' does not exist on type 'Element'. @@ -13027,7 +13213,7 @@ node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(592,35): error node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(601,32): error TS2339: Property 'isAncestor' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(610,54): error TS2339: Property 'isAncestor' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(622,35): error TS2339: Property 'getComponentSelection' does not exist on type 'Element'. -node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(627,7): error TS2740: Type 'ChildNode' is missing the following properties from type 'Element': assignedSlot, attributes, classList, className, and 67 more. +node_modules/chrome-devtools-frontend/front_end/ui/TextPrompt.js(627,7): error TS2322: Type 'ChildNode' is not assignable to type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/Toolbar.js(43,50): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/Toolbar.js(48,45): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/ui/Toolbar.js(75,24): error TS2694: Namespace 'Common' has no exported member 'Event'. diff --git a/tests/baselines/reference/user/npm.log b/tests/baselines/reference/user/npm.log index 91a408b91d7c1..525a1007870f2 100644 --- a/tests/baselines/reference/user/npm.log +++ b/tests/baselines/reference/user/npm.log @@ -802,9 +802,9 @@ node_modules/npm/lib/utils/error-handler.js(146,27): error TS2339: Property 'con node_modules/npm/lib/utils/error-handler.js(166,14): error TS2339: Property 'code' does not exist on type 'Error'. node_modules/npm/lib/utils/error-handler.js(167,16): error TS2339: Property 'code' does not exist on type 'Error'. node_modules/npm/lib/utils/error-handler.js(168,8): error TS2339: Property 'code' does not exist on type 'Error'. -node_modules/npm/lib/utils/error-handler.js(186,40): error TS2345: Argument of type '{ (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | ... 1 more ... | undefined): string; }' is not assignable to parameter of type '(value: string, index: number, array: string[]) => string'. +node_modules/npm/lib/utils/error-handler.js(186,40): error TS2345: Argument of type '{ (value: any, replacer?: ((this: any, key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | ... 1 more ... | undefined): string; }' is not assignable to parameter of type '(value: string, index: number, array: string[]) => string'. Types of parameters 'replacer' and 'index' are incompatible. - Type 'number' is not assignable to type '((key: string, value: any) => any) | undefined'. + Type 'number' is not assignable to type '((this: any, key: string, value: any) => any) | undefined'. node_modules/npm/lib/utils/error-handler.js(188,33): error TS2339: Property 'version' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/utils/error-handler.js(205,11): error TS2339: Property 'config' does not exist on type 'typeof EventEmitter'. node_modules/npm/lib/utils/error-handler.js(208,18): error TS2339: Property 'code' does not exist on type 'Error'. From bbf559b9c7fd21b984d7cb538140c74e3d6a6b45 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Fri, 8 Feb 2019 11:03:58 -0800 Subject: [PATCH 10/64] Update user baselines (#29826) --- .../reference/user/chrome-devtools-frontend.log | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 3c86f06756a2b..55c189a92d6a0 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -3751,6 +3751,7 @@ node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(152,25): err node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(161,25): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(211,34): error TS2339: Property 'asParsedURL' does not exist on type 'string'. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(215,29): error TS2339: Property 'asParsedURL' does not exist on type 'string'. +node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(318,32): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/common/ParsedURL.js(375,18): error TS2339: Property 'asParsedURL' does not exist on type 'String'. node_modules/chrome-devtools-frontend/front_end/common/SegmentedRange.js(48,37): error TS2339: Property 'lowerBound' does not exist on type 'Segment[]'. node_modules/chrome-devtools-frontend/front_end/common/Settings.js(49,10): error TS2339: Property 'runtime' does not exist on type 'Window'. @@ -3902,6 +3903,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.j node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(192,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(200,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(255,28): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. +node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(256,27): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(257,31): error TS2339: Property 'createChild' does not exist on type 'DocumentFragment'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(264,13): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleContextSelector.js(279,14): error TS2555: Expected at least 2 arguments, but got 1. @@ -4180,6 +4182,7 @@ node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(70 node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(733,19): error TS2339: Property 'removeChildren' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(735,35): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(736,31): error TS2555: Expected at least 2 arguments, but got 1. +node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(750,27): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(803,34): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(804,31): error TS2339: Property 'style' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/console/ConsoleViewMessage.js(806,43): error TS2339: Property 'style' does not exist on type 'Element'. @@ -4517,6 +4520,7 @@ node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(98,48): er node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(109,26): error TS2352: Conversion of type 'DataGridNode' to type 'NODE_TYPE' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(121,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(123,17): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. +node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(134,29): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(135,15): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(139,15): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/data_grid/DataGrid.js(159,33): error TS2694: Namespace 'DataGrid.DataGrid' has no exported member 'ColumnDescriptor'. @@ -7751,6 +7755,7 @@ node_modules/chrome-devtools-frontend/front_end/object_ui/JavaScriptAutocomplete node_modules/chrome-devtools-frontend/front_end/object_ui/JavaScriptAutocomplete.js(471,33): error TS2339: Property 'CompletionGroup' does not exist on type 'typeof JavaScriptAutocomplete'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(82,35): error TS2694: Namespace 'SDK.DebuggerModel' has no exported member 'FunctionDetails'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(91,29): error TS2339: Property 'createChild' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(108,23): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(114,48): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(129,7): error TS2722: Cannot invoke an object which is possibly 'undefined'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPopoverHelper.js(145,50): error TS2339: Property 'createChild' does not exist on type 'Element'. @@ -7763,6 +7768,7 @@ node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSectio node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(181,18): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(207,22): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(209,22): error TS2339: Property 'createTextChild' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(209,38): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(211,22): error TS2339: Property 'createTextChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(263,20): error TS2339: Property 'title' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/object_ui/ObjectPropertiesSection.js(268,22): error TS2339: Property 'setTextContentTruncatedIfNeeded' does not exist on type 'Element'. @@ -8242,6 +8248,7 @@ node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(125,15): e node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(125,39): error TS2339: Property 'regexSpecialCharacters' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(132,8): error TS2339: Property 'filterRegex' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(133,27): error TS2339: Property 'regexSpecialCharacters' does not exist on type 'StringConstructor'. +node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(198,1): error TS2322: Type '(maxLength: number) => string' is not assignable to type '() => string'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(250,8): error TS2339: Property 'hashCode' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(275,8): error TS2339: Property 'isDigitAt' does not exist on type 'StringConstructor'. node_modules/chrome-devtools-frontend/front_end/platform/utilities.js(320,8): error TS2339: Property 'naturalOrderComparator' does not exist on type 'StringConstructor'. @@ -11052,6 +11059,7 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(81,60): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(82,62): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(119,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. +node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(131,38): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(141,29): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(156,33): error TS2339: Property 'checkboxElement' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(159,11): error TS2339: Property 'consume' does not exist on type 'Event'. @@ -13399,6 +13407,7 @@ node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1561,11): error TS node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1562,17): error TS2339: Property 'value' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1570,25): error TS2339: Property 'value' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1574,11): error TS2339: Property 'value' does not exist on type 'Element'. +node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1633,64): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1646,40): error TS2339: Property '_textWidthCache' does not exist on type '(context: CanvasRenderingContext2D, text: string) => number'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1649,25): error TS2339: Property '_textWidthCache' does not exist on type '(context: CanvasRenderingContext2D, text: string) => number'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1715,20): error TS2339: Property 'type' does not exist on type 'Element'. From 1aca1dd036928ce56173bb93e4478af6b28b464a Mon Sep 17 00:00:00 2001 From: Matt McCutchen Date: Wed, 10 Oct 2018 19:30:50 -0400 Subject: [PATCH 11/64] Make the assignability rule for conditional types require the check types and distributivity to be identical. Fixes #27118. --- src/compiler/checker.ts | 9 +- .../reference/conditionalTypes2.errors.txt | 122 +-- .../baselines/reference/conditionalTypes2.js | 121 +-- .../reference/conditionalTypes2.symbols | 870 +++++++++--------- .../reference/conditionalTypes2.types | 115 +-- .../types/conditional/conditionalTypes2.ts | 57 +- 6 files changed, 607 insertions(+), 687 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7cc72c534d05..2d7c65fdde0a3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12693,10 +12693,11 @@ namespace ts { else if (source.flags & TypeFlags.Conditional) { if (target.flags & TypeFlags.Conditional) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if - // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, - // and Y1 is related to Y2. - if (isTypeIdenticalTo((source).extendsType, (target).extendsType) && - (isRelatedTo((source).checkType, (target).checkType) || isRelatedTo((target).checkType, (source).checkType))) { + // they have the same distributivity, T1 and T2 are identical types, U1 and U2 are identical + // types, X1 is related to X2, and Y1 is related to Y2. + if ((source).root.isDistributive === (target).root.isDistributive && + isTypeIdenticalTo((source).extendsType, (target).extendsType) && + isTypeIdenticalTo((source).checkType, (target).checkType)) { if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index a1a23b6da1870..343a0a8412cfb 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -1,29 +1,38 @@ -tests/cases/conformance/types/conditional/conditionalTypes2.ts(15,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(19,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(24,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(16,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Types of property 'foo' are incompatible. + Type 'B extends string ? B : number' is not assignable to type 'A extends string ? A : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(17,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Types of property 'foo' are incompatible. + Type 'A extends string ? A : number' is not assignable to type 'B extends string ? B : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(21,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Types of property 'foo' are incompatible. + Type 'B extends string ? keyof B : number' is not assignable to type 'A extends string ? keyof A : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(22,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Types of property 'foo' are incompatible. + Type 'A extends string ? keyof A : number' is not assignable to type 'B extends string ? keyof B : number'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(26,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. - Type 'keyof B' is not assignable to type 'keyof A'. - Type 'string | number | symbol' is not assignable to type 'keyof A'. - Type 'string' is not assignable to type 'keyof A'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(27,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(73,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(74,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(76,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(77,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. Type 'T extends Bar ? T : never' is not assignable to type '{ foo: string; bat: string; }'. Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(165,5): error TS2322: Type 'MyElement' is not assignable to type 'MyElement'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(170,5): error TS2322: Type 'MyAcceptor' is not assignable to type 'MyAcceptor'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2322: Type 'Dist' is not assignable to type 'Aux<{ a: T; }>'. -==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (7 errors) ==== +==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (12 errors) ==== + // #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -37,19 +46,29 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error + ~ +!!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'B extends string ? B : number' is not assignable to type 'A extends string ? A : number'. b = a; // Error ~ !!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'A extends string ? A : number' is not assignable to type 'B extends string ? B : number'. } function f2(a: Contravariant, b: Contravariant) { a = b; // Error ~ !!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. - b = a; +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'B extends string ? keyof B : number' is not assignable to type 'A extends string ? keyof A : number'. + b = a; // Error + ~ +!!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'A extends string ? keyof A : number' is not assignable to type 'B extends string ? keyof B : number'. } function f3(a: Invariant, b: Invariant) { @@ -58,15 +77,11 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. -!!! error TS2322: Type 'keyof B' is not assignable to type 'keyof A'. -!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'keyof A'. -!!! error TS2322: Type 'string' is not assignable to type 'keyof A'. b = a; // Error ~ !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. } // Extract is a T that is known to be a Function @@ -120,13 +135,13 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. !!! error TS2345: Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. fooBat(y); // Error ~ !!! error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. fooBat(z); // Error ~ !!! error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. @@ -134,38 +149,6 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2345: Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. } - // Repros from #22860 - - class Opt { - toVector(): Vector { - return undefined; - } - } - - interface Seq { - tail(): Opt>; - } - - class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } - } - - interface A1 { - bat: B1>; - } - - interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true - } - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -246,4 +229,29 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + + // Repros from #27118 + + type MyElement = [A] extends [[infer E]] ? E : never; + function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'MyElement' is not assignable to type 'MyElement'. + } + + type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; + function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'MyAcceptor' is not assignable to type 'MyAcceptor'. + } + + type Dist = T extends number ? number : string; + type Aux = A["a"] extends number ? number : string; + type Nondist = Aux<{a: T}>; + function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error + ~~~~~~~~~~~ +!!! error TS2322: Type 'Dist' is not assignable to type 'Aux<{ a: T; }>'. + } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes2.js b/tests/baselines/reference/conditionalTypes2.js index 4f4f35e821afb..c59c996711dfb 100644 --- a/tests/baselines/reference/conditionalTypes2.js +++ b/tests/baselines/reference/conditionalTypes2.js @@ -1,4 +1,6 @@ //// [conditionalTypes2.ts] +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -12,13 +14,13 @@ interface Invariant { } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error b = a; // Error } function f2(a: Contravariant, b: Contravariant) { a = b; // Error - b = a; + b = a; // Error } function f3(a: Invariant, b: Invariant) { @@ -76,38 +78,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E fooBat(z); // Error } -// Repros from #22860 - -class Opt { - toVector(): Vector { - return undefined; - } -} - -interface Seq { - tail(): Opt>; -} - -class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } -} - -interface A1 { - bat: B1>; -} - -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -188,17 +158,37 @@ type ProductComplementComplement = { }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error +} + +type Dist = T extends number ? number : string; +type Aux = A["a"] extends number ? number : string; +type Nondist = Aux<{a: T}>; +function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error +} //// [conditionalTypes2.js] "use strict"; +// #27118: Conditional types are now invariant in the check type. function f1(a, b) { - a = b; + a = b; // Error b = a; // Error } function f2(a, b) { a = b; // Error - b = a; + b = a; // Error } function f3(a, b) { a = b; // Error @@ -239,32 +229,21 @@ function f21(x, y, z) { fooBat(y); // Error fooBat(z); // Error } -// Repros from #22860 -var Opt = /** @class */ (function () { - function Opt() { - } - Opt.prototype.toVector = function () { - return undefined; - }; - return Opt; -}()); -var Vector = /** @class */ (function () { - function Vector() { - } - Vector.prototype.tail = function () { - return undefined; - }; - Vector.prototype.partition2 = function (predicate) { - return undefined; - }; - return Vector; -}()); function foo(value) { if (isFunction(value)) { toString1(value); toString2(value); } } +function oops(arg) { + return arg; // Unsound, should be error +} +function oops2(arg) { + return arg; // Unsound, should be error +} +function oops3(arg) { + return arg; // Unsound, should be error +} //// [conditionalTypes2.d.ts] @@ -302,24 +281,6 @@ declare function fooBat(x: { declare type Extract2 = T extends U ? T extends V ? T : never : never; declare function f20(x: Extract, Bar>, y: Extract, z: Extract2): void; declare function f21(x: Extract, Bar>, y: Extract, z: Extract2): void; -declare class Opt { - toVector(): Vector; -} -interface Seq { - tail(): Opt>; -} -declare class Vector implements Seq { - tail(): Opt>; - partition2(predicate: (v: T) => v is U): [Vector, Vector>]; - partition2(predicate: (x: T) => boolean): [Vector, Vector]; -} -interface A1 { - bat: B1>; -} -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true; -} declare function toString1(value: object | Function): string; declare function toString2(value: Function): string; declare function foo(value: T): void; @@ -392,3 +353,15 @@ declare type ProductComplementComplement = { }; declare type PCCA = ProductComplementComplement['a']; declare type PCCB = ProductComplementComplement['b']; +declare type MyElement = [A] extends [[infer E]] ? E : never; +declare function oops(arg: MyElement): MyElement; +declare type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +declare function oops2(arg: MyAcceptor): MyAcceptor; +declare type Dist = T extends number ? number : string; +declare type Aux = A["a"] extends number ? number : string; +declare type Nondist = Aux<{ + a: T; +}>; +declare function oops3(arg: Dist): Nondist; diff --git a/tests/baselines/reference/conditionalTypes2.symbols b/tests/baselines/reference/conditionalTypes2.symbols index b164d26e45089..7bbf837eeced4 100644 --- a/tests/baselines/reference/conditionalTypes2.symbols +++ b/tests/baselines/reference/conditionalTypes2.symbols @@ -1,687 +1,655 @@ === tests/cases/conformance/types/conditional/conditionalTypes2.ts === +// #27118: Conditional types are now invariant in the check type. + interface Covariant { >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) foo: T extends string ? T : number; ->foo : Symbol(Covariant.foo, Decl(conditionalTypes2.ts, 0, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) +>foo : Symbol(Covariant.foo, Decl(conditionalTypes2.ts, 2, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) } interface Contravariant { ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) foo: T extends string ? keyof T : number; ->foo : Symbol(Contravariant.foo, Decl(conditionalTypes2.ts, 4, 28)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) +>foo : Symbol(Contravariant.foo, Decl(conditionalTypes2.ts, 6, 28)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) } interface Invariant { ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) foo: T extends string ? keyof T : T; ->foo : Symbol(Invariant.foo, Decl(conditionalTypes2.ts, 8, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) +>foo : Symbol(Invariant.foo, Decl(conditionalTypes2.ts, 10, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) } function f1(a: Covariant, b: Covariant) { ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 10, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 12, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 12, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 14, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 12, 14)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 14, 14)) - a = b; ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) + a = b; // Error +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) } function f2(a: Contravariant, b: Contravariant) { ->f2 : Symbol(f2, Decl(conditionalTypes2.ts, 15, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 17, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 17, 14)) +>f2 : Symbol(f2, Decl(conditionalTypes2.ts, 17, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 19, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 19, 14)) a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) - b = a; ->b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) + b = a; // Error +>b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) } function f3(a: Invariant, b: Invariant) { ->f3 : Symbol(f3, Decl(conditionalTypes2.ts, 20, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 22, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 22, 14)) +>f3 : Symbol(f3, Decl(conditionalTypes2.ts, 22, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 24, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 24, 14)) a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) } // Extract is a T that is known to be a Function function isFunction(value: T): value is Extract { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return typeof value === "function"; ->value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) } function getFunction(item: T) { ->getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 30, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 32, 21)) ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 32, 21)) +>getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 32, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 34, 21)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 34, 21)) if (isFunction(item)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) return item; ->item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) } throw new Error(); >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } function f10(x: T) { ->f10 : Symbol(f10, Decl(conditionalTypes2.ts, 37, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) +>f10 : Symbol(f10, Decl(conditionalTypes2.ts, 39, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) if (isFunction(x)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) const f: Function = x; ->f : Symbol(f, Decl(conditionalTypes2.ts, 41, 13)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 43, 13)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) const t: T = x; ->t : Symbol(t, Decl(conditionalTypes2.ts, 42, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>t : Symbol(t, Decl(conditionalTypes2.ts, 44, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) } } function f11(x: string | (() => string) | undefined) { ->f11 : Symbol(f11, Decl(conditionalTypes2.ts, 44, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>f11 : Symbol(f11, Decl(conditionalTypes2.ts, 46, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) if (isFunction(x)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) x(); ->x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) } } function f12(x: string | (() => string) | undefined) { ->f12 : Symbol(f12, Decl(conditionalTypes2.ts, 50, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 52, 13)) +>f12 : Symbol(f12, Decl(conditionalTypes2.ts, 52, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 54, 13)) const f = getFunction(x); // () => string ->f : Symbol(f, Decl(conditionalTypes2.ts, 53, 9)) ->getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 30, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 52, 13)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 55, 9)) +>getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 32, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 54, 13)) f(); ->f : Symbol(f, Decl(conditionalTypes2.ts, 53, 9)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 55, 9)) } type Foo = { foo: string }; ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 57, 12)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 59, 12)) type Bar = { bar: string }; ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->bar : Symbol(bar, Decl(conditionalTypes2.ts, 58, 12)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>bar : Symbol(bar, Decl(conditionalTypes2.ts, 60, 12)) declare function fooBar(x: { foo: string, bar: string }): void; ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 60, 24)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 60, 28)) ->bar : Symbol(bar, Decl(conditionalTypes2.ts, 60, 41)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 62, 24)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 62, 28)) +>bar : Symbol(bar, Decl(conditionalTypes2.ts, 62, 41)) declare function fooBat(x: { foo: string, bat: string }): void; ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 61, 24)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 61, 28)) ->bat : Symbol(bat, Decl(conditionalTypes2.ts, 61, 41)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 63, 24)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 63, 28)) +>bat : Symbol(bat, Decl(conditionalTypes2.ts, 63, 41)) type Extract2 = T extends U ? T extends V ? T : never : never; ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 63, 16)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 63, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 63, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 63, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 65, 16)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 65, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 65, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 65, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) function f20(x: Extract, Bar>, y: Extract, z: Extract2) { ->f20 : Symbol(f20, Decl(conditionalTypes2.ts, 63, 71)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 65, 16)) +>f20 : Symbol(f20, Decl(conditionalTypes2.ts, 65, 71)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 67, 16)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 65, 49)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 67, 49)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 65, 75)) ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 67, 75)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) fooBar(x); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 65, 16)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 67, 16)) fooBar(y); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 65, 49)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 67, 49)) fooBar(z); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 65, 75)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 67, 75)) } function f21(x: Extract, Bar>, y: Extract, z: Extract2) { ->f21 : Symbol(f21, Decl(conditionalTypes2.ts, 69, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 71, 16)) +>f21 : Symbol(f21, Decl(conditionalTypes2.ts, 71, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 73, 16)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 71, 49)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 73, 49)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 71, 75)) ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 73, 75)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) fooBat(x); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 71, 16)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 73, 16)) fooBat(y); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 71, 49)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 73, 49)) fooBat(z); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 71, 75)) -} - -// Repros from #22860 - -class Opt { ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 79, 10)) - - toVector(): Vector { ->toVector : Symbol(Opt.toVector, Decl(conditionalTypes2.ts, 79, 14)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 79, 10)) - - return undefined; ->undefined : Symbol(undefined) - } -} - -interface Seq { ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 85, 14)) - - tail(): Opt>; ->tail : Symbol(Seq.tail, Decl(conditionalTypes2.ts, 85, 18)) ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 85, 14)) -} - -class Vector implements Seq { ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - tail(): Opt> { ->tail : Symbol(Vector.tail, Decl(conditionalTypes2.ts, 89, 35)) ->Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - return undefined; ->undefined : Symbol(undefined) - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 93, 28)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 93, 39)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 93, 39)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) - - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 94, 15)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 94, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) - - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { ->partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 95, 15)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 95, 28)) ->v : Symbol(v, Decl(conditionalTypes2.ts, 95, 39)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 95, 15)) ->Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) - - return undefined; ->undefined : Symbol(undefined) - } -} - -interface A1 { ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 100, 13)) - - bat: B1>; ->bat : Symbol(A1.bat, Decl(conditionalTypes2.ts, 100, 17)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 100, 13)) -} - -interface B1 extends A1 { ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) ->A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) - - bat: B1>; ->bat : Symbol(B1.bat, Decl(conditionalTypes2.ts, 104, 31)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) - - boom: T extends any ? true : true ->boom : Symbol(B1.boom, Decl(conditionalTypes2.ts, 105, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 73, 75)) } // Repro from #22899 declare function toString1(value: object | Function): string ; ->toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 107, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 111, 27)) +>toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 77, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 81, 27)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function toString2(value: Function): string ; ->toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 111, 62)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 112, 27)) +>toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 81, 62)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 82, 27)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) function foo(value: T) { ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 112, 53)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 13)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 13)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 82, 53)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 84, 13)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 84, 13)) if (isFunction(value)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) toString1(value); ->toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 107, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 77, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) toString2(value); ->toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 111, 62)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 81, 62)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) } } // Repro from #23052 type A = ->A : Symbol(A, Decl(conditionalTypes2.ts, 119, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 123, 12)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 89, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 93, 12)) T extends object ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ? { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: A; } ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 125, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 119, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 125, 9)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 123, 12)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 95, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 89, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 95, 9)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 93, 12)) : T extends V ? T : never; ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) type B = ->B : Symbol(B, Decl(conditionalTypes2.ts, 126, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 96, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) T extends object ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ? { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: B; } ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 130, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 126, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 130, 9)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 100, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 96, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 100, 9)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) : T extends V ? T : never; ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) type C = ->C : Symbol(C, Decl(conditionalTypes2.ts, 131, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 133, 12)) +>C : Symbol(C, Decl(conditionalTypes2.ts, 101, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 103, 12)) { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: C; }; ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 134, 5)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->C : Symbol(C, Decl(conditionalTypes2.ts, 131, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 134, 5)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 133, 12)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 104, 5)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>C : Symbol(C, Decl(conditionalTypes2.ts, 101, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 104, 5)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 103, 12)) // Repro from #23100 type A2 = ->A2 : Symbol(A2, Decl(conditionalTypes2.ts, 134, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 138, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 138, 13)) +>A2 : Symbol(A2, Decl(conditionalTypes2.ts, 104, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 108, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 108, 13)) T extends object ? T extends any[] ? T : { [Q in keyof T]: A2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 139, 48)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->A2 : Symbol(A2, Decl(conditionalTypes2.ts, 134, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 139, 48)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 138, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 138, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 109, 48)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>A2 : Symbol(A2, Decl(conditionalTypes2.ts, 104, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 109, 48)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 108, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 108, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) type B2 = ->B2 : Symbol(B2, Decl(conditionalTypes2.ts, 139, 85)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 141, 10)) +>B2 : Symbol(B2, Decl(conditionalTypes2.ts, 109, 85)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 111, 10)) T extends object ? T extends any[] ? T : { [Q in keyof T]: B2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 142, 48)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->B2 : Symbol(B2, Decl(conditionalTypes2.ts, 139, 85)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 142, 48)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 141, 10)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 112, 48)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>B2 : Symbol(B2, Decl(conditionalTypes2.ts, 109, 85)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 112, 48)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 111, 10)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) type C2 = ->C2 : Symbol(C2, Decl(conditionalTypes2.ts, 142, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 144, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 144, 13)) +>C2 : Symbol(C2, Decl(conditionalTypes2.ts, 112, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 114, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 114, 13)) T extends object ? { [Q in keyof T]: C2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 145, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->C2 : Symbol(C2, Decl(conditionalTypes2.ts, 142, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 145, 26)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 144, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 144, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 115, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>C2 : Symbol(C2, Decl(conditionalTypes2.ts, 112, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 115, 26)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 114, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 114, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) // Repro from #28654 type MaybeTrue = true extends T["b"] ? "yes" : "no"; ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 149, 15)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 149, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 149, 15)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 119, 15)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 119, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 119, 15)) type T0 = MaybeTrue<{ b: never }> // "no" ->T0 : Symbol(T0, Decl(conditionalTypes2.ts, 149, 78)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 151, 21)) +>T0 : Symbol(T0, Decl(conditionalTypes2.ts, 119, 78)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 121, 21)) type T1 = MaybeTrue<{ b: false }>; // "no" ->T1 : Symbol(T1, Decl(conditionalTypes2.ts, 151, 33)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 152, 21)) +>T1 : Symbol(T1, Decl(conditionalTypes2.ts, 121, 33)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 122, 21)) type T2 = MaybeTrue<{ b: true }>; // "yes" ->T2 : Symbol(T2, Decl(conditionalTypes2.ts, 152, 34)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 153, 21)) +>T2 : Symbol(T2, Decl(conditionalTypes2.ts, 122, 34)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 123, 21)) type T3 = MaybeTrue<{ b: boolean }>; // "yes" ->T3 : Symbol(T3, Decl(conditionalTypes2.ts, 153, 33)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 154, 21)) +>T3 : Symbol(T3, Decl(conditionalTypes2.ts, 123, 33)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 124, 21)) // Repro from #28824 type Union = 'a' | 'b'; ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) type Product = { f1: A, f2: B}; ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 159, 13)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 159, 29)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 159, 36)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 159, 13)) ->f2 : Symbol(f2, Decl(conditionalTypes2.ts, 159, 43)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 159, 29)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 129, 13)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 129, 29)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 129, 36)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 129, 13)) +>f2 : Symbol(f2, Decl(conditionalTypes2.ts, 129, 43)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 129, 29)) type ProductUnion = Product<'a', 0> | Product<'b', 1>; ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) // {a: "b"; b: "a"} type UnionComplement = { ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) [K in Union]: Exclude ->K : Symbol(K, Decl(conditionalTypes2.ts, 164, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 134, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 164, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 134, 3)) }; type UCA = UnionComplement['a']; ->UCA : Symbol(UCA, Decl(conditionalTypes2.ts, 165, 2)) ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UCA : Symbol(UCA, Decl(conditionalTypes2.ts, 135, 2)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) type UCB = UnionComplement['b']; ->UCB : Symbol(UCB, Decl(conditionalTypes2.ts, 166, 32)) ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) +>UCB : Symbol(UCB, Decl(conditionalTypes2.ts, 136, 32)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) // {a: "a"; b: "b"} type UnionComplementComplement = { ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) [K in Union]: Exclude> ->K : Symbol(K, Decl(conditionalTypes2.ts, 171, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 141, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 171, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 141, 3)) }; type UCCA = UnionComplementComplement['a']; ->UCCA : Symbol(UCCA, Decl(conditionalTypes2.ts, 172, 2)) ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UCCA : Symbol(UCCA, Decl(conditionalTypes2.ts, 142, 2)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) type UCCB = UnionComplementComplement['b']; ->UCCB : Symbol(UCCB, Decl(conditionalTypes2.ts, 173, 43)) ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) +>UCCB : Symbol(UCCB, Decl(conditionalTypes2.ts, 143, 43)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) // {a: Product<'b', 1>; b: Product<'a', 0>} type ProductComplement = { ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) [K in Union]: Exclude ->K : Symbol(K, Decl(conditionalTypes2.ts, 178, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 148, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 178, 39)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 178, 3)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 148, 39)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 148, 3)) }; type PCA = ProductComplement['a']; ->PCA : Symbol(PCA, Decl(conditionalTypes2.ts, 179, 2)) ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>PCA : Symbol(PCA, Decl(conditionalTypes2.ts, 149, 2)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) type PCB = ProductComplement['b']; ->PCB : Symbol(PCB, Decl(conditionalTypes2.ts, 180, 34)) ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) +>PCB : Symbol(PCB, Decl(conditionalTypes2.ts, 150, 34)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) // {a: Product<'a', 0>; b: Product<'b', 1>} type ProductComplementComplement = { ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) [K in Union]: Exclude> ->K : Symbol(K, Decl(conditionalTypes2.ts, 185, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 155, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 185, 61)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 185, 3)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 155, 61)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 155, 3)) }; type PCCA = ProductComplementComplement['a']; ->PCCA : Symbol(PCCA, Decl(conditionalTypes2.ts, 186, 2)) ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>PCCA : Symbol(PCCA, Decl(conditionalTypes2.ts, 156, 2)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) type PCCB = ProductComplementComplement['b']; ->PCCB : Symbol(PCCB, Decl(conditionalTypes2.ts, 187, 45)) ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) +>PCCB : Symbol(PCCB, Decl(conditionalTypes2.ts, 157, 45)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 162, 15)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 162, 15)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 162, 39)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 162, 39)) + +function oops(arg: MyElement): MyElement { +>oops : Symbol(oops, Decl(conditionalTypes2.ts, 162, 56)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 163, 16)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 163, 30)) +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) +>MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 163, 16)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 163, 30)) +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 167, 16)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 167, 16)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 167, 40)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 167, 48)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 167, 40)) + +function oops2(arg: MyAcceptor): MyAcceptor { +>oops2 : Symbol(oops2, Decl(conditionalTypes2.ts, 167, 72)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 168, 17)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 168, 31)) +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 168, 17)) +>MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 168, 31)) +} + +type Dist = T extends number ? number : string; +>Dist : Symbol(Dist, Decl(conditionalTypes2.ts, 170, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 172, 10)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 172, 10)) + +type Aux = A["a"] extends number ? number : string; +>Aux : Symbol(Aux, Decl(conditionalTypes2.ts, 172, 50)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 173, 9)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 173, 20)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 173, 9)) + +type Nondist = Aux<{a: T}>; +>Nondist : Symbol(Nondist, Decl(conditionalTypes2.ts, 173, 77)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 174, 13)) +>Aux : Symbol(Aux, Decl(conditionalTypes2.ts, 172, 50)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 174, 23)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 174, 13)) + +function oops3(arg: Dist): Nondist { +>oops3 : Symbol(oops3, Decl(conditionalTypes2.ts, 174, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 175, 18)) +>Dist : Symbol(Dist, Decl(conditionalTypes2.ts, 170, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) +>Nondist : Symbol(Nondist, Decl(conditionalTypes2.ts, 173, 77)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) + + return arg; // Unsound, should be error +>arg : Symbol(arg, Decl(conditionalTypes2.ts, 175, 18)) +} diff --git a/tests/baselines/reference/conditionalTypes2.types b/tests/baselines/reference/conditionalTypes2.types index aac6ba47475c6..3cffe6ab48e2c 100644 --- a/tests/baselines/reference/conditionalTypes2.types +++ b/tests/baselines/reference/conditionalTypes2.types @@ -1,4 +1,6 @@ === tests/cases/conformance/types/conditional/conditionalTypes2.ts === +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; >foo : T extends string ? T : number @@ -19,7 +21,7 @@ function f1(a: Covariant, b: Covariant) { >a : Covariant >b : Covariant - a = b; + a = b; // Error >a = b : Covariant >a : Covariant >b : Covariant @@ -40,7 +42,7 @@ function f2(a: Contravariant, b: Contravariant) { >a : Contravariant >b : Contravariant - b = a; + b = a; // Error >b = a : Contravariant >b : Contravariant >a : Contravariant @@ -207,71 +209,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E >z : Extract2 } -// Repros from #22860 - -class Opt { ->Opt : Opt - - toVector(): Vector { ->toVector : () => Vector - - return undefined; ->undefined : any ->undefined : undefined - } -} - -interface Seq { - tail(): Opt>; ->tail : () => Opt> -} - -class Vector implements Seq { ->Vector : Vector - - tail(): Opt> { ->tail : () => Opt> - - return undefined; ->undefined : any ->undefined : undefined - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (v: T) => v is U ->v : T - - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (x: T) => boolean ->x : T - - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { ->partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } ->predicate : (v: T) => boolean ->v : T - - return undefined; ->undefined : any ->undefined : undefined - } -} - -interface A1 { - bat: B1>; ->bat : B1> -} - -interface B1 extends A1 { - bat: B1>; ->bat : B1> - - boom: T extends any ? true : true ->boom : T extends any ? true : true ->true : true ->true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -431,3 +368,47 @@ type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; >PCCB : Product<"b", 1> +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +>MyElement : MyElement + +function oops(arg: MyElement): MyElement { +>oops : (arg: MyElement) => MyElement +>arg : MyElement + + return arg; // Unsound, should be error +>arg : MyElement +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +>MyAcceptor : MyAcceptor +>arg : E + +function oops2(arg: MyAcceptor): MyAcceptor { +>oops2 : (arg: MyAcceptor) => MyAcceptor +>arg : MyAcceptor + + return arg; // Unsound, should be error +>arg : MyAcceptor +} + +type Dist = T extends number ? number : string; +>Dist : Dist + +type Aux = A["a"] extends number ? number : string; +>Aux : Aux +>a : unknown + +type Nondist = Aux<{a: T}>; +>Nondist : Aux<{ a: T; }> +>a : T + +function oops3(arg: Dist): Nondist { +>oops3 : (arg: Dist) => Aux<{ a: T; }> +>arg : Dist + + return arg; // Unsound, should be error +>arg : Dist +} + diff --git a/tests/cases/conformance/types/conditional/conditionalTypes2.ts b/tests/cases/conformance/types/conditional/conditionalTypes2.ts index 4b65b5ddeb202..5d73c58fe7f37 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes2.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes2.ts @@ -1,6 +1,8 @@ // @strict: true // @declaration: true +// #27118: Conditional types are now invariant in the check type. + interface Covariant { foo: T extends string ? T : number; } @@ -14,13 +16,13 @@ interface Invariant { } function f1(a: Covariant, b: Covariant) { - a = b; + a = b; // Error b = a; // Error } function f2(a: Contravariant, b: Contravariant) { a = b; // Error - b = a; + b = a; // Error } function f3(a: Invariant, b: Invariant) { @@ -78,38 +80,6 @@ function f21(x: Extract, Bar>, y: Extract, z: E fooBat(z); // Error } -// Repros from #22860 - -class Opt { - toVector(): Vector { - return undefined; - } -} - -interface Seq { - tail(): Opt>; -} - -class Vector implements Seq { - tail(): Opt> { - return undefined; - } - partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; - partition2(predicate:(x:T)=>boolean): [Vector,Vector]; - partition2(predicate:(v:T)=>boolean): [Vector,Vector] { - return undefined; - } -} - -interface A1 { - bat: B1>; -} - -interface B1 extends A1 { - bat: B1>; - boom: T extends any ? true : true -} - // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -190,3 +160,22 @@ type ProductComplementComplement = { }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; + +// Repros from #27118 + +type MyElement = [A] extends [[infer E]] ? E : never; +function oops(arg: MyElement): MyElement { + return arg; // Unsound, should be error +} + +type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; +function oops2(arg: MyAcceptor): MyAcceptor { + return arg; // Unsound, should be error +} + +type Dist = T extends number ? number : string; +type Aux = A["a"] extends number ? number : string; +type Nondist = Aux<{a: T}>; +function oops3(arg: Dist): Nondist { + return arg; // Unsound, should be error +} From 9a0a838d1270d46212848ca0e7cafa435a65112d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 07:48:22 -0800 Subject: [PATCH 12/64] Use getIndexedAccess to compute type for contextual rest parameters --- src/compiler/checker.ts | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7cc72c534d05..354d6af67bec5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21550,13 +21550,8 @@ namespace ts { } if (signature.hasRestParameter) { const restType = getTypeOfSymbol(signature.parameters[paramCount]); - if (isTupleType(restType)) { - if (pos - paramCount < getLengthOfTupleType(restType)) { - return restType.typeArguments![pos - paramCount]; - } - return getRestTypeOfTupleType(restType); - } - return getIndexTypeOfType(restType, IndexKind.Number); + const indexType = getLiteralType(pos - paramCount); + return getIndexedAccessType(restType, indexType); } return undefined; } @@ -21564,18 +21559,22 @@ namespace ts { function getRestTypeAtPosition(source: Signature, pos: number): Type { const paramCount = getParameterCount(source); const restType = getEffectiveRestType(source); - if (restType && pos === paramCount - 1) { + const nonRestCount = paramCount - (restType ? 1 : 0); + if (restType && pos === nonRestCount) { return restType; } - const start = restType ? Math.min(pos, paramCount - 1) : pos; const types = []; const names = []; - for (let i = start; i < paramCount; i++) { + for (let i = pos; i < nonRestCount; i++) { types.push(getTypeAtPosition(source, i)); names.push(getParameterNameAtPosition(source, i)); } + if (restType) { + types.push(getIndexedAccessType(restType, numberType)); + names.push(getParameterNameAtPosition(source, nonRestCount)); + } const minArgumentCount = getMinArgumentCount(source); - const minLength = minArgumentCount < start ? 0 : minArgumentCount - start; + const minLength = minArgumentCount < pos ? 0 : minArgumentCount - pos; return createTupleType(types, minLength, !!restType, /*readonly*/ false, names); } From 1f3213981181d6ff68e6f6e478032cb02d962961 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:07:01 -0800 Subject: [PATCH 13/64] Make inferences to union types containing multiple naked type variables --- src/compiler/checker.ts | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7cc72c534d05..9dc9efdf514d8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14472,26 +14472,15 @@ namespace ts { inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); } else if (target.flags & TypeFlags.UnionOrIntersection) { - const targetTypes = (target).types; - let typeVariableCount = 0; - let typeVariable: TypeParameter | IndexedAccessType | undefined; - // First infer to each type in union or intersection that isn't a type variable - for (const t of targetTypes) { + for (const t of (target).types) { + const savePriority = priority; + // Inferences directly to naked type variables are given lower priority as they are + // less specific. For example, when inferring from Promise to T | Promise, + // we want to infer string for T, not Promise | string. if (getInferenceInfoForType(t)) { - typeVariable = t; - typeVariableCount++; - } - else { - inferFromTypes(source, t); + priority |= InferencePriority.NakedTypeVariable; } - } - // Next, if target containings a single naked type variable, make a secondary inference to that type - // variable. This gives meaningful results for union types in co-variant positions and intersection - // types in contra-variant positions (such as callback parameters). - if (typeVariableCount === 1) { - const savePriority = priority; - priority |= InferencePriority.NakedTypeVariable; - inferFromTypes(source, typeVariable!); + inferFromTypes(source, t); priority = savePriority; } } From 3ffb15fd7045c82393034ae4315ddd3633280db0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:16:32 -0800 Subject: [PATCH 14/64] Accept new baselines --- .../conditionalTypeDoesntSpinForever.types | 16 ++++++++-------- tests/baselines/reference/objectSpread.types | 2 +- .../baselines/reference/restTupleElements1.types | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/baselines/reference/conditionalTypeDoesntSpinForever.types b/tests/baselines/reference/conditionalTypeDoesntSpinForever.types index d4fe4bf48261b..1f4b4a62cd293 100644 --- a/tests/baselines/reference/conditionalTypeDoesntSpinForever.types +++ b/tests/baselines/reference/conditionalTypeDoesntSpinForever.types @@ -120,9 +120,9 @@ export enum PubSubRecordIsStoredInRedisAsA { buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) as >buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) as BuildPubSubRecordType : BuildPubSubRecordType ->buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) : BuildPubSubRecordType +>buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString})) : BuildPubSubRecordType >buildPubSubRecordType : (soFar: SO_FAR) => BuildPubSubRecordType ->Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString}) : SO_FAR & { storedAs: PubSubRecordIsStoredInRedisAsA; } +>Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString}) : SO_FAR & { storedAs: PubSubRecordIsStoredInRedisAsA.jsonEncodedRedisString; } >Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >Object : ObjectConstructor >assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } @@ -144,9 +144,9 @@ export enum PubSubRecordIsStoredInRedisAsA { buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) as >buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) as BuildPubSubRecordType : BuildPubSubRecordType ->buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) : BuildPubSubRecordType +>buildPubSubRecordType(Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash})) : BuildPubSubRecordType >buildPubSubRecordType : (soFar: SO_FAR) => BuildPubSubRecordType ->Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash}) : SO_FAR & { storedAs: PubSubRecordIsStoredInRedisAsA; } +>Object.assign({}, soFar, {storedAs: PubSubRecordIsStoredInRedisAsA.redisHash}) : SO_FAR & { storedAs: PubSubRecordIsStoredInRedisAsA.redisHash; } >Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >Object : ObjectConstructor >assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } @@ -337,16 +337,16 @@ export enum PubSubRecordIsStoredInRedisAsA { buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) as BuildPubSubRecordType, >buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) as BuildPubSubRecordType : BuildPubSubRecordType ->buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) : BuildPubSubRecordType +>buildPubSubRecordType(Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0})) : BuildPubSubRecordType >buildPubSubRecordType : (soFar: SO_FAR) => BuildPubSubRecordType ->Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0}) : SO_FAR & { maxMsToWaitBeforePublishing: number; } +>Object.assign({}, soFar, {maxMsToWaitBeforePublishing: 0}) : SO_FAR & { maxMsToWaitBeforePublishing: 0; } >Object.assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >Object : ObjectConstructor >assign : { (target: T, source: U): T & U; (target: T, source1: U, source2: V): T & U & V; (target: T, source1: U, source2: V, source3: W): T & U & V & W; (target: object, ...sources: any[]): any; } >{} : {} >soFar : SO_FAR ->{maxMsToWaitBeforePublishing: 0} : { maxMsToWaitBeforePublishing: number; } ->maxMsToWaitBeforePublishing : number +>{maxMsToWaitBeforePublishing: 0} : { maxMsToWaitBeforePublishing: 0; } +>maxMsToWaitBeforePublishing : 0 >0 : 0 >maxMsToWaitBeforePublishing : 0 } diff --git a/tests/baselines/reference/objectSpread.types b/tests/baselines/reference/objectSpread.types index 0ffd5dd20b718..e095a4e03bb1c 100644 --- a/tests/baselines/reference/objectSpread.types +++ b/tests/baselines/reference/objectSpread.types @@ -602,7 +602,7 @@ let exclusive: { id: string, a: number, b: string, c: string, d: boolean } = >d : boolean f({ a: 1, b: 'yes' }, { c: 'no', d: false }) ->f({ a: 1, b: 'yes' }, { c: 'no', d: false }) : { a: number; b: string; } & { c: string; d: boolean; } & { id: string; } +>f({ a: 1, b: 'yes' }, { c: 'no', d: false }) : { a: number; b: string; } & { c: string; d: false; } & { id: string; } >f : (t: T, u: U) => T & U & { id: string; } >{ a: 1, b: 'yes' } : { a: number; b: string; } >a : number diff --git a/tests/baselines/reference/restTupleElements1.types b/tests/baselines/reference/restTupleElements1.types index 9a8b3aaeb7ef1..ffa20bf503ede 100644 --- a/tests/baselines/reference/restTupleElements1.types +++ b/tests/baselines/reference/restTupleElements1.types @@ -173,7 +173,7 @@ f0([]); // Error >[] : never[] f0([1]); ->f0([1]) : [number, {}] +>f0([1]) : [number, number] >f0 : (x: [T, ...U[]]) => [T, U] >[1] : [number] >1 : 1 From 15610faa9de4b06ecc24eec6f3c83948b4dd77cd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:18:45 -0800 Subject: [PATCH 15/64] Update test --- tests/cases/compiler/jqueryInference.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cases/compiler/jqueryInference.ts b/tests/cases/compiler/jqueryInference.ts index 6016591625789..5784638e453ba 100644 --- a/tests/cases/compiler/jqueryInference.ts +++ b/tests/cases/compiler/jqueryInference.ts @@ -10,4 +10,4 @@ declare function shouldBeIdentity(p: DoNothingAlias): MyPromise; var p2 = shouldBeIdentity(p1); -var p2: MyPromise; +var p2: MyPromise; From 62e270c04d014d58d5bde60d026d91ea5e022c3e Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:18:51 -0800 Subject: [PATCH 16/64] Accept new baselines --- tests/baselines/reference/jqueryInference.js | 2 +- tests/baselines/reference/jqueryInference.symbols | 2 +- tests/baselines/reference/jqueryInference.types | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/jqueryInference.js b/tests/baselines/reference/jqueryInference.js index 05664a889deae..cea70bc4391dd 100644 --- a/tests/baselines/reference/jqueryInference.js +++ b/tests/baselines/reference/jqueryInference.js @@ -11,7 +11,7 @@ declare function shouldBeIdentity(p: DoNothingAlias): MyPromise; var p2 = shouldBeIdentity(p1); -var p2: MyPromise; +var p2: MyPromise; //// [jqueryInference.js] diff --git a/tests/baselines/reference/jqueryInference.symbols b/tests/baselines/reference/jqueryInference.symbols index ce3836aacd478..3d6c4f2f9609f 100644 --- a/tests/baselines/reference/jqueryInference.symbols +++ b/tests/baselines/reference/jqueryInference.symbols @@ -48,7 +48,7 @@ var p2 = shouldBeIdentity(p1); >shouldBeIdentity : Symbol(shouldBeIdentity, Decl(jqueryInference.ts, 6, 58)) >p1 : Symbol(p1, Decl(jqueryInference.ts, 10, 13)) -var p2: MyPromise; +var p2: MyPromise; >p2 : Symbol(p2, Decl(jqueryInference.ts, 11, 3), Decl(jqueryInference.ts, 12, 3)) >MyPromise : Symbol(MyPromise, Decl(jqueryInference.ts, 0, 0)) diff --git a/tests/baselines/reference/jqueryInference.types b/tests/baselines/reference/jqueryInference.types index 5f055fe16b248..558b0f53df36c 100644 --- a/tests/baselines/reference/jqueryInference.types +++ b/tests/baselines/reference/jqueryInference.types @@ -22,11 +22,11 @@ declare const p1: MyPromise; >p1 : MyPromise var p2 = shouldBeIdentity(p1); ->p2 : MyPromise ->shouldBeIdentity(p1) : MyPromise +>p2 : MyPromise +>shouldBeIdentity(p1) : MyPromise >shouldBeIdentity : (p: DoNothingAlias) => MyPromise >p1 : MyPromise -var p2: MyPromise; ->p2 : MyPromise +var p2: MyPromise; +>p2 : MyPromise From 35cf397ae3083536884304a27d9494be0a758b38 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:29:14 -0800 Subject: [PATCH 17/64] Add regression tests --- .../unionAndIntersectionInference1.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts b/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts index 7066c3e679084..d4c7d25615e46 100644 --- a/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts +++ b/tests/cases/conformance/types/typeRelationships/typeInference/unionAndIntersectionInference1.ts @@ -1,3 +1,5 @@ +// @target: es2015 + // Repro from #2264 interface Y { 'i am a very certain type': Y } @@ -70,3 +72,21 @@ declare var mbp: Man & Bear; pigify(mbp).oinks; // OK, mbp is treated as Pig pigify(mbp).walks; // Ok, mbp is treated as Man + +// Repros from #29815 + +interface ITest { + name: 'test' +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) + +const createTest = (): ITest => { + return { name: 'test' } +} + +declare function f1(x: T | U): T | U; +declare function f2(x: T & U): T & U; + +let x1: string = f1('a'); +let x2: string = f2('a'); From 1c9fe44726535ad15ca742a6521eea8a0eec3475 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 10 Feb 2019 15:29:22 -0800 Subject: [PATCH 18/64] Accept new baselines --- .../unionAndIntersectionInference1.js | 28 ++++++++- .../unionAndIntersectionInference1.symbols | 58 ++++++++++++++++++- .../unionAndIntersectionInference1.types | 53 +++++++++++++++++ 3 files changed, 136 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/unionAndIntersectionInference1.js b/tests/baselines/reference/unionAndIntersectionInference1.js index 235eb23ebf847..ca9e527d99ed2 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.js +++ b/tests/baselines/reference/unionAndIntersectionInference1.js @@ -71,6 +71,24 @@ declare var mbp: Man & Bear; pigify(mbp).oinks; // OK, mbp is treated as Pig pigify(mbp).walks; // Ok, mbp is treated as Man + +// Repros from #29815 + +interface ITest { + name: 'test' +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) + +const createTest = (): ITest => { + return { name: 'test' } +} + +declare function f1(x: T | U): T | U; +declare function f2(x: T & U): T & U; + +let x1: string = f1('a'); +let x2: string = f2('a'); //// [unionAndIntersectionInference1.js] @@ -80,7 +98,7 @@ function destructure(something, haveValue, haveY) { return something === y ? haveY(y) : haveValue(something); } var value = Math.random() > 0.5 ? 'hey!' : undefined; -var result = destructure(value, function (text) { return 'string'; }, function (y) { return 'other one'; }); // text: string, y: Y +var result = destructure(value, text => 'string', y => 'other one'); // text: string, y: Y // Repro from #4212 function isVoid(value) { return undefined; @@ -107,7 +125,13 @@ function baz1(value) { function get(x) { return null; // just an example } -var foo; +let foo; get(foo).toUpperCase(); // Ok pigify(mbp).oinks; // OK, mbp is treated as Pig pigify(mbp).walks; // Ok, mbp is treated as Man +const createTestAsync = () => Promise.resolve().then(() => ({ name: 'test' })); +const createTest = () => { + return { name: 'test' }; +}; +let x1 = f1('a'); +let x2 = f2('a'); diff --git a/tests/baselines/reference/unionAndIntersectionInference1.symbols b/tests/baselines/reference/unionAndIntersectionInference1.symbols index 38bcd416dff8f..e866f19daa423 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.symbols +++ b/tests/baselines/reference/unionAndIntersectionInference1.symbols @@ -50,7 +50,7 @@ function destructure( var value = Math.random() > 0.5 ? 'hey!' : undefined; >value : Symbol(value, Decl(unionAndIntersectionInference1.ts, 12, 3)) >Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) ->Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) >random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) >Y : Symbol(Y, Decl(unionAndIntersectionInference1.ts, 0, 0)) >undefined : Symbol(undefined) @@ -201,3 +201,59 @@ pigify(mbp).walks; // Ok, mbp is treated as Man >mbp : Symbol(mbp, Decl(unionAndIntersectionInference1.ts, 68, 11)) >walks : Symbol(Man.walks, Decl(unionAndIntersectionInference1.ts, 55, 15)) +// Repros from #29815 + +interface ITest { +>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18)) + + name: 'test' +>name : Symbol(ITest.name, Decl(unionAndIntersectionInference1.ts, 75, 17)) +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) +>createTestAsync : Symbol(createTestAsync, Decl(unionAndIntersectionInference1.ts, 79, 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, --, --)) +>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18)) +>Promise.resolve().then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>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, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --)) +>name : Symbol(name, Decl(unionAndIntersectionInference1.ts, 79, 77)) + +const createTest = (): ITest => { +>createTest : Symbol(createTest, Decl(unionAndIntersectionInference1.ts, 81, 5)) +>ITest : Symbol(ITest, Decl(unionAndIntersectionInference1.ts, 71, 18)) + + return { name: 'test' } +>name : Symbol(name, Decl(unionAndIntersectionInference1.ts, 82, 10)) +} + +declare function f1(x: T | U): T | U; +>f1 : Symbol(f1, Decl(unionAndIntersectionInference1.ts, 83, 1)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22)) +>x : Symbol(x, Decl(unionAndIntersectionInference1.ts, 85, 26)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 85, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 85, 22)) + +declare function f2(x: T & U): T & U; +>f2 : Symbol(f2, Decl(unionAndIntersectionInference1.ts, 85, 43)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22)) +>x : Symbol(x, Decl(unionAndIntersectionInference1.ts, 86, 26)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22)) +>T : Symbol(T, Decl(unionAndIntersectionInference1.ts, 86, 20)) +>U : Symbol(U, Decl(unionAndIntersectionInference1.ts, 86, 22)) + +let x1: string = f1('a'); +>x1 : Symbol(x1, Decl(unionAndIntersectionInference1.ts, 88, 3)) +>f1 : Symbol(f1, Decl(unionAndIntersectionInference1.ts, 83, 1)) + +let x2: string = f2('a'); +>x2 : Symbol(x2, Decl(unionAndIntersectionInference1.ts, 89, 3)) +>f2 : Symbol(f2, Decl(unionAndIntersectionInference1.ts, 85, 43)) + diff --git a/tests/baselines/reference/unionAndIntersectionInference1.types b/tests/baselines/reference/unionAndIntersectionInference1.types index 7b2515c6b581f..4dddcb8bd0f32 100644 --- a/tests/baselines/reference/unionAndIntersectionInference1.types +++ b/tests/baselines/reference/unionAndIntersectionInference1.types @@ -179,3 +179,56 @@ pigify(mbp).walks; // Ok, mbp is treated as Man >mbp : Man & Bear >walks : boolean +// Repros from #29815 + +interface ITest { + name: 'test' +>name : "test" +} + +const createTestAsync = (): Promise => Promise.resolve().then(() => ({ name: 'test' })) +>createTestAsync : () => Promise +>(): Promise => Promise.resolve().then(() => ({ name: 'test' })) : () => Promise +>Promise.resolve().then(() => ({ name: 'test' })) : Promise +>Promise.resolve().then : (onfulfilled?: (value: void) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>Promise.resolve() : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>then : (onfulfilled?: (value: void) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike) => Promise +>() => ({ name: 'test' }) : () => { name: "test"; } +>({ name: 'test' }) : { name: "test"; } +>{ name: 'test' } : { name: "test"; } +>name : "test" +>'test' : "test" + +const createTest = (): ITest => { +>createTest : () => ITest +>(): ITest => { return { name: 'test' }} : () => ITest + + return { name: 'test' } +>{ name: 'test' } : { name: "test"; } +>name : "test" +>'test' : "test" +} + +declare function f1(x: T | U): T | U; +>f1 : (x: T | U) => T | U +>x : T | U + +declare function f2(x: T & U): T & U; +>f2 : (x: T & U) => T & U +>x : T & U + +let x1: string = f1('a'); +>x1 : string +>f1('a') : "a" +>f1 : (x: T | U) => T | U +>'a' : "a" + +let x2: string = f2('a'); +>x2 : string +>f2('a') : "a" +>f2 : (x: T & U) => T & U +>'a' : "a" + From 17d16d1bbb943e4c5ead1dfb50d0da53cc499693 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Mon, 11 Feb 2019 08:36:35 -0800 Subject: [PATCH 19/64] Disable checkJS survey (#29830) * Disable checkJS survey * Completely remove survey infrastructure * Re-instate the protocol part of SurveyReady --- src/server/editorServices.ts | 32 ----- src/server/project.ts | 2 - src/server/session.ts | 4 - src/testRunner/tsconfig.json | 1 - .../unittests/tsserver/events/surveyReady.ts | 111 ------------------ .../reference/api/tsserverlibrary.d.ts | 11 +- .../TypeScript-Node-Starter | 2 +- tests/cases/user/prettier/prettier | 2 +- tests/cases/user/webpack/webpack | 2 +- 9 files changed, 4 insertions(+), 163 deletions(-) delete mode 100644 src/testRunner/unittests/tsserver/events/surveyReady.ts diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6dccc08c4b5cd..e9d97f6e03c02 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -7,7 +7,6 @@ namespace ts.server { export const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; export const ProjectLoadingStartEvent = "projectLoadingStart"; export const ProjectLoadingFinishEvent = "projectLoadingFinish"; - export const SurveyReady = "surveyReady"; export const LargeFileReferencedEvent = "largeFileReferenced"; export const ConfigFileDiagEvent = "configFileDiag"; export const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; @@ -30,11 +29,6 @@ namespace ts.server { data: { project: Project; }; } - export interface SurveyReady { - eventName: typeof SurveyReady; - data: { surveyId: string; }; - } - export interface LargeFileReferencedEvent { eventName: typeof LargeFileReferencedEvent; data: { file: string; fileSize: number; maxFileSize: number; }; @@ -146,7 +140,6 @@ namespace ts.server { } export type ProjectServiceEvent = LargeFileReferencedEvent | - SurveyReady | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | @@ -518,9 +511,6 @@ namespace ts.server { /** Tracks projects that we have already sent telemetry for. */ private readonly seenProjects = createMap(); - /** Tracks projects that we have already sent survey events for. */ - private readonly seenSurveyProjects = createMap(); - /*@internal*/ readonly watchFactory: WatchFactory; @@ -722,14 +712,6 @@ namespace ts.server { this.eventHandler(event); } - /* @internal */ - sendSurveyReadyEvent(surveyId: string) { - if (!this.eventHandler) { - return; - } - this.eventHandler({ eventName: SurveyReady, data: { surveyId } }); - } - /* @internal */ sendLargeFileReferencedEvent(file: string, fileSize: number) { if (!this.eventHandler) { @@ -1611,20 +1593,6 @@ namespace ts.server { return project; } - /*@internal*/ - sendSurveyReady(project: ExternalProject | ConfiguredProject): void { - if (this.seenSurveyProjects.has(project.projectName)) { - return; - } - - if (project.getCompilerOptions().checkJs !== undefined) { - const name = "checkJs"; - this.logger.info(`Survey ${name} is ready`); - this.sendSurveyReadyEvent(name); - this.seenSurveyProjects.set(project.projectName, true); - } - } - /*@internal*/ sendProjectTelemetry(project: ExternalProject | ConfiguredProject): void { if (this.seenProjects.has(project.projectName)) { diff --git a/src/server/project.ts b/src/server/project.ts index b296668e6ae4c..280cedb424d6b 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -1431,7 +1431,6 @@ namespace ts.server { } this.projectService.sendProjectLoadingFinishEvent(this); this.projectService.sendProjectTelemetry(this); - this.projectService.sendSurveyReady(this); return result; } @@ -1627,7 +1626,6 @@ namespace ts.server { updateGraph() { const result = super.updateGraph(); this.projectService.sendProjectTelemetry(this); - this.projectService.sendSurveyReady(this); return result; } diff --git a/src/server/session.ts b/src/server/session.ts index e5b128c984e82..b47dfe6b716e7 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -610,10 +610,6 @@ namespace ts.server { diagnostics: bakedDiags }, ConfigFileDiagEvent); break; - case SurveyReady: - const { surveyId } = event.data; - this.event({ surveyId }, SurveyReady); - break; case ProjectLanguageServiceStateEvent: { const eventName: protocol.ProjectLanguageServiceStateEventName = ProjectLanguageServiceStateEvent; this.event({ diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 7e75c0105a2d3..137e4d8af58b7 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -109,7 +109,6 @@ "unittests/tsserver/events/projectLanguageServiceState.ts", "unittests/tsserver/events/projectLoading.ts", "unittests/tsserver/events/projectUpdatedInBackground.ts", - "unittests/tsserver/events/surveyReady.ts", "unittests/tsserver/externalProjects.ts", "unittests/tsserver/forceConsistentCasingInFileNames.ts", "unittests/tsserver/formatSettings.ts", diff --git a/src/testRunner/unittests/tsserver/events/surveyReady.ts b/src/testRunner/unittests/tsserver/events/surveyReady.ts deleted file mode 100644 index b04746800d0cd..0000000000000 --- a/src/testRunner/unittests/tsserver/events/surveyReady.ts +++ /dev/null @@ -1,111 +0,0 @@ -namespace ts.projectSystem { - describe("unittests:: tsserver:: events:: SurveyReady", () => { - function createSessionWithEventHandler(host: TestServerHost) { - const { session, events: surveyEvents } = createSessionWithEventTracking(host, server.SurveyReady); - - return { session, verifySurveyReadyEvent }; - - function verifySurveyReadyEvent(numberOfEvents: number) { - assert.equal(surveyEvents.length, numberOfEvents); - const expectedEvents = numberOfEvents === 0 ? [] : [{ - eventName: server.SurveyReady, - data: { surveyId: "checkJs" } - }]; - assert.deepEqual(surveyEvents, expectedEvents); - } - } - - it("doesn't log an event when checkJs isn't set", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: {} }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - const service = session.getProjectService(); - openFilesForSession([file], session); - checkNumberOfProjects(service, { configuredProjects: 1 }); - const project = service.configuredProjects.get(tsconfig.path)!; - checkProjectActualFiles(project, [file.path, tsconfig.path]); - - verifySurveyReadyEvent(0); - }); - - it("logs an event when checkJs is set", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: { checkJs: true } }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - - it("logs an event when checkJs is set, only the first time", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const rando: File = { - path: `/rando/calrissian.ts`, - content: "export function f() { }" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({ compilerOptions: { checkJs: true } }), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - - closeFilesForSession([file], session); - openFilesForSession([rando], session); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - - it("logs an event when checkJs is set after closing and reopening", () => { - const projectRoot = "/user/username/projects/project"; - const file: File = { - path: `${projectRoot}/src/file.ts`, - content: "export var y = 10;" - }; - const rando: File = { - path: `/rando/calrissian.ts`, - content: "export function f() { }" - }; - const tsconfig: File = { - path: `${projectRoot}/tsconfig.json`, - content: JSON.stringify({}), - }; - const host = createServerHost([file, tsconfig]); - const { session, verifySurveyReadyEvent } = createSessionWithEventHandler(host); - openFilesForSession([file], session); - - verifySurveyReadyEvent(0); - - closeFilesForSession([file], session); - openFilesForSession([rando], session); - host.writeFile(tsconfig.path, JSON.stringify({ compilerOptions: { checkJs: true } })); - openFilesForSession([file], session); - - verifySurveyReadyEvent(1); - }); - }); -} diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 025880dc09ebe..36c246c999f23 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8357,7 +8357,6 @@ declare namespace ts.server { const ProjectsUpdatedInBackgroundEvent = "projectsUpdatedInBackground"; const ProjectLoadingStartEvent = "projectLoadingStart"; const ProjectLoadingFinishEvent = "projectLoadingFinish"; - const SurveyReady = "surveyReady"; const LargeFileReferencedEvent = "largeFileReferenced"; const ConfigFileDiagEvent = "configFileDiag"; const ProjectLanguageServiceStateEvent = "projectLanguageServiceState"; @@ -8382,12 +8381,6 @@ declare namespace ts.server { project: Project; }; } - interface SurveyReady { - eventName: typeof SurveyReady; - data: { - surveyId: string; - }; - } interface LargeFileReferencedEvent { eventName: typeof LargeFileReferencedEvent; data: { @@ -8472,7 +8465,7 @@ declare namespace ts.server { interface OpenFileInfo { readonly checkJs: boolean; } - type ProjectServiceEvent = LargeFileReferencedEvent | SurveyReady | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; + type ProjectServiceEvent = LargeFileReferencedEvent | ProjectsUpdatedInBackgroundEvent | ProjectLoadingStartEvent | ProjectLoadingFinishEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent | OpenFileInfoTelemetryEvent; type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void; interface SafeList { [name: string]: { @@ -8589,8 +8582,6 @@ declare namespace ts.server { readonly syntaxOnly?: boolean; /** Tracks projects that we have already sent telemetry for. */ private readonly seenProjects; - /** Tracks projects that we have already sent survey events for. */ - private readonly seenSurveyProjects; constructor(opts: ProjectServiceOptions); toPath(fileName: string): Path; private loadTypesMap; diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index 40bdb4eadabc9..6b9706810b55a 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6 +Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32 diff --git a/tests/cases/user/prettier/prettier b/tests/cases/user/prettier/prettier index 67f1c4877ee10..6e0de0812231c 160000 --- a/tests/cases/user/prettier/prettier +++ b/tests/cases/user/prettier/prettier @@ -1 +1 @@ -Subproject commit 67f1c4877ee1090b66d468a847caccca411a6f82 +Subproject commit 6e0de0812231c3a48387d398d092418749aa39f1 diff --git a/tests/cases/user/webpack/webpack b/tests/cases/user/webpack/webpack index 10282ea20648b..a28f44f613276 160000 --- a/tests/cases/user/webpack/webpack +++ b/tests/cases/user/webpack/webpack @@ -1 +1 @@ -Subproject commit 10282ea20648b465caec6448849f24fc34e1ba3e +Subproject commit a28f44f613276446fb764dec7fab38b7cff8a07c From 36be6c8b6859ea5b8a18e375609133311fd0cce3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Feb 2019 09:41:38 -0800 Subject: [PATCH 20/64] Accept new baselines --- .../restTuplesFromContextualTypes.errors.txt | 12 ++++++------ .../reference/restTuplesFromContextualTypes.types | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt index d2246fbfd8409..7af71017a7119 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt +++ b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error TS2345: Argument of type '(a: number, b: any, ...x: any[]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. +tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error TS2345: Argument of type '(a: number, b: T[0], ...x: T[number][]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. Types of parameters 'b' and 'args' are incompatible. - Type 'T' is not assignable to type '[any, ...any[]]'. - Property '0' is missing in type 'any[]' but required in type '[any, ...any[]]'. + Type 'T' is not assignable to type '[T[0], ...T[number][]]'. + Property '0' is missing in type 'any[]' but required in type '[T[0], ...T[number][]]'. ==== tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts (1 errors) ==== @@ -62,10 +62,10 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error f((a, ...x) => {}); f((a, b, ...x) => {}); ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(a: number, b: any, ...x: any[]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. +!!! error TS2345: Argument of type '(a: number, b: T[0], ...x: T[number][]) => void' is not assignable to parameter of type '(x: number, ...args: T) => void'. !!! error TS2345: Types of parameters 'b' and 'args' are incompatible. -!!! error TS2345: Type 'T' is not assignable to type '[any, ...any[]]'. -!!! error TS2345: Property '0' is missing in type 'any[]' but required in type '[any, ...any[]]'. +!!! error TS2345: Type 'T' is not assignable to type '[T[0], ...T[number][]]'. +!!! error TS2345: Property '0' is missing in type 'any[]' but required in type '[T[0], ...T[number][]]'. } // Repro from #25288 diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.types b/tests/baselines/reference/restTuplesFromContextualTypes.types index ee63057b9ebb2..ad5a4788426e0 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.types +++ b/tests/baselines/reference/restTuplesFromContextualTypes.types @@ -332,8 +332,8 @@ function f4(t: T) { f((...x) => {}); >f((...x) => {}) : void >f : (cb: (x: number, ...args: T) => void) => void ->(...x) => {} : (x: number, ...args: any[]) => void ->x : [number, ...any[]] +>(...x) => {} : (x: number, ...args: T[number][]) => void +>x : [number, ...T[number][]] f((a, ...x) => {}); >f((a, ...x) => {}) : void @@ -345,10 +345,10 @@ function f4(t: T) { f((a, b, ...x) => {}); >f((a, b, ...x) => {}) : void >f : (cb: (x: number, ...args: T) => void) => void ->(a, b, ...x) => {} : (a: number, b: any, ...x: any[]) => void +>(a, b, ...x) => {} : (a: number, b: T[0], ...x: T[number][]) => void >a : number ->b : any ->x : any[] +>b : T[0] +>x : T[number][] } // Repro from #25288 From 710826e37e9fc2627e1c4ea2746645d1befb7b89 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Feb 2019 09:46:02 -0800 Subject: [PATCH 21/64] Add regression test --- .../types/rest/restTuplesFromContextualTypes.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts b/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts index 84bf81195b0b1..d5623a000a20d 100644 --- a/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts +++ b/tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts @@ -70,3 +70,17 @@ declare function take(cb: (a: number, b: string) => void): void; (function foo(...rest){}(1, '')); take(function(...rest){}); + +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +type TupleUnionFunc = (...params: ArgsUnion) => number; + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; +}; From f33c740b8c29d5b2b07ec6d01422ccd16e7a0d63 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 11 Feb 2019 09:46:10 -0800 Subject: [PATCH 22/64] Accept new baselines --- .../restTuplesFromContextualTypes.errors.txt | 14 +++++++ .../restTuplesFromContextualTypes.js | 29 +++++++++++++++ .../restTuplesFromContextualTypes.symbols | 37 +++++++++++++++++++ .../restTuplesFromContextualTypes.types | 35 ++++++++++++++++++ 4 files changed, 115 insertions(+) diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt index 7af71017a7119..2b94b57f462b6 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt +++ b/tests/baselines/reference/restTuplesFromContextualTypes.errors.txt @@ -79,4 +79,18 @@ tests/cases/conformance/types/rest/restTuplesFromContextualTypes.ts(56,7): error (function foo(...rest){}(1, '')); take(function(...rest){}); + + // Repro from #29833 + + type ArgsUnion = [number, string] | [number, Error]; + type TupleUnionFunc = (...params: ArgsUnion) => number; + + const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; + }; + + const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; + }; \ No newline at end of file diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.js b/tests/baselines/reference/restTuplesFromContextualTypes.js index 3db6c53f384fd..34e75fcea6e30 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.js +++ b/tests/baselines/reference/restTuplesFromContextualTypes.js @@ -68,6 +68,20 @@ declare function take(cb: (a: number, b: string) => void): void; (function foo(...rest){}(1, '')); take(function(...rest){}); + +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +type TupleUnionFunc = (...params: ArgsUnion) => number; + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { + return num; +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { + const [num, strOrErr] = params; + return num; +}; //// [restTuplesFromContextualTypes.js] @@ -274,6 +288,17 @@ take(function () { rest[_i] = arguments[_i]; } }); +var funcUnionTupleNoRest = function (num, strOrErr) { + return num; +}; +var funcUnionTupleRest = function () { + var params = []; + for (var _i = 0; _i < arguments.length; _i++) { + params[_i] = arguments[_i]; + } + var num = params[0], strOrErr = params[1]; + return num; +}; //// [restTuplesFromContextualTypes.d.ts] @@ -286,3 +311,7 @@ declare function f3(cb: (x: number, ...args: typeof t3) => void): void; declare function f4(t: T): void; declare var tuple: [number, string]; declare function take(cb: (a: number, b: string) => void): void; +declare type ArgsUnion = [number, string] | [number, Error]; +declare type TupleUnionFunc = (...params: ArgsUnion) => number; +declare const funcUnionTupleNoRest: TupleUnionFunc; +declare const funcUnionTupleRest: TupleUnionFunc; diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.symbols b/tests/baselines/reference/restTuplesFromContextualTypes.symbols index d9b2310b5e27c..c58e8cabcae7d 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.symbols +++ b/tests/baselines/reference/restTuplesFromContextualTypes.symbols @@ -265,3 +265,40 @@ take(function(...rest){}); >take : Symbol(take, Decl(restTuplesFromContextualTypes.ts, 61, 33)) >rest : Symbol(rest, Decl(restTuplesFromContextualTypes.ts, 68, 14)) +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +>ArgsUnion : Symbol(ArgsUnion, Decl(restTuplesFromContextualTypes.ts, 68, 26)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +type TupleUnionFunc = (...params: ArgsUnion) => number; +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 73, 23)) +>ArgsUnion : Symbol(ArgsUnion, Decl(restTuplesFromContextualTypes.ts, 68, 26)) + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { +>funcUnionTupleNoRest : Symbol(funcUnionTupleNoRest, Decl(restTuplesFromContextualTypes.ts, 75, 5)) +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 75, 46)) +>strOrErr : Symbol(strOrErr, Decl(restTuplesFromContextualTypes.ts, 75, 50)) + + return num; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 75, 46)) + +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { +>funcUnionTupleRest : Symbol(funcUnionTupleRest, Decl(restTuplesFromContextualTypes.ts, 79, 5)) +>TupleUnionFunc : Symbol(TupleUnionFunc, Decl(restTuplesFromContextualTypes.ts, 72, 52)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 79, 44)) + + const [num, strOrErr] = params; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 80, 9)) +>strOrErr : Symbol(strOrErr, Decl(restTuplesFromContextualTypes.ts, 80, 13)) +>params : Symbol(params, Decl(restTuplesFromContextualTypes.ts, 79, 44)) + + return num; +>num : Symbol(num, Decl(restTuplesFromContextualTypes.ts, 80, 9)) + +}; + diff --git a/tests/baselines/reference/restTuplesFromContextualTypes.types b/tests/baselines/reference/restTuplesFromContextualTypes.types index ad5a4788426e0..c282dbbae311e 100644 --- a/tests/baselines/reference/restTuplesFromContextualTypes.types +++ b/tests/baselines/reference/restTuplesFromContextualTypes.types @@ -389,3 +389,38 @@ take(function(...rest){}); >function(...rest){} : (a: number, b: string) => void >rest : [number, string] +// Repro from #29833 + +type ArgsUnion = [number, string] | [number, Error]; +>ArgsUnion : ArgsUnion + +type TupleUnionFunc = (...params: ArgsUnion) => number; +>TupleUnionFunc : TupleUnionFunc +>params : ArgsUnion + +const funcUnionTupleNoRest: TupleUnionFunc = (num, strOrErr) => { +>funcUnionTupleNoRest : TupleUnionFunc +>(num, strOrErr) => { return num;} : (num: number, strOrErr: string | Error) => number +>num : number +>strOrErr : string | Error + + return num; +>num : number + +}; + +const funcUnionTupleRest: TupleUnionFunc = (...params) => { +>funcUnionTupleRest : TupleUnionFunc +>(...params) => { const [num, strOrErr] = params; return num;} : (...params: ArgsUnion) => number +>params : ArgsUnion + + const [num, strOrErr] = params; +>num : number +>strOrErr : string | Error +>params : ArgsUnion + + return num; +>num : number + +}; + From 1f10e74abc0aad67c1064abd51a77bcc2808e8e6 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 11 Feb 2019 11:18:29 -0800 Subject: [PATCH 23/64] Enable no-eval rule --- src/harness/evaluator.ts | 1 + src/harness/fourslash.ts | 1 + src/harness/harness.ts | 1 + tslint.json | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/harness/evaluator.ts b/src/harness/evaluator.ts index 168fda1d7670e..a22bdb958bc5f 100644 --- a/src/harness/evaluator.ts +++ b/src/harness/evaluator.ts @@ -56,6 +56,7 @@ namespace evaluator { } const evaluateText = `(function (module, exports, require, __dirname, __filename, ${globalNames.join(", ")}) { ${output.text} })`; + // tslint:disable-next-line:no-eval const evaluateThunk = eval(evaluateText) as (module: any, exports: any, require: (id: string) => any, dirname: string, filename: string, ...globalArgs: any[]) => void; const module: { exports: any; } = { exports: {} }; evaluateThunk.call(globals, module, module.exports, noRequire, vpath.dirname(output.file), output.file, FakeSymbol, ...globalArgs); diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index b0bb35d5db3bc..f3a7197e7772c 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3159,6 +3159,7 @@ ${code} const debug = new FourSlashInterface.Debug(state); const format = new FourSlashInterface.Format(state); const cancellation = new FourSlashInterface.Cancellation(state); + // tslint:disable-next-line:no-eval const f = eval(wrappedCode); f(test, goTo, plugins, verify, edit, debug, format, cancellation, FourSlashInterface.Classification, FourSlashInterface.Completion, verifyOperationIsCancelled); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 13ef2adbf90be..a78a04c3ecbe3 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -77,6 +77,7 @@ namespace Utils { const environment = getExecutionEnvironment(); switch (environment) { case ExecutionEnvironment.Browser: + // tslint:disable-next-line:no-eval eval(fileContents); break; case ExecutionEnvironment.Node: diff --git a/tslint.json b/tslint.json index a3ca10e75edbc..488c6a8d003bc 100644 --- a/tslint.json +++ b/tslint.json @@ -34,6 +34,7 @@ ], "no-bom": true, "no-double-space": true, + "no-eval": true, "no-in-operator": true, "no-increment-decrement": true, "no-inferrable-types": true, @@ -100,7 +101,6 @@ "no-console": false, "no-debugger": false, "no-empty-interface": false, - "no-eval": false, "no-object-literal-type-assertion": false, "no-shadowed-variable": false, "no-submodule-imports": false, From 02a5ef6a179c9a08a410b6d042c45a47ec13cb42 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 11 Feb 2019 11:26:19 -0800 Subject: [PATCH 24/64] Add setInterval/setTimeout --- src/harness/harnessLanguageService.ts | 1 + src/testRunner/parallel/host.ts | 2 ++ src/tsserver/server.ts | 1 + tslint.json | 5 +++++ 4 files changed, 9 insertions(+) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index a78ef88e5b74b..b70afecb7916d 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -766,6 +766,7 @@ namespace Harness.LanguageService { } setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): any { + // tslint:disable-next-line:ban return setTimeout(callback, ms, args); } diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 376896a469777..9adf9e7e850df 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -302,6 +302,7 @@ namespace Harness.Parallel.Host { worker.timer = undefined; } else { + // tslint:disable-next-line:ban worker.timer = setTimeout(killChild, data.payload.duration, data.payload); } break; @@ -623,6 +624,7 @@ namespace Harness.Parallel.Host { shimNoopTestInterface(global); } + // tslint:disable-next-line:ban setTimeout(() => startDelayed(perfData, totalCost), 0); // Do real startup on next tick, so all unit tests have been collected } } diff --git a/src/tsserver/server.ts b/src/tsserver/server.ts index 21146958748a8..0dc57ca520ad5 100644 --- a/src/tsserver/server.ts +++ b/src/tsserver/server.ts @@ -705,6 +705,7 @@ namespace ts.server { // stat due to inconsistencies of fs.watch // and efficiency of stat on modern filesystems function startWatchTimer() { + // tslint:disable-next-line:ban setInterval(() => { let count = 0; let nextToCheck = nextFileToCheck; diff --git a/tslint.json b/tslint.json index 488c6a8d003bc..5952c770c5e7e 100644 --- a/tslint.json +++ b/tslint.json @@ -5,6 +5,11 @@ "no-unnecessary-type-assertion": true, "array-type": [true, "array"], + "ban": [ + true, + "setInterval", + "setTimeout" + ], "ban-types": { "options": [ ["Object", "Avoid using the `Object` type. Did you mean `object`?"], From 6d2b738bd844ac73b57b6577912b146f1e4f3ef5 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 12 Feb 2019 17:55:19 -0800 Subject: [PATCH 25/64] Use built local on CI and not LKG (#29886) * Use built local on CI and not LKG * Adjust function to remove need for assertions * Accept baseline diff to go back to local based baseline * Remove comment --- Jakefile.js | 2 +- src/compiler/core.ts | 7 ++++--- tests/baselines/reference/api/tsserverlibrary.d.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index c6b1cde9d4e2b..18f4aa56f8d92 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -24,7 +24,7 @@ const host = process.env.TYPESCRIPT_HOST || process.env.host || "node"; const defaultTestTimeout = 40000; const useBuilt = - process.env.USE_BUILT === "true" ? true : + (process.env.USE_BUILT === "true" || process.env.CI === "true") ? true : process.env.LKG === "true" ? false : false; diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c5505ec373669..4bd4801ce8f64 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1396,9 +1396,10 @@ namespace ts { export function assign(t: T, ...args: (T | undefined)[]) { for (const arg of args) { - for (const p in arg!) { - if (hasProperty(arg!, p)) { - t![p] = arg![p]; // TODO: GH#23368 + if (arg === undefined) continue; + for (const p in arg) { + if (hasProperty(arg, p)) { + t[p] = arg[p]; } } } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 36c246c999f23..70fccdf87c1a3 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8347,7 +8347,7 @@ declare namespace ts.server { excludedFiles: ReadonlyArray; private typeAcquisition; updateGraph(): boolean; - getExcludedFiles(): ReadonlyArray; + getExcludedFiles(): readonly NormalizedPath[]; getTypeAcquisition(): TypeAcquisition; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; } From 950861ec7f314db7092f71eab815c248fe5dc5b8 Mon Sep 17 00:00:00 2001 From: Titian Cernicova-Dragomir Date: Wed, 13 Feb 2019 17:25:23 +0200 Subject: [PATCH 26/64] Improve error message for using value as type. --- src/compiler/checker.ts | 14 +++++++++++++- src/compiler/diagnosticMessages.json | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9021a50ef8d60..a1248d536a801 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1518,7 +1518,8 @@ namespace ts { !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && - !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) { + !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && + !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { let suggestion: Symbol | undefined; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning); @@ -1708,6 +1709,17 @@ namespace ts { return false; } + function checkAndReportErrorForUsingValueAsType(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { + if (meaning & (SymbolFlags.Type & ~SymbolFlags.Namespace)) { + const symbol = resolveSymbol(resolveName(errorLocation, name, ~SymbolFlags.Type & SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined, /*isUse*/ false)); + if (symbol && !(symbol.flags & SymbolFlags.Namespace)) { + error(errorLocation, Diagnostics._0_refers_to_a_value_but_is_being_used_as_a_type_here, unescapeLeadingUnderscores(name)); + return true; + } + } + return false; + } + function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: __String, meaning: SymbolFlags): boolean { if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) { if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index e40fccd8bf2f0..89794d2618111 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2581,6 +2581,10 @@ "category": "Error", "code": 2748 }, + "'{0}' refers to a value, but is being used as a type here.": { + "category": "Error", + "code": 2749 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From e1855740961320eda7fa79e45b7ec4bad73c6aab Mon Sep 17 00:00:00 2001 From: Titian Cernicova-Dragomir Date: Wed, 13 Feb 2019 17:39:06 +0200 Subject: [PATCH 27/64] Accept new baseline for Improve error message for using value as type. --- ...owImportClausesToMergeWithTypes.errors.txt | 4 ++-- .../reference/callOverloads3.errors.txt | 8 ++++---- .../reference/callOverloads4.errors.txt | 8 ++++---- .../reference/callOverloads5.errors.txt | 8 ++++---- .../constructorOverloads7.errors.txt | 8 ++++---- .../baselines/reference/intrinsics.errors.txt | 4 ++-- ...eNongenericInstantiationAttempt.errors.txt | 4 ++-- ...serAmbiguityWithBinaryOperator4.errors.txt | 8 ++++---- .../reference/typeAssertions.errors.txt | 8 ++++---- .../typeGuardFunctionErrors.errors.txt | 20 +++++++++---------- 10 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.errors.txt b/tests/baselines/reference/allowImportClausesToMergeWithTypes.errors.txt index 684921ae12633..8c4f995531047 100644 --- a/tests/baselines/reference/allowImportClausesToMergeWithTypes.errors.txt +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/index.ts(4,1): error TS2693: 'zzz' only refers to a type, but is being used as a value here. -tests/cases/compiler/index.ts(9,10): error TS2304: Cannot find name 'originalZZZ'. +tests/cases/compiler/index.ts(9,10): error TS2749: 'originalZZZ' refers to a value, but is being used as a type here. ==== tests/cases/compiler/b.ts (0 errors) ==== @@ -31,4 +31,4 @@ tests/cases/compiler/index.ts(9,10): error TS2304: Cannot find name 'originalZZZ const y: originalZZZ = x; ~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'originalZZZ'. \ No newline at end of file +!!! error TS2749: 'originalZZZ' refers to a value, but is being used as a type here. \ No newline at end of file diff --git a/tests/baselines/reference/callOverloads3.errors.txt b/tests/baselines/reference/callOverloads3.errors.txt index 9b14a6791a3a4..7a38d132cbbb1 100644 --- a/tests/baselines/reference/callOverloads3.errors.txt +++ b/tests/baselines/reference/callOverloads3.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/callOverloads3.ts(1,10): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads3.ts(1,16): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/callOverloads3.ts(1,16): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads3.ts(2,10): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads3.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/callOverloads3.ts(2,24): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/callOverloads3.ts(2,24): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads3.ts(3,7): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads3.ts(11,10): error TS2350: Only a void function can be called with the 'new' keyword. @@ -12,14 +12,14 @@ tests/cases/compiler/callOverloads3.ts(11,10): error TS2350: Only a void functio ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ -!!! error TS2304: Cannot find name 'Foo'. +!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. function Foo(s:string):Foo; // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. ~~~ -!!! error TS2304: Cannot find name 'Foo'. +!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. class Foo { // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. diff --git a/tests/baselines/reference/callOverloads4.errors.txt b/tests/baselines/reference/callOverloads4.errors.txt index 04ac340c990f0..dcecd65666e18 100644 --- a/tests/baselines/reference/callOverloads4.errors.txt +++ b/tests/baselines/reference/callOverloads4.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/callOverloads4.ts(1,10): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads4.ts(1,16): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/callOverloads4.ts(1,16): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads4.ts(2,10): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads4.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/callOverloads4.ts(2,24): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/callOverloads4.ts(2,24): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads4.ts(3,7): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads4.ts(11,10): error TS2350: Only a void function can be called with the 'new' keyword. @@ -12,14 +12,14 @@ tests/cases/compiler/callOverloads4.ts(11,10): error TS2350: Only a void functio ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ -!!! error TS2304: Cannot find name 'Foo'. +!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. function Foo(s:string):Foo; // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. ~~~ -!!! error TS2304: Cannot find name 'Foo'. +!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. class Foo { // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. diff --git a/tests/baselines/reference/callOverloads5.errors.txt b/tests/baselines/reference/callOverloads5.errors.txt index e521a9a9076ae..e9ebdc8a52443 100644 --- a/tests/baselines/reference/callOverloads5.errors.txt +++ b/tests/baselines/reference/callOverloads5.errors.txt @@ -1,8 +1,8 @@ tests/cases/compiler/callOverloads5.ts(1,10): error TS2300: Duplicate identifier 'Foo'. -tests/cases/compiler/callOverloads5.ts(1,16): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/callOverloads5.ts(1,16): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads5.ts(2,10): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads5.ts(2,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/compiler/callOverloads5.ts(2,24): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/callOverloads5.ts(2,24): error TS2749: 'Foo' refers to a value, but is being used as a type here. tests/cases/compiler/callOverloads5.ts(3,7): error TS2300: Duplicate identifier 'Foo'. tests/cases/compiler/callOverloads5.ts(13,10): error TS2350: Only a void function can be called with the 'new' keyword. @@ -12,14 +12,14 @@ tests/cases/compiler/callOverloads5.ts(13,10): error TS2350: Only a void functio ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ -!!! error TS2304: Cannot find name 'Foo'. +!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. function Foo(s:string):Foo; // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. ~~~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. ~~~ -!!! error TS2304: Cannot find name 'Foo'. +!!! error TS2749: 'Foo' refers to a value, but is being used as a type here. class Foo { // error ~~~ !!! error TS2300: Duplicate identifier 'Foo'. diff --git a/tests/baselines/reference/constructorOverloads7.errors.txt b/tests/baselines/reference/constructorOverloads7.errors.txt index c915b8f97543d..81aeaaf24ff1e 100644 --- a/tests/baselines/reference/constructorOverloads7.errors.txt +++ b/tests/baselines/reference/constructorOverloads7.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/constructorOverloads7.ts(1,15): error TS2300: Duplicate identifier 'Point'. -tests/cases/compiler/constructorOverloads7.ts(7,35): error TS2304: Cannot find name 'Point'. -tests/cases/compiler/constructorOverloads7.ts(8,14): error TS2304: Cannot find name 'Point'. +tests/cases/compiler/constructorOverloads7.ts(7,35): error TS2749: 'Point' refers to a value, but is being used as a type here. +tests/cases/compiler/constructorOverloads7.ts(8,14): error TS2749: 'Point' refers to a value, but is being used as a type here. tests/cases/compiler/constructorOverloads7.ts(15,10): error TS2300: Duplicate identifier 'Point'. tests/cases/compiler/constructorOverloads7.ts(22,18): error TS2384: Overload signatures must all be ambient or non-ambient. @@ -16,10 +16,10 @@ tests/cases/compiler/constructorOverloads7.ts(22,18): error TS2384: Overload sig add(dx: number, dy: number): Point; ~~~~~ -!!! error TS2304: Cannot find name 'Point'. +!!! error TS2749: 'Point' refers to a value, but is being used as a type here. origin: Point; ~~~~~ -!!! error TS2304: Cannot find name 'Point'. +!!! error TS2749: 'Point' refers to a value, but is being used as a type here. } diff --git a/tests/baselines/reference/intrinsics.errors.txt b/tests/baselines/reference/intrinsics.errors.txt index 5692f057903e5..13d61dacbcf97 100644 --- a/tests/baselines/reference/intrinsics.errors.txt +++ b/tests/baselines/reference/intrinsics.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/intrinsics.ts(1,21): error TS2304: Cannot find name 'hasOwnProperty'. +tests/cases/compiler/intrinsics.ts(1,21): error TS2749: 'hasOwnProperty' refers to a value, but is being used as a type here. tests/cases/compiler/intrinsics.ts(1,21): error TS4025: Exported variable 'hasOwnProperty' has or is using private name 'hasOwnProperty'. tests/cases/compiler/intrinsics.ts(10,1): error TS2304: Cannot find name '__proto__'. @@ -6,7 +6,7 @@ tests/cases/compiler/intrinsics.ts(10,1): error TS2304: Cannot find name '__prot ==== tests/cases/compiler/intrinsics.ts (3 errors) ==== var hasOwnProperty: hasOwnProperty; // Error ~~~~~~~~~~~~~~ -!!! error TS2304: Cannot find name 'hasOwnProperty'. +!!! error TS2749: 'hasOwnProperty' refers to a value, but is being used as a type here. ~~~~~~~~~~~~~~ !!! error TS4025: Exported variable 'hasOwnProperty' has or is using private name 'hasOwnProperty'. diff --git a/tests/baselines/reference/jsdocTypeNongenericInstantiationAttempt.errors.txt b/tests/baselines/reference/jsdocTypeNongenericInstantiationAttempt.errors.txt index 941e4386f9927..b3298f137f14f 100644 --- a/tests/baselines/reference/jsdocTypeNongenericInstantiationAttempt.errors.txt +++ b/tests/baselines/reference/jsdocTypeNongenericInstantiationAttempt.errors.txt @@ -5,7 +5,7 @@ tests/cases/compiler/index4.js(2,19): error TS2315: Type 'Function' is not gener tests/cases/compiler/index5.js(2,19): error TS2315: Type 'String' is not generic. tests/cases/compiler/index6.js(2,19): error TS2315: Type 'Number' is not generic. tests/cases/compiler/index7.js(2,19): error TS2315: Type 'Object' is not generic. -tests/cases/compiler/index8.js(4,12): error TS2304: Cannot find name 'fn'. +tests/cases/compiler/index8.js(4,12): error TS2749: 'fn' refers to a value, but is being used as a type here. tests/cases/compiler/index8.js(4,15): error TS2304: Cannot find name 'T'. @@ -90,7 +90,7 @@ tests/cases/compiler/index8.js(4,15): error TS2304: Cannot find name 'T'. /** * @param {fn} somebody ~~ -!!! error TS2304: Cannot find name 'fn'. +!!! error TS2749: 'fn' refers to a value, but is being used as a type here. ~ !!! error TS2304: Cannot find name 'T'. */ diff --git a/tests/baselines/reference/parserAmbiguityWithBinaryOperator4.errors.txt b/tests/baselines/reference/parserAmbiguityWithBinaryOperator4.errors.txt index 41147305ce059..a94b60e5f996d 100644 --- a/tests/baselines/reference/parserAmbiguityWithBinaryOperator4.errors.txt +++ b/tests/baselines/reference/parserAmbiguityWithBinaryOperator4.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserAmbiguityWithBinaryOperator4.ts(3,9): error TS2347: Untyped function calls may not accept type arguments. -tests/cases/conformance/parser/ecmascript5/Generics/parserAmbiguityWithBinaryOperator4.ts(3,11): error TS2304: Cannot find name 'b'. -tests/cases/conformance/parser/ecmascript5/Generics/parserAmbiguityWithBinaryOperator4.ts(3,14): error TS2304: Cannot find name 'b'. +tests/cases/conformance/parser/ecmascript5/Generics/parserAmbiguityWithBinaryOperator4.ts(3,11): error TS2749: 'b' refers to a value, but is being used as a type here. +tests/cases/conformance/parser/ecmascript5/Generics/parserAmbiguityWithBinaryOperator4.ts(3,14): error TS2749: 'b' refers to a value, but is being used as a type here. ==== tests/cases/conformance/parser/ecmascript5/Generics/parserAmbiguityWithBinaryOperator4.ts (3 errors) ==== @@ -10,7 +10,7 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserAmbiguityWithBinaryOpe ~~~~~~~~~~~~~~ !!! error TS2347: Untyped function calls may not accept type arguments. ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS2749: 'b' refers to a value, but is being used as a type here. ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS2749: 'b' refers to a value, but is being used as a type here. } \ No newline at end of file diff --git a/tests/baselines/reference/typeAssertions.errors.txt b/tests/baselines/reference/typeAssertions.errors.txt index 27de59a76453f..ef9a23b8d8ae4 100644 --- a/tests/baselines/reference/typeAssertions.errors.txt +++ b/tests/baselines/reference/typeAssertions.errors.txt @@ -7,7 +7,7 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(37,13): err Property 'q' is missing in type 'SomeDerived' but required in type 'SomeOther'. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(38,13): error TS2352: Conversion of type 'SomeBase' to type 'SomeOther' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first. Property 'q' is missing in type 'SomeBase' but required in type 'SomeOther'. -tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,5): error TS2304: Cannot find name 'numOrStr'. +tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,5): error TS2749: 'numOrStr' refers to a value, but is being used as a type here. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,14): error TS1005: '>' expected. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,14): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,17): error TS1005: ')' expected. @@ -15,7 +15,7 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,17): err tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(44,48): error TS1005: ';' expected. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(45,2): error TS2322: Type 'string | number' is not assignable to type 'string'. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,32): error TS2304: Cannot find name 'numOrStr'. +tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,32): error TS2749: 'numOrStr' refers to a value, but is being used as a type here. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,41): error TS1005: ')' expected. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,41): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,44): error TS1005: ';' expected. @@ -86,7 +86,7 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,50): err var str: string; if((numOrStr === undefined)) { // Error ~~~~~~~~ -!!! error TS2304: Cannot find name 'numOrStr'. +!!! error TS2749: 'numOrStr' refers to a value, but is being used as a type here. ~~ !!! error TS1005: '>' expected. ~~ @@ -105,7 +105,7 @@ tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(48,50): err if((numOrStr === undefined) as numOrStr is string) { // Error ~~~~~~~~ -!!! error TS2304: Cannot find name 'numOrStr'. +!!! error TS2749: 'numOrStr' refers to a value, but is being used as a type here. ~~ !!! error TS1005: ')' expected. ~~ diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index a6ea9961c54f5..6f24585a85f2b 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -1,10 +1,10 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(1,7): error TS2300: Duplicate identifier 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(14,5): error TS2322: Type '""' is not assignable to type 'boolean'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,55): error TS2304: Cannot find name 'x'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,55): error TS2749: 'x' refers to a value, but is being used as a type here. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,57): error TS1144: '{' or ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,60): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,62): error TS1005: ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(21,33): error TS2304: Cannot find name 'x'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(21,33): error TS2749: 'x' refers to a value, but is being used as a type here. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(25,33): error TS1225: Cannot find parameter 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(29,10): error TS2391: Function implementation is missing or not immediately following the declaration. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(30,5): error TS1131: Property or signature expected. @@ -28,14 +28,14 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(84,1): Type predicate 'p2 is A' is not assignable to 'p1 is A'. Parameter 'p2' is not in the same position as parameter 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(90,1): error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,9): error TS2304: Cannot find name 'b'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,9): error TS2749: 'b' refers to a value, but is being used as a type here. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,11): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,14): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,14): error TS2300: Duplicate identifier 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,16): error TS2304: Cannot find name 'b'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,16): error TS2749: 'b' refers to a value, but is being used as a type here. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,18): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,21): error TS1005: ',' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,20): error TS2304: Cannot find name 'b'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,20): error TS2749: 'b' refers to a value, but is being used as a type here. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,22): error TS1144: '{' or ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,27): error TS1005: ';' expected. @@ -91,7 +91,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A { ~ -!!! error TS2304: Cannot find name 'x'. +!!! error TS2749: 'x' refers to a value, but is being used as a type here. ~~ !!! error TS1144: '{' or ';' expected. ~ @@ -103,7 +103,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 function hasMissingIsKeyword(): x { ~ -!!! error TS2304: Cannot find name 'x'. +!!! error TS2749: 'x' refers to a value, but is being used as a type here. return true; } @@ -222,7 +222,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 // Type predicates in non-return type positions var b1: b is A; ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS2749: 'b' refers to a value, but is being used as a type here. ~~ !!! error TS1005: ',' expected. ~ @@ -231,14 +231,14 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 !!! error TS2300: Duplicate identifier 'A'. function b2(a: b is A) {}; ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS2749: 'b' refers to a value, but is being used as a type here. ~~ !!! error TS1005: ',' expected. ~ !!! error TS1005: ',' expected. function b3(): A | b is A { ~ -!!! error TS2304: Cannot find name 'b'. +!!! error TS2749: 'b' refers to a value, but is being used as a type here. ~~ !!! error TS1144: '{' or ';' expected. ~ From ad7702f15a89d7056459375898fa7bfa5f96e5ef Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 13 Feb 2019 12:57:35 -0800 Subject: [PATCH 28/64] Disable node 6 (#29832) * Disable node 6 It exits LTS in a couple of months, and doesn't support async/await, meaning that it blocks us from switching Travis to use gulp instead of jake. * Swap in node 8 for node 6 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0f720b7375e62..b35dabcbb5f74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: node_js node_js: - 'node' - '10' - - '6' + - '8' sudo: false From 5ec35c1ee80a621cec8066bdd53a000b4b4a633f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 13 Feb 2019 17:27:28 -0800 Subject: [PATCH 29/64] Readd configure-insiders task to Gulpfile (#29907) It's identical to configure-nightly but with the flag changed from dev to insiders. We use it to manually publish an insiders build via pipeline, and went missing when we copied functionality from the jakefile. --- Gulpfile.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Gulpfile.js b/Gulpfile.js index 68a2b79f222e9..7d31e0a6137a1 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -618,6 +618,10 @@ const configureNightly = () => exec(process.execPath, ["scripts/configurePrerele task("configure-nightly", series(buildScripts, configureNightly)); task("configure-nightly").description = "Runs scripts/configurePrerelease.ts to prepare a build for nightly publishing"; +const configureInsiders = () => exec(process.execPath, ["scripts/configurePrerelease.js", "insiders", "package.json", "src/compiler/core.ts"]) +task("configure-insiders", series(buildScripts, configureInsiders)); +task("configure-insiders").description = "Runs scripts/configurePrerelease.ts to prepare a build for insiders publishing"; + const publishNightly = () => exec("npm", ["publish", "--tag", "next"]); task("publish-nightly", series(task("clean"), task("LKG"), task("clean"), task("runtests-parallel"), publishNightly)); task("publish-nightly").description = "Runs `npm publish --tag next` to create a new nightly build on npm"; From c358b0b4a547866b1fd8fba15dcb8ff31b812ea1 Mon Sep 17 00:00:00 2001 From: Titian Cernicova-Dragomir Date: Thu, 14 Feb 2019 07:23:11 +0200 Subject: [PATCH 30/64] Fixed tslint error. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a1248d536a801..0dce8cf8ecad6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1518,7 +1518,7 @@ namespace ts { !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && - !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && + !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) { let suggestion: Symbol | undefined; if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { From 84076a55351684296f7b3f1d2715690acbe8039f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 13 Feb 2019 22:54:33 -0800 Subject: [PATCH 31/64] Add diagnostic context for expando property declarations (#29905) --- src/compiler/transformers/declarations.ts | 2 ++ .../transformers/declarations/diagnostics.ts | 10 +++--- ...nEmitExpandoPropertyPrivateName.errors.txt | 14 +++++++++ ...clarationEmitExpandoPropertyPrivateName.js | 31 +++++++++++++++++++ ...tionEmitExpandoPropertyPrivateName.symbols | 22 +++++++++++++ ...rationEmitExpandoPropertyPrivateName.types | 22 +++++++++++++ ...clarationEmitExpandoPropertyPrivateName.ts | 9 ++++++ .../TypeScript-Node-Starter | 2 +- tests/cases/user/prettier/prettier | 2 +- tests/cases/user/webpack/webpack | 2 +- 10 files changed, 109 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.errors.txt create mode 100644 tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.js create mode 100644 tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.symbols create mode 100644 tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.types create mode 100644 tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 42bb5d7793131..63c340d81dc8a 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1006,7 +1006,9 @@ namespace ts { if (!isPropertyAccessExpression(p.valueDeclaration)) { return undefined; } + getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); const type = resolver.createTypeOfDeclaration(p.valueDeclaration, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker); + getSymbolAccessibilityDiagnostic = oldDiag; const varDecl = createVariableDeclaration(unescapeLeadingUnderscores(p.escapedName), type, /*initializer*/ undefined); return createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([varDecl])); }); diff --git a/src/compiler/transformers/declarations/diagnostics.ts b/src/compiler/transformers/declarations/diagnostics.ts index b4c72c7901214..9a9aed99e4791 100644 --- a/src/compiler/transformers/declarations/diagnostics.ts +++ b/src/compiler/transformers/declarations/diagnostics.ts @@ -26,7 +26,8 @@ namespace ts { | ImportEqualsDeclaration | TypeAliasDeclaration | ConstructorDeclaration - | IndexSignatureDeclaration; + | IndexSignatureDeclaration + | PropertyAccessExpression; export function canProduceDiagnostics(node: Node): node is DeclarationDiagnosticProducing { return isVariableDeclaration(node) || @@ -46,7 +47,8 @@ namespace ts { isImportEqualsDeclaration(node) || isTypeAliasDeclaration(node) || isConstructorDeclaration(node) || - isIndexSignatureDeclaration(node); + isIndexSignatureDeclaration(node) || + isPropertyAccessExpression(node); } export function createGetSymbolAccessibilityDiagnosticForNodeName(node: DeclarationDiagnosticProducing) { @@ -123,7 +125,7 @@ namespace ts { } export function createGetSymbolAccessibilityDiagnosticForNode(node: DeclarationDiagnosticProducing): (symbolAccessibilityResult: SymbolAccessibilityResult) => SymbolAccessibilityDiagnostic | undefined { - if (isVariableDeclaration(node) || isPropertyDeclaration(node) || isPropertySignature(node) || isBindingElement(node) || isConstructorDeclaration(node)) { + if (isVariableDeclaration(node) || isPropertyDeclaration(node) || isPropertySignature(node) || isPropertyAccessExpression(node) || isBindingElement(node) || isConstructorDeclaration(node)) { return getVariableDeclarationTypeVisibilityError; } else if (isSetAccessor(node) || isGetAccessor(node)) { @@ -164,7 +166,7 @@ namespace ts { } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. - else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || + else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertyAccessExpression || node.kind === SyntaxKind.PropertySignature || (node.kind === SyntaxKind.Parameter && hasModifier(node.parent, ModifierFlags.Private))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (hasModifier(node, ModifierFlags.Static)) { diff --git a/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.errors.txt b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.errors.txt new file mode 100644 index 0000000000000..343a3a5351a8f --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/b.ts(4,1): error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"tests/cases/compiler/a"'. + + +==== tests/cases/compiler/a.ts (0 errors) ==== + interface I {} + export function f(): I { return null as I; } +==== tests/cases/compiler/b.ts (1 errors) ==== + import {f} from "./a"; + + export function q() {} + q.val = f(); + ~~~~~ +!!! error TS4032: Property 'val' of exported interface has or is using name 'I' from private module '"tests/cases/compiler/a"'. + \ No newline at end of file diff --git a/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.js b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.js new file mode 100644 index 0000000000000..a40fb25276005 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.js @@ -0,0 +1,31 @@ +//// [tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts] //// + +//// [a.ts] +interface I {} +export function f(): I { return null as I; } +//// [b.ts] +import {f} from "./a"; + +export function q() {} +q.val = f(); + + +//// [a.js] +"use strict"; +exports.__esModule = true; +function f() { return null; } +exports.f = f; +//// [b.js] +"use strict"; +exports.__esModule = true; +var a_1 = require("./a"); +function q() { } +exports.q = q; +q.val = a_1.f(); + + +//// [a.d.ts] +interface I { +} +export declare function f(): I; +export {}; diff --git a/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.symbols b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.symbols new file mode 100644 index 0000000000000..841620f036182 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/a.ts === +interface I {} +>I : Symbol(I, Decl(a.ts, 0, 0)) + +export function f(): I { return null as I; } +>f : Symbol(f, Decl(a.ts, 0, 14)) +>I : Symbol(I, Decl(a.ts, 0, 0)) +>I : Symbol(I, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.ts === +import {f} from "./a"; +>f : Symbol(f, Decl(b.ts, 0, 8)) + +export function q() {} +>q : Symbol(q, Decl(b.ts, 0, 22), Decl(b.ts, 2, 22)) + +q.val = f(); +>q.val : Symbol(q.val, Decl(b.ts, 2, 22)) +>q : Symbol(q, Decl(b.ts, 0, 22), Decl(b.ts, 2, 22)) +>val : Symbol(q.val, Decl(b.ts, 2, 22)) +>f : Symbol(f, Decl(b.ts, 0, 8)) + diff --git a/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.types b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.types new file mode 100644 index 0000000000000..7418b4140297b --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoPropertyPrivateName.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/a.ts === +interface I {} +export function f(): I { return null as I; } +>f : () => I +>null as I : I +>null : null + +=== tests/cases/compiler/b.ts === +import {f} from "./a"; +>f : () => I + +export function q() {} +>q : typeof q + +q.val = f(); +>q.val = f() : I +>q.val : I +>q : typeof q +>val : I +>f() : I +>f : () => I + diff --git a/tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts b/tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts new file mode 100644 index 0000000000000..09be2a08ff89b --- /dev/null +++ b/tests/cases/compiler/declarationEmitExpandoPropertyPrivateName.ts @@ -0,0 +1,9 @@ +// @declaration: true +// @filename: a.ts +interface I {} +export function f(): I { return null as I; } +// @filename: b.ts +import {f} from "./a"; + +export function q() {} +q.val = f(); diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter index 6b9706810b55a..40bdb4eadabc9 160000 --- a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -1 +1 @@ -Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32 +Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6 diff --git a/tests/cases/user/prettier/prettier b/tests/cases/user/prettier/prettier index 6e0de0812231c..67f1c4877ee10 160000 --- a/tests/cases/user/prettier/prettier +++ b/tests/cases/user/prettier/prettier @@ -1 +1 @@ -Subproject commit 6e0de0812231c3a48387d398d092418749aa39f1 +Subproject commit 67f1c4877ee1090b66d468a847caccca411a6f82 diff --git a/tests/cases/user/webpack/webpack b/tests/cases/user/webpack/webpack index a28f44f613276..10282ea20648b 160000 --- a/tests/cases/user/webpack/webpack +++ b/tests/cases/user/webpack/webpack @@ -1 +1 @@ -Subproject commit a28f44f613276446fb764dec7fab38b7cff8a07c +Subproject commit 10282ea20648b465caec6448849f24fc34e1ba3e From b57956673e95884023e4bfe6ab308837b3e300c9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 14 Feb 2019 14:42:55 -0800 Subject: [PATCH 32/64] Move TypeFlags.PropapatingFlags to ObjectFlags to free up 3 flags --- src/compiler/checker.ts | 143 +++++++++++++++++++------------------- src/compiler/types.ts | 105 ++++++++++++++++------------ src/compiler/utilities.ts | 2 +- 3 files changed, 133 insertions(+), 117 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9021a50ef8d60..f76505ad4a51a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -390,10 +390,10 @@ namespace ts { const wildcardType = createIntrinsicType(TypeFlags.Any, "any"); const errorType = createIntrinsicType(TypeFlags.Any, "error"); const unknownType = createIntrinsicType(TypeFlags.Unknown, "unknown"); - const undefinedType = createIntrinsicType(TypeFlags.Undefined, "undefined"); - const undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsWideningType, "undefined"); - const nullType = createIntrinsicType(TypeFlags.Null, "null"); - const nullWideningType = strictNullChecks ? nullType : createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsWideningType, "null"); + const undefinedType = createNullableType(TypeFlags.Undefined, "undefined", 0); + const undefinedWideningType = strictNullChecks ? undefinedType : createNullableType(TypeFlags.Undefined, "undefined", ObjectFlags.ContainsWideningType); + const nullType = createNullableType(TypeFlags.Null, "null", 0); + const nullWideningType = strictNullChecks ? nullType : createNullableType(TypeFlags.Null, "null", ObjectFlags.ContainsWideningType); const stringType = createIntrinsicType(TypeFlags.String, "string"); const numberType = createIntrinsicType(TypeFlags.Number, "number"); const bigintType = createIntrinsicType(TypeFlags.BigInt, "bigint"); @@ -439,7 +439,7 @@ namespace ts { const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated // in getPropagatingFlagsOfTypes, and it is checked in inferFromTypes. - anyFunctionType.flags |= TypeFlags.ContainsAnyFunctionType; + anyFunctionType.objectFlags |= ObjectFlags.ContainsAnyFunctionType; const noConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); const circularConstraintType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); @@ -2741,6 +2741,12 @@ namespace ts { return type; } + function createNullableType(kind: TypeFlags, intrinsicName: string, objectFlags: ObjectFlags): NullableType { + const type = createIntrinsicType(kind, intrinsicName); + type.objectFlags = objectFlags; + return type; + } + function createBooleanType(trueFalseTypes: ReadonlyArray): IntrinsicType & UnionType { const type = getUnionType(trueFalseTypes); type.flags |= TypeFlags.Boolean; @@ -5128,7 +5134,7 @@ namespace ts { definedInConstructor = true; } } - const sourceTypes = some(constructorTypes, t => !!(t.flags & ~(TypeFlags.Nullable | TypeFlags.ContainsWideningType))) ? constructorTypes : types; // TODO: GH#18217 + const sourceTypes = some(constructorTypes, t => !!(t.flags & ~TypeFlags.Nullable)) ? constructorTypes : types; // TODO: GH#18217 type = getUnionType(sourceTypes!, UnionReduction.Subtype); } const widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); @@ -5293,7 +5299,7 @@ namespace ts { function getTypeFromObjectBindingPattern(pattern: ObjectBindingPattern, includePatternInType: boolean, reportErrors: boolean): Type { const members = createSymbolTable(); let stringIndexInfo: IndexInfo | undefined; - let objectFlags = ObjectFlags.ObjectLiteral; + let objectFlags = ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral; forEach(pattern.elements, e => { const name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -5315,7 +5321,6 @@ namespace ts { members.set(symbol.escapedName, symbol); }); const result = createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, undefined); - result.flags |= TypeFlags.ContainsObjectLiteral; result.objectFlags |= objectFlags; if (includePatternInType) { result.pattern = pattern; @@ -8540,14 +8545,14 @@ namespace ts { // It is only necessary to do so if a constituent type might be the undefined type, the null type, the type // of an object literal or the anyFunctionType. This is because there are operations in the type checker // that care about the presence of such types at arbitrary depth in a containing type. - function getPropagatingFlagsOfTypes(types: ReadonlyArray, excludeKinds: TypeFlags): TypeFlags { - let result: TypeFlags = 0; + function getPropagatingFlagsOfTypes(types: ReadonlyArray, excludeKinds: TypeFlags): ObjectFlags { + let result: ObjectFlags = 0; for (const type of types) { if (!(type.flags & excludeKinds)) { - result |= type.flags; + result |= getObjectFlags(type); } } - return result & TypeFlags.PropagatingFlags; + return result & ObjectFlags.PropagatingFlags; } function createTypeReference(target: GenericType, typeArguments: ReadonlyArray | undefined): TypeReference { @@ -8556,7 +8561,7 @@ namespace ts { if (!type) { type = createObjectType(ObjectFlags.Reference, target.symbol); target.instantiations.set(id, type); - type.flags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; + type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, /*excludeKinds*/ 0) : 0; type.target = target; type.typeArguments = typeArguments; } @@ -9235,10 +9240,11 @@ namespace ts { // intersections of unit types into 'never' upon construction, but deferring the reduction makes it // easier to reason about their origin. if (!(flags & TypeFlags.Never || flags & TypeFlags.Intersection && isEmptyIntersectionType(type))) { - includes |= flags & ~TypeFlags.ConstructionFlags; - if (type === wildcardType) includes |= TypeFlags.Wildcard; + includes |= flags & TypeFlags.IncludesMask; + if (flags & TypeFlags.StructuredOrInstantiable) includes |= TypeFlags.IncludesStructuredOrInstantiable; + if (type === wildcardType) includes |= TypeFlags.IncludesWildcard; if (!strictNullChecks && flags & TypeFlags.Nullable) { - if (!(flags & TypeFlags.ContainsWideningType)) includes |= TypeFlags.NonWideningType; + if (!(getObjectFlags(type) & ObjectFlags.ContainsWideningType)) includes |= TypeFlags.IncludesNonWideningType; } else { const len = typeSet.length; @@ -9349,7 +9355,7 @@ namespace ts { const includes = addTypesToUnion(typeSet, 0, types); if (unionReduction !== UnionReduction.None) { if (includes & TypeFlags.AnyOrUnknown) { - return includes & TypeFlags.Any ? includes & TypeFlags.Wildcard ? wildcardType : anyType : unknownType; + return includes & TypeFlags.Any ? includes & TypeFlags.IncludesWildcard ? wildcardType : anyType : unknownType; } switch (unionReduction) { case UnionReduction.Literal: @@ -9358,18 +9364,18 @@ namespace ts { } break; case UnionReduction.Subtype: - if (!removeSubtypes(typeSet, !(includes & TypeFlags.StructuredOrInstantiable))) { + if (!removeSubtypes(typeSet, !(includes & TypeFlags.IncludesStructuredOrInstantiable))) { return errorType; } break; } if (typeSet.length === 0) { - return includes & TypeFlags.Null ? includes & TypeFlags.NonWideningType ? nullType : nullWideningType : - includes & TypeFlags.Undefined ? includes & TypeFlags.NonWideningType ? undefinedType : undefinedWideningType : + return includes & TypeFlags.Null ? includes & TypeFlags.IncludesNonWideningType ? nullType : nullWideningType : + includes & TypeFlags.Undefined ? includes & TypeFlags.IncludesNonWideningType ? undefinedType : undefinedWideningType : neverType; } } - return getUnionTypeFromSortedList(typeSet, !(includes & TypeFlags.NotPrimitiveUnion), aliasSymbol, aliasTypeArguments); + return getUnionTypeFromSortedList(typeSet, includes & TypeFlags.NotPrimitiveUnion ? 0 : ObjectFlags.PrimitiveUnion, aliasSymbol, aliasTypeArguments); } function getUnionTypePredicate(signatures: ReadonlyArray): TypePredicate | undefined { @@ -9409,7 +9415,7 @@ namespace ts { } // This function assumes the constituent type list is sorted and deduplicated. - function getUnionTypeFromSortedList(types: Type[], primitiveTypesOnly: boolean, aliasSymbol?: Symbol, aliasTypeArguments?: ReadonlyArray): Type { + function getUnionTypeFromSortedList(types: Type[], objectFlags: ObjectFlags, aliasSymbol?: Symbol, aliasTypeArguments?: ReadonlyArray): Type { if (types.length === 0) { return neverType; } @@ -9419,11 +9425,10 @@ namespace ts { const id = getTypeListId(types); let type = unionTypes.get(id); if (!type) { - const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); - type = createType(TypeFlags.Union | propagatedFlags); + type = createType(TypeFlags.Union); unionTypes.set(id, type); + type.objectFlags = objectFlags | getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); type.types = types; - type.primitiveTypesOnly = primitiveTypesOnly; /* Note: This is the alias symbol (or lack thereof) that we see when we first encounter this union type. For aliases of identical unions, eg `type T = A | B; type U = A | B`, the symbol of the first alias encountered is the aliasSymbol. @@ -9452,15 +9457,15 @@ namespace ts { return addTypesToIntersection(typeSet, includes, (type).types); } if (isEmptyAnonymousObjectType(type)) { - if (!(includes & TypeFlags.EmptyObject)) { - includes |= TypeFlags.EmptyObject; + if (!(includes & TypeFlags.IncludesEmptyObject)) { + includes |= TypeFlags.IncludesEmptyObject; typeSet.push(type); } } else { - includes |= flags & ~TypeFlags.ConstructionFlags; + includes |= flags & TypeFlags.IncludesMask; if (flags & TypeFlags.AnyOrUnknown) { - if (type === wildcardType) includes |= TypeFlags.Wildcard; + if (type === wildcardType) includes |= TypeFlags.IncludesWildcard; } else if ((strictNullChecks || !(flags & TypeFlags.Nullable)) && !contains(typeSet, type)) { typeSet.push(type); @@ -9518,7 +9523,7 @@ namespace ts { // other unions and return true. Otherwise, do nothing and return false. function intersectUnionsOfPrimitiveTypes(types: Type[]) { let unionTypes: UnionType[] | undefined; - const index = findIndex(types, t => !!(t.flags & TypeFlags.Union) && (t).primitiveTypesOnly); + const index = findIndex(types, t => !!(getObjectFlags(t) & ObjectFlags.PrimitiveUnion)); if (index < 0) { return false; } @@ -9527,7 +9532,7 @@ namespace ts { // the unionTypes array. while (i < types.length) { const t = types[i]; - if (t.flags & TypeFlags.Union && (t).primitiveTypesOnly) { + if (getObjectFlags(t) & ObjectFlags.PrimitiveUnion) { (unionTypes || (unionTypes = [types[index]])).push(t); orderedRemoveItemAt(types, i); } @@ -9554,7 +9559,7 @@ namespace ts { } } // Finally replace the first union with the result - types[index] = getUnionTypeFromSortedList(result, /*primitiveTypesOnly*/ true); + types[index] = getUnionTypeFromSortedList(result, ObjectFlags.PrimitiveUnion); return true; } @@ -9575,7 +9580,7 @@ namespace ts { return neverType; } if (includes & TypeFlags.Any) { - return includes & TypeFlags.Wildcard ? wildcardType : anyType; + return includes & TypeFlags.IncludesWildcard ? wildcardType : anyType; } if (!strictNullChecks && includes & TypeFlags.Nullable) { return includes & TypeFlags.Undefined ? undefinedType : nullType; @@ -9586,7 +9591,7 @@ namespace ts { includes & TypeFlags.ESSymbol && includes & TypeFlags.UniqueESSymbol) { removeRedundantPrimitiveTypes(typeSet, includes); } - if (includes & TypeFlags.EmptyObject && includes & TypeFlags.Object) { + if (includes & TypeFlags.IncludesEmptyObject && includes & TypeFlags.Object) { orderedRemoveItemAt(typeSet, findIndex(typeSet, isEmptyAnonymousObjectType)); } if (typeSet.length === 0) { @@ -9612,9 +9617,9 @@ namespace ts { const id = getTypeListId(typeSet); let type = intersectionTypes.get(id); if (!type) { - const propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); - type = createType(TypeFlags.Intersection | propagatedFlags); + type = createType(TypeFlags.Intersection); intersectionTypes.set(id, type); + type.objectFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); type.types = typeSet; type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. type.aliasTypeArguments = aliasTypeArguments; @@ -10273,7 +10278,7 @@ namespace ts { * this function should be called in a left folding style, with left = previous result of getSpreadType * and right = the new element to be spread. */ - function getSpreadType(left: Type, right: Type, symbol: Symbol | undefined, typeFlags: TypeFlags, objectFlags: ObjectFlags, readonly: boolean): Type { + function getSpreadType(left: Type, right: Type, symbol: Symbol | undefined, objectFlags: ObjectFlags, readonly: boolean): Type { if (left.flags & TypeFlags.Any || right.flags & TypeFlags.Any) { return anyType; } @@ -10287,10 +10292,10 @@ namespace ts { return left; } if (left.flags & TypeFlags.Union) { - return mapType(left, t => getSpreadType(t, right, symbol, typeFlags, objectFlags, readonly)); + return mapType(left, t => getSpreadType(t, right, symbol, objectFlags, readonly)); } if (right.flags & TypeFlags.Union) { - return mapType(right, t => getSpreadType(left, t, symbol, typeFlags, objectFlags, readonly)); + return mapType(right, t => getSpreadType(left, t, symbol, objectFlags, readonly)); } if (right.flags & (TypeFlags.BooleanLike | TypeFlags.NumberLike | TypeFlags.BigIntLike | TypeFlags.StringLike | TypeFlags.EnumLike | TypeFlags.NonPrimitive | TypeFlags.Index)) { return left; @@ -10307,7 +10312,7 @@ namespace ts { const types = (left).types; const lastLeft = types[types.length - 1]; if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) { - return getIntersectionType(concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, typeFlags, objectFlags, readonly)])); + return getIntersectionType(concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, objectFlags, readonly)])); } } return getIntersectionType([left, right]); @@ -10367,8 +10372,7 @@ namespace ts { emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.flags |= TypeFlags.ContainsObjectLiteral | typeFlags; - spread.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsSpread | objectFlags; + spread.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral | ObjectFlags.ContainsSpread | objectFlags; return spread; } @@ -13853,7 +13857,7 @@ namespace ts { resolved.stringIndexInfo, resolved.numberIndexInfo); regularNew.flags = resolved.flags; - regularNew.objectFlags |= ObjectFlags.ObjectLiteral | (getObjectFlags(resolved) & ObjectFlags.JSLiteral); + regularNew.objectFlags |= resolved.objectFlags & ~ObjectFlags.FreshLiteral; (type).regularType = regularNew; return regularNew; } @@ -13944,7 +13948,7 @@ namespace ts { } function getWidenedTypeWithContext(type: Type, context: WideningContext | undefined): Type { - if (type.flags & TypeFlags.RequiresWidening) { + if (getObjectFlags(type) & ObjectFlags.RequiresWidening) { if (type.flags & TypeFlags.Nullable) { return anyType; } @@ -13982,7 +13986,7 @@ namespace ts { */ function reportWideningErrorsInType(type: Type): boolean { let errorReported = false; - if (type.flags & TypeFlags.ContainsWideningType) { + if (getObjectFlags(type) & ObjectFlags.ContainsWideningType) { if (type.flags & TypeFlags.Union) { if (some((type).types, isEmptyObjectType)) { errorReported = true; @@ -14005,7 +14009,7 @@ namespace ts { if (isObjectLiteralType(type)) { for (const p of getPropertiesOfObjectType(type)) { const t = getTypeOfSymbol(p); - if (t.flags & TypeFlags.ContainsWideningType) { + if (getObjectFlags(t) & ObjectFlags.ContainsWideningType) { if (!reportWideningErrorsInType(t)) { error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t))); } @@ -14080,7 +14084,7 @@ namespace ts { } function reportErrorsFromWidening(declaration: Declaration, type: Type) { - if (produceDiagnostics && noImplicitAny && type.flags & TypeFlags.ContainsWideningType) { + if (produceDiagnostics && noImplicitAny && getObjectFlags(type) & ObjectFlags.ContainsWideningType) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAny(declaration, type); @@ -14225,7 +14229,7 @@ namespace ts { // If any property contains context sensitive functions that have been skipped, the source type // is incomplete and we can't infer a meaningful input type. for (const prop of properties) { - if (getTypeOfSymbol(prop).flags & TypeFlags.ContainsAnyFunctionType) { + if (getObjectFlags(getTypeOfSymbol(prop)) & ObjectFlags.ContainsAnyFunctionType) { return undefined; } } @@ -14383,7 +14387,7 @@ namespace ts { // not contain anyFunctionType when we come back to this argument for its second round // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard // when constructing types from type parameters that had no inference candidates). - if (source.flags & TypeFlags.ContainsAnyFunctionType || source === silentNeverType || (priority & InferencePriority.ReturnType && (source === autoType || source === autoArrayType))) { + if (getObjectFlags(source) & ObjectFlags.ContainsAnyFunctionType || source === silentNeverType || (priority & InferencePriority.ReturnType && (source === autoType || source === autoArrayType))) { return; } const inference = getInferenceInfoForType(target); @@ -14686,7 +14690,7 @@ namespace ts { const sourceLen = sourceSignatures.length; const targetLen = targetSignatures.length; const len = sourceLen < targetLen ? sourceLen : targetLen; - const skipParameters = !!(source.flags & TypeFlags.ContainsAnyFunctionType); + const skipParameters = !!(getObjectFlags(source) & ObjectFlags.ContainsAnyFunctionType); for (let i = 0; i < len; i++) { inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getBaseSignature(targetSignatures[targetLen - len + i]), skipParameters); } @@ -15444,7 +15448,7 @@ namespace ts { if (type.flags & TypeFlags.Union) { const types = (type).types; const filtered = filter(types, f); - return filtered === types ? type : getUnionTypeFromSortedList(filtered, (type).primitiveTypesOnly); + return filtered === types ? type : getUnionTypeFromSortedList(filtered, (type).objectFlags); } return f(type) ? type : neverType; } @@ -18350,7 +18354,7 @@ namespace ts { let propertiesTable: SymbolTable; let propertiesArray: Symbol[] = []; let spread: Type = emptyObjectType; - let propagatedFlags: TypeFlags = 0; + let propagatedFlags: ObjectFlags = 0; const contextualType = getApparentTypeOfContextualType(node); const contextualTypeHasPattern = contextualType && contextualType.pattern && @@ -18360,7 +18364,7 @@ namespace ts { const isInJavascript = isInJSFile(node) && !isInJsonFile(node); const enumTag = getJSDocEnumTag(node); const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; - let typeFlags: TypeFlags = 0; + let objectFlags: ObjectFlags = 0; let patternWithComputedProperties = false; let hasComputedStringProperty = false; let hasComputedNumberProperty = false; @@ -18388,7 +18392,7 @@ namespace ts { checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - typeFlags |= type.flags; + objectFlags |= getObjectFlags(type); const nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; const prop = nameType ? createSymbol(SymbolFlags.Property | member.flags, getPropertyNameFromType(nameType), checkFlags | CheckFlags.Late) : @@ -18436,19 +18440,19 @@ namespace ts { checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, ObjectFlags.FreshLiteral, inConstContext); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags | ObjectFlags.FreshLiteral, inConstContext); propertiesArray = []; propertiesTable = createSymbolTable(); hasComputedStringProperty = false; hasComputedNumberProperty = false; - typeFlags = 0; + objectFlags = 0; } const type = checkExpression(memberDecl.expression); if (!isValidSpreadType(type)) { error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags, ObjectFlags.FreshLiteral, inConstContext); + spread = getSpreadType(spread, type, node.symbol, propagatedFlags | ObjectFlags.FreshLiteral, inConstContext); offset = i + 1; continue; } @@ -18498,7 +18502,7 @@ namespace ts { if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags, ObjectFlags.FreshLiteral, inConstContext); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags | ObjectFlags.FreshLiteral, inConstContext); } return spread; } @@ -18509,8 +18513,7 @@ namespace ts { const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, IndexKind.String) : undefined; const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - result.flags |= TypeFlags.ContainsObjectLiteral | typeFlags & TypeFlags.PropagatingFlags; - result.objectFlags |= ObjectFlags.ObjectLiteral | freshObjectLiteralFlag; + result.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral | freshObjectLiteralFlag | objectFlags & ObjectFlags.PropagatingFlags; if (isJSObjectLiteral) { result.objectFlags |= ObjectFlags.JSLiteral; } @@ -18520,7 +18523,7 @@ namespace ts { if (inDestructuringPattern) { result.pattern = node; } - propagatedFlags |= result.flags & TypeFlags.PropagatingFlags; + propagatedFlags |= result.objectFlags & ObjectFlags.PropagatingFlags; return result; } } @@ -18611,7 +18614,6 @@ namespace ts { let hasSpreadAnyType = false; let typeToIntersect: Type | undefined; let explicitlySpecifyChildrenAttribute = false; - let typeFlags: TypeFlags = 0; let objectFlags: ObjectFlags = ObjectFlags.JsxAttributes; const jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement)); @@ -18619,7 +18621,7 @@ namespace ts { const member = attributeDecl.symbol; if (isJsxAttribute(attributeDecl)) { const exprType = checkJsxAttribute(attributeDecl, checkMode); - typeFlags |= exprType.flags & TypeFlags.PropagatingFlags; + objectFlags |= getObjectFlags(exprType) & ObjectFlags.PropagatingFlags; const attributeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.escapedName); attributeSymbol.declarations = member.declarations; @@ -18637,7 +18639,7 @@ namespace ts { else { Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute); if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags, /*readonly*/ false); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); attributesTable = createSymbolTable(); } const exprType = checkExpressionCached(attributeDecl.expression, checkMode); @@ -18645,7 +18647,7 @@ namespace ts { hasSpreadAnyType = true; } if (isValidSpreadType(exprType)) { - spread = getSpreadType(spread, exprType, attributes.symbol, typeFlags, objectFlags, /*readonly*/ false); + spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, /*readonly*/ false); } else { typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; @@ -18655,7 +18657,7 @@ namespace ts { if (!hasSpreadAnyType) { if (attributesTable.size > 0) { - spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, typeFlags, objectFlags, /*readonly*/ false); + spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, /*readonly*/ false); } } @@ -18687,7 +18689,7 @@ namespace ts { const childPropMap = createSymbolTable(); childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol); spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined), - attributes.symbol, typeFlags, objectFlags, /*readonly*/ false); + attributes.symbol, objectFlags, /*readonly*/ false); } } @@ -18708,8 +18710,7 @@ namespace ts { function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; const result = createAnonymousType(attributes.symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.flags |= TypeFlags.ContainsObjectLiteral | typeFlags; - result.objectFlags |= ObjectFlags.ObjectLiteral | objectFlags; + result.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral | objectFlags; return result; } } @@ -21374,7 +21375,7 @@ namespace ts { const anonymousSymbol = createSymbol(SymbolFlags.TypeLiteral, InternalSymbolName.Type); const defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); anonymousSymbol.type = defaultContainingObject; - synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*typeFLags*/ 0, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; + synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject; } else { synthType.syntheticType = type; @@ -22052,7 +22053,7 @@ namespace ts { const returnType = getReturnTypeFromBody(node, checkMode); const returnOnlySignature = createSignature(undefined, undefined, undefined, emptyArray, returnType, /*resolvedTypePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); const returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], emptyArray, undefined, undefined); - returnOnlyType.flags |= TypeFlags.ContainsAnyFunctionType; + returnOnlyType.objectFlags |= ObjectFlags.ContainsAnyFunctionType; return links.contextFreeType = returnOnlyType; } return anyFunctionType; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a524ce13cb90e..c0ae3b99c4477 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3817,39 +3817,33 @@ namespace ts { } export const enum TypeFlags { - Any = 1 << 0, - Unknown = 1 << 1, - String = 1 << 2, - Number = 1 << 3, - Boolean = 1 << 4, - Enum = 1 << 5, - BigInt = 1 << 6, - StringLiteral = 1 << 7, - NumberLiteral = 1 << 8, - BooleanLiteral = 1 << 9, - EnumLiteral = 1 << 10, // Always combined with StringLiteral, NumberLiteral, or Union - BigIntLiteral = 1 << 11, - ESSymbol = 1 << 12, // Type of symbol primitive introduced in ES6 - UniqueESSymbol = 1 << 13, // unique symbol - Void = 1 << 14, - Undefined = 1 << 15, - Null = 1 << 16, - Never = 1 << 17, // Never type - TypeParameter = 1 << 18, // Type parameter - Object = 1 << 19, // Object type - Union = 1 << 20, // Union (T | U) - Intersection = 1 << 21, // Intersection (T & U) - Index = 1 << 22, // keyof T - IndexedAccess = 1 << 23, // T[K] - Conditional = 1 << 24, // T extends U ? X : Y - Substitution = 1 << 25, // Type parameter substitution - NonPrimitive = 1 << 26, // intrinsic object type - /* @internal */ - ContainsWideningType = 1 << 27, // Type is or contains undefined or null widening type - /* @internal */ - ContainsObjectLiteral = 1 << 28, // Type is or contains object literal type - /* @internal */ - ContainsAnyFunctionType = 1 << 29, // Type is or contains the anyFunctionType + Any = 1 << 0, + Unknown = 1 << 1, + String = 1 << 2, + Number = 1 << 3, + Boolean = 1 << 4, + Enum = 1 << 5, + BigInt = 1 << 6, + StringLiteral = 1 << 7, + NumberLiteral = 1 << 8, + BooleanLiteral = 1 << 9, + EnumLiteral = 1 << 10, // Always combined with StringLiteral, NumberLiteral, or Union + BigIntLiteral = 1 << 11, + ESSymbol = 1 << 12, // Type of symbol primitive introduced in ES6 + UniqueESSymbol = 1 << 13, // unique symbol + Void = 1 << 14, + Undefined = 1 << 15, + Null = 1 << 16, + Never = 1 << 17, // Never type + TypeParameter = 1 << 18, // Type parameter + Object = 1 << 19, // Object type + Union = 1 << 20, // Union (T | U) + Intersection = 1 << 21, // Intersection (T & U) + Index = 1 << 22, // keyof T + IndexedAccess = 1 << 23, // T[K] + Conditional = 1 << 24, // T extends U ? X : Y + Substitution = 1 << 25, // Type parameter substitution + NonPrimitive = 1 << 26, // intrinsic object type /* @internal */ AnyOrUnknown = Any | Unknown, @@ -3883,29 +3877,29 @@ namespace ts { InstantiablePrimitive = Index, Instantiable = InstantiableNonPrimitive | InstantiablePrimitive, StructuredOrInstantiable = StructuredType | Instantiable, - + /* @internal */ + ObjectFlagsType = Nullable | Object | Union | Intersection, // 'Narrowable' types are types where narrowing actually narrows. // This *should* be every type other than null, undefined, void, and never Narrowable = Any | Unknown | StructuredOrInstantiable | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbol | UniqueESSymbol | NonPrimitive, NotUnionOrUnit = Any | Unknown | ESSymbol | Object | NonPrimitive, /* @internal */ NotPrimitiveUnion = Any | Unknown | Enum | Void | Never | StructuredOrInstantiable, + // The following flags are aggregated during union and intersection type construction /* @internal */ - RequiresWidening = ContainsWideningType | ContainsObjectLiteral, - /* @internal */ - PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType, + IncludesMask = Any | Unknown | Primitive | Never | Object | Union, // The following flags are used for different purposes during union and intersection type construction /* @internal */ - NonWideningType = ContainsWideningType, + IncludesStructuredOrInstantiable = TypeParameter, /* @internal */ - Wildcard = ContainsObjectLiteral, + IncludesNonWideningType = Intersection, /* @internal */ - EmptyObject = ContainsAnyFunctionType, + IncludesWildcard = Index, /* @internal */ - ConstructionFlags = NonWideningType | Wildcard | EmptyObject, + IncludesEmptyObject = IndexedAccess, // The following flag is used for different purposes by maybeTypeOfKind /* @internal */ - GenericMappedType = ContainsWideningType + GenericMappedType = Never, } export type DestructuringPattern = BindingPattern | ObjectLiteralExpression | ArrayLiteralExpression; @@ -3932,6 +3926,12 @@ namespace ts { // Intrinsic types (TypeFlags.Intrinsic) export interface IntrinsicType extends Type { intrinsicName: string; // Name of intrinsic type + objectFlags: ObjectFlags; + } + + /* @internal */ + export interface NullableType extends IntrinsicType { + objectFlags: ObjectFlags; } /* @internal */ @@ -3991,9 +3991,24 @@ namespace ts { MarkerType = 1 << 13, // Marker type used for variance probing JSLiteral = 1 << 14, // Object type declared in JS - disables errors on read/write of nonexisting members FreshLiteral = 1 << 15, // Fresh object literal - ClassOrInterface = Class | Interface + /* @internal */ + PrimitiveUnion = 1 << 16, // Union of only primitive types + /* @internal */ + ContainsWideningType = 1 << 17, // Type is or contains undefined or null widening type + /* @internal */ + ContainsObjectLiteral = 1 << 18, // Type is or contains object literal type + /* @internal */ + ContainsAnyFunctionType = 1 << 19, // Type is or contains the anyFunctionType + ClassOrInterface = Class | Interface, + /* @internal */ + RequiresWidening = ContainsWideningType | ContainsObjectLiteral, + /* @internal */ + PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | ContainsAnyFunctionType } + /* @internal */ + export type ObjectFlagsType = NullableType | ObjectType | UnionType | IntersectionType; + // Object types (TypeFlags.ObjectType) export interface ObjectType extends Type { objectFlags: ObjectFlags; @@ -4074,6 +4089,8 @@ namespace ts { export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types /* @internal */ + objectFlags: ObjectFlags; + /* @internal */ propertyCache: SymbolTable; // Cache of resolved properties /* @internal */ resolvedProperties: Symbol[]; @@ -4088,8 +4105,6 @@ namespace ts { } export interface UnionType extends UnionOrIntersectionType { - /* @internal */ - primitiveTypesOnly: boolean; } export interface IntersectionType extends UnionOrIntersectionType { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 29d2ebfa59e3f..aa2ebe3d60c07 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -4515,7 +4515,7 @@ namespace ts { } export function getObjectFlags(type: Type): ObjectFlags { - return type.flags & TypeFlags.Object ? (type).objectFlags : 0; + return type.flags & TypeFlags.ObjectFlagsType ? (type).objectFlags : 0; } export function typeHasCallOrConstructSignatures(type: Type, checker: TypeChecker) { From ed8c81a5638c7d745cb8541137ad6990da045467 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 14 Feb 2019 14:56:22 -0800 Subject: [PATCH 33/64] Update lodash dependency (#29903) For security reasons --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4f4f7db571da7..f891f99be5657 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "gulp-sourcemaps": "latest", "istanbul": "latest", "jake": "latest", - "lodash": "4.17.10", + "lodash": "^4.17.11", "merge2": "latest", "minimist": "latest", "mkdirp": "latest", From 3e745e65cda9a0879741fe1ef6afcf395fced8e6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 14 Feb 2019 15:22:19 -0800 Subject: [PATCH 34/64] Simplify flags propagation logic --- src/compiler/checker.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f76505ad4a51a..579e27a848a79 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18354,7 +18354,6 @@ namespace ts { let propertiesTable: SymbolTable; let propertiesArray: Symbol[] = []; let spread: Type = emptyObjectType; - let propagatedFlags: ObjectFlags = 0; const contextualType = getApparentTypeOfContextualType(node); const contextualTypeHasPattern = contextualType && contextualType.pattern && @@ -18364,7 +18363,7 @@ namespace ts { const isInJavascript = isInJSFile(node) && !isInJsonFile(node); const enumTag = getJSDocEnumTag(node); const isJSObjectLiteral = !contextualType && isInJavascript && !enumTag; - let objectFlags: ObjectFlags = 0; + let objectFlags: ObjectFlags = freshObjectLiteralFlag; let patternWithComputedProperties = false; let hasComputedStringProperty = false; let hasComputedNumberProperty = false; @@ -18392,7 +18391,7 @@ namespace ts { checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl); } } - objectFlags |= getObjectFlags(type); + objectFlags |= getObjectFlags(type) & ObjectFlags.PropagatingFlags; const nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined; const prop = nameType ? createSymbol(SymbolFlags.Property | member.flags, getPropertyNameFromType(nameType), checkFlags | CheckFlags.Late) : @@ -18440,19 +18439,18 @@ namespace ts { checkExternalEmitHelpers(memberDecl, ExternalEmitHelpers.Assign); } if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags | ObjectFlags.FreshLiteral, inConstContext); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); propertiesArray = []; propertiesTable = createSymbolTable(); hasComputedStringProperty = false; hasComputedNumberProperty = false; - objectFlags = 0; } const type = checkExpression(memberDecl.expression); if (!isValidSpreadType(type)) { error(memberDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); return errorType; } - spread = getSpreadType(spread, type, node.symbol, propagatedFlags | ObjectFlags.FreshLiteral, inConstContext); + spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext); offset = i + 1; continue; } @@ -18502,7 +18500,7 @@ namespace ts { if (spread !== emptyObjectType) { if (propertiesArray.length > 0) { - spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, propagatedFlags | ObjectFlags.FreshLiteral, inConstContext); + spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext); } return spread; } @@ -18513,7 +18511,7 @@ namespace ts { const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, IndexKind.String) : undefined; const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral | freshObjectLiteralFlag | objectFlags & ObjectFlags.PropagatingFlags; + result.objectFlags |= objectFlags | ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral; if (isJSObjectLiteral) { result.objectFlags |= ObjectFlags.JSLiteral; } @@ -18523,7 +18521,6 @@ namespace ts { if (inDestructuringPattern) { result.pattern = node; } - propagatedFlags |= result.objectFlags & ObjectFlags.PropagatingFlags; return result; } } @@ -18710,7 +18707,7 @@ namespace ts { function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; const result = createAnonymousType(attributes.symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral | objectFlags; + result.objectFlags |= objectFlags | ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral; return result; } } From 8f52f21f0d13be285e7d2a9f8d7de1604c619d54 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 15 Feb 2019 06:22:17 -0800 Subject: [PATCH 35/64] Fix broken check in getUnionType (check was always true) --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 579e27a848a79..718c7e541b9ad 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -9359,7 +9359,7 @@ namespace ts { } switch (unionReduction) { case UnionReduction.Literal: - if (includes & TypeFlags.StringOrNumberLiteralOrUnique | TypeFlags.BooleanLiteral) { + if (includes & (TypeFlags.Literal | TypeFlags.UniqueESSymbol)) { removeRedundantLiteralTypes(typeSet, includes); } break; From 7983813be0cfc1500f2f4c83793c784a3433e173 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 15 Feb 2019 09:03:15 -0800 Subject: [PATCH 36/64] Use sha256 to hash file contents --- src/compiler/sys.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 35e9a9ec35fd0..33283c9380352 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -632,7 +632,7 @@ namespace ts { getModifiedTime, setModifiedTime, deleteFile, - createHash: _crypto ? createMD5HashUsingNativeCrypto : generateDjb2Hash, + createHash: _crypto ? createSHA256Hash : generateDjb2Hash, createSHA256Hash: _crypto ? createSHA256Hash : undefined, getMemoryUsage() { if (global.gc) { @@ -1125,12 +1125,6 @@ namespace ts { } } - function createMD5HashUsingNativeCrypto(data: string): string { - const hash = _crypto!.createHash("md5"); - hash.update(data); - return hash.digest("hex"); - } - function createSHA256Hash(data: string): string { const hash = _crypto!.createHash("sha256"); hash.update(data); From 540aeb6073dec5e1669f84468c7e76310895249a Mon Sep 17 00:00:00 2001 From: Tom J Date: Sun, 17 Feb 2019 18:28:32 +0000 Subject: [PATCH 37/64] update docs: dated build cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hopefully I didn't miss something obvious. Running `gulp build` as suggested causes the following: ``` $ gulp build [18:26:11] Using gulpfile ~/git/TypeScript/Gulpfile.js [18:26:11] Task never defined: build [18:26:11] To list available tasks, try running: gulp --tasks ``` ``` $ gulp --tasks gulp --tasks [18:21:26] Tasks for ~/git/TypeScript/Gulpfile.js [18:21:26] ├── lib Builds the library targets ... ... [18:21:27] ├─┬ default Runs 'local' [18:21:27] │ └─┬ [18:21:27] │ └─┬ local [18:21:27] │ └─┬ [18:21:27] │ ├── buildFoldStart [18:21:27] │ ├─┬ [18:21:27] │ │ ├── generateLibs [18:21:27] │ │ └─┬ [18:21:27] │ │ ├── buildScripts [18:21:27] │ │ └── generateDiagnostics [18:21:27] │ ├─┬ [18:21:27] │ │ ├── localize [18:21:27] │ │ ├── buildTsc [18:21:27] │ │ ├── buildServer [18:21:27] │ │ ├─┬ [18:21:27] │ │ │ ├── flattenServicesConfig [18:21:27] │ │ │ ├── buildTypescriptServicesOut [18:21:27] │ │ │ ├── createTypescriptServicesJs [18:21:27] │ │ │ ├── createTypescriptServicesDts [18:21:27] │ │ │ ├── createTypescriptJs [18:21:27] │ │ │ ├── createTypescriptDts [18:21:27] │ │ │ └── createTypescriptStandaloneDts [18:21:27] │ │ └─┬ [18:21:27] │ │ ├── flattenTsServerProject [18:21:27] │ │ ├── buildServerLibraryOut [18:21:27] │ │ ├── createServerLibraryJs [18:21:27] │ │ └── createServerLibraryDts [18:21:27] │ └── buildFoldEnd [18:21:27] └── help Prints the top-level tasks. ``` The default task seems to do something useful: ``` $ gulp [18:21:49] Using gulpfile ~/git/TypeScript/Gulpfile.js [18:21:49] Starting 'default'... [18:21:49] Starting 'local'... [18:21:49] Starting 'buildFoldStart'... [18:21:49] Finished 'buildFoldStart' after 726 μs [18:21:49] Starting 'generateLibs'... [18:21:49] Starting 'buildScripts'... [18:21:49] Finished 'generateLibs' after 207 ms [18:21:49] Finished 'buildScripts' after 686 ms [18:21:49] Starting 'generateDiagnostics'... [18:21:49] Finished 'generateDiagnostics' after 700 μs [18:21:49] Starting 'localize'... [18:21:49] Starting 'buildTsc'... [18:21:49] Starting 'buildServer'... [18:21:49] > /usr/bin/node scripts/generateLocalizedDiagnosticMessages.js src/loc/lcl built/local src/compiler/diagnosticMessages.generated.json [18:21:49] Starting 'flattenServicesConfig'... [18:21:49] Starting 'flattenTsServerProject'... [18:21:49] Finished 'flattenServicesConfig' after 54 ms [18:21:49] Starting 'buildTypescriptServicesOut'... [18:21:49] Finished 'flattenTsServerProject' after 54 ms [18:21:49] Starting 'buildServerLibraryOut'... [18:21:53] Finished 'localize' after 3.38 s [18:23:17] Finished 'buildTsc' after 1.45 min [18:23:17] Finished 'buildServer' after 1.45 min [18:23:17] Finished 'buildTypescriptServicesOut' after 1.45 min [18:23:17] Starting 'createTypescriptServicesJs'... [18:23:17] Finished 'buildServerLibraryOut' after 1.45 min [18:23:17] Starting 'createServerLibraryJs'... [18:23:17] Finished 'createServerLibraryJs' after 635 ms [18:23:17] Starting 'createServerLibraryDts'... [18:23:18] Finished 'createTypescriptServicesJs' after 642 ms [18:23:18] Starting 'createTypescriptServicesDts'... [18:23:18] Finished 'createTypescriptServicesDts' after 20 ms [18:23:18] Starting 'createTypescriptJs'... [18:23:18] Finished 'createServerLibraryDts' after 30 ms [18:23:18] Finished 'createTypescriptJs' after 260 ms [18:23:18] Starting 'createTypescriptDts'... [18:23:18] Finished 'createTypescriptDts' after 4.47 ms [18:23:18] Starting 'createTypescriptStandaloneDts'... [18:23:18] Finished 'createTypescriptStandaloneDts' after 5.59 ms [18:23:18] Starting 'buildFoldEnd'... [18:23:18] Finished 'buildFoldEnd' after 350 μs [18:23:18] Finished 'local' after 1.48 min [18:23:18] Finished 'default' after 1.48 min ``` I'm I'm guessing wrongly, please reject & correct the docs to whatever the right way to run builds is. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 980f84a380088..31cfb8580890c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ The TypeScript repository is relatively large. To save some time, you might want ### Using local builds -Run `gulp build` to build a version of the compiler/language service that reflects changes you've made. You can then run `node /built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`. +Run `gulp` to build a version of the compiler/language service that reflects changes you've made. You can then run `node /built/local/tsc.js` in place of `tsc` in your project. For example, to run `tsc --watch` from within the root of the repository on a file called `test.ts`, you can run `node ./built/local/tsc.js --watch test.ts`. ## Contributing bug fixes From 059fd2d42eef48cafafe5569b4313aace312e190 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 18 Feb 2019 07:25:08 -1000 Subject: [PATCH 38/64] Never overwrite resolved type of symbol --- src/compiler/checker.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3bd089aff6f19..47ed48b5dd05e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5425,7 +5425,16 @@ namespace ts { function getTypeOfVariableOrParameterOrProperty(symbol: Symbol): Type { const links = getSymbolLinks(symbol); - return links.type || (links.type = getTypeOfVariableOrParameterOrPropertyWorker(symbol)); + if (!links.type) { + const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol); + // For a contextually typed parameter it is possible that a type has already + // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want + // to preserve this type. + if (!links.type) { + links.type = type; + } + } + return links.type; } function getTypeOfVariableOrParameterOrPropertyWorker(symbol: Symbol) { @@ -5469,7 +5478,7 @@ namespace ts { if (symbol.flags & SymbolFlags.ValueModule) { return getTypeOfFuncClassEnumModule(symbol); } - return errorType; + return reportCircularityError(symbol); } let type: Type | undefined; if (isInJSFile(declaration) && @@ -5528,7 +5537,7 @@ namespace ts { if (symbol.flags & SymbolFlags.ValueModule) { return getTypeOfFuncClassEnumModule(symbol); } - type = reportCircularityError(symbol); + return reportCircularityError(symbol); } return type; } From ecfd40891ff3394834df89594a2fd8a563d51343 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 18 Feb 2019 07:25:22 -1000 Subject: [PATCH 39/64] Accept new baselines --- .../reference/jsFileClassSelfReferencedProperty.types | 4 ++-- tests/baselines/reference/parserES5ForOfStatement18.types | 2 +- tests/baselines/reference/parserES5ForOfStatement19.types | 2 +- tests/baselines/reference/parserForOfStatement18.types | 2 +- tests/baselines/reference/parserForOfStatement19.types | 2 +- tests/baselines/reference/recur1.types | 2 +- .../recursiveExportAssignmentAndFindAliasedType7.types | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/baselines/reference/jsFileClassSelfReferencedProperty.types b/tests/baselines/reference/jsFileClassSelfReferencedProperty.types index d5c2fe39c9fce..204eee67c9707 100644 --- a/tests/baselines/reference/jsFileClassSelfReferencedProperty.types +++ b/tests/baselines/reference/jsFileClassSelfReferencedProperty.types @@ -4,11 +4,11 @@ export class StackOverflowTest { constructor () { this.testStackOverflow = this.testStackOverflow.bind(this) ->this.testStackOverflow = this.testStackOverflow.bind(this) : error +>this.testStackOverflow = this.testStackOverflow.bind(this) : any >this.testStackOverflow : any >this : this >testStackOverflow : any ->this.testStackOverflow.bind(this) : error +>this.testStackOverflow.bind(this) : any >this.testStackOverflow.bind : any >this.testStackOverflow : any >this : this diff --git a/tests/baselines/reference/parserES5ForOfStatement18.types b/tests/baselines/reference/parserES5ForOfStatement18.types index 156ed2c68f306..f9544e39a31d1 100644 --- a/tests/baselines/reference/parserES5ForOfStatement18.types +++ b/tests/baselines/reference/parserES5ForOfStatement18.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement18.ts === for (var of of of) { } >of : any ->of : error +>of : any diff --git a/tests/baselines/reference/parserES5ForOfStatement19.types b/tests/baselines/reference/parserES5ForOfStatement19.types index cc3a1ed01b195..13abc7ae757b4 100644 --- a/tests/baselines/reference/parserES5ForOfStatement19.types +++ b/tests/baselines/reference/parserES5ForOfStatement19.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/Statements/parserES5ForOfStatement19.ts === for (var of in of) { } >of : any ->of : error +>of : any diff --git a/tests/baselines/reference/parserForOfStatement18.types b/tests/baselines/reference/parserForOfStatement18.types index 3fe8de5b6c10e..8e3b52ac87743 100644 --- a/tests/baselines/reference/parserForOfStatement18.types +++ b/tests/baselines/reference/parserForOfStatement18.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement18.ts === for (var of of of) { } >of : any ->of : error +>of : any diff --git a/tests/baselines/reference/parserForOfStatement19.types b/tests/baselines/reference/parserForOfStatement19.types index 04104a9667c0e..6fcc5e8f79216 100644 --- a/tests/baselines/reference/parserForOfStatement19.types +++ b/tests/baselines/reference/parserForOfStatement19.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript6/Iterators/parserForOfStatement19.ts === for (var of in of) { } >of : any ->of : error +>of : any diff --git a/tests/baselines/reference/recur1.types b/tests/baselines/reference/recur1.types index d4893d27b8687..83b4dbd598b82 100644 --- a/tests/baselines/reference/recur1.types +++ b/tests/baselines/reference/recur1.types @@ -15,7 +15,7 @@ salt.pepper = function() {} var cobalt = new cobalt.pitch(); >cobalt : any ->new cobalt.pitch() : error +>new cobalt.pitch() : any >cobalt.pitch : any >cobalt : any >pitch : any diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.types b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.types index 939e7beb79b25..a5675737c214c 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.types +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.types @@ -14,7 +14,7 @@ import self = require("recursiveExportAssignmentAndFindAliasedType7_moduleD"); var selfVar = self; >selfVar : any ->self : error +>self : any export = selfVar; >selfVar : any From eafff75c2a334b6bf6f84530c581086e821722fa Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 19 Feb 2019 11:39:16 -0800 Subject: [PATCH 40/64] Remove diagnostic dependent output in `structuredTypeRelatedTo` (#29817) * Unify variance probing error exceptions between interfaces/aliases * Consistiently return false on variance probe failure * Remove strictFunctionTypes early bail from getVariances so independent type parameters are correctly measured * Fix lint, remove now-redundant change from covariant void check function --- src/compiler/checker.ts | 86 +++--- ...eckInfiniteExpansionTermination.errors.txt | 32 +++ .../complexRecursiveCollections.types | 2 +- .../reference/conditionalTypes1.errors.txt | 8 + .../mappedTypeRelationships.errors.txt | 4 + .../reference/mappedTypes5.errors.txt | 2 + .../recursiveTypeComparison.errors.txt | 27 ++ .../strictFunctionTypesErrors.errors.txt | 82 ++---- ...unionTypeErrorMessageTypeRefs01.errors.txt | 18 +- ...derIndexSignatureRelationsAlign.errors.txt | 82 ++++++ ...ndZeroOrderIndexSignatureRelationsAlign.js | 146 +++++++++++ ...oOrderIndexSignatureRelationsAlign.symbols | 246 ++++++++++++++++++ ...eroOrderIndexSignatureRelationsAlign.types | 168 ++++++++++++ ...erIndexSignatureRelationsAlign2.errors.txt | 79 ++++++ ...dZeroOrderIndexSignatureRelationsAlign2.js | 146 +++++++++++ ...OrderIndexSignatureRelationsAlign2.symbols | 244 +++++++++++++++++ ...roOrderIndexSignatureRelationsAlign2.types | 165 ++++++++++++ ...ndZeroOrderIndexSignatureRelationsAlign.ts | 67 +++++ ...dZeroOrderIndexSignatureRelationsAlign2.ts | 67 +++++ 19 files changed, 1564 insertions(+), 107 deletions(-) create mode 100644 tests/baselines/reference/checkInfiniteExpansionTermination.errors.txt create mode 100644 tests/baselines/reference/recursiveTypeComparison.errors.txt create mode 100644 tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.errors.txt create mode 100644 tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.js create mode 100644 tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.symbols create mode 100644 tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.types create mode 100644 tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.errors.txt create mode 100644 tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.js create mode 100644 tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.symbols create mode 100644 tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.types create mode 100644 tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts create mode 100644 tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3bd089aff6f19..1cce639a781a8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12586,6 +12586,7 @@ namespace ts { let result: Ternary; let originalErrorInfo: DiagnosticMessageChain | undefined; + let varianceCheckFailed = false; const saveErrorInfo = errorInfo; // We limit alias variance probing to only object and conditional types since their alias behavior @@ -12595,11 +12596,10 @@ namespace ts { source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol && !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) { const variances = getAliasVariances(source.aliasSymbol); - if (result = typeArgumentsRelatedTo(source.aliasTypeArguments, target.aliasTypeArguments, variances, reportErrors)) { - return result; + const varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances); + if (varianceResult !== undefined) { + return varianceResult; } - originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; } if (target.flags & TypeFlags.TypeParameter) { @@ -12764,31 +12764,9 @@ namespace ts { // type references (which are intended by be compared structurally). Obtain the variance // information for the type parameters and relate the type arguments accordingly. const variances = getVariances((source).target); - if (result = typeArgumentsRelatedTo((source).typeArguments, (target).typeArguments, variances, reportErrors)) { - return result; - } - // The type arguments did not relate appropriately, but it may be because we have no variance - // information (in which case typeArgumentsRelatedTo defaulted to covariance for all type - // arguments). It might also be the case that the target type has a 'void' type argument for - // a covariant type parameter that is only used in return positions within the generic type - // (in which case any type argument is permitted on the source side). In those cases we proceed - // with a structural comparison. Otherwise, we know for certain the instantiations aren't - // related and we can return here. - if (variances !== emptyArray && !hasCovariantVoidArgument(target, variances)) { - // In some cases generic types that are covariant in regular type checking mode become - // invariant in --strictFunctionTypes mode because one or more type parameters are used in - // both co- and contravariant positions. In order to make it easier to diagnose *why* such - // types are invariant, if any of the type parameters are invariant we reset the reported - // errors and instead force a structural comparison (which will include elaborations that - // reveal the reason). - if (!(reportErrors && some(variances, v => v === Variance.Invariant))) { - return Ternary.False; - } - // We remember the original error information so we can restore it in case the structural - // comparison unexpectedly succeeds. This can happen when the structural comparison result - // is a Ternary.Maybe for example caused by the recursion depth limiter. - originalErrorInfo = errorInfo; - errorInfo = saveErrorInfo; + const varianceResult = relateVariances((source).typeArguments, (target).typeArguments, variances); + if (varianceResult !== undefined) { + return varianceResult; } } else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { @@ -12815,16 +12793,48 @@ namespace ts { } } } - if (result) { - if (!originalErrorInfo) { - errorInfo = saveErrorInfo; - return result; - } - errorInfo = originalErrorInfo; + if (varianceCheckFailed && result) { + errorInfo = originalErrorInfo || errorInfo || saveErrorInfo; // Use variance error (there is no structural one) and return false + } + else if (result) { + return result; } } } return Ternary.False; + + function relateVariances(sourceTypeArguments: ReadonlyArray | undefined, targetTypeArguments: ReadonlyArray | undefined, variances: Variance[]) { + if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors)) { + return result; + } + const isCovariantVoid = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances); + varianceCheckFailed = !isCovariantVoid; + // The type arguments did not relate appropriately, but it may be because we have no variance + // information (in which case typeArgumentsRelatedTo defaulted to covariance for all type + // arguments). It might also be the case that the target type has a 'void' type argument for + // a covariant type parameter that is only used in return positions within the generic type + // (in which case any type argument is permitted on the source side). In those cases we proceed + // with a structural comparison. Otherwise, we know for certain the instantiations aren't + // related and we can return here. + if (variances !== emptyArray && !isCovariantVoid) { + // In some cases generic types that are covariant in regular type checking mode become + // invariant in --strictFunctionTypes mode because one or more type parameters are used in + // both co- and contravariant positions. In order to make it easier to diagnose *why* such + // types are invariant, if any of the type parameters are invariant we reset the reported + // errors and instead force a structural comparison (which will include elaborations that + // reveal the reason). + // We can switch on `reportErrors` here, since varianceCheckFailed guarantees we return `False`, + // we can return `False` early here to skip calculating the structural error message we don't need. + if (varianceCheckFailed && !(reportErrors && some(variances, v => v === Variance.Invariant))) { + return Ternary.False; + } + // We remember the original error information so we can restore it in case the structural + // comparison unexpectedly succeeds. This can happen when the structural comparison result + // is a Ternary.Maybe for example caused by the recursion depth limiter. + originalErrorInfo = errorInfo; + errorInfo = saveErrorInfo; + } + } } // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is @@ -13333,7 +13343,7 @@ namespace ts { function getVariances(type: GenericType): Variance[] { // Arrays and tuples are known to be covariant, no need to spend time computing this (emptyArray implies covariance for all parameters) - if (!strictFunctionTypes || type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & ObjectFlags.Tuple) { + if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & ObjectFlags.Tuple) { return emptyArray; } return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference); @@ -13341,9 +13351,9 @@ namespace ts { // Return true if the given type reference has a 'void' type argument for a covariant type parameter. // See comment at call in recursiveTypeRelatedTo for when this case matters. - function hasCovariantVoidArgument(type: TypeReference, variances: Variance[]): boolean { + function hasCovariantVoidArgument(typeArguments: ReadonlyArray, variances: Variance[]): boolean { for (let i = 0; i < variances.length; i++) { - if (variances[i] === Variance.Covariant && type.typeArguments![i].flags & TypeFlags.Void) { + if (variances[i] === Variance.Covariant && typeArguments[i].flags & TypeFlags.Void) { return true; } } diff --git a/tests/baselines/reference/checkInfiniteExpansionTermination.errors.txt b/tests/baselines/reference/checkInfiniteExpansionTermination.errors.txt new file mode 100644 index 0000000000000..014087ff6275e --- /dev/null +++ b/tests/baselines/reference/checkInfiniteExpansionTermination.errors.txt @@ -0,0 +1,32 @@ +tests/cases/compiler/checkInfiniteExpansionTermination.ts(16,1): error TS2322: Type 'ISubject' is not assignable to type 'IObservable'. + Types of property 'n' are incompatible. + Type 'IObservable' is not assignable to type 'IObservable'. + Type 'Bar[]' is not assignable to type 'Foo[]'. + Property 'x' is missing in type 'Bar' but required in type 'Foo'. + + +==== tests/cases/compiler/checkInfiniteExpansionTermination.ts (1 errors) ==== + // Regression test for #1002 + // Before fix this code would cause infinite loop + + interface IObservable { + n: IObservable; // Needed, must be T[] + } + + // Needed + interface ISubject extends IObservable { } + + interface Foo { x } + interface Bar { y } + + var values: IObservable; + var values2: ISubject; + values = values2; + ~~~~~~ +!!! error TS2322: Type 'ISubject' is not assignable to type 'IObservable'. +!!! error TS2322: Types of property 'n' are incompatible. +!!! error TS2322: Type 'IObservable' is not assignable to type 'IObservable'. +!!! error TS2322: Type 'Bar[]' is not assignable to type 'Foo[]'. +!!! error TS2322: Property 'x' is missing in type 'Bar' but required in type 'Foo'. +!!! related TS2728 tests/cases/compiler/checkInfiniteExpansionTermination.ts:11:17: 'x' is declared here. + \ No newline at end of file diff --git a/tests/baselines/reference/complexRecursiveCollections.types b/tests/baselines/reference/complexRecursiveCollections.types index a9fc13e7d1dc1..feaff62048628 100644 --- a/tests/baselines/reference/complexRecursiveCollections.types +++ b/tests/baselines/reference/complexRecursiveCollections.types @@ -1137,7 +1137,7 @@ declare module Immutable { >Seq : typeof Seq function isSeq(maybeSeq: any): maybeSeq is Seq.Indexed | Seq.Keyed; ->isSeq : (maybeSeq: any) => maybeSeq is Keyed | Indexed +>isSeq : (maybeSeq: any) => maybeSeq is Indexed | Keyed >maybeSeq : any >Seq : any >Seq : any diff --git a/tests/baselines/reference/conditionalTypes1.errors.txt b/tests/baselines/reference/conditionalTypes1.errors.txt index 62239eca7b821..ec35f89161589 100644 --- a/tests/baselines/reference/conditionalTypes1.errors.txt +++ b/tests/baselines/reference/conditionalTypes1.errors.txt @@ -17,8 +17,12 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(103,5): error TS2 tests/cases/conformance/types/conditional/conditionalTypes1.ts(104,5): error TS2322: Type 'Pick' is not assignable to type 'T'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(106,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. + Type 'keyof T' is not assignable to type 'never'. + Type 'string | number | symbol' is not assignable to type 'never'. + Type 'string' is not assignable to type 'never'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(108,5): error TS2322: Type 'Pick' is not assignable to type 'Pick'. Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. + Type 'keyof T' is not assignable to type 'never'. tests/cases/conformance/types/conditional/conditionalTypes1.ts(114,5): error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. Type 'string' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. @@ -183,11 +187,15 @@ tests/cases/conformance/types/conditional/conditionalTypes1.ts(288,43): error TS ~ !!! error TS2322: Type 'Pick' is not assignable to type 'Pick'. !!! error TS2322: Type 'T[keyof T] extends Function ? keyof T : never' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'never'. +!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'never'. +!!! error TS2322: Type 'string' is not assignable to type 'never'. z = x; z = y; // Error ~ !!! error TS2322: Type 'Pick' is not assignable to type 'Pick'. !!! error TS2322: Type 'T[keyof T] extends Function ? never : keyof T' is not assignable to type 'T[keyof T] extends Function ? keyof T : never'. +!!! error TS2322: Type 'keyof T' is not assignable to type 'never'. } function f8(x: keyof T, y: FunctionPropertyNames, z: NonFunctionPropertyNames) { diff --git a/tests/baselines/reference/mappedTypeRelationships.errors.txt b/tests/baselines/reference/mappedTypeRelationships.errors.txt index 60a06e000c255..3d63765407972 100644 --- a/tests/baselines/reference/mappedTypeRelationships.errors.txt +++ b/tests/baselines/reference/mappedTypeRelationships.errors.txt @@ -34,7 +34,9 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2 tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(66,5): error TS2542: Index signature in type 'Readonly' only permits reading. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(72,5): error TS2322: Type 'Partial' is not assignable to type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(78,5): error TS2322: Type 'Partial' is not assignable to type 'Partial'. + Type 'Thing' is not assignable to type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(88,5): error TS2322: Type 'Readonly' is not assignable to type 'Readonly'. + Type 'Thing' is not assignable to type 'T'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(127,5): error TS2322: Type 'Partial' is not assignable to type 'Identity'. tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(143,5): error TS2322: Type '{ [P in keyof T]: T[P]; }' is not assignable to type '{ [P in keyof T]: U[P]; }'. Type 'T[P]' is not assignable to type 'U[P]'. @@ -197,6 +199,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS y = x; // Error ~ !!! error TS2322: Type 'Partial' is not assignable to type 'Partial'. +!!! error TS2322: Type 'Thing' is not assignable to type 'T'. } function f40(x: T, y: Readonly) { @@ -209,6 +212,7 @@ tests/cases/conformance/types/mapped/mappedTypeRelationships.ts(168,5): error TS y = x; // Error ~ !!! error TS2322: Type 'Readonly' is not assignable to type 'Readonly'. +!!! error TS2322: Type 'Thing' is not assignable to type 'T'. } type Item = { diff --git a/tests/baselines/reference/mappedTypes5.errors.txt b/tests/baselines/reference/mappedTypes5.errors.txt index d0c32cd1dd956..21d6f98964ae5 100644 --- a/tests/baselines/reference/mappedTypes5.errors.txt +++ b/tests/baselines/reference/mappedTypes5.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/mapped/mappedTypes5.ts(6,9): error TS2322: Type 'Partial' is not assignable to type 'Readonly'. tests/cases/conformance/types/mapped/mappedTypes5.ts(8,9): error TS2322: Type 'Partial>' is not assignable to type 'Readonly'. tests/cases/conformance/types/mapped/mappedTypes5.ts(9,9): error TS2322: Type 'Readonly>' is not assignable to type 'Readonly'. + Type 'Partial' is not assignable to type 'T'. ==== tests/cases/conformance/types/mapped/mappedTypes5.ts (3 errors) ==== @@ -19,6 +20,7 @@ tests/cases/conformance/types/mapped/mappedTypes5.ts(9,9): error TS2322: Type 'R let b4: Readonly = rp; // Error ~~ !!! error TS2322: Type 'Readonly>' is not assignable to type 'Readonly'. +!!! error TS2322: Type 'Partial' is not assignable to type 'T'. let c1: Partial> = p; let c2: Partial> = r; let c3: Partial> = pr; diff --git a/tests/baselines/reference/recursiveTypeComparison.errors.txt b/tests/baselines/reference/recursiveTypeComparison.errors.txt new file mode 100644 index 0000000000000..f647763b2e275 --- /dev/null +++ b/tests/baselines/reference/recursiveTypeComparison.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/recursiveTypeComparison.ts(14,5): error TS2322: Type 'Observable<{}>' is not assignable to type 'Property'. + Types of property 'needThisOne' are incompatible. + Type 'Observable<{}>' is not assignable to type 'Observable'. + Type '{}' is not assignable to type 'number'. + + +==== tests/cases/compiler/recursiveTypeComparison.ts (1 errors) ==== + // Before fix this would take an exceeding long time to complete (#1170) + + interface Observable { + // This member can't be of type T, Property, or Observable + needThisOne: Observable; + // Add more to make it slower + expo1: Property; // 0.31 seconds in check + expo2: Property; // 3.11 seconds + expo3: Property; // 82.28 seconds + } + interface Property extends Observable { } + + var p: Observable<{}>; + var stuck: Property = p; + ~~~~~ +!!! error TS2322: Type 'Observable<{}>' is not assignable to type 'Property'. +!!! error TS2322: Types of property 'needThisOne' are incompatible. +!!! error TS2322: Type 'Observable<{}>' is not assignable to type 'Observable'. +!!! error TS2322: Type '{}' is not assignable to type 'number'. + \ No newline at end of file diff --git a/tests/baselines/reference/strictFunctionTypesErrors.errors.txt b/tests/baselines/reference/strictFunctionTypesErrors.errors.txt index 369919850f085..3ff04c44fb75b 100644 --- a/tests/baselines/reference/strictFunctionTypesErrors.errors.txt +++ b/tests/baselines/reference/strictFunctionTypesErrors.errors.txt @@ -17,19 +17,15 @@ tests/cases/compiler/strictFunctionTypesErrors.ts(21,1): error TS2322: Type '(x: tests/cases/compiler/strictFunctionTypesErrors.ts(23,1): error TS2322: Type '(x: string) => Object' is not assignable to type '(x: string) => string'. Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(33,1): error TS2322: Type 'Func' is not assignable to type 'Func'. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(34,1): error TS2322: Type 'Func' is not assignable to type 'Func'. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(36,1): error TS2322: Type 'Func' is not assignable to type 'Func'. Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(37,1): error TS2322: Type 'Func' is not assignable to type 'Func'. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(38,1): error TS2322: Type 'Func' is not assignable to type 'Func'. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(44,1): error TS2322: Type 'Func' is not assignable to type 'Func'. Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(46,1): error TS2322: Type 'Func' is not assignable to type 'Func'. @@ -39,37 +35,26 @@ tests/cases/compiler/strictFunctionTypesErrors.ts(57,1): error TS2322: Type 'Fun tests/cases/compiler/strictFunctionTypesErrors.ts(58,1): error TS2322: Type 'Func, Object>' is not assignable to type 'Func, string>'. Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(61,1): error TS2322: Type 'Func, Object>' is not assignable to type 'Func, Object>'. - Types of parameters 'x' and 'x' are incompatible. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Func' is not assignable to type 'Func'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(62,1): error TS2322: Type 'Func, string>' is not assignable to type 'Func, Object>'. - Types of parameters 'x' and 'x' are incompatible. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Func' is not assignable to type 'Func'. tests/cases/compiler/strictFunctionTypesErrors.ts(65,1): error TS2322: Type 'Func, Object>' is not assignable to type 'Func, string>'. - Types of parameters 'x' and 'x' are incompatible. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Func' is not assignable to type 'Func'. tests/cases/compiler/strictFunctionTypesErrors.ts(66,1): error TS2322: Type 'Func, string>' is not assignable to type 'Func, string>'. - Types of parameters 'x' and 'x' are incompatible. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Func' is not assignable to type 'Func'. tests/cases/compiler/strictFunctionTypesErrors.ts(67,1): error TS2322: Type 'Func, Object>' is not assignable to type 'Func, string>'. Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(74,1): error TS2322: Type 'Func>' is not assignable to type 'Func>'. Type 'Func' is not assignable to type 'Func'. tests/cases/compiler/strictFunctionTypesErrors.ts(75,1): error TS2322: Type 'Func>' is not assignable to type 'Func>'. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(76,1): error TS2322: Type 'Func>' is not assignable to type 'Func>'. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(79,1): error TS2322: Type 'Func>' is not assignable to type 'Func>'. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(80,1): error TS2322: Type 'Func>' is not assignable to type 'Func>'. - Types of parameters 'x' and 'x' are incompatible. - Type 'Object' is not assignable to type 'string'. + Type 'Object' is not assignable to type 'string'. tests/cases/compiler/strictFunctionTypesErrors.ts(83,1): error TS2322: Type 'Func>' is not assignable to type 'Func>'. Type 'Func' is not assignable to type 'Func'. tests/cases/compiler/strictFunctionTypesErrors.ts(84,1): error TS2322: Type 'Func>' is not assignable to type 'Func>'. @@ -162,13 +147,11 @@ tests/cases/compiler/strictFunctionTypesErrors.ts(155,5): error TS2322: Type '(c g1 = g3; // Error ~~ !!! error TS2322: Type 'Func' is not assignable to type 'Func'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. g1 = g4; // Error ~~ !!! error TS2322: Type 'Func' is not assignable to type 'Func'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. g2 = g1; // Error ~~ @@ -177,13 +160,11 @@ tests/cases/compiler/strictFunctionTypesErrors.ts(155,5): error TS2322: Type '(c g2 = g3; // Error ~~ !!! error TS2322: Type 'Func' is not assignable to type 'Func'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. g2 = g4; // Error ~~ !!! error TS2322: Type 'Func' is not assignable to type 'Func'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. g3 = g1; // Ok g3 = g2; // Ok @@ -221,29 +202,22 @@ tests/cases/compiler/strictFunctionTypesErrors.ts(155,5): error TS2322: Type '(c h3 = h1; // Error ~~ !!! error TS2322: Type 'Func, Object>' is not assignable to type 'Func, Object>'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Func' is not assignable to type 'Func'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. h3 = h2; // Error ~~ !!! error TS2322: Type 'Func, string>' is not assignable to type 'Func, Object>'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Func' is not assignable to type 'Func'. h3 = h4; // Ok h4 = h1; // Error ~~ !!! error TS2322: Type 'Func, Object>' is not assignable to type 'Func, string>'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Func' is not assignable to type 'Func'. h4 = h2; // Error ~~ !!! error TS2322: Type 'Func, string>' is not assignable to type 'Func, string>'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Func' is not assignable to type 'Func'. h4 = h3; // Error ~~ !!! error TS2322: Type 'Func, Object>' is not assignable to type 'Func, string>'. @@ -261,25 +235,21 @@ tests/cases/compiler/strictFunctionTypesErrors.ts(155,5): error TS2322: Type '(c i1 = i3; // Error ~~ !!! error TS2322: Type 'Func>' is not assignable to type 'Func>'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. i1 = i4; // Error ~~ !!! error TS2322: Type 'Func>' is not assignable to type 'Func>'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. i2 = i1; // Ok i2 = i3; // Error ~~ !!! error TS2322: Type 'Func>' is not assignable to type 'Func>'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. i2 = i4; // Error ~~ !!! error TS2322: Type 'Func>' is not assignable to type 'Func>'. -!!! error TS2322: Types of parameters 'x' and 'x' are incompatible. -!!! error TS2322: Type 'Object' is not assignable to type 'string'. +!!! error TS2322: Type 'Object' is not assignable to type 'string'. i3 = i1; // Ok i3 = i2; // Error diff --git a/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.errors.txt b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.errors.txt index 5fdeab58610af..ab661b6fee7c8 100644 --- a/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.errors.txt +++ b/tests/baselines/reference/unionTypeErrorMessageTypeRefs01.errors.txt @@ -9,16 +9,13 @@ tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(27,1): error TS2322: Typ Property 'kwah' is missing in type 'Foo' but required in type 'Kwah'. tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(48,1): error TS2322: Type 'X' is not assignable to type 'X | Y | Z'. Type 'X' is not assignable to type 'X'. - Types of property 'xProp' are incompatible. - Type 'Foo' is not assignable to type 'Bar'. + Type 'Foo' is not assignable to type 'Bar'. tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(49,1): error TS2322: Type 'Y' is not assignable to type 'X | Y | Z'. Type 'Y' is not assignable to type 'Y'. - Types of property 'yProp' are incompatible. - Type 'Foo' is not assignable to type 'Baz'. + Type 'Foo' is not assignable to type 'Baz'. tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(50,1): error TS2322: Type 'Z' is not assignable to type 'X | Y | Z'. Type 'Z' is not assignable to type 'Z'. - Types of property 'zProp' are incompatible. - Type 'Foo' is not assignable to type 'Kwah'. + Type 'Foo' is not assignable to type 'Kwah'. ==== tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts (6 errors) ==== @@ -88,17 +85,14 @@ tests/cases/compiler/unionTypeErrorMessageTypeRefs01.ts(50,1): error TS2322: Typ ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'X' is not assignable to type 'X | Y | Z'. !!! error TS2322: Type 'X' is not assignable to type 'X'. -!!! error TS2322: Types of property 'xProp' are incompatible. -!!! error TS2322: Type 'Foo' is not assignable to type 'Bar'. +!!! error TS2322: Type 'Foo' is not assignable to type 'Bar'. thingOfTypeAliases = y; ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Y' is not assignable to type 'X | Y | Z'. !!! error TS2322: Type 'Y' is not assignable to type 'Y'. -!!! error TS2322: Types of property 'yProp' are incompatible. -!!! error TS2322: Type 'Foo' is not assignable to type 'Baz'. +!!! error TS2322: Type 'Foo' is not assignable to type 'Baz'. thingOfTypeAliases = z; ~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type 'Z' is not assignable to type 'X | Y | Z'. !!! error TS2322: Type 'Z' is not assignable to type 'Z'. -!!! error TS2322: Types of property 'zProp' are incompatible. -!!! error TS2322: Type 'Foo' is not assignable to type 'Kwah'. \ No newline at end of file +!!! error TS2322: Type 'Foo' is not assignable to type 'Kwah'. \ No newline at end of file diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.errors.txt b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.errors.txt new file mode 100644 index 0000000000000..47f97958f0d53 --- /dev/null +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.errors.txt @@ -0,0 +1,82 @@ +tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts(63,6): error TS2345: Argument of type 'NeededInfo>' is not assignable to parameter of type 'NeededInfo<{}>'. + Types of property 'ASchema' are incompatible. + Type 'ToA>' is not assignable to type 'ToA<{}>'. + Type '{}' is not assignable to type 'ToB<{ initialize: any; }>'. +tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts(66,38): error TS2344: Type 'NeededInfo>' does not satisfy the constraint 'NeededInfo<{}>'. + + +==== tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts (2 errors) ==== + type Either = Left | Right; + + class Left { + readonly _tag: 'Left' = 'Left' + readonly _A!: A + readonly _L!: L + constructor(readonly value: L) {} + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { + return this as any + } + ap(fab: Either B>): Either { + return null as any + } + } + + class Right { + readonly _tag: 'Right' = 'Right' + readonly _A!: A + readonly _L!: L + constructor(readonly value: A) {} + map(f: (a: A) => B): Either { + return new Right(f(this.value)) + } + ap(fab: Either B>): Either { + return null as any; + } + } + + class Type { + readonly _A!: A; + readonly _O!: O; + readonly _I!: I; + constructor( + /** a unique name for this codec */ + readonly name: string, + /** a custom type guard */ + readonly is: (u: unknown) => u is A, + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } + } + + interface Any extends Type {} + + type TypeOf = C["_A"]; + + type ToB = { [k in keyof S]: TypeOf }; + type ToA = { [k in keyof S]: Type }; + + type NeededInfo = { + ASchema: ToA; + }; + + export type MyInfo = NeededInfo>; + + const tmp1: MyInfo = null!; + function tmp2(n: N) {} + tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? + ~~~~ +!!! error TS2345: Argument of type 'NeededInfo>' is not assignable to parameter of type 'NeededInfo<{}>'. +!!! error TS2345: Types of property 'ASchema' are incompatible. +!!! error TS2345: Type 'ToA>' is not assignable to type 'ToA<{}>'. +!!! error TS2345: Type '{}' is not assignable to type 'ToB<{ initialize: any; }>'. +!!! related TS2728 tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts:59:39: 'initialize' is declared here. + + class Server {} + export class MyServer extends Server {} // not assignable error at `MyInfo` + ~~~~~~ +!!! error TS2344: Type 'NeededInfo>' does not satisfy the constraint 'NeededInfo<{}>'. \ No newline at end of file diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.js b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.js new file mode 100644 index 0000000000000..cbac03d7a82cc --- /dev/null +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.js @@ -0,0 +1,146 @@ +//// [varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts] +type Either = Left | Right; + +class Left { + readonly _tag: 'Left' = 'Left' + readonly _A!: A + readonly _L!: L + constructor(readonly value: L) {} + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { + return this as any + } + ap(fab: Either B>): Either { + return null as any + } +} + +class Right { + readonly _tag: 'Right' = 'Right' + readonly _A!: A + readonly _L!: L + constructor(readonly value: A) {} + map(f: (a: A) => B): Either { + return new Right(f(this.value)) + } + ap(fab: Either B>): Either { + return null as any; + } +} + +class Type { + readonly _A!: A; + readonly _O!: O; + readonly _I!: I; + constructor( + /** a unique name for this codec */ + readonly name: string, + /** a custom type guard */ + readonly is: (u: unknown) => u is A, + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } +} + +interface Any extends Type {} + +type TypeOf = C["_A"]; + +type ToB = { [k in keyof S]: TypeOf }; +type ToA = { [k in keyof S]: Type }; + +type NeededInfo = { + ASchema: ToA; +}; + +export type MyInfo = NeededInfo>; + +const tmp1: MyInfo = null!; +function tmp2(n: N) {} +tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? + +class Server {} +export class MyServer extends Server {} // not assignable error at `MyInfo` + +//// [varianceProblingAndZeroOrderIndexSignatureRelationsAlign.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 (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var Left = /** @class */ (function () { + function Left(value) { + this.value = value; + this._tag = 'Left'; + } + /** The given function is applied if this is a `Right` */ + Left.prototype.map = function (f) { + return this; + }; + Left.prototype.ap = function (fab) { + return null; + }; + return Left; +}()); +var Right = /** @class */ (function () { + function Right(value) { + this.value = value; + this._tag = 'Right'; + } + Right.prototype.map = function (f) { + return new Right(f(this.value)); + }; + Right.prototype.ap = function (fab) { + return null; + }; + return Right; +}()); +var Type = /** @class */ (function () { + function Type( + /** a unique name for this codec */ + name, + /** a custom type guard */ + is, + /** succeeds if a value of type I can be decoded to a value of type A */ + validate, + /** converts a value of type A to a value of type O */ + encode) { + this.name = name; + this.is = is; + this.validate = validate; + this.encode = encode; + } + /** a version of `validate` with a default context */ + Type.prototype.decode = function (i) { return null; }; + return Type; +}()); +var tmp1 = null; +function tmp2(n) { } +tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? +var Server = /** @class */ (function () { + function Server() { + } + return Server; +}()); +var MyServer = /** @class */ (function (_super) { + __extends(MyServer, _super); + function MyServer() { + return _super !== null && _super.apply(this, arguments) || this; + } + return MyServer; +}(Server)); // not assignable error at `MyInfo` +exports.MyServer = MyServer; diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.symbols b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.symbols new file mode 100644 index 0000000000000..bd9792840637a --- /dev/null +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.symbols @@ -0,0 +1,246 @@ +=== tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts === +type Either = Left | Right; +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 12)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 14)) +>Left : Symbol(Left, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 45)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 12)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 14)) +>Right : Symbol(Right, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 14, 1)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 12)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 14)) + +class Left { +>Left : Symbol(Left, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 45)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 11)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 13)) + + readonly _tag: 'Left' = 'Left' +>_tag : Symbol(Left._tag, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 18)) + + readonly _A!: A +>_A : Symbol(Left._A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 3, 34)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 13)) + + readonly _L!: L +>_L : Symbol(Left._L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 4, 19)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 11)) + + constructor(readonly value: L) {} +>value : Symbol(Left.value, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 6, 16)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 11)) + + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { +>map : Symbol(Left.map, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 6, 37)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 8, 8)) +>f : Symbol(f, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 8, 11)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 8, 15)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 13)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 8, 8)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 11)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 8, 8)) + + return this as any +>this : Symbol(Left, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 45)) + } + ap(fab: Either B>): Either { +>ap : Symbol(Left.ap, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 10, 5)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 11, 7)) +>fab : Symbol(fab, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 11, 10)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 11)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 11, 26)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 13)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 11, 7)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 2, 11)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 11, 7)) + + return null as any + } +} + +class Right { +>Right : Symbol(Right, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 14, 1)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 12)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 14)) + + readonly _tag: 'Right' = 'Right' +>_tag : Symbol(Right._tag, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 19)) + + readonly _A!: A +>_A : Symbol(Right._A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 17, 36)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 14)) + + readonly _L!: L +>_L : Symbol(Right._L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 18, 19)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 12)) + + constructor(readonly value: A) {} +>value : Symbol(Right.value, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 20, 16)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 14)) + + map(f: (a: A) => B): Either { +>map : Symbol(Right.map, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 20, 37)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 21, 8)) +>f : Symbol(f, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 21, 11)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 21, 15)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 14)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 21, 8)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 12)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 21, 8)) + + return new Right(f(this.value)) +>Right : Symbol(Right, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 14, 1)) +>f : Symbol(f, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 21, 11)) +>this.value : Symbol(Right.value, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 20, 16)) +>this : Symbol(Right, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 14, 1)) +>value : Symbol(Right.value, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 20, 16)) + } + ap(fab: Either B>): Either { +>ap : Symbol(Right.ap, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 23, 5)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 24, 7)) +>fab : Symbol(fab, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 24, 10)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 12)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 24, 26)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 14)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 24, 7)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 16, 12)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 24, 7)) + + return null as any; + } +} + +class Type { +>Type : Symbol(Type, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 27, 1)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 11)) +>O : Symbol(O, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 13)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 11)) +>I : Symbol(I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 20)) + + readonly _A!: A; +>_A : Symbol(Type._A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 35)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 11)) + + readonly _O!: O; +>_O : Symbol(Type._O, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 30, 18)) +>O : Symbol(O, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 13)) + + readonly _I!: I; +>_I : Symbol(Type._I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 31, 18)) +>I : Symbol(I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 20)) + + constructor( + /** a unique name for this codec */ + readonly name: string, +>name : Symbol(Type.name, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 33, 14)) + + /** a custom type guard */ + readonly is: (u: unknown) => u is A, +>is : Symbol(Type.is, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 35, 26)) +>u : Symbol(u, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 37, 18)) +>u : Symbol(u, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 37, 18)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 11)) + + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, +>validate : Symbol(Type.validate, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 37, 40)) +>input : Symbol(input, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 39, 24)) +>I : Symbol(I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 20)) +>context : Symbol(context, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 39, 33)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 11)) + + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O +>encode : Symbol(Type.encode, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 39, 68)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 41, 22)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 11)) +>O : Symbol(O, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 13)) + + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } +>decode : Symbol(Type.decode, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 42, 6)) +>i : Symbol(i, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 44, 9)) +>I : Symbol(I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 20)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 0, 0)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 29, 11)) +} + +interface Any extends Type {} +>Any : Symbol(Any, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 45, 1)) +>Type : Symbol(Type, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 27, 1)) + +type TypeOf = C["_A"]; +>TypeOf : Symbol(TypeOf, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 47, 44)) +>C : Symbol(C, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 49, 12)) +>Any : Symbol(Any, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 45, 1)) +>C : Symbol(C, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 49, 12)) + +type ToB = { [k in keyof S]: TypeOf }; +>ToB : Symbol(ToB, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 49, 37)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 9)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 29)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 9)) +>TypeOf : Symbol(TypeOf, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 47, 44)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 9)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 29)) + +type ToA = { [k in keyof S]: Type }; +>ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 59)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 9)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 17)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 9)) +>Type : Symbol(Type, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 27, 1)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 9)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 17)) + +type NeededInfo = { +>NeededInfo : Symbol(NeededInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 45)) +>MyNamespaceSchema : Symbol(MyNamespaceSchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 54, 16)) + + ASchema: ToA; +>ASchema : Symbol(ASchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 54, 43)) +>ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 51, 59)) +>MyNamespaceSchema : Symbol(MyNamespaceSchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 54, 16)) + +}; + +export type MyInfo = NeededInfo>; +>MyInfo : Symbol(MyInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 56, 2)) +>NeededInfo : Symbol(NeededInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 45)) +>ToB : Symbol(ToB, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 49, 37)) +>initialize : Symbol(initialize, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 58, 37)) + +const tmp1: MyInfo = null!; +>tmp1 : Symbol(tmp1, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 60, 5)) +>MyInfo : Symbol(MyInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 56, 2)) + +function tmp2(n: N) {} +>tmp2 : Symbol(tmp2, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 60, 27)) +>N : Symbol(N, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 61, 14)) +>NeededInfo : Symbol(NeededInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 45)) +>n : Symbol(n, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 61, 36)) +>N : Symbol(N, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 61, 14)) + +tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? +>tmp2 : Symbol(tmp2, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 60, 27)) +>tmp1 : Symbol(tmp1, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 60, 5)) + +class Server {} +>Server : Symbol(Server, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 62, 11)) +>X : Symbol(X, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 64, 13)) +>NeededInfo : Symbol(NeededInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 52, 45)) + +export class MyServer extends Server {} // not assignable error at `MyInfo` +>MyServer : Symbol(MyServer, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 64, 37)) +>Server : Symbol(Server, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 62, 11)) +>MyInfo : Symbol(MyInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts, 56, 2)) + diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.types b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.types new file mode 100644 index 0000000000000..d360372d5aaee --- /dev/null +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.types @@ -0,0 +1,168 @@ +=== tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts === +type Either = Left | Right; +>Either : Either + +class Left { +>Left : Left + + readonly _tag: 'Left' = 'Left' +>_tag : "Left" +>'Left' : "Left" + + readonly _A!: A +>_A : A + + readonly _L!: L +>_L : L + + constructor(readonly value: L) {} +>value : L + + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { +>map : (f: (a: A) => B) => Either +>f : (a: A) => B +>a : A + + return this as any +>this as any : any +>this : this + } + ap(fab: Either B>): Either { +>ap : (fab: Either B>) => Either +>fab : Either B> +>a : A + + return null as any +>null as any : any +>null : null + } +} + +class Right { +>Right : Right + + readonly _tag: 'Right' = 'Right' +>_tag : "Right" +>'Right' : "Right" + + readonly _A!: A +>_A : A + + readonly _L!: L +>_L : L + + constructor(readonly value: A) {} +>value : A + + map(f: (a: A) => B): Either { +>map : (f: (a: A) => B) => Either +>f : (a: A) => B +>a : A + + return new Right(f(this.value)) +>new Right(f(this.value)) : Right +>Right : typeof Right +>f(this.value) : B +>f : (a: A) => B +>this.value : A +>this : this +>value : A + } + ap(fab: Either B>): Either { +>ap : (fab: Either B>) => Either +>fab : Either B> +>a : A + + return null as any; +>null as any : any +>null : null + } +} + +class Type { +>Type : Type + + readonly _A!: A; +>_A : A + + readonly _O!: O; +>_O : O + + readonly _I!: I; +>_I : I + + constructor( + /** a unique name for this codec */ + readonly name: string, +>name : string + + /** a custom type guard */ + readonly is: (u: unknown) => u is A, +>is : (u: unknown) => u is A +>u : unknown + + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, +>validate : (input: I, context: {}[]) => Either<{}[], A> +>input : I +>context : {}[] + + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O +>encode : (a: A) => O +>a : A + + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } +>decode : (i: I) => Either<{}[], A> +>i : I +>null as any : any +>null : null +} + +interface Any extends Type {} + +type TypeOf = C["_A"]; +>TypeOf : C["_A"] + +type ToB = { [k in keyof S]: TypeOf }; +>ToB : ToB + +type ToA = { [k in keyof S]: Type }; +>ToA : ToA + +type NeededInfo = { +>NeededInfo : NeededInfo + + ASchema: ToA; +>ASchema : ToA + +}; + +export type MyInfo = NeededInfo>; +>MyInfo : NeededInfo> +>initialize : any + +const tmp1: MyInfo = null!; +>tmp1 : NeededInfo> +>null! : never +>null : null + +function tmp2(n: N) {} +>tmp2 : >(n: N) => void +>n : N + +tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? +>tmp2(tmp1) : any +>tmp2 : >(n: N) => void +>tmp1 : NeededInfo> + +class Server {} +>Server : Server + +export class MyServer extends Server {} // not assignable error at `MyInfo` +>MyServer : MyServer +>Server : Server>> + diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.errors.txt b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.errors.txt new file mode 100644 index 0000000000000..aba1bc1db66d9 --- /dev/null +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.errors.txt @@ -0,0 +1,79 @@ +tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts(66,38): error TS2344: Type 'NeededInfo>' does not satisfy the constraint 'NeededInfo<{}>'. + Types of property 'ASchema' are incompatible. + Type 'ToA>' is not assignable to type 'ToA<{}>'. + Type '{}' is not assignable to type 'ToB<{ initialize: any; }>'. + + +==== tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts (1 errors) ==== + type Either = Left | Right; + + class Left { + readonly _tag: 'Left' = 'Left' + readonly _A!: A + readonly _L!: L + constructor(readonly value: L) {} + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { + return this as any + } + ap(fab: Either B>): Either { + return null as any + } + } + + class Right { + readonly _tag: 'Right' = 'Right' + readonly _A!: A + readonly _L!: L + constructor(readonly value: A) {} + map(f: (a: A) => B): Either { + return new Right(f(this.value)) + } + ap(fab: Either B>): Either { + return null as any; + } + } + + class Type { + readonly _A!: A; + readonly _O!: O; + readonly _I!: I; + constructor( + /** a unique name for this codec */ + readonly name: string, + /** a custom type guard */ + readonly is: (u: unknown) => u is A, + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } + } + + interface Any extends Type {} + + type TypeOf = C["_A"]; + + type ToB = { [k in keyof S]: TypeOf }; + type ToA = { [k in keyof S]: Type }; + + type NeededInfo = { + ASchema: ToA; + }; + + export type MyInfo = NeededInfo>; + + const tmp1: MyInfo = null!; + function tmp2(n: N) {} + // tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? (see test 1, needs to behave the same) + + class Server {} + export class MyServer extends Server {} // not assignable error at `MyInfo` + ~~~~~~ +!!! error TS2344: Type 'NeededInfo>' does not satisfy the constraint 'NeededInfo<{}>'. +!!! error TS2344: Types of property 'ASchema' are incompatible. +!!! error TS2344: Type 'ToA>' is not assignable to type 'ToA<{}>'. +!!! error TS2344: Type '{}' is not assignable to type 'ToB<{ initialize: any; }>'. +!!! related TS2728 tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts:59:39: 'initialize' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.js b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.js new file mode 100644 index 0000000000000..8a4340ada95a6 --- /dev/null +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.js @@ -0,0 +1,146 @@ +//// [varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts] +type Either = Left | Right; + +class Left { + readonly _tag: 'Left' = 'Left' + readonly _A!: A + readonly _L!: L + constructor(readonly value: L) {} + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { + return this as any + } + ap(fab: Either B>): Either { + return null as any + } +} + +class Right { + readonly _tag: 'Right' = 'Right' + readonly _A!: A + readonly _L!: L + constructor(readonly value: A) {} + map(f: (a: A) => B): Either { + return new Right(f(this.value)) + } + ap(fab: Either B>): Either { + return null as any; + } +} + +class Type { + readonly _A!: A; + readonly _O!: O; + readonly _I!: I; + constructor( + /** a unique name for this codec */ + readonly name: string, + /** a custom type guard */ + readonly is: (u: unknown) => u is A, + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } +} + +interface Any extends Type {} + +type TypeOf = C["_A"]; + +type ToB = { [k in keyof S]: TypeOf }; +type ToA = { [k in keyof S]: Type }; + +type NeededInfo = { + ASchema: ToA; +}; + +export type MyInfo = NeededInfo>; + +const tmp1: MyInfo = null!; +function tmp2(n: N) {} +// tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? (see test 1, needs to behave the same) + +class Server {} +export class MyServer extends Server {} // not assignable error at `MyInfo` + +//// [varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.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 (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var Left = /** @class */ (function () { + function Left(value) { + this.value = value; + this._tag = 'Left'; + } + /** The given function is applied if this is a `Right` */ + Left.prototype.map = function (f) { + return this; + }; + Left.prototype.ap = function (fab) { + return null; + }; + return Left; +}()); +var Right = /** @class */ (function () { + function Right(value) { + this.value = value; + this._tag = 'Right'; + } + Right.prototype.map = function (f) { + return new Right(f(this.value)); + }; + Right.prototype.ap = function (fab) { + return null; + }; + return Right; +}()); +var Type = /** @class */ (function () { + function Type( + /** a unique name for this codec */ + name, + /** a custom type guard */ + is, + /** succeeds if a value of type I can be decoded to a value of type A */ + validate, + /** converts a value of type A to a value of type O */ + encode) { + this.name = name; + this.is = is; + this.validate = validate; + this.encode = encode; + } + /** a version of `validate` with a default context */ + Type.prototype.decode = function (i) { return null; }; + return Type; +}()); +var tmp1 = null; +function tmp2(n) { } +// tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? (see test 1, needs to behave the same) +var Server = /** @class */ (function () { + function Server() { + } + return Server; +}()); +var MyServer = /** @class */ (function (_super) { + __extends(MyServer, _super); + function MyServer() { + return _super !== null && _super.apply(this, arguments) || this; + } + return MyServer; +}(Server)); // not assignable error at `MyInfo` +exports.MyServer = MyServer; diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.symbols b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.symbols new file mode 100644 index 0000000000000..6d8983bd953d4 --- /dev/null +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.symbols @@ -0,0 +1,244 @@ +=== tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts === +type Either = Left | Right; +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 12)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 14)) +>Left : Symbol(Left, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 45)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 12)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 14)) +>Right : Symbol(Right, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 14, 1)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 12)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 14)) + +class Left { +>Left : Symbol(Left, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 45)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 11)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 13)) + + readonly _tag: 'Left' = 'Left' +>_tag : Symbol(Left._tag, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 18)) + + readonly _A!: A +>_A : Symbol(Left._A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 3, 34)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 13)) + + readonly _L!: L +>_L : Symbol(Left._L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 4, 19)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 11)) + + constructor(readonly value: L) {} +>value : Symbol(Left.value, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 6, 16)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 11)) + + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { +>map : Symbol(Left.map, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 6, 37)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 8, 8)) +>f : Symbol(f, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 8, 11)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 8, 15)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 13)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 8, 8)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 11)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 8, 8)) + + return this as any +>this : Symbol(Left, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 45)) + } + ap(fab: Either B>): Either { +>ap : Symbol(Left.ap, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 10, 5)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 11, 7)) +>fab : Symbol(fab, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 11, 10)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 11)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 11, 26)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 13)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 11, 7)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 2, 11)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 11, 7)) + + return null as any + } +} + +class Right { +>Right : Symbol(Right, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 14, 1)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 12)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 14)) + + readonly _tag: 'Right' = 'Right' +>_tag : Symbol(Right._tag, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 19)) + + readonly _A!: A +>_A : Symbol(Right._A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 17, 36)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 14)) + + readonly _L!: L +>_L : Symbol(Right._L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 18, 19)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 12)) + + constructor(readonly value: A) {} +>value : Symbol(Right.value, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 20, 16)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 14)) + + map(f: (a: A) => B): Either { +>map : Symbol(Right.map, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 20, 37)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 21, 8)) +>f : Symbol(f, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 21, 11)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 21, 15)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 14)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 21, 8)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 12)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 21, 8)) + + return new Right(f(this.value)) +>Right : Symbol(Right, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 14, 1)) +>f : Symbol(f, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 21, 11)) +>this.value : Symbol(Right.value, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 20, 16)) +>this : Symbol(Right, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 14, 1)) +>value : Symbol(Right.value, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 20, 16)) + } + ap(fab: Either B>): Either { +>ap : Symbol(Right.ap, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 23, 5)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 24, 7)) +>fab : Symbol(fab, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 24, 10)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 12)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 24, 26)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 14)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 24, 7)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>L : Symbol(L, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 16, 12)) +>B : Symbol(B, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 24, 7)) + + return null as any; + } +} + +class Type { +>Type : Symbol(Type, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 27, 1)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 11)) +>O : Symbol(O, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 13)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 11)) +>I : Symbol(I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 20)) + + readonly _A!: A; +>_A : Symbol(Type._A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 35)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 11)) + + readonly _O!: O; +>_O : Symbol(Type._O, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 30, 18)) +>O : Symbol(O, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 13)) + + readonly _I!: I; +>_I : Symbol(Type._I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 31, 18)) +>I : Symbol(I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 20)) + + constructor( + /** a unique name for this codec */ + readonly name: string, +>name : Symbol(Type.name, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 33, 14)) + + /** a custom type guard */ + readonly is: (u: unknown) => u is A, +>is : Symbol(Type.is, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 35, 26)) +>u : Symbol(u, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 37, 18)) +>u : Symbol(u, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 37, 18)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 11)) + + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, +>validate : Symbol(Type.validate, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 37, 40)) +>input : Symbol(input, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 39, 24)) +>I : Symbol(I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 20)) +>context : Symbol(context, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 39, 33)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 11)) + + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O +>encode : Symbol(Type.encode, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 39, 68)) +>a : Symbol(a, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 41, 22)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 11)) +>O : Symbol(O, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 13)) + + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } +>decode : Symbol(Type.decode, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 42, 6)) +>i : Symbol(i, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 44, 9)) +>I : Symbol(I, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 20)) +>Either : Symbol(Either, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 0, 0)) +>A : Symbol(A, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 29, 11)) +} + +interface Any extends Type {} +>Any : Symbol(Any, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 45, 1)) +>Type : Symbol(Type, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 27, 1)) + +type TypeOf = C["_A"]; +>TypeOf : Symbol(TypeOf, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 47, 44)) +>C : Symbol(C, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 49, 12)) +>Any : Symbol(Any, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 45, 1)) +>C : Symbol(C, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 49, 12)) + +type ToB = { [k in keyof S]: TypeOf }; +>ToB : Symbol(ToB, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 49, 37)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 9)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 29)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 9)) +>TypeOf : Symbol(TypeOf, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 47, 44)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 9)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 29)) + +type ToA = { [k in keyof S]: Type }; +>ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 59)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 9)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 17)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 9)) +>Type : Symbol(Type, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 27, 1)) +>S : Symbol(S, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 9)) +>k : Symbol(k, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 17)) + +type NeededInfo = { +>NeededInfo : Symbol(NeededInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 45)) +>MyNamespaceSchema : Symbol(MyNamespaceSchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 54, 16)) + + ASchema: ToA; +>ASchema : Symbol(ASchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 54, 43)) +>ToA : Symbol(ToA, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 51, 59)) +>MyNamespaceSchema : Symbol(MyNamespaceSchema, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 54, 16)) + +}; + +export type MyInfo = NeededInfo>; +>MyInfo : Symbol(MyInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 56, 2)) +>NeededInfo : Symbol(NeededInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 45)) +>ToB : Symbol(ToB, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 49, 37)) +>initialize : Symbol(initialize, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 58, 37)) + +const tmp1: MyInfo = null!; +>tmp1 : Symbol(tmp1, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 60, 5)) +>MyInfo : Symbol(MyInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 56, 2)) + +function tmp2(n: N) {} +>tmp2 : Symbol(tmp2, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 60, 27)) +>N : Symbol(N, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 61, 14)) +>NeededInfo : Symbol(NeededInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 45)) +>n : Symbol(n, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 61, 36)) +>N : Symbol(N, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 61, 14)) + +// tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? (see test 1, needs to behave the same) + +class Server {} +>Server : Symbol(Server, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 61, 44)) +>X : Symbol(X, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 64, 13)) +>NeededInfo : Symbol(NeededInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 52, 45)) + +export class MyServer extends Server {} // not assignable error at `MyInfo` +>MyServer : Symbol(MyServer, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 64, 37)) +>Server : Symbol(Server, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 61, 44)) +>MyInfo : Symbol(MyInfo, Decl(varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts, 56, 2)) + diff --git a/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.types b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.types new file mode 100644 index 0000000000000..02a69f2fab0a5 --- /dev/null +++ b/tests/baselines/reference/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.types @@ -0,0 +1,165 @@ +=== tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts === +type Either = Left | Right; +>Either : Either + +class Left { +>Left : Left + + readonly _tag: 'Left' = 'Left' +>_tag : "Left" +>'Left' : "Left" + + readonly _A!: A +>_A : A + + readonly _L!: L +>_L : L + + constructor(readonly value: L) {} +>value : L + + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { +>map : (f: (a: A) => B) => Either +>f : (a: A) => B +>a : A + + return this as any +>this as any : any +>this : this + } + ap(fab: Either B>): Either { +>ap : (fab: Either B>) => Either +>fab : Either B> +>a : A + + return null as any +>null as any : any +>null : null + } +} + +class Right { +>Right : Right + + readonly _tag: 'Right' = 'Right' +>_tag : "Right" +>'Right' : "Right" + + readonly _A!: A +>_A : A + + readonly _L!: L +>_L : L + + constructor(readonly value: A) {} +>value : A + + map(f: (a: A) => B): Either { +>map : (f: (a: A) => B) => Either +>f : (a: A) => B +>a : A + + return new Right(f(this.value)) +>new Right(f(this.value)) : Right +>Right : typeof Right +>f(this.value) : B +>f : (a: A) => B +>this.value : A +>this : this +>value : A + } + ap(fab: Either B>): Either { +>ap : (fab: Either B>) => Either +>fab : Either B> +>a : A + + return null as any; +>null as any : any +>null : null + } +} + +class Type { +>Type : Type + + readonly _A!: A; +>_A : A + + readonly _O!: O; +>_O : O + + readonly _I!: I; +>_I : I + + constructor( + /** a unique name for this codec */ + readonly name: string, +>name : string + + /** a custom type guard */ + readonly is: (u: unknown) => u is A, +>is : (u: unknown) => u is A +>u : unknown + + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, +>validate : (input: I, context: {}[]) => Either<{}[], A> +>input : I +>context : {}[] + + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O +>encode : (a: A) => O +>a : A + + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } +>decode : (i: I) => Either<{}[], A> +>i : I +>null as any : any +>null : null +} + +interface Any extends Type {} + +type TypeOf = C["_A"]; +>TypeOf : C["_A"] + +type ToB = { [k in keyof S]: TypeOf }; +>ToB : ToB + +type ToA = { [k in keyof S]: Type }; +>ToA : ToA + +type NeededInfo = { +>NeededInfo : NeededInfo + + ASchema: ToA; +>ASchema : ToA + +}; + +export type MyInfo = NeededInfo>; +>MyInfo : NeededInfo> +>initialize : any + +const tmp1: MyInfo = null!; +>tmp1 : NeededInfo> +>null! : never +>null : null + +function tmp2(n: N) {} +>tmp2 : >(n: N) => void +>n : N + +// tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? (see test 1, needs to behave the same) + +class Server {} +>Server : Server + +export class MyServer extends Server {} // not assignable error at `MyInfo` +>MyServer : MyServer +>Server : Server>> + diff --git a/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts b/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts new file mode 100644 index 0000000000000..c84abda5e5617 --- /dev/null +++ b/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign.ts @@ -0,0 +1,67 @@ +// @strict: true +type Either = Left | Right; + +class Left { + readonly _tag: 'Left' = 'Left' + readonly _A!: A + readonly _L!: L + constructor(readonly value: L) {} + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { + return this as any + } + ap(fab: Either B>): Either { + return null as any + } +} + +class Right { + readonly _tag: 'Right' = 'Right' + readonly _A!: A + readonly _L!: L + constructor(readonly value: A) {} + map(f: (a: A) => B): Either { + return new Right(f(this.value)) + } + ap(fab: Either B>): Either { + return null as any; + } +} + +class Type { + readonly _A!: A; + readonly _O!: O; + readonly _I!: I; + constructor( + /** a unique name for this codec */ + readonly name: string, + /** a custom type guard */ + readonly is: (u: unknown) => u is A, + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } +} + +interface Any extends Type {} + +type TypeOf = C["_A"]; + +type ToB = { [k in keyof S]: TypeOf }; +type ToA = { [k in keyof S]: Type }; + +type NeededInfo = { + ASchema: ToA; +}; + +export type MyInfo = NeededInfo>; + +const tmp1: MyInfo = null!; +function tmp2(n: N) {} +tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? + +class Server {} +export class MyServer extends Server {} // not assignable error at `MyInfo` \ No newline at end of file diff --git a/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts b/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts new file mode 100644 index 0000000000000..14d835e618595 --- /dev/null +++ b/tests/cases/compiler/varianceProblingAndZeroOrderIndexSignatureRelationsAlign2.ts @@ -0,0 +1,67 @@ +// @strict: true +type Either = Left | Right; + +class Left { + readonly _tag: 'Left' = 'Left' + readonly _A!: A + readonly _L!: L + constructor(readonly value: L) {} + /** The given function is applied if this is a `Right` */ + map(f: (a: A) => B): Either { + return this as any + } + ap(fab: Either B>): Either { + return null as any + } +} + +class Right { + readonly _tag: 'Right' = 'Right' + readonly _A!: A + readonly _L!: L + constructor(readonly value: A) {} + map(f: (a: A) => B): Either { + return new Right(f(this.value)) + } + ap(fab: Either B>): Either { + return null as any; + } +} + +class Type { + readonly _A!: A; + readonly _O!: O; + readonly _I!: I; + constructor( + /** a unique name for this codec */ + readonly name: string, + /** a custom type guard */ + readonly is: (u: unknown) => u is A, + /** succeeds if a value of type I can be decoded to a value of type A */ + readonly validate: (input: I, context: {}[]) => Either<{}[], A>, + /** converts a value of type A to a value of type O */ + readonly encode: (a: A) => O + ) {} + /** a version of `validate` with a default context */ + decode(i: I): Either<{}[], A> { return null as any; } +} + +interface Any extends Type {} + +type TypeOf = C["_A"]; + +type ToB = { [k in keyof S]: TypeOf }; +type ToA = { [k in keyof S]: Type }; + +type NeededInfo = { + ASchema: ToA; +}; + +export type MyInfo = NeededInfo>; + +const tmp1: MyInfo = null!; +function tmp2(n: N) {} +// tmp2(tmp1); // uncommenting this line removes a type error from a completely unrelated line ?? (see test 1, needs to behave the same) + +class Server {} +export class MyServer extends Server {} // not assignable error at `MyInfo` \ No newline at end of file From ee17915801d3e1cf796c7a92861c6b1dc5f4d884 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 19 Feb 2019 14:30:58 -0800 Subject: [PATCH 41/64] Fix build breaks (#29977) * Some callbacks in watchUtilities werent being strictly checked due to the structural fallback * Add direct dependeny on ms since mocha removed its impl * Manually init stats collection on base runner like mocha.run now does --- package.json | 2 ++ src/compiler/watchUtilities.ts | 10 +++++----- src/testRunner/parallel/host.ts | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index f891f99be5657..abf7aa17d350e 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@types/minimist": "latest", "@types/mkdirp": "latest", "@types/mocha": "latest", + "@types/ms": "latest", "@types/node": "8.5.5", "@types/q": "latest", "@types/source-map-support": "latest", @@ -74,6 +75,7 @@ "mkdirp": "latest", "mocha": "latest", "mocha-fivemat-progress-reporter": "latest", + "ms": "latest", "plugin-error": "latest", "pretty-hrtime": "^1.0.3", "prex": "^0.4.3", diff --git a/src/compiler/watchUtilities.ts b/src/compiler/watchUtilities.ts index 9bf242e07e82c..565af054b8feb 100644 --- a/src/compiler/watchUtilities.ts +++ b/src/compiler/watchUtilities.ts @@ -361,9 +361,9 @@ namespace ts { function getWatchFactoryWith(watchLogLevel: WatchLogLevel, log: (s: string) => void, getDetailWatchInfo: GetDetailWatchInfo | undefined, watchFile: (host: WatchFileHost, file: string, callback: FileWatcherCallback, watchPriority: PollingInterval) => FileWatcher, watchDirectory: (host: WatchDirectoryHost, directory: string, callback: DirectoryWatcherCallback, flags: WatchDirectoryFlags) => FileWatcher): WatchFactory { - const createFileWatcher: CreateFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); + const createFileWatcher: CreateFileWatcher = getCreateFileWatcher(watchLogLevel, watchFile); const createFilePathWatcher: CreateFileWatcher = watchLogLevel === WatchLogLevel.None ? watchFilePath : createFileWatcher; - const createDirectoryWatcher: CreateFileWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); + const createDirectoryWatcher: CreateFileWatcher = getCreateFileWatcher(watchLogLevel, watchDirectory); return { watchFile: (host, file, callback, pollingInterval, detailInfo1, detailInfo2) => createFileWatcher(host, file, callback, pollingInterval, /*passThrough*/ undefined, detailInfo1, detailInfo2, watchFile, log, "FileWatcher", getDetailWatchInfo), @@ -402,7 +402,7 @@ namespace ts { } } - function createFileWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { + function createFileWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { log(`${watchCaption}:: Added:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`); const watcher = createFileWatcherWithTriggerLogging(host, file, cb, flags, passThrough, detailInfo1, detailInfo2, addWatch, log, watchCaption, getDetailWatchInfo); return { @@ -413,7 +413,7 @@ namespace ts { }; } - function createDirectoryWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { + function createDirectoryWatcherWithLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { const watchInfo = `${watchCaption}:: Added:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`; log(watchInfo); const start = timestamp(); @@ -432,7 +432,7 @@ namespace ts { }; } - function createFileWatcherWithTriggerLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { + function createFileWatcherWithTriggerLogging(host: H, file: string, cb: WatchCallback, flags: T, passThrough: V | undefined, detailInfo1: X | undefined, detailInfo2: Y | undefined, addWatch: AddWatch, log: (s: string) => void, watchCaption: string, getDetailWatchInfo: GetDetailWatchInfo | undefined): FileWatcher { return addWatch(host, file, (fileName, cbOptional) => { const triggerredInfo = `${watchCaption}:: Triggered with ${fileName} ${cbOptional !== undefined ? cbOptional : ""}:: ${getWatchInfo(file, flags, detailInfo1, detailInfo2, getDetailWatchInfo)}`; log(triggerredInfo); diff --git a/src/testRunner/parallel/host.ts b/src/testRunner/parallel/host.ts index 9adf9e7e850df..597013ed0d985 100644 --- a/src/testRunner/parallel/host.ts +++ b/src/testRunner/parallel/host.ts @@ -7,7 +7,7 @@ namespace Harness.Parallel.Host { const Base = Mocha.reporters.Base; const color = Base.color; const cursor = Base.cursor; - const ms = require("mocha/lib/ms") as typeof import("mocha/lib/ms"); + const ms = require("ms") as typeof import("ms"); const readline = require("readline") as typeof import("readline"); const os = require("os") as typeof import("os"); const tty = require("tty") as typeof import("tty"); @@ -530,6 +530,8 @@ namespace Harness.Parallel.Host { const replayRunner = new Mocha.Runner(new Mocha.Suite(""), /*delay*/ false); replayRunner.started = true; + const createStatsCollector = require("mocha/lib/stats-collector"); + createStatsCollector(replayRunner); // manually init stats collector like mocha.run would const consoleReporter = new Base(replayRunner); patchStats(consoleReporter.stats); From 7c8c6cf4d085cc934b9fc7777f85808151cef481 Mon Sep 17 00:00:00 2001 From: xiaofa Date: Wed, 20 Feb 2019 18:12:09 +0800 Subject: [PATCH 42/64] fix no space before equal operator in type parameter --- src/services/formatting/rules.ts | 2 +- tests/cases/fourslash/formatTypeParameters.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/formatTypeParameters.ts diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index b2dac950323cd..8d710f87a4ea2 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -442,7 +442,7 @@ namespace ts.formatting { case SyntaxKind.ForInStatement: // "in" keyword in [P in keyof T]: T[P] case SyntaxKind.TypeParameter: - return context.currentTokenSpan.kind === SyntaxKind.InKeyword || context.nextTokenSpan.kind === SyntaxKind.InKeyword; + return context.currentTokenSpan.kind === SyntaxKind.InKeyword || context.nextTokenSpan.kind === SyntaxKind.InKeyword || context.currentTokenSpan.kind === SyntaxKind.EqualsToken || context.nextTokenSpan.kind === SyntaxKind.EqualsToken; // Technically, "of" is not a binary operator, but format it the same way as "in" case SyntaxKind.ForOfStatement: return context.currentTokenSpan.kind === SyntaxKind.OfKeyword || context.nextTokenSpan.kind === SyntaxKind.OfKeyword; diff --git a/tests/cases/fourslash/formatTypeParameters.ts b/tests/cases/fourslash/formatTypeParameters.ts new file mode 100644 index 0000000000000..a6823a4d0bf74 --- /dev/null +++ b/tests/cases/fourslash/formatTypeParameters.ts @@ -0,0 +1,8 @@ +/// + +/////**/type Bar = T + + +format.document(); +goTo.marker(); +verify.currentLineContentIs('type Bar = T'); \ No newline at end of file From b67f2d6bdfd7244d1f98c98b6038d7f3280abdc4 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 20 Feb 2019 15:32:15 -0800 Subject: [PATCH 43/64] Remove jake (hopefully for real this time) (#29085) * Remove jake (hopefully for real this time) * Fix gulpfile non-lkg build, add sanity-check build to posttest on CI, accept older baseline style to go with lkgd build * More docs/scripts jake -> gulp --- .github/pull_request_template.md | 2 +- CONTRIBUTING.md | 28 +- Gulpfile.js | 4 +- Jakefile.js | 860 ------------------ README.md | 26 +- lib/README.md | 2 +- package.json | 15 +- scripts/bisect-test.ts | 1 + scripts/build/tests.js | 13 +- scripts/hooks/post-checkout | 2 +- scripts/open-user-pr.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 2 +- 12 files changed, 54 insertions(+), 903 deletions(-) delete mode 100644 Jakefile.js diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index daec1666314a7..2365098deb9a4 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -5,7 +5,7 @@ Here's a checklist you might find useful. * [ ] There is an associated issue that is labeled 'Bug' or 'help wanted' or is in the Community milestone * [ ] Code is up-to-date with the `master` branch -* [ ] You've successfully run `jake runtests` locally +* [ ] You've successfully run `gulp runtests` locally * [ ] You've signed the CLA * [ ] There are new or updated unit tests validating the change diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 31cfb8580890c..4b58cc2875a78 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -104,7 +104,7 @@ Any changes should be made to [src/lib](https://github.com/Microsoft/TypeScript/ Library files in `built/local/` are updated automatically by running the standard build task: ```sh -jake +gulp ``` The files in `lib/` are used to bootstrap compilation and usually **should not** be updated unless publishing a new version or updating the LKG. @@ -115,49 +115,49 @@ The files `src/lib/dom.generated.d.ts` and `src/lib/webworker.generated.d.ts` bo ## Running the Tests -To run all tests, invoke the `runtests-parallel` target using jake: +To run all tests, invoke the `runtests-parallel` target using gulp: ```Shell -jake runtests-parallel +gulp runtests-parallel ``` This will run all tests; to run only a specific subset of tests, use: ```Shell -jake runtests tests= +gulp runtests --tests= ``` e.g. to run all compiler baseline tests: ```Shell -jake runtests tests=compiler +gulp runtests --tests=compiler ``` or to run a specific test: `tests\cases\compiler\2dArrays.ts` ```Shell -jake runtests tests=2dArrays +gulp runtests --tests=2dArrays ``` ## Debugging the tests -To debug the tests, invoke the `runtests-browser` task from jake. +To debug the tests, invoke the `runtests-browser` task from gulp. You will probably only want to debug one test at a time: ```Shell -jake runtests-browser tests=2dArrays +gulp runtests-browser --tests=2dArrays ``` You can specify which browser to use for debugging. Currently Chrome and IE are supported: ```Shell -jake runtests-browser tests=2dArrays browser=chrome +gulp runtests-browser --tests=2dArrays --browser=chrome ``` -You can debug with VS Code or Node instead with `jake runtests inspect=true`: +You can debug with VS Code or Node instead with `gulp runtests --inspect=true`: ```Shell -jake runtests tests=2dArrays inspect=true +gulp runtests --tests=2dArrays --inspect=true ``` ## Adding a Test @@ -197,13 +197,13 @@ Compiler testcases generate baselines that track the emitted `.js`, the errors p When a change in the baselines is detected, the test will fail. To inspect changes vs the expected baselines, use ```Shell -jake diff +gulp diff ``` After verifying that the changes in the baselines are correct, run ```Shell -jake baseline-accept +gulp baseline-accept ``` to establish the new baselines as the desired behavior. This will change the files in `tests\baselines\reference`, which should be included as part of your commit. It's important to carefully validate changes in the baselines. @@ -211,6 +211,6 @@ to establish the new baselines as the desired behavior. This will change the fil ## Localization All strings the user may see are stored in [`diagnosticMessages.json`](./src/compiler/diagnosticMessages.json). -If you make changes to it, run `jake generate-diagnostics` to push them to the `Diagnostic` interface in `diagnosticInformationMap.generated.ts`. +If you make changes to it, run `gulp generate-diagnostics` to push them to the `Diagnostic` interface in `diagnosticInformationMap.generated.ts`. See [coding guidelines on diagnostic messages](https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#diagnostic-messages). diff --git a/Gulpfile.js b/Gulpfile.js index 7d31e0a6137a1..3367010f6bdf5 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -232,7 +232,7 @@ task("watch-tsserver").flags = { " --built": "Compile using the built version of the compiler." } -task("min", series(lkgPreBuild, parallel(buildTsc, buildServer))); +task("min", series(preBuild, parallel(buildTsc, buildServer))); task("min").description = "Builds only tsc and tsserver"; task("min").flags = { " --built": "Compile using the built version of the compiler." @@ -375,7 +375,7 @@ task("lint").flags = { const buildFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("build")); }; const buildFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("build")); }; -task("local", series(buildFoldStart, lkgPreBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl), buildFoldEnd)); +task("local", series(buildFoldStart, preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl), buildFoldEnd)); task("local").description = "Builds the full compiler and services"; task("local").flags = { " --built": "Compile using the built version of the compiler." diff --git a/Jakefile.js b/Jakefile.js deleted file mode 100644 index 18f4aa56f8d92..0000000000000 --- a/Jakefile.js +++ /dev/null @@ -1,860 +0,0 @@ -// This file contains the build logic for the public repo -// @ts-check -/// - -const fs = require("fs"); -const os = require("os"); -const path = require("path"); -const fold = require("travis-fold"); -const ts = require("./lib/typescript"); -const del = require("del"); -const { getDirSize, needsUpdate, flatten } = require("./scripts/build/utils"); -const { base64VLQFormatEncode } = require("./scripts/build/sourcemaps"); - -// add node_modules to path so we don't need global modules, prefer the modules by adding them first -var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter; -if (process.env.path !== undefined) { - process.env.path = nodeModulesPathPrefix + process.env.path; -} -else if (process.env.PATH !== undefined) { - process.env.PATH = nodeModulesPathPrefix + process.env.PATH; -} - -const host = process.env.TYPESCRIPT_HOST || process.env.host || "node"; - -const defaultTestTimeout = 40000; -const useBuilt = - (process.env.USE_BUILT === "true" || process.env.CI === "true") ? true : - process.env.LKG === "true" ? false : - false; - -let useDebugMode = true; - -const TaskNames = { - local: "local", - runtests: "runtests", - runtestsParallel: "runtests-parallel", - buildRules: "build-rules", - clean: "clean", - lib: "lib", - buildFoldStart: "build-fold-start", - buildFoldEnd: "build-fold-end", - generateDiagnostics: "generate-diagnostics", - coreBuild: "core-build", - tsc: "tsc", - lkg: "LKG", - release: "release", - lssl: "lssl", - lint: "lint", - scripts: "scripts", - localize: "localize", - configureInsiders: "configure-insiders", - publishInsiders: "publish-insiders", - configureNightly: "configure-nightly", - publishNightly: "publish-nightly", - help: "help" -}; - -const Paths = {}; -Paths.lkg = "lib"; -Paths.lkgCompiler = "lib/tsc.js"; -Paths.built = "built"; -Paths.builtLocal = "built/local"; -Paths.builtLocalCompiler = "built/local/tsc.js"; -Paths.builtLocalTSServer = "built/local/tsserver.js"; -Paths.builtLocalRun = "built/local/run.js"; -Paths.releaseCompiler = "built/local/tsc.release.js"; -Paths.typesMapOutput = "built/local/typesMap.json"; -Paths.typescriptFile = "built/local/typescript.js"; -Paths.servicesFile = "built/local/typescriptServices.js"; -Paths.servicesDefinitionFile = "built/local/typescriptServices.d.ts"; -Paths.servicesOutFile = "built/local/typescriptServices.out.js"; -Paths.servicesDefinitionOutFile = "built/local/typescriptServices.out.d.ts"; -Paths.typescriptDefinitionFile = "built/local/typescript.d.ts"; -Paths.typescriptStandaloneDefinitionFile = "built/local/typescript_standalone.d.ts"; -Paths.tsserverLibraryFile = "built/local/tsserverlibrary.js"; -Paths.tsserverLibraryDefinitionFile = "built/local/tsserverlibrary.d.ts"; -Paths.tsserverLibraryOutFile = "built/local/tsserverlibrary.out.js"; -Paths.tsserverLibraryDefinitionOutFile = "built/local/tsserverlibrary.out.d.ts"; -Paths.baselines = {}; -Paths.baselines.local = "tests/baselines/local"; -Paths.baselines.localTest262 = "tests/baselines/test262/local"; -Paths.baselines.localRwc = "internal/baselines/rwc/local"; -Paths.baselines.reference = "tests/baselines/reference"; -Paths.baselines.referenceTest262 = "tests/baselines/test262/reference"; -Paths.baselines.referenceRwc = "internal/baselines/rwc/reference"; -Paths.copyright = "CopyrightNotice.txt"; -Paths.thirdParty = "ThirdPartyNoticeText.txt"; -Paths.processDiagnosticMessagesJs = "scripts/processDiagnosticMessages.js"; -Paths.diagnosticInformationMap = "src/compiler/diagnosticInformationMap.generated.ts"; -Paths.diagnosticMessagesJson = "src/compiler/diagnosticMessages.json"; -Paths.diagnosticGeneratedJson = "src/compiler/diagnosticMessages.generated.json"; -Paths.builtDiagnosticGeneratedJson = "built/local/diagnosticMessages.generated.json"; -Paths.lcl = "src/loc/lcl" -Paths.locLcg = "built/local/enu/diagnosticMessages.generated.json.lcg"; -Paths.generatedLCGFile = path.join(Paths.builtLocal, "enu", "diagnosticMessages.generated.json.lcg"); -Paths.library = "src/lib"; -Paths.srcServer = "src/server"; -Paths.scripts = {}; -Paths.scripts.generateLocalizedDiagnosticMessages = "scripts/generateLocalizedDiagnosticMessages.js"; -Paths.scripts.processDiagnosticMessages = "scripts/processDiagnosticMessages.js"; -Paths.scripts.produceLKG = "scripts/produceLKG.js"; -Paths.scripts.configurePrerelease = "scripts/configurePrerelease.js"; -Paths.packageJson = "package.json"; -Paths.versionFile = "src/compiler/core.ts"; - -const ConfigFileFor = { - tsc: "src/tsc", - tscRelease: "src/tsc/tsconfig.release.json", - tsserver: "src/tsserver", - runjs: "src/testRunner", - lint: "scripts/tslint", - scripts: "scripts", - all: "src", - typescriptServices: "built/local/typescriptServices.tsconfig.json", - tsserverLibrary: "built/local/tsserverlibrary.tsconfig.json", -}; - -const ExpectedLKGFiles = [ - "tsc.js", - "tsserver.js", - "typescriptServices.js", - "typescriptServices.d.ts", - "typescript.js", - "typescript.d.ts", - "cancellationToken.js", - "typingsInstaller.js", - "protocol.d.ts", - "watchGuard.js" -]; - -directory(Paths.builtLocal); - -// Local target to build the compiler and services -desc("Builds the full compiler and services"); -task(TaskNames.local, [ - TaskNames.buildFoldStart, - TaskNames.coreBuild, - Paths.servicesDefinitionFile, - Paths.typescriptFile, - Paths.typescriptDefinitionFile, - Paths.typescriptStandaloneDefinitionFile, - Paths.tsserverLibraryDefinitionFile, - TaskNames.localize, - TaskNames.buildFoldEnd -]); - -task("default", [TaskNames.local]); - -const RunTestsPrereqs = [TaskNames.lib, Paths.servicesDefinitionFile, Paths.typescriptDefinitionFile, Paths.tsserverLibraryDefinitionFile]; -desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... i[nspect]=true."); -task(TaskNames.runtestsParallel, RunTestsPrereqs, function () { - tsbuild([ConfigFileFor.runjs], true, () => { - runConsoleTests("min", /*parallel*/ true); - }); -}, { async: true }); - -desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... i[nspect]=true."); -task(TaskNames.runtests, RunTestsPrereqs, function () { - tsbuild([ConfigFileFor.runjs], true, () => { - runConsoleTests('mocha-fivemat-progress-reporter', /*runInParallel*/ false); - }); -}, { async: true }); - -desc("Generates a diagnostic file in TypeScript based on an input JSON file"); -task(TaskNames.generateDiagnostics, [Paths.diagnosticInformationMap]); - -const libraryTargets = getLibraryTargets(); -desc("Builds the library targets"); -task(TaskNames.lib, libraryTargets); - -desc("Builds internal scripts"); -task(TaskNames.scripts, [TaskNames.coreBuild], function() { - tsbuild([ConfigFileFor.scripts], true, () => { - complete(); - }); -}, { async: true }); - -task(Paths.releaseCompiler, function () { - tsbuild([ConfigFileFor.tscRelease], true, () => { - complete(); - }); -}, { async: true }); - -// Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory -desc("Makes a new LKG out of the built js files"); -task(TaskNames.lkg, [ - TaskNames.scripts, - TaskNames.release, - TaskNames.local, - Paths.servicesDefinitionFile, - Paths.typescriptFile, - Paths.typescriptDefinitionFile, - Paths.typescriptStandaloneDefinitionFile, - Paths.tsserverLibraryDefinitionFile, - Paths.releaseCompiler, - ...libraryTargets -], () => { - const sizeBefore = getDirSize(Paths.lkg); - - exec(`${host} ${Paths.scripts.produceLKG}`, () => { - const sizeAfter = getDirSize(Paths.lkg); - if (sizeAfter > (sizeBefore * 1.10)) { - throw new Error("The lib folder increased by 10% or more. This likely indicates a bug."); - } - - complete(); - }); -}, { async: true }); - -desc("Makes the most recent test results the new baseline, overwriting the old baseline"); -task("baseline-accept", function () { - acceptBaseline(Paths.baselines.local, Paths.baselines.reference); -}); - -desc("Makes the most recent rwc test results the new baseline, overwriting the old baseline"); -task("baseline-accept-rwc", function () { - acceptBaseline(Paths.baselines.localRwc, Paths.baselines.referenceRwc); -}); - -desc("Makes the most recent test262 test results the new baseline, overwriting the old baseline"); -task("baseline-accept-test262", function () { - acceptBaseline(Paths.baselines.localTest262, Paths.baselines.referenceTest262); -}); - -desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex"); -task(TaskNames.lint, [TaskNames.buildRules], () => { - if (fold.isTravis()) console.log(fold.start("lint")); - function lint(project, cb) { - const fix = process.env.fix || process.env.f; - const cmd = `node node_modules/tslint/bin/tslint --project ${project} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish${fix ? " --fix" : ""}`; - exec(cmd, cb); - } - lint("scripts/tslint/tsconfig.json", () => lint("src/tsconfig-base.json", () => { - if (fold.isTravis()) console.log(fold.end("lint")); - complete(); - })); -}, { async: true }); - -desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable"); -task('diff', function () { - var cmd = `"${getDiffTool()}" ${Paths.baselines.reference} ${Paths.baselines.local}`; - exec(cmd); -}, { async: true }); - -desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable"); -task('diff-rwc', function () { - var cmd = `"${getDiffTool()}" ${Paths.baselines.referenceRwc} ${Paths.baselines.localRwc}`; - exec(cmd); -}, { async: true }); - -task(TaskNames.configureNightly, [TaskNames.scripts], function () { - const cmd = `${host} ${Paths.scripts.configurePrerelease} dev ${Paths.packageJson} ${Paths.versionFile}`; - exec(cmd, () => complete()); -}, { async: true }); - -desc("Configure, build, test, and publish the nightly release."); -task(TaskNames.publishNightly, [TaskNames.coreBuild, TaskNames.configureNightly, TaskNames.lkg, "setDebugMode", "runtests-parallel"], function () { - var cmd = "npm publish --tag next"; - exec(cmd, () => complete()); -}, { async: true }); - -task(TaskNames.help, function() { - var cmd = "jake --tasks"; - exec(cmd, () => complete()); -}) - -task(TaskNames.configureInsiders, [TaskNames.scripts], function () { - const cmd = `${host} ${Paths.scripts.configurePrerelease} insiders ${Paths.packageJson} ${Paths.versionFile}`; - exec(cmd, () => complete()); -}, { async: true }); - -desc("Configure, build, test, and publish the insiders release."); -task(TaskNames.publishInsiders, [TaskNames.coreBuild, TaskNames.configureInsiders, TaskNames.lkg, "setDebugMode", "runtests-parallel"], function () { - var cmd = "npm publish --tag insiders"; - exec(cmd, () => complete()); -}, { async: true }); - -desc("Sets the release mode flag"); -task("release", function () { - useDebugMode = false; -}); - -desc("Clears the release mode flag"); -task("setDebugMode", function () { - useDebugMode = true; -}); - -desc("Generates localized diagnostic messages"); -task(TaskNames.localize, [Paths.generatedLCGFile]); - -desc("Emit the start of the build fold"); -task(TaskNames.buildFoldStart, [], function () { - if (fold.isTravis()) console.log(fold.start("build")); -}); - -desc("Emit the end of the build fold"); -task(TaskNames.buildFoldEnd, [], function () { - if (fold.isTravis()) console.log(fold.end("build")); -}); - -desc("Compiles tslint rules to js"); -task(TaskNames.buildRules, [], function () { - tsbuild(ConfigFileFor.lint, !useBuilt, () => complete()); -}, { async: true }); - -desc("Cleans the compiler output, declare files, and tests"); -task(TaskNames.clean, function () { - jake.rmRf(Paths.built); -}); - -desc("Generates the LCG file for localization"); -task("localize", [Paths.generatedLCGFile]); - -task(TaskNames.tsc, [Paths.diagnosticInformationMap, TaskNames.lib], function () { - tsbuild(ConfigFileFor.tsc, true, () => { - complete(); - }); -}, { async: true }); - -task(TaskNames.coreBuild, [Paths.diagnosticInformationMap, TaskNames.lib], function () { - tsbuild(ConfigFileFor.all, true, () => { - complete(); - }); -}, { async: true }); - -file(Paths.diagnosticMessagesJson); - -file(Paths.typesMapOutput, /** @type {*} */(function () { - var content = readFileSync(path.join(Paths.srcServer, 'typesMap.json')); - // Validate that it's valid JSON - try { - JSON.parse(content); - } catch (e) { - console.log("Parse error in typesMap.json: " + e); - } - fs.writeFileSync(Paths.typesMapOutput, content); -})); - -file(Paths.builtDiagnosticGeneratedJson, [Paths.diagnosticGeneratedJson], function () { - if (fs.existsSync(Paths.builtLocal)) { - jake.cpR(Paths.diagnosticGeneratedJson, Paths.builtDiagnosticGeneratedJson); - } -}); - -// Localized diagnostics -file(Paths.generatedLCGFile, [TaskNames.scripts, Paths.diagnosticInformationMap, Paths.diagnosticGeneratedJson], function () { - const cmd = `${host} ${Paths.scripts.generateLocalizedDiagnosticMessages} ${Paths.lcl} ${Paths.builtLocal} ${Paths.diagnosticGeneratedJson}` - exec(cmd, complete); -}, { async: true }); - - -// The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task -file(Paths.diagnosticInformationMap, [Paths.diagnosticMessagesJson], function () { - tsbuild(ConfigFileFor.scripts, true, () => { - const cmd = `${host} ${Paths.scripts.processDiagnosticMessages} ${Paths.diagnosticMessagesJson}`; - exec(cmd, complete); - }); -}, { async: true }); - -file(ConfigFileFor.tsserverLibrary, [], function () { - flatten("src/tsserver/tsconfig.json", ConfigFileFor.tsserverLibrary, { - exclude: ["src/tsserver/server.ts"], - compilerOptions: { - "removeComments": false, - "stripInternal": true, - "declaration": true, - "outFile": "tsserverlibrary.out.js" - } - }) -}); - -// tsserverlibrary.js -// tsserverlibrary.d.ts -file(Paths.tsserverLibraryFile, [TaskNames.coreBuild, ConfigFileFor.tsserverLibrary], function() { - tsbuild(ConfigFileFor.tsserverLibrary, !useBuilt, () => { - if (needsUpdate([Paths.tsserverLibraryOutFile, Paths.tsserverLibraryDefinitionOutFile], [Paths.tsserverLibraryFile, Paths.tsserverLibraryDefinitionFile])) { - const copyright = readFileSync(Paths.copyright); - - let libraryDefinitionContent = readFileSync(Paths.tsserverLibraryDefinitionOutFile); - libraryDefinitionContent = copyright + removeConstModifierFromEnumDeclarations(libraryDefinitionContent); - libraryDefinitionContent += "\nexport = ts;\nexport as namespace ts;"; - fs.writeFileSync(Paths.tsserverLibraryDefinitionFile, libraryDefinitionContent, "utf8"); - - let libraryContent = readFileSync(Paths.tsserverLibraryOutFile); - libraryContent = copyright + libraryContent; - fs.writeFileSync(Paths.tsserverLibraryFile, libraryContent, "utf8"); - - // adjust source map for tsserverlibrary.js - let libraryMapContent = readFileSync(Paths.tsserverLibraryOutFile + ".map"); - const map = JSON.parse(libraryMapContent); - const lineStarts = /**@type {*}*/(ts).computeLineStarts(copyright); - let prependMappings = ""; - for (let i = 1; i < lineStarts.length; i++) { - prependMappings += ";"; - } - - const offset = copyright.length - lineStarts[lineStarts.length - 1]; - if (offset > 0) { - prependMappings += base64VLQFormatEncode(offset) + ","; - } - - const outputMap = { - version: map.version, - file: map.file, - sources: map.sources, - sourceRoot: map.sourceRoot, - mappings: prependMappings + map.mappings, - names: map.names, - sourcesContent: map.sourcesContent - }; - - libraryMapContent = JSON.stringify(outputMap); - fs.writeFileSync(Paths.tsserverLibraryFile + ".map", libraryMapContent); - } - complete(); - }); -}, { async: true }); -task(Paths.tsserverLibraryDefinitionFile, [Paths.tsserverLibraryFile]); - -file(ConfigFileFor.typescriptServices, [], function () { - flatten("src/services/tsconfig.json", ConfigFileFor.typescriptServices, { - compilerOptions: { - "removeComments": false, - "stripInternal": true, - "declarationMap": false, - "outFile": "typescriptServices.out.js" - } - }); -}); - -// typescriptServices.js -// typescriptServices.d.ts -file(Paths.servicesFile, [TaskNames.coreBuild, ConfigFileFor.typescriptServices], function() { - tsbuild(ConfigFileFor.typescriptServices, !useBuilt, () => { - if (needsUpdate([Paths.servicesOutFile, Paths.servicesDefinitionOutFile], [Paths.servicesFile, Paths.servicesDefinitionFile])) { - const copyright = readFileSync(Paths.copyright); - - let servicesDefinitionContent = readFileSync(Paths.servicesDefinitionOutFile); - servicesDefinitionContent = copyright + removeConstModifierFromEnumDeclarations(servicesDefinitionContent); - fs.writeFileSync(Paths.servicesDefinitionFile, servicesDefinitionContent, "utf8"); - - let servicesContent = readFileSync(Paths.servicesOutFile); - servicesContent = copyright + servicesContent; - fs.writeFileSync(Paths.servicesFile, servicesContent, "utf8"); - - // adjust source map for typescriptServices.js - let servicesMapContent = readFileSync(Paths.servicesOutFile + ".map"); - const map = JSON.parse(servicesMapContent); - const lineStarts = /**@type {*}*/(ts).computeLineStarts(copyright); - let prependMappings = ""; - for (let i = 1; i < lineStarts.length; i++) { - prependMappings += ";"; - } - - const offset = copyright.length - lineStarts[lineStarts.length - 1]; - if (offset > 0) { - prependMappings += base64VLQFormatEncode(offset) + ","; - } - - const outputMap = { - version: map.version, - file: map.file, - sources: map.sources, - sourceRoot: map.sourceRoot, - mappings: prependMappings + map.mappings, - names: map.names, - sourcesContent: map.sourcesContent - }; - - servicesMapContent = JSON.stringify(outputMap); - fs.writeFileSync(Paths.servicesFile + ".map", servicesMapContent); - } - - complete(); - }); -}, { async: true }); -task(Paths.servicesDefinitionFile, [Paths.servicesFile]); - -// typescript.js -// typescript.d.ts -file(Paths.typescriptFile, [Paths.servicesFile], function() { - if (needsUpdate([Paths.servicesFile, Paths.servicesDefinitionFile], [Paths.typescriptFile, Paths.typescriptDefinitionFile])) { - jake.cpR(Paths.servicesFile, Paths.typescriptFile); - if (fs.existsSync(Paths.servicesFile + ".map")) { - jake.cpR(Paths.servicesFile + ".map", Paths.typescriptFile + ".map"); - } - const content = readFileSync(Paths.servicesDefinitionFile); - fs.writeFileSync(Paths.typescriptDefinitionFile, content + "\r\nexport = ts;", { encoding: "utf-8" }); - } -}); -task(Paths.typescriptDefinitionFile, [Paths.typescriptFile]); - -// typescript_standalone.d.ts -file(Paths.typescriptStandaloneDefinitionFile, [Paths.servicesDefinitionFile], function() { - if (needsUpdate(Paths.servicesDefinitionFile, Paths.typescriptStandaloneDefinitionFile)) { - const content = readFileSync(Paths.servicesDefinitionFile); - fs.writeFileSync(Paths.typescriptStandaloneDefinitionFile, content.replace(/declare (namespace|module) ts(\..+)? \{/g, 'declare module "typescript" {'), { encoding: "utf-8"}); - } -}); - -function getLibraryTargets() { - /** @type {{ libs: string[], paths?: Record, sources?: Record }} */ - const libraries = readJson("./src/lib/libs.json"); - return libraries.libs.map(function (lib) { - const relativeSources = ["header.d.ts"].concat(libraries.sources && libraries.sources[lib] || [lib + ".d.ts"]); - const relativeTarget = libraries.paths && libraries.paths[lib] || ("lib." + lib + ".d.ts"); - const sources = [Paths.copyright].concat(relativeSources.map(s => path.join(Paths.library, s))); - const target = path.join(Paths.builtLocal, relativeTarget); - file(target, [Paths.builtLocal].concat(sources), function () { - concatenateFiles(target, sources); - }); - return target; - }); -} - -function runConsoleTests(defaultReporter, runInParallel) { - var dirty = process.env.dirty; - if (!dirty) { - cleanTestDirs(); - } - - let testTimeout = process.env.timeout || defaultTestTimeout; - const inspect = process.env.inspect || process.env["inspect-brk"] || process.env.i; - const runners = process.env.runners || process.env.runner || process.env.ru; - const tests = process.env.test || process.env.tests || process.env.t; - const light = process.env.light === undefined || process.env.light !== "false"; - const failed = process.env.failed; - const keepFailed = process.env.keepFailed || failed; - const stackTraceLimit = process.env.stackTraceLimit; - const colorsFlag = process.env.color || process.env.colors; - const colors = colorsFlag !== "false" && colorsFlag !== "0"; - const reporter = process.env.reporter || process.env.r || defaultReporter; - const bail = process.env.bail || process.env.b; - const lintFlag = process.env.lint !== 'false'; - const testConfigFile = 'test.config'; - - if (fs.existsSync(testConfigFile)) { - fs.unlinkSync(testConfigFile); - } - - let workerCount, taskConfigsFolder; - if (runInParallel) { - // generate name to store task configuration files - const prefix = os.tmpdir() + "/ts-tests"; - let i = 1; - do { - taskConfigsFolder = prefix + i; - i++; - } while (fs.existsSync(taskConfigsFolder)); - fs.mkdirSync(taskConfigsFolder); - - workerCount = process.env.workerCount || process.env.p || os.cpus().length; - } - - if (tests && tests.toLocaleLowerCase() === "rwc") { - testTimeout = 800000; - } - - if (tests || runners || light || testTimeout || taskConfigsFolder || keepFailed) { - writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, colors, testTimeout, keepFailed); - } - - // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally - // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer - if (!runInParallel) { - var startTime = Travis.mark(); - var args = []; - args.push("-R", "scripts/failed-tests"); - args.push("-O", '"reporter=' + reporter + (keepFailed ? ",keepFailed=true" : "") + '"'); - if (tests) args.push("-g", `"${tests}"`); - args.push(colors ? "--colors" : "--no-colors"); - if (bail) args.push("--bail"); - if (inspect) { - args.unshift("--inspect-brk"); - } else { - args.push("-t", testTimeout); - } - args.push(Paths.builtLocalRun); - - var cmd; - if (failed) { - args.unshift("scripts/run-failed-tests.js"); - cmd = host + " " + args.join(" "); - } - else { - cmd = "mocha " + args.join(" "); - } - var savedNodeEnv = process.env.NODE_ENV; - process.env.NODE_ENV = "development"; - exec(cmd, function () { - process.env.NODE_ENV = savedNodeEnv; - Travis.measure(startTime); - runLinterAndComplete(); - }, function (e, status) { - process.env.NODE_ENV = savedNodeEnv; - Travis.measure(startTime); - finish(status); - }); - } - else { - var savedNodeEnv = process.env.NODE_ENV; - process.env.NODE_ENV = "development"; - var startTime = Travis.mark(); - const cmd = `${host} ${Paths.builtLocalRun}`; - exec(cmd, function () { - // Tests succeeded; run 'lint' task - process.env.NODE_ENV = savedNodeEnv; - Travis.measure(startTime); - runLinterAndComplete(); - }, function (e, status) { - // Tests failed - process.env.NODE_ENV = savedNodeEnv; - Travis.measure(startTime); - finish(status); - }); - } - - function finish(errorStatus) { - deleteTemporaryProjectOutput(); - if (errorStatus !== undefined) { - fail("Process exited with code " + errorStatus); - } - else { - complete(); - } - } - - function runLinterAndComplete() { - if (!lintFlag || dirty) { - return finish(); - } - var lint = jake.Task['lint']; - lint.once('complete', function () { - finish(); - }); - lint.invoke(); - } - - function deleteTemporaryProjectOutput() { - if (fs.existsSync(path.join(Paths.baselines.local, "projectOutput/"))) { - jake.rmRf(path.join(Paths.baselines.local, "projectOutput/")); - } - } -} - -// used to pass data from jake command line directly to run.js -function writeTestConfigFile(tests, runners, light, taskConfigsFolder, workerCount, stackTraceLimit, colors, testTimeout, keepFailed) { - var testConfigContents = JSON.stringify({ - runners: runners ? runners.split(",") : undefined, - test: tests ? [tests] : undefined, - light: light, - workerCount: workerCount, - taskConfigsFolder: taskConfigsFolder, - stackTraceLimit: stackTraceLimit, - noColor: !colors, - timeout: testTimeout, - keepFailed: keepFailed - }); - fs.writeFileSync('test.config', testConfigContents, { encoding: "utf-8" }); -} - -function cleanTestDirs() { - // Clean the local baselines directory - if (fs.existsSync(Paths.baselines.local)) { - del.sync(Paths.baselines.local); - } - - // Clean the local Rwc baselines directory - if (fs.existsSync(Paths.baselines.localRwc)) { - del.sync(Paths.baselines.localRwc); - } - - jake.mkdirP(Paths.baselines.local); - jake.mkdirP(Paths.baselines.localTest262); -} - -function tsbuild(tsconfigPath, useLkg = true, done = undefined) { - const startCompileTime = Travis.mark(); - const compilerPath = useLkg ? Paths.lkgCompiler : Paths.builtLocalCompiler; - const cmd = `${host} ${compilerPath} -b ${Array.isArray(tsconfigPath) ? tsconfigPath.join(" ") : tsconfigPath}`; - - exec(cmd, () => { - // Success - Travis.measure(startCompileTime); - done ? done() : complete(); - }, () => { - // Fail - Travis.measure(startCompileTime); - fail(`Compilation of ${tsconfigPath} unsuccessful`); - }); -} - -const Travis = { - mark() { - if (!fold.isTravis()) return; - var stamp = process.hrtime(); - var id = Math.floor(Math.random() * 0xFFFFFFFF).toString(16); - console.log("travis_time:start:" + id + "\r"); - return { - stamp: stamp, - id: id - }; - }, - measure(marker) { - if (!fold.isTravis()) return; - var diff = process.hrtime(marker.stamp); - var total = [marker.stamp[0] + diff[0], marker.stamp[1] + diff[1]]; - console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r"); - } -}; - -function toNs(diff) { - return diff[0] * 1e9 + diff[1]; -} - -function exec(cmd, successHandler, errorHandler) { - var ex = jake.createExec([cmd], /** @type {jake.ExecOptions} */({ windowsVerbatimArguments: true, interactive: true })); - // Add listeners for output and error - ex.addListener("stdout", function (output) { - process.stdout.write(output); - }); - ex.addListener("stderr", function (error) { - process.stderr.write(error); - }); - ex.addListener("cmdEnd", function () { - if (successHandler) { - successHandler(); - } - }); - ex.addListener("error", function (e, status) { - if (errorHandler) { - errorHandler(e, status); - } - else { - fail("Process exited with code " + status); - } - }); - - console.log(cmd); - ex.run(); -} - -function acceptBaseline(sourceFolder, targetFolder) { - console.log('Accept baselines from ' + sourceFolder + ' to ' + targetFolder); - var deleteEnding = '.delete'; - - jake.mkdirP(targetFolder); - acceptBaselineFolder(sourceFolder, targetFolder); - - function acceptBaselineFolder(sourceFolder, targetFolder) { - var files = fs.readdirSync(sourceFolder); - - for (var i in files) { - var filename = files[i]; - var fullLocalPath = path.join(sourceFolder, filename); - var stat = fs.statSync(fullLocalPath); - if (stat.isFile()) { - if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) { - filename = filename.substr(0, filename.length - deleteEnding.length); - fs.unlinkSync(path.join(targetFolder, filename)); - } - else { - var target = path.join(targetFolder, filename); - if (fs.existsSync(target)) { - fs.unlinkSync(target); - } - jake.mkdirP(path.dirname(target)); - fs.renameSync(path.join(sourceFolder, filename), target); - } - } - else if (stat.isDirectory()) { - acceptBaselineFolder(fullLocalPath, path.join(targetFolder, filename)); - } - } - } -} - -/** @param jsonPath {string} */ -function readJson(jsonPath) { - const jsonText = readFileSync(jsonPath); - const result = ts.parseConfigFileTextToJson(jsonPath, jsonText); - if (result.error) { - reportDiagnostics([result.error]); - throw new Error("An error occurred during parse."); - } - return result.config; -} - -/** @param diagnostics {ts.Diagnostic[]} */ -function reportDiagnostics(diagnostics) { - console.log(diagnosticsToString(diagnostics, process.stdout.isTTY)); -} - -/** - * @param diagnostics {ts.Diagnostic[]} - * @param [pretty] {boolean} - */ -function diagnosticsToString(diagnostics, pretty) { - const host = { - getCurrentDirectory() { return process.cwd(); }, - getCanonicalFileName(fileName) { return fileName; }, - getNewLine() { return os.EOL; } - }; - return pretty ? ts.formatDiagnosticsWithColorAndContext(diagnostics, host) : - ts.formatDiagnostics(diagnostics, host); -} - -/** - * Concatenate a list of sourceFiles to a destinationFile - * @param {string} destinationFile - * @param {string[]} sourceFiles - * @param {string=} extraContent - */ -function concatenateFiles(destinationFile, sourceFiles, extraContent) { - var temp = "temptemp"; - // append all files in sequence - var text = ""; - for (var i = 0; i < sourceFiles.length; i++) { - if (!fs.existsSync(sourceFiles[i])) { - fail(sourceFiles[i] + " does not exist!"); - } - if (i > 0) { text += "\n\n"; } - text += readFileSync(sourceFiles[i]).replace(/\r?\n/g, "\n"); - } - if (extraContent) { - text += extraContent; - } - fs.writeFileSync(temp, text); - // Move the file to the final destination - fs.renameSync(temp, destinationFile); -} - -function appendToFile(path, content) { - fs.writeFileSync(path, readFileSync(path) + "\r\n" + content); -} - -/** - * - * @param {string} path - * @returns string - */ -function readFileSync(path) { - return fs.readFileSync(path, { encoding: "utf-8" }); -} - -function getDiffTool() { - var program = process.env['DIFF']; - if (!program) { - fail("Add the 'DIFF' environment variable to the path of the program you want to use."); - } - return program; -} - -/** - * Replaces const enum declarations with non-const enums - * @param {string} text - */ -function removeConstModifierFromEnumDeclarations(text) { - return text.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4'); -} \ No newline at end of file diff --git a/README.md b/README.md index 2826db8aec664..3b20af2d39848 100644 --- a/README.md +++ b/README.md @@ -61,29 +61,29 @@ Change to the TypeScript directory: cd TypeScript ``` -Install [Jake](http://jakejs.com/) tools and dev dependencies: +Install [Gulp](https://gulpjs.com/) tools and dev dependencies: ```bash -npm install -g jake +npm install -g gulp npm install ``` Use one of the following to build and test: ``` -jake local # Build the compiler into built/local -jake clean # Delete the built compiler -jake LKG # Replace the last known good with the built one. +gulp local # Build the compiler into built/local +gulp clean # Delete the built compiler +gulp LKG # Replace the last known good with the built one. # Bootstrapping step to be executed when the built compiler reaches a stable state. -jake tests # Build the test infrastructure using the built compiler. -jake runtests # Run tests using the built compiler and test infrastructure. +gulp tests # Build the test infrastructure using the built compiler. +gulp runtests # Run tests using the built compiler and test infrastructure. # You can override the host or specify a test for this command. - # Use host= or tests=. -jake runtests-browser # Runs the tests using the built run.js file. Syntax is jake runtests. Optional - parameters 'host=', 'tests=[regex], reporter=[list|spec|json|]'. -jake baseline-accept # This replaces the baseline test results with the results obtained from jake runtests. -jake lint # Runs tslint on the TypeScript source. -jake help # List the above commands. + # Use --host= or --tests=. +gulp runtests-browser # Runs the tests using the built run.js file. Syntax is gulp runtests. Optional + parameters '--host=', '--tests=[regex], --reporter=[list|spec|json|]'. +gulp baseline-accept # This replaces the baseline test results with the results obtained from gulp runtests. +gulp lint # Runs tslint on the TypeScript source. +gulp help # List the above commands. ``` diff --git a/lib/README.md b/lib/README.md index 0a85a9e7b5c80..ce0455fa40d3c 100644 --- a/lib/README.md +++ b/lib/README.md @@ -2,4 +2,4 @@ **These files are not meant to be edited by hand.** If you need to make modifications, the respective files should be changed within the repository's top-level `src` directory. -Running `jake LKG` will then appropriately update the files in this directory. +Running `gulp LKG` will then appropriately update the files in this directory. diff --git a/package.json b/package.json index abf7aa17d350e..275411c477f13 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,6 @@ "gulp-rename": "latest", "gulp-sourcemaps": "latest", "istanbul": "latest", - "jake": "latest", "lodash": "^4.17.11", "merge2": "latest", "minimist": "latest", @@ -91,16 +90,16 @@ "xml2js": "^0.4.19" }, "scripts": { - "pretest": "jake tests", - "test": "jake runtests-parallel light=false", + "pretest": "gulp tests", + "test": "gulp runtests-parallel --light=false", "build": "npm run build:compiler && npm run build:tests", - "build:compiler": "jake local", - "build:tests": "jake tests", + "build:compiler": "gulp local", + "build:tests": "gulp tests", "start": "node lib/tsc", - "clean": "jake clean", + "clean": "gulp clean", "gulp": "gulp", - "jake": "jake", - "lint": "jake lint", + "jake": "gulp", + "lint": "gulp lint", "setup-hooks": "node scripts/link-hooks.js" }, "browser": { diff --git a/scripts/bisect-test.ts b/scripts/bisect-test.ts index cc0248f6d64f3..d66e0b7106132 100644 --- a/scripts/bisect-test.ts +++ b/scripts/bisect-test.ts @@ -15,6 +15,7 @@ function tsc(tscArgs: string, onExit: (exitCode: number) => void) { }); } +// TODO: Rewrite bisect script to handle the post-jake/gulp swap period var jake = cp.exec('jake clean local', () => void 0); jake.on('close', jakeExitCode => { if (jakeExitCode === 0) { diff --git a/scripts/build/tests.js b/scripts/build/tests.js index 36a9ea54cb9b5..bcf5431b8d949 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -116,6 +116,17 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, errorStatus = exitCode; error = new Error(`Process exited with status code ${errorStatus}.`); } + else if (process.env.CI === "true") { + // finally, do a sanity check and build the compiler with the built version of itself + log.info("Starting sanity check build..."); + // Cleanup everything except lint rules (we'll need those later and would rather not waste time rebuilding them) + await exec("gulp", ["clean-tsc", "clean-services", "clean-tsserver", "clean-lssl", "clean-tests"], { cancelToken }); + const { exitCode } = await exec("gulp", ["local", "--lkg=false"], { cancelToken }); + if (exitCode !== 0) { + errorStatus = exitCode; + error = new Error(`Sanity check build process exited with status code ${errorStatus}.`); + } + } } catch (e) { errorStatus = undefined; @@ -148,7 +159,7 @@ async function cleanTestDirs() { exports.cleanTestDirs = cleanTestDirs; /** - * used to pass data from jake command line directly to run.js + * used to pass data from gulp command line directly to run.js * @param {string} tests * @param {string} runners * @param {boolean} light diff --git a/scripts/hooks/post-checkout b/scripts/hooks/post-checkout index fb41e4e8652cd..28a583794d929 100644 --- a/scripts/hooks/post-checkout +++ b/scripts/hooks/post-checkout @@ -1,2 +1,2 @@ #!/bin/sh -npm run jake -- generate-diagnostics \ No newline at end of file +npm run gulp -- generate-diagnostics \ No newline at end of file diff --git a/scripts/open-user-pr.ts b/scripts/open-user-pr.ts index f510c63d4e308..aedfcc4254791 100644 --- a/scripts/open-user-pr.ts +++ b/scripts/open-user-pr.ts @@ -24,7 +24,7 @@ const branchName = `user-update-${now.getFullYear()}${padNum(now.getMonth())}${p const remoteUrl = `https://${process.argv[2]}@github.com/${userName}/TypeScript.git`; runSequence([ ["git", ["checkout", "."]], // reset any changes - ["node", ["./node_modules/jake/bin/cli.js", "baseline-accept"]], // accept baselines + ["node", ["./node_modules/gulp/bin/gulp.js", "baseline-accept"]], // accept baselines ["git", ["checkout", "-b", branchName]], // create a branch ["git", ["add", "."]], // Add all changes ["git", ["commit", "-m", `"Update user baselines"`]], // Commit all changes diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 70fccdf87c1a3..36c246c999f23 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -8347,7 +8347,7 @@ declare namespace ts.server { excludedFiles: ReadonlyArray; private typeAcquisition; updateGraph(): boolean; - getExcludedFiles(): readonly NormalizedPath[]; + getExcludedFiles(): ReadonlyArray; getTypeAcquisition(): TypeAcquisition; setTypeAcquisition(newTypeAcquisition: TypeAcquisition): void; } From cee933ff099af026eba520cc34281765ea4a621a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 Feb 2019 10:31:55 -0800 Subject: [PATCH 44/64] Be more specific in errors. --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9ac19fb98d060..53ded49daed5a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24448,7 +24448,7 @@ namespace ts { const bodySignature = getSignatureFromDeclaration(bodyDeclaration); for (const signature of signatures) { if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { - error(signature.declaration, Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); + error(signature.declaration, Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature); break; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 89794d2618111..c0686d10db618 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1404,7 +1404,7 @@ "category": "Error", "code": 2393 }, - "Overload signature is not compatible with function implementation.": { + "This overload signature is not compatible with its implementation signature.": { "category": "Error", "code": 2394 }, From 4a256abc8a18335f55f8ce21abea9f25c471823f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 Feb 2019 10:42:38 -0800 Subject: [PATCH 45/64] Give a related span pointing to the implementation signature when reporting incompatibility. --- src/compiler/checker.ts | 5 ++++- src/compiler/diagnosticMessages.json | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 53ded49daed5a..958ceae0395a2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -24448,7 +24448,10 @@ namespace ts { const bodySignature = getSignatureFromDeclaration(bodyDeclaration); for (const signature of signatures) { if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { - error(signature.declaration, Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature); + addRelatedInfo( + error(signature.declaration, Diagnostics.This_overload_signature_is_not_compatible_with_its_implementation_signature), + createDiagnosticForNode(bodyDeclaration, Diagnostics.The_implementation_signature_is_declared_here) + ); break; } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c0686d10db618..09b0f72129255 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2585,6 +2585,10 @@ "category": "Error", "code": 2749 }, + "The implementation signature is declared here.": { + "category": "Error", + "code": 2750 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", From d6bb3ee64cf3c51f0014c0f6410ab72df7803b25 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 21 Feb 2019 10:45:40 -0800 Subject: [PATCH 46/64] Accepted baselines. --- .../reference/anyIdenticalToItself.errors.txt | 5 +++-- ...nstructorsWithSpecializedSignatures.errors.txt | 10 ++++++---- ...ctionAndInterfaceWithSeparateErrors.errors.txt | 5 +++-- ...tionOverloadCompatibilityWithVoid01.errors.txt | 5 +++-- .../reference/functionOverloadErrors.errors.txt | 15 +++++++++------ .../reference/functionOverloads11.errors.txt | 5 +++-- .../reference/functionOverloads17.errors.txt | 5 +++-- .../reference/functionOverloads18.errors.txt | 5 +++-- .../reference/functionOverloads19.errors.txt | 5 +++-- .../reference/functionOverloads20.errors.txt | 5 +++-- .../reference/functionOverloads4.errors.txt | 5 +++-- .../reference/overloadAssignmentCompat.errors.txt | 5 +++-- .../overloadOnConstNoAnyImplementation.errors.txt | 5 +++-- ...overloadOnConstNoAnyImplementation2.errors.txt | 5 +++-- ...overloadOnConstantsInvalidOverload1.errors.txt | 5 +++-- .../reference/overloadingOnConstants2.errors.txt | 10 ++++++---- .../parameterPropertyInConstructor2.errors.txt | 5 +++-- .../reference/parserClassDeclaration12.errors.txt | 5 +++-- .../reference/parserParameterList15.errors.txt | 5 +++-- .../reference/parserParameterList16.errors.txt | 5 +++-- .../reference/parserParameterList17.errors.txt | 5 +++-- .../reference/recursiveFunctionTypes.errors.txt | 5 +++-- ...NotSubtypeOfNonSpecializedSignature.errors.txt | 5 +++-- .../stringLiteralTypesOverloads05.errors.txt | 5 +++-- ...mplateStringInFunctionParameterType.errors.txt | 5 +++-- ...ateStringInFunctionParameterTypeES6.errors.txt | 5 +++-- .../voidAsNonAmbiguousReturnType.errors.txt | 5 +++-- 27 files changed, 93 insertions(+), 62 deletions(-) diff --git a/tests/baselines/reference/anyIdenticalToItself.errors.txt b/tests/baselines/reference/anyIdenticalToItself.errors.txt index bcd3b52daef1d..3eff1c4b87a03 100644 --- a/tests/baselines/reference/anyIdenticalToItself.errors.txt +++ b/tests/baselines/reference/anyIdenticalToItself.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/anyIdenticalToItself.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/anyIdenticalToItself.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/anyIdenticalToItself.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/anyIdenticalToItself.ts(10,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -6,7 +6,8 @@ tests/cases/compiler/anyIdenticalToItself.ts(10,9): error TS1056: Accessors are ==== tests/cases/compiler/anyIdenticalToItself.ts (3 errors) ==== function foo(x: any); ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/anyIdenticalToItself.ts:3:10: The implementation signature is declared here. function foo(x: any); function foo(x: any, y: number) { } diff --git a/tests/baselines/reference/constructorsWithSpecializedSignatures.errors.txt b/tests/baselines/reference/constructorsWithSpecializedSignatures.errors.txt index 4f869fd63a06f..682959074e800 100644 --- a/tests/baselines/reference/constructorsWithSpecializedSignatures.errors.txt +++ b/tests/baselines/reference/constructorsWithSpecializedSignatures.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/constructorsWithSpecializedSignatures.ts(18,5): error TS2394: Overload signature is not compatible with function implementation. -tests/cases/compiler/constructorsWithSpecializedSignatures.ts(26,5): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/constructorsWithSpecializedSignatures.ts(18,5): error TS2394: This overload signature is not compatible with its implementation signature. +tests/cases/compiler/constructorsWithSpecializedSignatures.ts(26,5): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/constructorsWithSpecializedSignatures.ts (2 errors) ==== @@ -22,7 +22,8 @@ tests/cases/compiler/constructorsWithSpecializedSignatures.ts(26,5): error TS239 constructor(x: "hi"); constructor(x: "foo"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/constructorsWithSpecializedSignatures.ts:20:5: The implementation signature is declared here. constructor(x: number); constructor(x: "hi") { } } @@ -32,7 +33,8 @@ tests/cases/compiler/constructorsWithSpecializedSignatures.ts(26,5): error TS239 constructor(x: "hi"); constructor(x: "foo"); ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/constructorsWithSpecializedSignatures.ts:28:5: The implementation signature is declared here. constructor(x: string); constructor(x: "hi") { } // error } diff --git a/tests/baselines/reference/functionAndInterfaceWithSeparateErrors.errors.txt b/tests/baselines/reference/functionAndInterfaceWithSeparateErrors.errors.txt index a87dc989178c5..a22bdef219965 100644 --- a/tests/baselines/reference/functionAndInterfaceWithSeparateErrors.errors.txt +++ b/tests/baselines/reference/functionAndInterfaceWithSeparateErrors.errors.txt @@ -1,11 +1,12 @@ -tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts(6,5): error TS2411: Property 'prop' of type 'number' is not assignable to string index type 'string'. ==== tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts (2 errors) ==== function Foo(s: string); ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/functionAndInterfaceWithSeparateErrors.ts:2:10: The implementation signature is declared here. function Foo(n: number) { } interface Foo { diff --git a/tests/baselines/reference/functionOverloadCompatibilityWithVoid01.errors.txt b/tests/baselines/reference/functionOverloadCompatibilityWithVoid01.errors.txt index 56951e380e452..5e81224b5eb69 100644 --- a/tests/baselines/reference/functionOverloadCompatibilityWithVoid01.errors.txt +++ b/tests/baselines/reference/functionOverloadCompatibilityWithVoid01.errors.txt @@ -1,10 +1,11 @@ -tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid01.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid01.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid01.ts (1 errors) ==== function f(x: string): number; ~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/functions/functionOverloadCompatibilityWithVoid01.ts:2:10: The implementation signature is declared here. function f(x: string): void { return; } \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloadErrors.errors.txt b/tests/baselines/reference/functionOverloadErrors.errors.txt index ddcaf4786021c..66f0751fb4291 100644 --- a/tests/baselines/reference/functionOverloadErrors.errors.txt +++ b/tests/baselines/reference/functionOverloadErrors.errors.txt @@ -5,9 +5,9 @@ tests/cases/conformance/functions/functionOverloadErrors.ts(75,21): error TS2383 tests/cases/conformance/functions/functionOverloadErrors.ts(79,14): error TS2383: Overload signatures must all be exported or non-exported. tests/cases/conformance/functions/functionOverloadErrors.ts(85,18): error TS2384: Overload signatures must all be ambient or non-ambient. tests/cases/conformance/functions/functionOverloadErrors.ts(90,18): error TS2384: Overload signatures must all be ambient or non-ambient. -tests/cases/conformance/functions/functionOverloadErrors.ts(94,10): error TS2394: Overload signature is not compatible with function implementation. -tests/cases/conformance/functions/functionOverloadErrors.ts(99,10): error TS2394: Overload signature is not compatible with function implementation. -tests/cases/conformance/functions/functionOverloadErrors.ts(103,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/functions/functionOverloadErrors.ts(94,10): error TS2394: This overload signature is not compatible with its implementation signature. +tests/cases/conformance/functions/functionOverloadErrors.ts(99,10): error TS2394: This overload signature is not compatible with its implementation signature. +tests/cases/conformance/functions/functionOverloadErrors.ts(103,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/conformance/functions/functionOverloadErrors.ts(116,19): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -121,20 +121,23 @@ tests/cases/conformance/functions/functionOverloadErrors.ts(116,19): error TS237 //Function overloads with fewer params than implementation signature function fewerParams(); ~~~~~~~~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/functions/functionOverloadErrors.ts:95:10: The implementation signature is declared here. function fewerParams(n: string) { } //Function implementation whose parameter types are not assignable to all corresponding overload signature parameters function fn13(n: string); ~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/functions/functionOverloadErrors.ts:100:10: The implementation signature is declared here. function fn13(n: number) { } //Function overloads where return types are not all subtype of implementation return type function fn14(n: string): string; ~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/functions/functionOverloadErrors.ts:104:10: The implementation signature is declared here. function fn14() { return 3; } diff --git a/tests/baselines/reference/functionOverloads11.errors.txt b/tests/baselines/reference/functionOverloads11.errors.txt index 005ee9bb1438a..a2e37789b60b3 100644 --- a/tests/baselines/reference/functionOverloads11.errors.txt +++ b/tests/baselines/reference/functionOverloads11.errors.txt @@ -1,9 +1,10 @@ -tests/cases/compiler/functionOverloads11.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/functionOverloads11.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/functionOverloads11.ts (1 errors) ==== function foo():number; ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/functionOverloads11.ts:2:10: The implementation signature is declared here. function foo():string { return "" } \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads17.errors.txt b/tests/baselines/reference/functionOverloads17.errors.txt index febd2c03ac8d0..1945e3fc17a18 100644 --- a/tests/baselines/reference/functionOverloads17.errors.txt +++ b/tests/baselines/reference/functionOverloads17.errors.txt @@ -1,9 +1,10 @@ -tests/cases/compiler/functionOverloads17.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/functionOverloads17.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/functionOverloads17.ts (1 errors) ==== function foo():{a:number;} ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/functionOverloads17.ts:2:10: The implementation signature is declared here. function foo():{a:string;} { return {a:""} } \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads18.errors.txt b/tests/baselines/reference/functionOverloads18.errors.txt index bec6a45ed8918..6010c633abf0f 100644 --- a/tests/baselines/reference/functionOverloads18.errors.txt +++ b/tests/baselines/reference/functionOverloads18.errors.txt @@ -1,9 +1,10 @@ -tests/cases/compiler/functionOverloads18.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/functionOverloads18.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/functionOverloads18.ts (1 errors) ==== function foo(bar:{a:number;}); ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/functionOverloads18.ts:2:10: The implementation signature is declared here. function foo(bar:{a:string;}) { return {a:""} } \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads19.errors.txt b/tests/baselines/reference/functionOverloads19.errors.txt index d87ba17562ae6..bd2ce38ec1652 100644 --- a/tests/baselines/reference/functionOverloads19.errors.txt +++ b/tests/baselines/reference/functionOverloads19.errors.txt @@ -1,10 +1,11 @@ -tests/cases/compiler/functionOverloads19.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/functionOverloads19.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/functionOverloads19.ts (1 errors) ==== function foo(bar:{b:string;}); ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/functionOverloads19.ts:3:10: The implementation signature is declared here. function foo(bar:{a:string;}); function foo(bar:{a:any;}) { return {a:""} } \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads20.errors.txt b/tests/baselines/reference/functionOverloads20.errors.txt index 6b33795bc3eca..b4e4f969dfb35 100644 --- a/tests/baselines/reference/functionOverloads20.errors.txt +++ b/tests/baselines/reference/functionOverloads20.errors.txt @@ -1,10 +1,11 @@ -tests/cases/compiler/functionOverloads20.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/functionOverloads20.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/functionOverloads20.ts (1 errors) ==== function foo(bar:{a:number;}): number; ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/functionOverloads20.ts:3:10: The implementation signature is declared here. function foo(bar:{a:string;}): string; function foo(bar:{a:any;}): string {return ""} \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads4.errors.txt b/tests/baselines/reference/functionOverloads4.errors.txt index 78d772a0f6f5c..d9ce3a7d1893e 100644 --- a/tests/baselines/reference/functionOverloads4.errors.txt +++ b/tests/baselines/reference/functionOverloads4.errors.txt @@ -1,8 +1,9 @@ -tests/cases/compiler/functionOverloads4.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/functionOverloads4.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/functionOverloads4.ts (1 errors) ==== function foo():number; ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/functionOverloads4.ts:2:10: The implementation signature is declared here. function foo():string { return "a" } \ No newline at end of file diff --git a/tests/baselines/reference/overloadAssignmentCompat.errors.txt b/tests/baselines/reference/overloadAssignmentCompat.errors.txt index 35906ee92c9aa..a0609b70e713a 100644 --- a/tests/baselines/reference/overloadAssignmentCompat.errors.txt +++ b/tests/baselines/reference/overloadAssignmentCompat.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/overloadAssignmentCompat.ts(34,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/overloadAssignmentCompat.ts(34,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/overloadAssignmentCompat.ts (1 errors) ==== @@ -37,7 +37,8 @@ tests/cases/compiler/overloadAssignmentCompat.ts(34,10): error TS2394: Overload // error - signatures are not assignment compatible function foo():number; ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/overloadAssignmentCompat.ts:35:10: The implementation signature is declared here. function foo():string { return "a" }; \ No newline at end of file diff --git a/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt b/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt index aa7bbf7723968..457f7f5b3888f 100644 --- a/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt +++ b/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt @@ -1,11 +1,12 @@ -tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(9,8): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/overloadOnConstNoAnyImplementation.ts (2 errors) ==== function x1(a: number, cb: (x: 'hi') => number); ~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/overloadOnConstNoAnyImplementation.ts:3:10: The implementation signature is declared here. function x1(a: number, cb: (x: 'bye') => number); function x1(a: number, cb: (x: string) => number) { cb('hi'); diff --git a/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt b/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt index a090f370863f5..f6792949e596e 100644 --- a/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt +++ b/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(6,5): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(6,5): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(12,18): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(18,9): error TS2345: Argument of type '(x: "bye") => number' is not assignable to parameter of type '(x: "hi") => number'. Types of parameters 'x' and 'x' are incompatible. @@ -16,7 +16,8 @@ tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(21,9): error TS2345: class C { x1(a: number, callback: (x: 'hi') => number); ~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts:7:5: The implementation signature is declared here. x1(a: number, callback: (x: string) => number) { callback('hi'); callback('bye'); diff --git a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.errors.txt b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.errors.txt index 3fe0a43d855c8..9fc6c97f6b77d 100644 --- a/tests/baselines/reference/overloadOnConstantsInvalidOverload1.errors.txt +++ b/tests/baselines/reference/overloadOnConstantsInvalidOverload1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(6,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(6,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(11,5): error TS2345: Argument of type '"HI"' is not assignable to parameter of type '"SPAN"'. @@ -10,7 +10,8 @@ tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts(11,5): error TS2345: function foo(name: "SPAN"): Derived1; ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/overloadOnConstantsInvalidOverload1.ts:7:10: The implementation signature is declared here. function foo(name: "DIV"): Derived2 { return null; } diff --git a/tests/baselines/reference/overloadingOnConstants2.errors.txt b/tests/baselines/reference/overloadingOnConstants2.errors.txt index f50a6bbd8c3a0..c12d77714a31e 100644 --- a/tests/baselines/reference/overloadingOnConstants2.errors.txt +++ b/tests/baselines/reference/overloadingOnConstants2.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/overloadingOnConstants2.ts(9,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/overloadingOnConstants2.ts(9,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/overloadingOnConstants2.ts(15,13): error TS2345: Argument of type '"um"' is not assignable to parameter of type '"bye"'. -tests/cases/compiler/overloadingOnConstants2.ts(19,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/overloadingOnConstants2.ts(19,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/overloadingOnConstants2.ts (3 errors) ==== @@ -14,7 +14,8 @@ tests/cases/compiler/overloadingOnConstants2.ts(19,10): error TS2394: Overload s function foo(x: "hi", items: string[]): D; function foo(x: "bye", items: string[]): E; ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/overloadingOnConstants2.ts:10:10: The implementation signature is declared here. function foo(x: string, items: string[]): C { return null; } @@ -28,7 +29,8 @@ tests/cases/compiler/overloadingOnConstants2.ts(19,10): error TS2394: Overload s //function bar(x: "hi", items: string[]): D; function bar(x: "bye", items: string[]): E; ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/overloadingOnConstants2.ts:21:10: The implementation signature is declared here. function bar(x: string, items: string[]): C; function bar(x: string, items: string[]): C { return null; diff --git a/tests/baselines/reference/parameterPropertyInConstructor2.errors.txt b/tests/baselines/reference/parameterPropertyInConstructor2.errors.txt index d1a0513c1f68d..6f64fdc86697f 100644 --- a/tests/baselines/reference/parameterPropertyInConstructor2.errors.txt +++ b/tests/baselines/reference/parameterPropertyInConstructor2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/parameterPropertyInConstructor2.ts(3,5): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/parameterPropertyInConstructor2.ts(3,5): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/parameterPropertyInConstructor2.ts(3,17): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/compiler/parameterPropertyInConstructor2.ts(4,24): error TS2300: Duplicate identifier 'names'. @@ -8,7 +8,8 @@ tests/cases/compiler/parameterPropertyInConstructor2.ts(4,24): error TS2300: Dup class Customers { constructor(public names: string); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/parameterPropertyInConstructor2.ts:4:5: The implementation signature is declared here. ~~~~~~~~~~~~~~~~~~~~ !!! error TS2369: A parameter property is only allowed in a constructor implementation. constructor(public names: string, public ages: number) { diff --git a/tests/baselines/reference/parserClassDeclaration12.errors.txt b/tests/baselines/reference/parserClassDeclaration12.errors.txt index 130eaa3defd2e..453c4f13eba93 100644 --- a/tests/baselines/reference/parserClassDeclaration12.errors.txt +++ b/tests/baselines/reference/parserClassDeclaration12.errors.txt @@ -1,10 +1,11 @@ -tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration12.ts(2,4): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration12.ts(2,4): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration12.ts (1 errors) ==== class C { constructor(); ~~~~~~~~~~~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/parser/ecmascript5/ClassDeclarations/parserClassDeclaration12.ts:3:4: The implementation signature is declared here. constructor(a) { } } \ No newline at end of file diff --git a/tests/baselines/reference/parserParameterList15.errors.txt b/tests/baselines/reference/parserParameterList15.errors.txt index 7a1a8af90937b..cca41d949879c 100644 --- a/tests/baselines/reference/parserParameterList15.errors.txt +++ b/tests/baselines/reference/parserParameterList15.errors.txt @@ -1,11 +1,12 @@ -tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList15.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList15.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList15.ts(1,14): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. ==== tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList15.ts (2 errors) ==== function foo(a = 4); ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList15.ts:2:10: The implementation signature is declared here. ~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. function foo(a, b) {} \ No newline at end of file diff --git a/tests/baselines/reference/parserParameterList16.errors.txt b/tests/baselines/reference/parserParameterList16.errors.txt index 4b30b386e6f91..7d496cc03ea42 100644 --- a/tests/baselines/reference/parserParameterList16.errors.txt +++ b/tests/baselines/reference/parserParameterList16.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16.ts(2,4): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16.ts(2,4): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16.ts(2,8): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -6,7 +6,8 @@ tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16. class C { foo(a = 4); ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList16.ts:3:4: The implementation signature is declared here. ~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. foo(a, b) { } diff --git a/tests/baselines/reference/parserParameterList17.errors.txt b/tests/baselines/reference/parserParameterList17.errors.txt index a75e3c3b71299..025c2eabbba86 100644 --- a/tests/baselines/reference/parserParameterList17.errors.txt +++ b/tests/baselines/reference/parserParameterList17.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList17.ts(2,4): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList17.ts(2,4): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList17.ts(2,16): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. @@ -6,7 +6,8 @@ tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList17. class C { constructor(a = 4); ~~~~~~~~~~~~~~~~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/parser/ecmascript5/ParameterLists/parserParameterList17.ts:3:4: The implementation signature is declared here. ~~~~~ !!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. constructor(a, b) { } diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index 77010d7efa198..cf30a4ff273f4 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -7,7 +7,7 @@ tests/cases/compiler/recursiveFunctionTypes.ts(12,16): error TS2355: A function tests/cases/compiler/recursiveFunctionTypes.ts(17,5): error TS2322: Type '() => I' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(22,5): error TS2345: Argument of type '3' is not assignable to parameter of type '(t: typeof g) => void'. tests/cases/compiler/recursiveFunctionTypes.ts(25,1): error TS2322: Type '3' is not assignable to type '() => any'. -tests/cases/compiler/recursiveFunctionTypes.ts(30,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/recursiveFunctionTypes.ts(30,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/compiler/recursiveFunctionTypes.ts(33,1): error TS2554: Expected 0-1 arguments, but got 2. tests/cases/compiler/recursiveFunctionTypes.ts(34,4): error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f6; (a: typeof f6): () => number; }'. tests/cases/compiler/recursiveFunctionTypes.ts(42,1): error TS2554: Expected 0-1 arguments, but got 2. @@ -63,7 +63,8 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of function f6(): typeof f6; function f6(a: typeof f6): () => number; ~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/recursiveFunctionTypes.ts:31:10: The implementation signature is declared here. function f6(a?: any) { return f6; } f6("", 3); // error (arity mismatch) diff --git a/tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt b/tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt index 0e9454b9018d1..e6dd1aa26ee04 100644 --- a/tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt +++ b/tests/baselines/reference/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.errors.txt @@ -1,10 +1,11 @@ -tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.ts (1 errors) ==== function foo(x: 'a'); ~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/types/objectTypeLiteral/callSignatures/specializedSignatureIsNotSubtypeOfNonSpecializedSignature.ts:2:10: The implementation signature is declared here. function foo(x: number) { } class C { diff --git a/tests/baselines/reference/stringLiteralTypesOverloads05.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads05.errors.txt index 027feb7cc31a6..4353264b64983 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads05.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesOverloads05.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads05.ts(6,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads05.ts(6,10): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads05.ts (1 errors) ==== @@ -9,7 +9,8 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads05.ts(6,1 function doThing(x: "dog"): Dog; ~~~~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads05.ts:9:10: The implementation signature is declared here. function doThing(x: "cat"): Cat; function doThing(x: string): Animal; function doThing(x: string, y?: string): Moose { diff --git a/tests/baselines/reference/templateStringInFunctionParameterType.errors.txt b/tests/baselines/reference/templateStringInFunctionParameterType.errors.txt index e523b4c2dcb9d..256d9dc1e9105 100644 --- a/tests/baselines/reference/templateStringInFunctionParameterType.errors.txt +++ b/tests/baselines/reference/templateStringInFunctionParameterType.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,12): error TS1138: Parameter declaration expected. tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1,19): error TS1005: ';' expected. @@ -9,7 +9,8 @@ tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts(1 ~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. ~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/es6/templates/templateStringInFunctionParameterType.ts:3:10: The implementation signature is declared here. ~~~~~~~ !!! error TS1138: Parameter declaration expected. ~ diff --git a/tests/baselines/reference/templateStringInFunctionParameterTypeES6.errors.txt b/tests/baselines/reference/templateStringInFunctionParameterTypeES6.errors.txt index be9c3556caf1c..feb068d49578a 100644 --- a/tests/baselines/reference/templateStringInFunctionParameterTypeES6.errors.txt +++ b/tests/baselines/reference/templateStringInFunctionParameterTypeES6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,10): error TS2391: Function implementation is missing or not immediately following the declaration. -tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,10): error TS2394: This overload signature is not compatible with its implementation signature. tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,12): error TS1138: Parameter declaration expected. tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts(1,19): error TS1005: ';' expected. @@ -9,7 +9,8 @@ tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.t ~ !!! error TS2391: Function implementation is missing or not immediately following the declaration. ~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/conformance/es6/templates/templateStringInFunctionParameterTypeES6.ts:3:10: The implementation signature is declared here. ~~~~~~~ !!! error TS1138: Parameter declaration expected. ~ diff --git a/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt b/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt index ce8b52f316c9e..09dfef337b2d9 100644 --- a/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt +++ b/tests/baselines/reference/voidAsNonAmbiguousReturnType.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/voidAsNonAmbiguousReturnType_0.ts(1,17): error TS2394: Overload signature is not compatible with function implementation. +tests/cases/compiler/voidAsNonAmbiguousReturnType_0.ts(1,17): error TS2394: This overload signature is not compatible with its implementation signature. ==== tests/cases/compiler/voidAsNonAmbiguousReturnType_1.ts (0 errors) ==== @@ -12,6 +12,7 @@ tests/cases/compiler/voidAsNonAmbiguousReturnType_0.ts(1,17): error TS2394: Over ==== tests/cases/compiler/voidAsNonAmbiguousReturnType_0.ts (1 errors) ==== export function mkdirSync(path: string, mode?: number): void; ~~~~~~~~~ -!!! error TS2394: Overload signature is not compatible with function implementation. +!!! error TS2394: This overload signature is not compatible with its implementation signature. +!!! related TS2750 tests/cases/compiler/voidAsNonAmbiguousReturnType_0.ts:2:17: The implementation signature is declared here. export function mkdirSync(path: string, mode?: string): void {} \ No newline at end of file From 592396d40a250147a4637a8db9376ffa0a90ebaf Mon Sep 17 00:00:00 2001 From: Wenlu Wang Date: Fri, 22 Feb 2019 07:09:37 +0800 Subject: [PATCH 47/64] expose token flags and numeric flags (#29897) * expose token flags and numeric flags * hide hide useless token flags --- src/compiler/factory.ts | 4 ++-- src/compiler/types.ts | 8 +++++++- tests/baselines/reference/api/tsserverlibrary.d.ts | 10 +++++++++- tests/baselines/reference/api/typescript.d.ts | 10 +++++++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 00d8419205579..f303dcb47a637 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -89,10 +89,10 @@ namespace ts { return createLiteralFromNode(value); } - export function createNumericLiteral(value: string): NumericLiteral { + export function createNumericLiteral(value: string, numericLiteralFlags: TokenFlags = TokenFlags.None): NumericLiteral { const node = createSynthesizedNode(SyntaxKind.NumericLiteral); node.text = value; - node.numericLiteralFlags = 0; + node.numericLiteralFlags = numericLiteralFlags; return node; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index c0ae3b99c4477..cce869df44ea1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1648,20 +1648,26 @@ namespace ts { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } - /* @internal */ export const enum TokenFlags { None = 0, + /* @internal */ PrecedingLineBreak = 1 << 0, + /* @internal */ PrecedingJSDocComment = 1 << 1, + /* @internal */ Unterminated = 1 << 2, + /* @internal */ ExtendedUnicodeEscape = 1 << 3, Scientific = 1 << 4, // e.g. `10e2` Octal = 1 << 5, // e.g. `0777` HexSpecifier = 1 << 6, // e.g. `0x00000000` BinarySpecifier = 1 << 7, // e.g. `0b0110010000000000` OctalSpecifier = 1 << 8, // e.g. `0o777` + /* @internal */ ContainsSeparator = 1 << 9, // e.g. `0b1100_0101` + /* @internal */ BinaryOrOctalSpecifier = BinarySpecifier | OctalSpecifier, + /* @internal */ NumericLiteralFlags = Scientific | Octal | HexSpecifier | BinaryOrOctalSpecifier | ContainsSeparator } diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 36c246c999f23..fab6f905efcca 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -997,6 +997,14 @@ declare namespace ts { interface NoSubstitutionTemplateLiteral extends LiteralExpression { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } + enum TokenFlags { + None = 0, + Scientific = 16, + Octal = 32, + HexSpecifier = 64, + BinarySpecifier = 128, + OctalSpecifier = 256 + } interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } @@ -3670,7 +3678,7 @@ declare namespace ts { function createLiteral(value: number | PseudoBigInt): NumericLiteral; function createLiteral(value: boolean): BooleanLiteral; function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression; - function createNumericLiteral(value: string): NumericLiteral; + function createNumericLiteral(value: string, numericLiteralFlags?: TokenFlags): NumericLiteral; function createBigIntLiteral(value: string): BigIntLiteral; function createStringLiteral(text: string): StringLiteral; function createRegularExpressionLiteral(text: string): RegularExpressionLiteral; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 15dbc080241ac..40e16bf55bdfb 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -997,6 +997,14 @@ declare namespace ts { interface NoSubstitutionTemplateLiteral extends LiteralExpression { kind: SyntaxKind.NoSubstitutionTemplateLiteral; } + enum TokenFlags { + None = 0, + Scientific = 16, + Octal = 32, + HexSpecifier = 64, + BinarySpecifier = 128, + OctalSpecifier = 256 + } interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; } @@ -3670,7 +3678,7 @@ declare namespace ts { function createLiteral(value: number | PseudoBigInt): NumericLiteral; function createLiteral(value: boolean): BooleanLiteral; function createLiteral(value: string | number | PseudoBigInt | boolean): PrimaryExpression; - function createNumericLiteral(value: string): NumericLiteral; + function createNumericLiteral(value: string, numericLiteralFlags?: TokenFlags): NumericLiteral; function createBigIntLiteral(value: string): BigIntLiteral; function createStringLiteral(text: string): StringLiteral; function createRegularExpressionLiteral(text: string): RegularExpressionLiteral; From fb0dcd49871df214c1c5911ed9714ebb9d1d9951 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 21 Feb 2019 18:17:53 -0800 Subject: [PATCH 48/64] Have runtests always throw on failure, make rm stream signal end of read queue (#30035) --- scripts/build/tests.js | 9 ++------- scripts/build/utils.js | 1 + 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/build/tests.js b/scripts/build/tests.js index bcf5431b8d949..0ac65002ab86a 100644 --- a/scripts/build/tests.js +++ b/scripts/build/tests.js @@ -140,13 +140,8 @@ async function runConsoleTests(runJs, defaultReporter, runInParallel, watchMode, await deleteTemporaryProjectOutput(); if (error !== undefined) { - if (watchMode) { - throw error; - } - else { - log.error(error); - process.exit(typeof errorStatus === "number" ? errorStatus : 2); - } + process.exitCode = typeof errorStatus === "number" ? errorStatus : 2; + throw error; } } exports.runConsoleTests = runConsoleTests; diff --git a/scripts/build/utils.js b/scripts/build/utils.js index 170c36adef6b4..f9e48c58256b7 100644 --- a/scripts/build/utils.js +++ b/scripts/build/utils.js @@ -340,6 +340,7 @@ function rm(dest, opts) { duplex.push(file); cb(); } + duplex.push(null); // signal end of read queue }; const duplex = new Duplex({ From 999eb0b9ed50d4824a1c4b5e03cf2bcdc3b97338 Mon Sep 17 00:00:00 2001 From: TypeScript Bot Date: Fri, 22 Feb 2019 08:56:15 -0800 Subject: [PATCH 49/64] Update user baselines (#30046) --- tests/baselines/reference/user/async.log | 2 +- .../user/chrome-devtools-frontend.log | 54 ++++++++----------- tests/baselines/reference/user/debug.log | 18 +++---- .../reference/user/follow-redirects.log | 14 +++-- 4 files changed, 40 insertions(+), 48 deletions(-) diff --git a/tests/baselines/reference/user/async.log b/tests/baselines/reference/user/async.log index 1477ce5faa65e..10f2d38ca6c93 100644 --- a/tests/baselines/reference/user/async.log +++ b/tests/baselines/reference/user/async.log @@ -51,7 +51,7 @@ node_modules/async/autoInject.js(160,28): error TS2695: Left side of comma opera node_modules/async/autoInject.js(164,14): error TS2695: Left side of comma operator is unused and has no side effects. node_modules/async/autoInject.js(168,6): error TS2695: Left side of comma operator is unused and has no side effects. node_modules/async/cargo.js(62,12): error TS2304: Cannot find name 'AsyncFunction'. -node_modules/async/cargo.js(67,14): error TS2591: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig. +node_modules/async/cargo.js(67,14): error TS2749: 'module' refers to a value, but is being used as a type here. node_modules/async/cargo.js(67,20): error TS1005: '}' expected. node_modules/async/cargo.js(92,11): error TS2695: Left side of comma operator is unused and has no side effects. node_modules/async/compose.js(8,37): error TS2695: Left side of comma operator is unused and has no side effects. diff --git a/tests/baselines/reference/user/chrome-devtools-frontend.log b/tests/baselines/reference/user/chrome-devtools-frontend.log index 55c189a92d6a0..5d98e163938c3 100644 --- a/tests/baselines/reference/user/chrome-devtools-frontend.log +++ b/tests/baselines/reference/user/chrome-devtools-frontend.log @@ -19,12 +19,7 @@ node_modules/chrome-devtools-frontend/front_end/Runtime.js(77,16): error TS7014: node_modules/chrome-devtools-frontend/front_end/Runtime.js(78,16): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/Runtime.js(95,28): error TS2339: Property 'response' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(147,37): error TS2339: Property '_importScriptPathPrefix' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/Runtime.js(158,21): error TS2345: Argument of type 'Promise' is not assignable to parameter of type 'Promise'. - Type 'string' is not assignable to type 'undefined'. -node_modules/chrome-devtools-frontend/front_end/Runtime.js(161,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. - Type 'undefined[]' is not assignable to type 'undefined'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(187,12): error TS2339: Property 'eval' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/Runtime.js(197,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(267,14): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(269,59): error TS2339: Property 'runtime' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(270,9): error TS2322: Type 'Promise' is not assignable to type 'Promise'. @@ -38,7 +33,6 @@ node_modules/chrome-devtools-frontend/front_end/Runtime.js(693,7): error TS2322: Type 'boolean' is not assignable to type 'undefined'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(705,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(715,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. -node_modules/chrome-devtools-frontend/front_end/Runtime.js(721,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(729,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(854,36): error TS2339: Property 'eval' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/Runtime.js(1083,15): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. @@ -282,7 +276,7 @@ node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(514, node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(553,11): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(583,43): error TS2339: Property 'remove' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(665,37): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. -node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(691,24): error TS2304: Cannot find name 'Image'. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(691,24): error TS2749: 'Image' refers to a value, but is being used as a type here. node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(708,11): error TS2339: Property 'AnimationDispatcher' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(731,24): error TS2694: Namespace 'Protocol' has no exported member 'Animation'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(741,11): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. @@ -293,7 +287,7 @@ node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(782, node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(811,11): error TS2339: Property 'AnimationModel' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationModel.js(811,44): error TS2300: Duplicate identifier 'Request'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(7,11): error TS2339: Property 'AnimationScreenshotPopover' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. -node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(9,23): error TS2304: Cannot find name 'Image'. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(9,23): error TS2749: 'Image' refers to a value, but is being used as a type here. node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(18,39): error TS2345: Argument of type 'new (width?: number, height?: number) => HTMLImageElement' is not assignable to parameter of type 'Node'. Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'Node': baseURI, childNodes, firstChild, isConnected, and 47 more. node_modules/chrome-devtools-frontend/front_end/animation/AnimationScreenshotPopover.js(19,13): error TS2339: Property 'style' does not exist on type 'new (width?: number, height?: number) => HTMLImageElement'. @@ -345,7 +339,7 @@ node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(1 node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(173,25): error TS2339: Property 'boxInWindow' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(176,44): error TS2339: Property 'keysArray' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(177,63): error TS2339: Property 'parentElement' does not exist on type 'EventTarget'. -node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(194,30): error TS2304: Cannot find name 'Image'. +node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(194,30): error TS2749: 'Image' refers to a value, but is being used as a type here. node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(197,25): error TS2339: Property 'AnimationScreenshotPopover' does not exist on type '{ new (effect?: AnimationEffect, timeline?: AnimationTimeline): Animation; prototype: Animation; }'. node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(208,50): error TS2554: Expected 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/animation/AnimationTimeline.js(208,67): error TS2554: Expected 2 arguments, but got 1. @@ -451,7 +445,7 @@ node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheSto node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(19,13): error TS2339: Property 'resources' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(21,37): error TS2339: Property 'resources' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(32,5): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? -node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(40,11): error TS2304: Cannot find name 'promise'. +node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(40,11): error TS2552: Cannot find name 'promise'. Did you mean 'Promise'? node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(61,13): error TS2339: Property 'resources' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(68,37): error TS2339: Property 'resources' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/application_test_runner/CacheStorageTestRunner.js(70,13): error TS2339: Property 'resources' does not exist on type 'any[]'. @@ -719,10 +713,11 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15630,28): error TS2304: Cannot find name 'fs'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15636,30): error TS2304: Cannot find name 'fs'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15645,18): error TS2304: Cannot find name 'fs'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15684,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. - Type 'void' is not assignable to type 'any[]'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15684,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. + Type 'void | any[]' is not assignable to type 'any[]'. + Type 'void' is not assignable to type 'any[]'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15687,1): error TS2304: Cannot find name 'fs'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15694,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15694,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15695,1): error TS2304: Cannot find name 'fs'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15695,78): error TS2345: Argument of type '0' is not assignable to parameter of type '(string | number)[]'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(15791,19): error TS2304: Cannot find name 'fs'. @@ -744,15 +739,17 @@ node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighth node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(17501,1): error TS2322: Type 'any[]' is not assignable to type 'string'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(18010,1): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19499,6): error TS2339: Property 'Util' does not exist on type 'Window'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19585,1): error TS2322: Type 'Promise<{ artifacts: any; auditResults: any[]; }>' is not assignable to type 'Promise'. - Type '{ artifacts: any; auditResults: any[]; }' is not assignable to type 'void'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19585,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. + Type 'void | { artifacts: any; auditResults: any[]; }' is not assignable to type 'void'. + Type '{ artifacts: any; auditResults: any[]; }' is not assignable to type 'void'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19591,15): error TS2339: Property 'artifacts' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19592,42): error TS2339: Property 'artifacts' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19597,31): error TS2339: Property 'auditResults' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19605,22): error TS2339: Property 'artifacts' does not exist on type 'void'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19612,22): error TS2339: Property 'artifacts' does not exist on type 'void'. -node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19683,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. - Type 'number' is not assignable to type 'void'. +node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19683,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. + Type 'number | void' is not assignable to type 'void'. + Type 'number' is not assignable to type 'void'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(19744,7): error TS2339: Property 'expected' does not exist on type 'Error'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(20005,8): error TS2339: Property 'runLighthouseForConnection' does not exist on type 'Window'. node_modules/chrome-devtools-frontend/front_end/audits2_worker/lighthouse/lighthouse-background.js(20035,8): error TS2339: Property 'runLighthouseInWorker' does not exist on type 'Window'. @@ -3094,8 +3091,6 @@ node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(341, node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(351,31): error TS2694: Namespace 'Protocol' has no exported member 'Debugger'. node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(362,31): error TS2694: Namespace 'Protocol' has no exported member 'Debugger'. node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(375,9): error TS2322: Type 'Promise' is not assignable to type 'Promise'. -node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(378,9): error TS2322: Type 'Promise' is not assignable to type 'Promise'. -node_modules/chrome-devtools-frontend/front_end/bindings/BlackboxManager.js(381,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/bindings/BreakpointManager.js(60,52): error TS2345: Argument of type 'this' is not assignable to parameter of type '{ modelAdded(model: T): void; modelRemoved(model: T): void; }'. Type 'BreakpointManager' is not assignable to type '{ modelAdded(model: T): void; modelRemoved(model: T): void; }'. Types of property 'modelAdded' are incompatible. @@ -5791,7 +5786,6 @@ node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(28 node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2906,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2910,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2918,7): error TS2322: Type 'Promise' is not assignable to type 'Promise'. -node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2956,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2978,35): error TS2300: Duplicate identifier 'Context'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(2978,35): error TS2339: Property 'Context' does not exist on type 'typeof StylePropertyTreeElement'. node_modules/chrome-devtools-frontend/front_end/elements/StylesSidebarPane.js(3021,19): error TS2339: Property 'key' does not exist on type 'Event'. @@ -6917,7 +6911,7 @@ node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(794 node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(795,22): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(796,22): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(841,14): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(852,15): error TS2304: Cannot find name 'Image'. +node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(852,15): error TS2749: 'Image' refers to a value, but is being used as a type here. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(858,13): error TS2339: Property 'image' does not exist on type 'WebGLTexture'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(861,81): error TS2339: Property 'image' does not exist on type 'WebGLTexture'. node_modules/chrome-devtools-frontend/front_end/layer_viewer/Layers3DView.js(928,26): error TS2694: Namespace 'SDK' has no exported member 'SnapshotWithRect'. @@ -7936,7 +7930,6 @@ node_modules/chrome-devtools-frontend/front_end/perf_ui/FilmStripView.js(254,19) node_modules/chrome-devtools-frontend/front_end/perf_ui/FilmStripView.js(256,35): error TS2339: Property 'metaKey' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FilmStripView.js(263,35): error TS2339: Property 'metaKey' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FilmStripView.js(306,51): error TS2339: Property 'millisToString' does not exist on type 'NumberConstructor'. -node_modules/chrome-devtools-frontend/front_end/perf_ui/FilmStripView.js(307,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(307,36): error TS2339: Property 'offsetX' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(308,36): error TS2339: Property 'offsetY' does not exist on type 'Event'. node_modules/chrome-devtools-frontend/front_end/perf_ui/FlameChart.js(313,45): error TS2339: Property 'offsetX' does not exist on type 'Event'. @@ -10269,8 +10262,6 @@ node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1179,3): err Types of parameters 'functionDeclaration' and 'functionDeclaration' are incompatible. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1234,21): error TS2694: Namespace 'SDK' has no exported member 'CallFunctionResult'. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1265,21): error TS2694: Namespace 'SDK' has no exported member 'CallFunctionResult'. -node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1325,5): error TS2322: Type 'Promise<{ properties: RemoteObjectProperty[]; internalProperties: RemoteObjectProperty[]; }>' is not assignable to type 'Promise'. - Type '{ properties: RemoteObjectProperty[]; internalProperties: RemoteObjectProperty[]; }' is missing the following properties from type 'RemoteObject': customPreview, objectId, type, subtype, and 20 more. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1345,43): error TS2694: Namespace 'SDK.DebuggerModel' has no exported member 'FunctionDetails'. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1352,45): error TS2694: Namespace 'SDK.DebuggerModel' has no exported member 'FunctionDetails'. node_modules/chrome-devtools-frontend/front_end/sdk/RemoteObject.js(1363,35): error TS2694: Namespace 'SDK.DebuggerModel' has no exported member 'FunctionDetails'. @@ -11058,7 +11049,6 @@ node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSid node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(80,71): error TS2339: Property 'uiLocation' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(81,60): error TS2339: Property 'breakpoint' does not exist on type 'V'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(82,62): error TS2339: Property 'breakpoint' does not exist on type 'V'. -node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(119,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(131,38): error TS2554: Expected 0 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(141,29): error TS2339: Property 'enclosingNodeOrSelfWithClass' does not exist on type 'EventTarget'. node_modules/chrome-devtools-frontend/front_end/sources/JavaScriptBreakpointsSidebarPane.js(156,33): error TS2339: Property 'checkboxElement' does not exist on type 'EventTarget'. @@ -11258,9 +11248,6 @@ node_modules/chrome-devtools-frontend/front_end/sources/SnippetsPlugin.js(41,73) node_modules/chrome-devtools-frontend/front_end/sources/SourceFormatter.js(48,22): error TS2694: Namespace 'Common' has no exported member 'Event'. node_modules/chrome-devtools-frontend/front_end/sources/SourceFormatter.js(55,32): error TS2339: Property 'remove' does not exist on type 'Map; formatData: SourceFormatData; }>'. node_modules/chrome-devtools-frontend/front_end/sources/SourceFormatter.js(67,32): error TS2339: Property 'remove' does not exist on type 'Map; formatData: SourceFormatData; }>'. -node_modules/chrome-devtools-frontend/front_end/sources/SourceMapNamesResolver.js(55,5): error TS2322: Type 'Promise<{ name: string; offset: number; }[]>' is not assignable to type 'Promise'. - Type '{ name: string; offset: number; }[]' is not assignable to type 'Identifier[]'. - Type '{ name: string; offset: number; }' is missing the following properties from type 'Identifier': lineNumber, columnNumber node_modules/chrome-devtools-frontend/front_end/sources/SourceMapNamesResolver.js(304,37): error TS2339: Property 'inverse' does not exist on type 'Map'. node_modules/chrome-devtools-frontend/front_end/sources/SourceMapNamesResolver.js(322,32): error TS2694: Namespace 'SDK.RuntimeModel' has no exported member 'EvaluationResult'. node_modules/chrome-devtools-frontend/front_end/sources/SourceMapNamesResolver.js(361,25): error TS2694: Namespace 'Protocol' has no exported member 'Runtime'. @@ -11935,8 +11922,9 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.j node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(204,36): error TS2339: Property '_overviewIndex' does not exist on type 'TimelineCategory'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(246,68): error TS2339: Property 'peekLast' does not exist on type 'any[]'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(248,81): error TS2339: Property '_overviewIndex' does not exist on type 'TimelineCategory'. -node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(384,7): error TS2322: Type 'Promise HTMLImageElement>' is not assignable to type 'Promise'. - Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'HTMLImageElement': align, alt, border, complete, and 261 more. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(384,7): error TS2322: Type 'Promise HTMLImageElement)>' is not assignable to type 'Promise'. + Type 'HTMLImageElement | (new (width?: number, height?: number) => HTMLImageElement)' is not assignable to type 'HTMLImageElement'. + Type 'new (width?: number, height?: number) => HTMLImageElement' is missing the following properties from type 'HTMLImageElement': align, alt, border, complete, and 261 more. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(457,17): error TS2339: Property 'createChild' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(483,24): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineEventOverview.js(524,28): error TS2339: Property 'peekLast' does not exist on type 'TimelineFrame[]'. @@ -11951,7 +11939,7 @@ node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataP node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(111,16): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(140,27): error TS2339: Property '_blackboxRoot' does not exist on type 'string | Event | TimelineFrame | Frame'. Property '_blackboxRoot' does not exist on type 'string'. -node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(171,49): error TS2304: Cannot find name 'Image'. +node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(171,49): error TS2749: 'Image' refers to a value, but is being used as a type here. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(203,24): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(222,11): error TS2555: Expected at least 2 arguments, but got 1. node_modules/chrome-devtools-frontend/front_end/timeline/TimelineFlameChartDataProvider.js(225,11): error TS2555: Expected at least 2 arguments, but got 1. @@ -13419,10 +13407,10 @@ node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1910,22): error TS node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1911,22): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1912,22): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1913,22): error TS2339: Property 'constrain' does not exist on type 'NumberConstructor'. -node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1938,23): error TS2304: Cannot find name 'Image'. +node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1938,23): error TS2749: 'Image' refers to a value, but is being used as a type here. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1943,50): error TS2345: Argument of type 'HTMLImageElement' is not assignable to parameter of type '(new (width?: number, height?: number) => HTMLImageElement) | PromiseLike HTMLImageElement>'. Property 'then' is missing in type 'HTMLImageElement' but required in type 'PromiseLike HTMLImageElement>'. -node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1951,23): error TS2304: Cannot find name 'Image'. +node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1951,23): error TS2749: 'Image' refers to a value, but is being used as a type here. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1961,12): error TS7014: Function type, which lacks return-type annotation, implicitly has an 'any' return type. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1966,23): error TS2339: Property 'type' does not exist on type 'Element'. node_modules/chrome-devtools-frontend/front_end/ui/UIUtils.js(1967,23): error TS2339: Property 'style' does not exist on type 'Element'. diff --git a/tests/baselines/reference/user/debug.log b/tests/baselines/reference/user/debug.log index 78c472d877fa8..4879bb3f8b305 100644 --- a/tests/baselines/reference/user/debug.log +++ b/tests/baselines/reference/user/debug.log @@ -53,21 +53,21 @@ node_modules/debug/src/browser.js(45,138): error TS2551: Property 'WebkitAppeara node_modules/debug/src/browser.js(46,70): error TS2339: Property 'firebug' does not exist on type 'Console'. node_modules/debug/src/browser.js(100,148): error TS2345: Argument of type 'IArguments' is not assignable to parameter of type '[any?, ...any[]]'. node_modules/debug/src/browser.js(152,13): error TS2304: Cannot find name 'LocalStorage'. -node_modules/debug/src/common.js(51,24): error TS2339: Property 'colors' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. -node_modules/debug/src/common.js(51,60): error TS2339: Property 'colors' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. +node_modules/debug/src/common.js(51,24): error TS2339: Property 'colors' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. +node_modules/debug/src/common.js(51,60): error TS2339: Property 'colors' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. node_modules/debug/src/common.js(80,12): error TS2339: Property 'diff' does not exist on type '{ (...args: any[]): void; namespace: string; enabled: boolean; useColors: any; color: string | number; destroy: () => boolean; extend: (namespace: any, delimiter: any) => Function; }'. node_modules/debug/src/common.js(81,12): error TS2339: Property 'prev' does not exist on type '{ (...args: any[]): void; namespace: string; enabled: boolean; useColors: any; color: string | number; destroy: () => boolean; extend: (namespace: any, delimiter: any) => Function; }'. node_modules/debug/src/common.js(82,12): error TS2339: Property 'curr' does not exist on type '{ (...args: any[]): void; namespace: string; enabled: boolean; useColors: any; color: string | number; destroy: () => boolean; extend: (namespace: any, delimiter: any) => Function; }'. -node_modules/debug/src/common.js(113,19): error TS2551: Property 'formatArgs' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. Did you mean 'formatters'? +node_modules/debug/src/common.js(113,19): error TS2551: Property 'formatArgs' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. Did you mean 'formatters'? node_modules/debug/src/common.js(114,24): error TS2339: Property 'log' does not exist on type '{ (...args: any[]): void; namespace: string; enabled: boolean; useColors: any; color: string | number; destroy: () => boolean; extend: (namespace: any, delimiter: any) => Function; }'. -node_modules/debug/src/common.js(114,43): error TS2339: Property 'log' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. -node_modules/debug/src/common.js(120,35): error TS2339: Property 'useColors' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. -node_modules/debug/src/common.js(127,28): error TS2339: Property 'init' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. -node_modules/debug/src/common.js(128,19): error TS2339: Property 'init' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. -node_modules/debug/src/common.js(159,17): error TS2339: Property 'save' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. +node_modules/debug/src/common.js(114,43): error TS2339: Property 'log' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. +node_modules/debug/src/common.js(120,35): error TS2339: Property 'useColors' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. +node_modules/debug/src/common.js(127,28): error TS2339: Property 'init' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. +node_modules/debug/src/common.js(128,19): error TS2339: Property 'init' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. +node_modules/debug/src/common.js(159,17): error TS2339: Property 'save' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. node_modules/debug/src/common.js(230,13): error TS2304: Cannot find name 'Mixed'. node_modules/debug/src/common.js(231,14): error TS2304: Cannot find name 'Mixed'. -node_modules/debug/src/common.js(244,34): error TS2339: Property 'load' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: any; ... 4 more ...; selectColor: (namespace: string) => string | number; }'. +node_modules/debug/src/common.js(244,34): error TS2339: Property 'load' does not exist on type '{ (namespace: string): Function; debug: ...; default: ...; coerce: (val: any) => any; disable: () => void; enable: (namespaces: string) => void; enabled: (name: string) => boolean; humanize: { (value: number, options?: { ...; } | undefined): string; (value: string): number; }; ... 4 more ...; selectColor: (namespace...'. node_modules/debug/src/index.js(7,47): error TS2339: Property 'type' does not exist on type 'Process'. node_modules/debug/src/index.js(7,78): error TS2339: Property 'browser' does not exist on type 'Process'. node_modules/debug/src/index.js(7,106): error TS2339: Property '__nwjs' does not exist on type 'Process'. diff --git a/tests/baselines/reference/user/follow-redirects.log b/tests/baselines/reference/user/follow-redirects.log index 7e3f419696e43..a5a924432271e 100644 --- a/tests/baselines/reference/user/follow-redirects.log +++ b/tests/baselines/reference/user/follow-redirects.log @@ -2,12 +2,16 @@ Exit Code: 1 Standard output: node_modules/follow-redirects/index.js(105,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. node_modules/follow-redirects/index.js(106,10): error TS2339: Property 'abort' does not exist on type 'RedirectableRequest'. -node_modules/follow-redirects/index.js(173,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. -node_modules/follow-redirects/index.js(212,16): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. -node_modules/follow-redirects/index.js(259,12): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. -node_modules/follow-redirects/index.js(293,35): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. +node_modules/follow-redirects/index.js(153,10): error TS2339: Property 'once' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(156,12): error TS2339: Property 'socket' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(166,8): error TS2339: Property 'once' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(167,8): error TS2339: Property 'once' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(206,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(245,16): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(292,12): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(326,35): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'. -node_modules/follow-redirects/index.js(306,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. +node_modules/follow-redirects/index.js(339,10): error TS2339: Property 'emit' does not exist on type 'RedirectableRequest'. From a41a27694ac9ca2848fb83cc0a5414c4c2c5338e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 22 Feb 2019 13:12:11 -0800 Subject: [PATCH 50/64] Fix baseline-accept-rwc (#30052) --- Gulpfile.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index 3367010f6bdf5..93770f9d498a0 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -473,22 +473,23 @@ task("diff").description = "Diffs the compiler baselines using the diff tool spe task("diff-rwc", () => exec(getDiffTool(), [refRwcBaseline, localRwcBaseline], { ignoreExitCode: true })); task("diff-rwc").description = "Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable"; -const baselineAccept = subfolder => merge2( - src([`${localBaseline}${subfolder ? `${subfolder}/` : ``}**`, `!${localBaseline}${subfolder}/**/*.delete`], { base: localBaseline }) +/** + * @param {string} localBaseline Path to the local copy of the baselines + * @param {string} refBaseline Path to the reference copy of the baselines + */ +const baselineAccept = (localBaseline, refBaseline) => merge2( + src([`${localBaseline}/**`, `!${localBaseline}/**/*.delete`], { base: localBaseline }) .pipe(dest(refBaseline)), - src([`${localBaseline}${subfolder ? `${subfolder}/` : ``}**/*.delete`], { base: localBaseline, read: false }) + src([`${localBaseline}/**/*.delete`], { base: localBaseline, read: false }) .pipe(rm()) .pipe(rename({ extname: "" })) .pipe(rm(refBaseline))); -task("baseline-accept", () => baselineAccept("")); +task("baseline-accept", () => baselineAccept(localBaseline, refBaseline)); task("baseline-accept").description = "Makes the most recent test results the new baseline, overwriting the old baseline"; -task("baseline-accept-rwc", () => baselineAccept("rwc")); +task("baseline-accept-rwc", () => baselineAccept(localRwcBaseline, refRwcBaseline)); task("baseline-accept-rwc").description = "Makes the most recent rwc test results the new baseline, overwriting the old baseline"; -task("baseline-accept-test262", () => baselineAccept("test262")); -task("baseline-accept-test262").description = "Makes the most recent test262 test results the new baseline, overwriting the old baseline"; - // TODO(rbuckton): Determine if 'webhost' is still in use. const buildWebHost = () => buildProject("tests/webhost/webtsc.tsconfig.json"); task("webhost", series(lkgPreBuild, buildWebHost)); From 21ab39649c0a090ef7bc1e7dfd701b5254947b61 Mon Sep 17 00:00:00 2001 From: Joseph Wunderlich Date: Fri, 22 Feb 2019 17:24:21 -0800 Subject: [PATCH 51/64] remove any annotation from declare method quickfix --- src/services/codefixes/helpers.ts | 2 +- .../fourslash/codeFixAddMissingMember9.ts | 2 +- .../fourslash/codeFixAddMissingMember_all.ts | 2 +- ...eFixAddMissingMember_generator_function.ts | 2 +- ...AddMissingMember_non_generator_function.ts | 2 +- .../codeFixUndeclaredAcrossFiles1.ts | 6 ++-- .../codeFixUndeclaredAcrossFiles3.ts | 2 +- .../codeFixUndeclaredInStaticMethod.ts | 14 ++++---- .../fourslash/codeFixUndeclaredMethod.ts | 12 +++---- .../codeFixUndeclaredMethodFunctionArgs.ts | 6 ++-- ...odeFixUndeclaredMethodObjectLiteralArgs.ts | 35 ++++++++++++++++++- 11 files changed, 59 insertions(+), 26 deletions(-) diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index ec86415b9fae9..5f448653a7813 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -156,7 +156,7 @@ namespace ts.codefix { isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) ? arg.name.text : undefined); const contextualType = checker.getContextualType(call); - const returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker) || createKeywordTypeNode(SyntaxKind.AnyKeyword); + const returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined, diff --git a/tests/cases/fourslash/codeFixAddMissingMember9.ts b/tests/cases/fourslash/codeFixAddMissingMember9.ts index b583cd28e9ad5..e22e854c2e51a 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember9.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember9.ts @@ -18,7 +18,7 @@ verify.codeFixAll({ const x = 0; this.y(x, "a", this.z); } - y(x: number, arg1: string, z: boolean): any { + y(x: number, arg1: string, z: boolean) { throw new Error("Method not implemented."); } }`, diff --git a/tests/cases/fourslash/codeFixAddMissingMember_all.ts b/tests/cases/fourslash/codeFixAddMissingMember_all.ts index 6c7076dd341a8..9c0c86f282dcf 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember_all.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember_all.ts @@ -36,7 +36,7 @@ verify.codeFixAll({ this.y(); this.x = ""; } - y(): any { + y() { throw new Error("Method not implemented."); } } diff --git a/tests/cases/fourslash/codeFixAddMissingMember_generator_function.ts b/tests/cases/fourslash/codeFixAddMissingMember_generator_function.ts index 6742cc43348dd..ad0bd7b47cad5 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember_generator_function.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember_generator_function.ts @@ -14,7 +14,7 @@ verify.codeFixAll({ *method() { yield* this.y(); } - *y(): any { + *y() { throw new Error("Method not implemented."); } }`, diff --git a/tests/cases/fourslash/codeFixAddMissingMember_non_generator_function.ts b/tests/cases/fourslash/codeFixAddMissingMember_non_generator_function.ts index a868646446aef..c3773bf285c30 100644 --- a/tests/cases/fourslash/codeFixAddMissingMember_non_generator_function.ts +++ b/tests/cases/fourslash/codeFixAddMissingMember_non_generator_function.ts @@ -14,7 +14,7 @@ verify.codeFixAll({ method() { yield* this.y(); } - y(): any { + y() { throw new Error("Method not implemented."); } }`, diff --git a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts index 8f775d5158e66..a8171668751d2 100644 --- a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts +++ b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles1.ts @@ -23,15 +23,15 @@ verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); verify.getAndApplyCodeFix(/*errorCode*/undefined, 0); verify.rangeIs(` - m2(c: C): any { + m2(c: C) { throw new Error("Method not implemented."); } y: {}; - m1(): any { + m1() { throw new Error("Method not implemented."); } static x: any; - static m0(arg0: number, arg1: string, arg2: undefined[]): any { + static m0(arg0: number, arg1: string, arg2: undefined[]) { throw new Error("Method not implemented."); } `); diff --git a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts index dcf5c999d6a3d..9ea5ac1a1652b 100644 --- a/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts +++ b/tests/cases/fourslash/codeFixUndeclaredAcrossFiles3.ts @@ -20,7 +20,7 @@ verify.getAndApplyCodeFix(/*errorCode*/ undefined, 0); verify.rangeIs(` - m0(arg0: import("./f2").D): any { + m0(arg0: import("./f2").D) { throw new Error("Method not implemented."); } `); \ No newline at end of file diff --git a/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts b/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts index a406360c5000d..17fcd9ce688f5 100644 --- a/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts +++ b/tests/cases/fourslash/codeFixUndeclaredInStaticMethod.ts @@ -20,7 +20,7 @@ verify.codeFix({ this.prop1 = 10; A.prop2 = "asdf"; } - static m1(arg0: number, arg1: number, arg2: number): any { + static m1(arg0: number, arg1: number, arg2: number) { throw new Error("Method not implemented."); } }`, @@ -38,10 +38,10 @@ verify.codeFix({ this.prop1 = 10; A.prop2 = "asdf"; } - static m2(arg0: number, arg1: number): any { + static m2(arg0: number, arg1: number) { throw new Error("Method not implemented."); } - static m1(arg0: number, arg1: number, arg2: number): any { + static m1(arg0: number, arg1: number, arg2: number) { throw new Error("Method not implemented."); } }`, @@ -60,10 +60,10 @@ verify.codeFix({ this.prop1 = 10; A.prop2 = "asdf"; } - static m2(arg0: number, arg1: number): any { + static m2(arg0: number, arg1: number) { throw new Error("Method not implemented."); } - static m1(arg0: number, arg1: number, arg2: number): any { + static m1(arg0: number, arg1: number, arg2: number) { throw new Error("Method not implemented."); } }`, @@ -83,10 +83,10 @@ verify.codeFix({ this.prop1 = 10; A.prop2 = "asdf"; } - static m2(arg0: number, arg1: number): any { + static m2(arg0: number, arg1: number) { throw new Error("Method not implemented."); } - static m1(arg0: number, arg1: number, arg2: number): any { + static m1(arg0: number, arg1: number, arg2: number) { throw new Error("Method not implemented."); } }`, diff --git a/tests/cases/fourslash/codeFixUndeclaredMethod.ts b/tests/cases/fourslash/codeFixUndeclaredMethod.ts index 151192078f3c9..32713e5dd19b8 100644 --- a/tests/cases/fourslash/codeFixUndeclaredMethod.ts +++ b/tests/cases/fourslash/codeFixUndeclaredMethod.ts @@ -15,7 +15,7 @@ verify.codeFix({ index: 0, newFileContent: `class A { - foo1(arg0: number, arg1: number, arg2: number): any { + foo1(arg0: number, arg1: number, arg2: number) { throw new Error("Method not implemented."); } constructor() { @@ -34,10 +34,10 @@ verify.codeFix({ index: 0, newFileContent: `class A { - foo2(): any { + foo2() { throw new Error("Method not implemented."); } - foo1(arg0: number, arg1: number, arg2: number): any { + foo1(arg0: number, arg1: number, arg2: number) { throw new Error("Method not implemented."); } constructor() { @@ -56,13 +56,13 @@ verify.codeFix({ index: 0, newFileContent: `class A { - foo3(): any { + foo3() { throw new Error("Method not implemented."); } - foo2(): any { + foo2() { throw new Error("Method not implemented."); } - foo1(arg0: number, arg1: number, arg2: number): any { + foo1(arg0: number, arg1: number, arg2: number) { throw new Error("Method not implemented."); } constructor() { diff --git a/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs.ts b/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs.ts index 478b2a7c64751..c4056625b70b9 100644 --- a/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs.ts +++ b/tests/cases/fourslash/codeFixUndeclaredMethodFunctionArgs.ts @@ -11,7 +11,7 @@ verify.codeFix({ description: "Declare method 'foo1'", index: 0, newRangeContent: ` - foo1(arg0: () => number, arg1: () => string, arg2: () => boolean): any { + foo1(arg0: () => number, arg1: () => string, arg2: () => boolean) { throw new Error("Method not implemented."); } `, @@ -22,10 +22,10 @@ verify.codeFix({ description: "Declare method 'foo2'", index: 0, newRangeContent: ` - foo2(arg0: (a: number) => number, arg1: (b: string) => string, arg2: (c: boolean) => boolean): any { + foo2(arg0: (a: number) => number, arg1: (b: string) => string, arg2: (c: boolean) => boolean) { throw new Error("Method not implemented."); } - foo1(arg0: () => number, arg1: () => string, arg2: () => boolean): any { + foo1(arg0: () => number, arg1: () => string, arg2: () => boolean) { throw new Error("Method not implemented."); } `, diff --git a/tests/cases/fourslash/codeFixUndeclaredMethodObjectLiteralArgs.ts b/tests/cases/fourslash/codeFixUndeclaredMethodObjectLiteralArgs.ts index bd434cf9d9d6b..5c0698ad653e9 100644 --- a/tests/cases/fourslash/codeFixUndeclaredMethodObjectLiteralArgs.ts +++ b/tests/cases/fourslash/codeFixUndeclaredMethodObjectLiteralArgs.ts @@ -3,6 +3,8 @@ //// class A {[| //// |]constructor() { //// this.foo1(null, {}, { a: 1, b: "2"}); +//// const bar = this.foo2(null, {}, { a: 1, b: "2"}); +//// const baz: number = this.foo3(null, {}, { a: 1, b: "2"}); //// } //// } @@ -10,7 +12,38 @@ verify.codeFix({ description: "Declare method 'foo1'", index: 0, newRangeContent: ` - foo1(arg0: null, arg1: {}, arg2: { a: number; b: string; }): any { + foo1(arg0: null, arg1: {}, arg2: { a: number; b: string; }) { + throw new Error("Method not implemented."); + } + `, + applyChanges: true +}); + +verify.codeFix({ + description: "Declare method 'foo2'", + index: 0, + newRangeContent: ` + foo2(arg0: null, arg1: {}, arg2: { a: number; b: string; }) { + throw new Error("Method not implemented."); + } + foo1(arg0: null, arg1: {}, arg2: { a: number; b: string; }) { + throw new Error("Method not implemented."); + } + `, + applyChanges: true +}); + +verify.codeFix({ + description: "Declare method 'foo3'", + index: 0, + newRangeContent: ` + foo3(arg0: null, arg1: {}, arg2: { a: number; b: string; }): number { + throw new Error("Method not implemented."); + } + foo2(arg0: null, arg1: {}, arg2: { a: number; b: string; }) { + throw new Error("Method not implemented."); + } + foo1(arg0: null, arg1: {}, arg2: { a: number; b: string; }) { throw new Error("Method not implemented."); } ` From d87e67df58bc2b35ace2e3120f12ffee35ddeaf9 Mon Sep 17 00:00:00 2001 From: Joseph Wunderlich Date: Fri, 22 Feb 2019 18:00:21 -0800 Subject: [PATCH 52/64] clarify intent in returnType creation --- src/services/codefixes/helpers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 5f448653a7813..45a79613db5fd 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -156,7 +156,7 @@ namespace ts.codefix { isIdentifier(arg) ? arg.text : isPropertyAccessExpression(arg) ? arg.name.text : undefined); const contextualType = checker.getContextualType(call); - const returnType = inJs ? undefined : contextualType && checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); + const returnType = (inJs || !contextualType) ? undefined : checker.typeToTypeNode(contextualType, contextNode, /*flags*/ undefined, tracker); return createMethod( /*decorators*/ undefined, /*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined, From 7a391fe6135b985afe6513d124373b75b41d3210 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sun, 24 Feb 2019 23:05:42 -0800 Subject: [PATCH 53/64] Fix `.npmignore` by adding the `.git` file (as opposed to just a directory, which is not the case for git worktrees) and the `.failed-tests` file. --- .npmignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index 6054bfbdb3705..482633f48fc40 100644 --- a/.npmignore +++ b/.npmignore @@ -12,7 +12,11 @@ tests tslint.json Jakefile.js .editorconfig +.failed-tests +.git +.git/ .gitattributes +.github/ .gitmodules .settings/ .travis.yml @@ -23,6 +27,5 @@ Jakefile.js test.config package-lock.json yarn.lock -.github/ CONTRIBUTING.md TEST-results.xml From c2f19983876c94035d5ff4f1a4c37c0999d08bed Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 25 Feb 2019 16:18:03 -0800 Subject: [PATCH 54/64] Fix baseline accept when there are multiple .delete files (#30091) --- scripts/build/utils.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/build/utils.js b/scripts/build/utils.js index f9e48c58256b7..b070bd133a94c 100644 --- a/scripts/build/utils.js +++ b/scripts/build/utils.js @@ -340,7 +340,6 @@ function rm(dest, opts) { duplex.push(file); cb(); } - duplex.push(null); // signal end of read queue }; const duplex = new Duplex({ @@ -374,15 +373,16 @@ function rm(dest, opts) { pending.push(entry); }, final(cb) { + const endThenCb = () => (duplex.push(null), cb()); // signal end of read queue processDeleted(); if (pending.length) { Promise .all(pending.map(entry => entry.promise)) .then(() => processDeleted()) - .then(() => cb(), cb); + .then(() => endThenCb(), endThenCb); return; } - cb(); + endThenCb(); }, read() { } From 0e858a6e16e04703900ce2aef4713bb6b64eef21 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 25 Feb 2019 16:33:20 -0800 Subject: [PATCH 55/64] Include misc script outputs in local build (#30092) * Include other misc script outputs in local build * Remove comment --- Gulpfile.js | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/Gulpfile.js b/Gulpfile.js index 93770f9d498a0..3ce488caeddf2 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -373,9 +373,34 @@ task("lint").flags = { " --f[iles]=": "pattern to match files to lint", }; +const buildCancellationToken = () => buildProject("src/cancellationToken"); +const cleanCancellationToken = () => cleanProject("src/cancellationToken"); +cleanTasks.push(cleanCancellationToken); + +const buildTypingsInstaller = () => buildProject("src/typingsInstaller"); +const cleanTypingsInstaller = () => cleanProject("src/typingsInstaller"); +cleanTasks.push(cleanTypingsInstaller); + +const buildWatchGuard = () => buildProject("src/watchGuard"); +const cleanWatchGuard = () => cleanProject("src/watchGuard"); +cleanTasks.push(cleanWatchGuard); + +const generateTypesMap = () => src("src/server/typesMap.json") + .pipe(newer("built/local/typesMap.json")) + .pipe(transform(contents => (JSON.parse(contents), contents))) // validates typesMap.json is valid JSON + .pipe(dest("built/local")); +task("generate-types-map", generateTypesMap); + +const cleanTypesMap = () => del("built/local/typesMap.json"); +cleanTasks.push(cleanTypesMap); + +const buildOtherOutputs = parallel(buildCancellationToken, buildTypingsInstaller, buildWatchGuard, generateTypesMap); +task("other-outputs", series(preBuild, buildOtherOutputs)); +task("other-outputs").description = "Builds miscelaneous scripts and documents distributed with the LKG"; + const buildFoldStart = async () => { if (fold.isTravis()) console.log(fold.start("build")); }; const buildFoldEnd = async () => { if (fold.isTravis()) console.log(fold.end("build")); }; -task("local", series(buildFoldStart, preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl), buildFoldEnd)); +task("local", series(buildFoldStart, preBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs), buildFoldEnd)); task("local").description = "Builds the full compiler and services"; task("local").flags = { " --built": "Compile using the built version of the compiler." @@ -551,28 +576,6 @@ const buildReleaseTsc = () => buildProject("src/tsc/tsconfig.release.json"); const cleanReleaseTsc = () => cleanProject("src/tsc/tsconfig.release.json"); cleanTasks.push(cleanReleaseTsc); -const buildCancellationToken = () => buildProject("src/cancellationToken"); -const cleanCancellationToken = () => cleanProject("src/cancellationToken"); -cleanTasks.push(cleanCancellationToken); - -const buildTypingsInstaller = () => buildProject("src/typingsInstaller"); -const cleanTypingsInstaller = () => cleanProject("src/typingsInstaller"); -cleanTasks.push(cleanTypingsInstaller); - -const buildWatchGuard = () => buildProject("src/watchGuard"); -const cleanWatchGuard = () => cleanProject("src/watchGuard"); -cleanTasks.push(cleanWatchGuard); - -// TODO(rbuckton): This task isn't triggered by any other task. Is it still needed? -const generateTypesMap = () => src("src/server/typesMap.json") - .pipe(newer("built/local/typesMap.json")) - .pipe(transform(contents => (JSON.parse(contents), contents))) // validates typesMap.json is valid JSON - .pipe(dest("built/local")); -task("generate-types-map", generateTypesMap); - -const cleanTypesMap = () => del("built/local/typesMap.json"); -cleanTasks.push(cleanTypesMap); - const cleanBuilt = () => del("built"); const produceLKG = async () => { @@ -602,7 +605,7 @@ const produceLKG = async () => { } }; -task("LKG", series(lkgPreBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildCancellationToken, buildTypingsInstaller, buildWatchGuard, buildReleaseTsc), produceLKG)); +task("LKG", series(lkgPreBuild, parallel(localize, buildTsc, buildServer, buildServices, buildLssl, buildOtherOutputs, buildReleaseTsc), produceLKG)); task("LKG").description = "Makes a new LKG out of the built js files"; task("LKG").flags = { " --built": "Compile using the built version of the compiler.", From c5061486a9ea1694af249c6e9d434d7166bd26bd Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 25 Feb 2019 17:10:03 -0800 Subject: [PATCH 56/64] Retain substitution types through instantiation if possible (#30059) --- src/compiler/checker.ts | 11 ++- ...dAliasAssignableToConstraintSameAsAlias.js | 36 ++++++++ ...sAssignableToConstraintSameAsAlias.symbols | 85 +++++++++++++++++++ ...iasAssignableToConstraintSameAsAlias.types | 45 ++++++++++ ...dAliasAssignableToConstraintSameAsAlias.ts | 24 ++++++ 5 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.js create mode 100644 tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.symbols create mode 100644 tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.types create mode 100644 tests/cases/compiler/inlinedAliasAssignableToConstraintSameAsAlias.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 958ceae0395a2..ddc958df0b41f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11062,7 +11062,13 @@ namespace ts { return getConditionalTypeInstantiation(type, combineTypeMappers((type).mapper, mapper)); } if (flags & TypeFlags.Substitution) { - return instantiateType((type).typeVariable, mapper); + const maybeVariable = instantiateType((type).typeVariable, mapper); + if (maybeVariable.flags & TypeFlags.TypeVariable) { + return getSubstitutionType(maybeVariable as TypeVariable, instantiateType((type).substitute, mapper)); + } + else { + return maybeVariable; + } } return type; } @@ -14465,6 +14471,9 @@ namespace ts { } } } + else if (target.flags & TypeFlags.Substitution) { + inferFromTypes(source, (target as SubstitutionType).typeVariable); + } if (getObjectFlags(source) & ObjectFlags.Reference && getObjectFlags(target) & ObjectFlags.Reference && (source).target === (target).target) { // If source and target are references to the same generic type, infer from type arguments const sourceTypes = (source).typeArguments || emptyArray; diff --git a/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.js b/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.js new file mode 100644 index 0000000000000..2d82034c6f7c9 --- /dev/null +++ b/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.js @@ -0,0 +1,36 @@ +//// [inlinedAliasAssignableToConstraintSameAsAlias.ts] +interface RelationFields { + x: A; + y: A[]; + z: A[]; +} +type Name = keyof RelationFields; +type ShouldA = RF[N] extends A[] + ? RF[N][0] + : never; + +class A { + x: A; + y: A[]; + z: A[]; + + whereRelated< // Works // Type is same as A1, but is not assignable to type A + RF extends RelationFields = RelationFields, + N extends Name = Name, + A1 extends A = RF[N] extends A[] ? RF[N][0] : never, + A2 extends A = ShouldA + >(): number { + return 1; + } +} + + +//// [inlinedAliasAssignableToConstraintSameAsAlias.js] +var A = /** @class */ (function () { + function A() { + } + A.prototype.whereRelated = function () { + return 1; + }; + return A; +}()); diff --git a/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.symbols b/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.symbols new file mode 100644 index 0000000000000..86e55f14ee924 --- /dev/null +++ b/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.symbols @@ -0,0 +1,85 @@ +=== tests/cases/compiler/inlinedAliasAssignableToConstraintSameAsAlias.ts === +interface RelationFields { +>RelationFields : Symbol(RelationFields, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 0, 0)) + + x: A; +>x : Symbol(RelationFields.x, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 0, 26)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) + + y: A[]; +>y : Symbol(RelationFields.y, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 1, 7)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) + + z: A[]; +>z : Symbol(RelationFields.z, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 2, 9)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) +} +type Name = keyof RelationFields; +>Name : Symbol(Name, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 4, 1)) +>RelationFields : Symbol(RelationFields, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 0, 0)) + +type ShouldA = RF[N] extends A[] +>ShouldA : Symbol(ShouldA, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 5, 33)) +>RF : Symbol(RF, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 6, 13)) +>RelationFields : Symbol(RelationFields, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 0, 0)) +>N : Symbol(N, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 6, 39)) +>Name : Symbol(Name, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 4, 1)) +>RF : Symbol(RF, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 6, 13)) +>N : Symbol(N, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 6, 39)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) + + ? RF[N][0] +>RF : Symbol(RF, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 6, 13)) +>N : Symbol(N, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 6, 39)) + + : never; + +class A { +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) + + x: A; +>x : Symbol(A.x, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 10, 9)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) + + y: A[]; +>y : Symbol(A.y, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 11, 7)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) + + z: A[]; +>z : Symbol(A.z, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 12, 9)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) + + whereRelated< // Works // Type is same as A1, but is not assignable to type A +>whereRelated : Symbol(A.whereRelated, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 13, 9)) + + RF extends RelationFields = RelationFields, +>RF : Symbol(RF, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 15, 15)) +>RelationFields : Symbol(RelationFields, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 0, 0)) +>RelationFields : Symbol(RelationFields, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 0, 0)) + + N extends Name = Name, +>N : Symbol(N, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 16, 47)) +>Name : Symbol(Name, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 4, 1)) +>Name : Symbol(Name, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 4, 1)) + + A1 extends A = RF[N] extends A[] ? RF[N][0] : never, +>A1 : Symbol(A1, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 17, 26)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) +>RF : Symbol(RF, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 15, 15)) +>N : Symbol(N, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 16, 47)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) +>RF : Symbol(RF, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 15, 15)) +>N : Symbol(N, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 16, 47)) + + A2 extends A = ShouldA +>A2 : Symbol(A2, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 18, 56)) +>A : Symbol(A, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 8, 10)) +>ShouldA : Symbol(ShouldA, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 5, 33)) +>RF : Symbol(RF, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 15, 15)) +>N : Symbol(N, Decl(inlinedAliasAssignableToConstraintSameAsAlias.ts, 16, 47)) + + >(): number { + return 1; + } +} + diff --git a/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.types b/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.types new file mode 100644 index 0000000000000..d337fbc718abb --- /dev/null +++ b/tests/baselines/reference/inlinedAliasAssignableToConstraintSameAsAlias.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/inlinedAliasAssignableToConstraintSameAsAlias.ts === +interface RelationFields { + x: A; +>x : A + + y: A[]; +>y : A[] + + z: A[]; +>z : A[] +} +type Name = keyof RelationFields; +>Name : "x" | "y" | "z" + +type ShouldA = RF[N] extends A[] +>ShouldA : ShouldA + + ? RF[N][0] + : never; + +class A { +>A : A + + x: A; +>x : A + + y: A[]; +>y : A[] + + z: A[]; +>z : A[] + + whereRelated< // Works // Type is same as A1, but is not assignable to type A +>whereRelated : >() => number + + RF extends RelationFields = RelationFields, + N extends Name = Name, + A1 extends A = RF[N] extends A[] ? RF[N][0] : never, + A2 extends A = ShouldA + >(): number { + return 1; +>1 : 1 + } +} + diff --git a/tests/cases/compiler/inlinedAliasAssignableToConstraintSameAsAlias.ts b/tests/cases/compiler/inlinedAliasAssignableToConstraintSameAsAlias.ts new file mode 100644 index 0000000000000..165ec0dc17e16 --- /dev/null +++ b/tests/cases/compiler/inlinedAliasAssignableToConstraintSameAsAlias.ts @@ -0,0 +1,24 @@ +interface RelationFields { + x: A; + y: A[]; + z: A[]; +} +type Name = keyof RelationFields; +type ShouldA = RF[N] extends A[] + ? RF[N][0] + : never; + +class A { + x: A; + y: A[]; + z: A[]; + + whereRelated< // Works // Type is same as A1, but is not assignable to type A + RF extends RelationFields = RelationFields, + N extends Name = Name, + A1 extends A = RF[N] extends A[] ? RF[N][0] : never, + A2 extends A = ShouldA + >(): number { + return 1; + } +} From 4d7ec380a9a5d6f7e2f882d6bae9557d7414afb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=96=87=E7=92=90?= Date: Tue, 26 Feb 2019 10:54:01 +0800 Subject: [PATCH 57/64] check completions with assignable rather than identity --- src/compiler/checker.ts | 2 +- .../completionsWithOptionalProperties.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/completionsWithOptionalProperties.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ddc958df0b41f..c882227ba0c69 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7406,7 +7406,7 @@ namespace ts { const nameType = property.name && getLiteralTypeFromPropertyName(property.name); const name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined; const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name); - return !!expected && isLiteralType(expected) && !isTypeIdenticalTo(getTypeOfNode(property), expected); + return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected); }); } diff --git a/tests/cases/fourslash/completionsWithOptionalProperties.ts b/tests/cases/fourslash/completionsWithOptionalProperties.ts new file mode 100644 index 0000000000000..e40029ddefac0 --- /dev/null +++ b/tests/cases/fourslash/completionsWithOptionalProperties.ts @@ -0,0 +1,18 @@ +/// +// @strict: true + +//// interface Options { +//// hello?: boolean; +//// world?: boolean; +//// } +//// declare function foo(options?: Options): void; +//// foo({ +//// hello: true, +//// /**/ +//// }); + +verify.completions({ + marker: "", + includes: ['world'] +}); + From 1ed5e1c63b71e0a4e7fd0493a37e43a7ef518ebb Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 25 Feb 2019 19:50:53 -0800 Subject: [PATCH 58/64] Do not wrap npm path with quotes Fixes #30086 --- src/typingsInstaller/nodeTypingsInstaller.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/typingsInstaller/nodeTypingsInstaller.ts b/src/typingsInstaller/nodeTypingsInstaller.ts index 1d75218c88323..2facb1223d01c 100644 --- a/src/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/typingsInstaller/nodeTypingsInstaller.ts @@ -89,10 +89,6 @@ namespace ts.server.typingsInstaller { log); this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0]); - // If the NPM path contains spaces and isn't wrapped in quotes, do so. - if (stringContains(this.npmPath, " ") && this.npmPath[0] !== `"`) { - this.npmPath = `"${this.npmPath}"`; - } if (this.log.isEnabled()) { this.log.writeLine(`Process id: ${process.pid}`); this.log.writeLine(`NPM location: ${this.npmPath} (explicit '${Arguments.NpmLocation}' ${npmLocation === undefined ? "not " : ""} provided)`); From 2533d8294ef8f88537339a3daf54e6c7925552c0 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 26 Feb 2019 13:43:22 -0800 Subject: [PATCH 59/64] Make a fresh empty object literal not a subtype of a type with an index signaure (#29975) * Forbid inferable index checkign during subtype relationship checking * Merge object.values and object.entries overloads to work around subtype change * Invert subtype relationship between fresh empty objects and non-empty object types * Remvoe comment * Revert lib change * Remove trailing whitespace ffs --- src/compiler/checker.ts | 5 + ...IndexSignatureContainingObject1.errors.txt | 53 ++++++++ ...ubtypeOfIndexSignatureContainingObject1.js | 58 ++++++++ ...eOfIndexSignatureContainingObject1.symbols | 118 ++++++++++++++++ ...ypeOfIndexSignatureContainingObject1.types | 88 ++++++++++++ ...IndexSignatureContainingObject2.errors.txt | 54 ++++++++ ...ubtypeOfIndexSignatureContainingObject2.js | 60 +++++++++ ...eOfIndexSignatureContainingObject2.symbols | 127 ++++++++++++++++++ ...ypeOfIndexSignatureContainingObject2.types | 99 ++++++++++++++ ...ubtypeOfIndexSignatureContainingObject1.ts | 42 ++++++ ...ubtypeOfIndexSignatureContainingObject2.ts | 43 ++++++ 11 files changed, 747 insertions(+) create mode 100644 tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.errors.txt create mode 100644 tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.js create mode 100644 tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.symbols create mode 100644 tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.types create mode 100644 tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.errors.txt create mode 100644 tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.js create mode 100644 tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.symbols create mode 100644 tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.types create mode 100644 tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts create mode 100644 tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ddc958df0b41f..4777092a7fdae 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12787,6 +12787,11 @@ namespace ts { else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) { return isRelatedTo(getIndexTypeOfType(source, IndexKind.Number) || anyType, getIndexTypeOfType(target, IndexKind.Number) || anyType, reportErrors); } + // Consider a fresh empty object literal type "closed" under the subtype relationship - this way `{} <- {[idx: string]: any} <- fresh({})` + // and not `{} <- fresh({}) <- {[idx: string]: any}` + else if (relation === subtypeRelation && isEmptyObjectType(target) && getObjectFlags(target) & ObjectFlags.FreshLiteral && !isEmptyObjectType(source)) { + return Ternary.False; + } // Even if relationship doesn't hold for unions, intersections, or generic type references, // it may hold in a structural comparison. // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates diff --git a/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.errors.txt b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.errors.txt new file mode 100644 index 0000000000000..56135cf8b0d14 --- /dev/null +++ b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.errors.txt @@ -0,0 +1,53 @@ +tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts(41,3): error TS2322: Type 'Dictionary' is not assignable to type 'Record'. + Index signatures are incompatible. + Type 'string' is not assignable to type 'Bar'. + + +==== tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts (1 errors) ==== + // This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts + // Begin types from Lodash. + interface Dictionary { + [index: string]: T; + } + + interface NumericDictionary { + [index: number]: T; + } + + type ObjectIterator = ( + value: TObject[keyof TObject], + key: string, + collection: TObject + ) => TResult; + + type DictionaryIterator = ObjectIterator, TResult>; + + // In lodash.d.ts this function has many overloads, but this seems to be the problematic one. + function mapValues( + obj: Dictionary | NumericDictionary | null | undefined, + callback: DictionaryIterator + ): Dictionary { + return null as any; + } + // End types from Lodash. + + interface Foo { + foo: string; + } + + interface Bar { + bar: string; + } + + export function fooToBar( + foos: Record + ): Record { + const result = foos == null ? {} : mapValues(foos, f => f.foo); + // This line _should_ fail, because `result` is not the right type. + return result; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type 'Dictionary' is not assignable to type 'Record'. +!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'Bar'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.js b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.js new file mode 100644 index 0000000000000..38418b365a2b0 --- /dev/null +++ b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.js @@ -0,0 +1,58 @@ +//// [emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts] +// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts +// Begin types from Lodash. +interface Dictionary { + [index: string]: T; +} + +interface NumericDictionary { + [index: number]: T; +} + +type ObjectIterator = ( + value: TObject[keyof TObject], + key: string, + collection: TObject +) => TResult; + +type DictionaryIterator = ObjectIterator, TResult>; + +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues( + obj: Dictionary | NumericDictionary | null | undefined, + callback: DictionaryIterator +): Dictionary { + return null as any; +} +// End types from Lodash. + +interface Foo { + foo: string; +} + +interface Bar { + bar: string; +} + +export function fooToBar( + foos: Record +): Record { + const result = foos == null ? {} : mapValues(foos, f => f.foo); + // This line _should_ fail, because `result` is not the right type. + return result; +} + + +//// [emptyObjectNotSubtypeOfIndexSignatureContainingObject1.js] +"use strict"; +exports.__esModule = true; +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues(obj, callback) { + return null; +} +function fooToBar(foos) { + var result = foos == null ? {} : mapValues(foos, function (f) { return f.foo; }); + // This line _should_ fail, because `result` is not the right type. + return result; +} +exports.fooToBar = fooToBar; diff --git a/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.symbols b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.symbols new file mode 100644 index 0000000000000..2d808fb513832 --- /dev/null +++ b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.symbols @@ -0,0 +1,118 @@ +=== tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts === +// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts +// Begin types from Lodash. +interface Dictionary { +>Dictionary : Symbol(Dictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 0, 0)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 2, 21)) + + [index: string]: T; +>index : Symbol(index, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 3, 3)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 2, 21)) +} + +interface NumericDictionary { +>NumericDictionary : Symbol(NumericDictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 4, 1)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 6, 28)) + + [index: number]: T; +>index : Symbol(index, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 7, 3)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 6, 28)) +} + +type ObjectIterator = ( +>ObjectIterator : Symbol(ObjectIterator, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 8, 1)) +>TObject : Symbol(TObject, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 10, 20)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 10, 28)) + + value: TObject[keyof TObject], +>value : Symbol(value, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 10, 41)) +>TObject : Symbol(TObject, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 10, 20)) +>TObject : Symbol(TObject, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 10, 20)) + + key: string, +>key : Symbol(key, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 11, 32)) + + collection: TObject +>collection : Symbol(collection, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 12, 14)) +>TObject : Symbol(TObject, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 10, 20)) + +) => TResult; +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 10, 28)) + +type DictionaryIterator = ObjectIterator, TResult>; +>DictionaryIterator : Symbol(DictionaryIterator, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 14, 13)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 16, 24)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 16, 26)) +>ObjectIterator : Symbol(ObjectIterator, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 8, 1)) +>Dictionary : Symbol(Dictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 0, 0)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 16, 24)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 16, 26)) + +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues( +>mapValues : Symbol(mapValues, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 16, 77)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 19, 19)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 19, 21)) + + obj: Dictionary | NumericDictionary | null | undefined, +>obj : Symbol(obj, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 19, 31)) +>Dictionary : Symbol(Dictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 0, 0)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 19, 19)) +>NumericDictionary : Symbol(NumericDictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 4, 1)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 19, 19)) + + callback: DictionaryIterator +>callback : Symbol(callback, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 20, 63)) +>DictionaryIterator : Symbol(DictionaryIterator, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 14, 13)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 19, 19)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 19, 21)) + +): Dictionary { +>Dictionary : Symbol(Dictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 0, 0)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 19, 21)) + + return null as any; +} +// End types from Lodash. + +interface Foo { +>Foo : Symbol(Foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 24, 1)) + + foo: string; +>foo : Symbol(Foo.foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 27, 15)) +} + +interface Bar { +>Bar : Symbol(Bar, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 29, 1)) + + bar: string; +>bar : Symbol(Bar.bar, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 31, 15)) +} + +export function fooToBar( +>fooToBar : Symbol(fooToBar, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 33, 1)) + + foos: Record +>foos : Symbol(foos, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 35, 25)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Foo : Symbol(Foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 24, 1)) + +): Record { +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Bar : Symbol(Bar, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 29, 1)) + + const result = foos == null ? {} : mapValues(foos, f => f.foo); +>result : Symbol(result, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 38, 7)) +>foos : Symbol(foos, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 35, 25)) +>mapValues : Symbol(mapValues, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 16, 77)) +>foos : Symbol(foos, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 35, 25)) +>f : Symbol(f, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 38, 52)) +>f.foo : Symbol(Foo.foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 27, 15)) +>f : Symbol(f, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 38, 52)) +>foo : Symbol(Foo.foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 27, 15)) + + // This line _should_ fail, because `result` is not the right type. + return result; +>result : Symbol(result, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts, 38, 7)) +} + diff --git a/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.types b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.types new file mode 100644 index 0000000000000..6426ab89c8ad9 --- /dev/null +++ b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.types @@ -0,0 +1,88 @@ +=== tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts === +// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts +// Begin types from Lodash. +interface Dictionary { + [index: string]: T; +>index : string +} + +interface NumericDictionary { + [index: number]: T; +>index : number +} + +type ObjectIterator = ( +>ObjectIterator : ObjectIterator + + value: TObject[keyof TObject], +>value : TObject[keyof TObject] + + key: string, +>key : string + + collection: TObject +>collection : TObject + +) => TResult; + +type DictionaryIterator = ObjectIterator, TResult>; +>DictionaryIterator : ObjectIterator, TResult> + +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues( +>mapValues : (obj: Dictionary | NumericDictionary, callback: ObjectIterator, TResult>) => Dictionary + + obj: Dictionary | NumericDictionary | null | undefined, +>obj : Dictionary | NumericDictionary +>null : null + + callback: DictionaryIterator +>callback : ObjectIterator, TResult> + +): Dictionary { + return null as any; +>null as any : any +>null : null +} +// End types from Lodash. + +interface Foo { + foo: string; +>foo : string +} + +interface Bar { + bar: string; +>bar : string +} + +export function fooToBar( +>fooToBar : (foos: Record) => Record + + foos: Record +>foos : Record + +): Record { +>null : null + + const result = foos == null ? {} : mapValues(foos, f => f.foo); +>result : Dictionary +>foos == null ? {} : mapValues(foos, f => f.foo) : Dictionary +>foos == null : boolean +>foos : Record +>null : null +>{} : {} +>mapValues(foos, f => f.foo) : Dictionary +>mapValues : (obj: Dictionary | NumericDictionary, callback: ObjectIterator, TResult>) => Dictionary +>foos : Record +>f => f.foo : (f: Foo) => string +>f : Foo +>f.foo : string +>f : Foo +>foo : string + + // This line _should_ fail, because `result` is not the right type. + return result; +>result : Dictionary +} + diff --git a/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.errors.txt b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.errors.txt new file mode 100644 index 0000000000000..58de463148308 --- /dev/null +++ b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.errors.txt @@ -0,0 +1,54 @@ +tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts(42,3): error TS2322: Type 'Dictionary' is not assignable to type 'Record'. + Index signatures are incompatible. + Type 'string' is not assignable to type 'Bar'. + + +==== tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts (1 errors) ==== + // This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts + // Begin types from Lodash. + interface Dictionary { + [index: string]: T; + } + + interface NumericDictionary { + [index: number]: T; + } + + type ObjectIterator = ( + value: TObject[keyof TObject], + key: string, + collection: TObject + ) => TResult; + + type DictionaryIterator = ObjectIterator, TResult>; + + // In lodash.d.ts this function has many overloads, but this seems to be the problematic one. + function mapValues( + obj: Dictionary | NumericDictionary | null | undefined, + callback: DictionaryIterator + ): Dictionary { + return null as any; + } + // End types from Lodash. + + interface Foo { + foo: string; + } + + interface Bar { + bar: string; + } + + export function fooToBar( + foos: Record + ): Record { + const wat = mapValues(foos, f => f.foo); + const result = foos == null ? {} : mapValues(foos, f => f.foo); + // This line _should_ fail, because `result` is not the right type. + return result; + ~~~~~~~~~~~~~~ +!!! error TS2322: Type 'Dictionary' is not assignable to type 'Record'. +!!! error TS2322: Index signatures are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'Bar'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.js b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.js new file mode 100644 index 0000000000000..b2193cc31010c --- /dev/null +++ b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.js @@ -0,0 +1,60 @@ +//// [emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts] +// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts +// Begin types from Lodash. +interface Dictionary { + [index: string]: T; +} + +interface NumericDictionary { + [index: number]: T; +} + +type ObjectIterator = ( + value: TObject[keyof TObject], + key: string, + collection: TObject +) => TResult; + +type DictionaryIterator = ObjectIterator, TResult>; + +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues( + obj: Dictionary | NumericDictionary | null | undefined, + callback: DictionaryIterator +): Dictionary { + return null as any; +} +// End types from Lodash. + +interface Foo { + foo: string; +} + +interface Bar { + bar: string; +} + +export function fooToBar( + foos: Record +): Record { + const wat = mapValues(foos, f => f.foo); + const result = foos == null ? {} : mapValues(foos, f => f.foo); + // This line _should_ fail, because `result` is not the right type. + return result; +} + + +//// [emptyObjectNotSubtypeOfIndexSignatureContainingObject2.js] +"use strict"; +exports.__esModule = true; +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues(obj, callback) { + return null; +} +function fooToBar(foos) { + var wat = mapValues(foos, function (f) { return f.foo; }); + var result = foos == null ? {} : mapValues(foos, function (f) { return f.foo; }); + // This line _should_ fail, because `result` is not the right type. + return result; +} +exports.fooToBar = fooToBar; diff --git a/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.symbols b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.symbols new file mode 100644 index 0000000000000..8ce432231e1dd --- /dev/null +++ b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.symbols @@ -0,0 +1,127 @@ +=== tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts === +// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts +// Begin types from Lodash. +interface Dictionary { +>Dictionary : Symbol(Dictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 0, 0)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 2, 21)) + + [index: string]: T; +>index : Symbol(index, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 3, 3)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 2, 21)) +} + +interface NumericDictionary { +>NumericDictionary : Symbol(NumericDictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 4, 1)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 6, 28)) + + [index: number]: T; +>index : Symbol(index, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 7, 3)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 6, 28)) +} + +type ObjectIterator = ( +>ObjectIterator : Symbol(ObjectIterator, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 8, 1)) +>TObject : Symbol(TObject, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 10, 20)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 10, 28)) + + value: TObject[keyof TObject], +>value : Symbol(value, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 10, 41)) +>TObject : Symbol(TObject, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 10, 20)) +>TObject : Symbol(TObject, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 10, 20)) + + key: string, +>key : Symbol(key, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 11, 32)) + + collection: TObject +>collection : Symbol(collection, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 12, 14)) +>TObject : Symbol(TObject, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 10, 20)) + +) => TResult; +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 10, 28)) + +type DictionaryIterator = ObjectIterator, TResult>; +>DictionaryIterator : Symbol(DictionaryIterator, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 14, 13)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 16, 24)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 16, 26)) +>ObjectIterator : Symbol(ObjectIterator, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 8, 1)) +>Dictionary : Symbol(Dictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 0, 0)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 16, 24)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 16, 26)) + +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues( +>mapValues : Symbol(mapValues, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 16, 77)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 19, 19)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 19, 21)) + + obj: Dictionary | NumericDictionary | null | undefined, +>obj : Symbol(obj, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 19, 31)) +>Dictionary : Symbol(Dictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 0, 0)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 19, 19)) +>NumericDictionary : Symbol(NumericDictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 4, 1)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 19, 19)) + + callback: DictionaryIterator +>callback : Symbol(callback, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 20, 63)) +>DictionaryIterator : Symbol(DictionaryIterator, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 14, 13)) +>T : Symbol(T, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 19, 19)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 19, 21)) + +): Dictionary { +>Dictionary : Symbol(Dictionary, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 0, 0)) +>TResult : Symbol(TResult, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 19, 21)) + + return null as any; +} +// End types from Lodash. + +interface Foo { +>Foo : Symbol(Foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 24, 1)) + + foo: string; +>foo : Symbol(Foo.foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 27, 15)) +} + +interface Bar { +>Bar : Symbol(Bar, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 29, 1)) + + bar: string; +>bar : Symbol(Bar.bar, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 31, 15)) +} + +export function fooToBar( +>fooToBar : Symbol(fooToBar, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 33, 1)) + + foos: Record +>foos : Symbol(foos, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 35, 25)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Foo : Symbol(Foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 24, 1)) + +): Record { +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>Bar : Symbol(Bar, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 29, 1)) + + const wat = mapValues(foos, f => f.foo); +>wat : Symbol(wat, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 38, 7)) +>mapValues : Symbol(mapValues, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 16, 77)) +>foos : Symbol(foos, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 35, 25)) +>f : Symbol(f, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 38, 29)) +>f.foo : Symbol(Foo.foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 27, 15)) +>f : Symbol(f, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 38, 29)) +>foo : Symbol(Foo.foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 27, 15)) + + const result = foos == null ? {} : mapValues(foos, f => f.foo); +>result : Symbol(result, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 39, 7)) +>foos : Symbol(foos, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 35, 25)) +>mapValues : Symbol(mapValues, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 16, 77)) +>foos : Symbol(foos, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 35, 25)) +>f : Symbol(f, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 39, 52)) +>f.foo : Symbol(Foo.foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 27, 15)) +>f : Symbol(f, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 39, 52)) +>foo : Symbol(Foo.foo, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 27, 15)) + + // This line _should_ fail, because `result` is not the right type. + return result; +>result : Symbol(result, Decl(emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts, 39, 7)) +} + diff --git a/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.types b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.types new file mode 100644 index 0000000000000..fd536cbd8498c --- /dev/null +++ b/tests/baselines/reference/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.types @@ -0,0 +1,99 @@ +=== tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts === +// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts +// Begin types from Lodash. +interface Dictionary { + [index: string]: T; +>index : string +} + +interface NumericDictionary { + [index: number]: T; +>index : number +} + +type ObjectIterator = ( +>ObjectIterator : ObjectIterator + + value: TObject[keyof TObject], +>value : TObject[keyof TObject] + + key: string, +>key : string + + collection: TObject +>collection : TObject + +) => TResult; + +type DictionaryIterator = ObjectIterator, TResult>; +>DictionaryIterator : ObjectIterator, TResult> + +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues( +>mapValues : (obj: Dictionary | NumericDictionary, callback: ObjectIterator, TResult>) => Dictionary + + obj: Dictionary | NumericDictionary | null | undefined, +>obj : Dictionary | NumericDictionary +>null : null + + callback: DictionaryIterator +>callback : ObjectIterator, TResult> + +): Dictionary { + return null as any; +>null as any : any +>null : null +} +// End types from Lodash. + +interface Foo { + foo: string; +>foo : string +} + +interface Bar { + bar: string; +>bar : string +} + +export function fooToBar( +>fooToBar : (foos: Record) => Record + + foos: Record +>foos : Record + +): Record { +>null : null + + const wat = mapValues(foos, f => f.foo); +>wat : Dictionary +>mapValues(foos, f => f.foo) : Dictionary +>mapValues : (obj: Dictionary | NumericDictionary, callback: ObjectIterator, TResult>) => Dictionary +>foos : Record +>f => f.foo : (f: Foo) => string +>f : Foo +>f.foo : string +>f : Foo +>foo : string + + const result = foos == null ? {} : mapValues(foos, f => f.foo); +>result : Dictionary +>foos == null ? {} : mapValues(foos, f => f.foo) : Dictionary +>foos == null : boolean +>foos : Record +>null : null +>{} : {} +>mapValues(foos, f => f.foo) : Dictionary +>mapValues : (obj: Dictionary | NumericDictionary, callback: ObjectIterator, TResult>) => Dictionary +>foos : Record +>f => f.foo : (f: Foo) => string +>f : Foo +>f.foo : string +>f : Foo +>foo : string + + // This line _should_ fail, because `result` is not the right type. + return result; +>result : Dictionary +} + diff --git a/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts b/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts new file mode 100644 index 0000000000000..3638ae796a77d --- /dev/null +++ b/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts @@ -0,0 +1,42 @@ +// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts +// Begin types from Lodash. +interface Dictionary { + [index: string]: T; +} + +interface NumericDictionary { + [index: number]: T; +} + +type ObjectIterator = ( + value: TObject[keyof TObject], + key: string, + collection: TObject +) => TResult; + +type DictionaryIterator = ObjectIterator, TResult>; + +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues( + obj: Dictionary | NumericDictionary | null | undefined, + callback: DictionaryIterator +): Dictionary { + return null as any; +} +// End types from Lodash. + +interface Foo { + foo: string; +} + +interface Bar { + bar: string; +} + +export function fooToBar( + foos: Record +): Record { + const result = foos == null ? {} : mapValues(foos, f => f.foo); + // This line _should_ fail, because `result` is not the right type. + return result; +} diff --git a/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts b/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts new file mode 100644 index 0000000000000..3c59e141b304d --- /dev/null +++ b/tests/cases/compiler/emptyObjectNotSubtypeOfIndexSignatureContainingObject2.ts @@ -0,0 +1,43 @@ +// This should behave the same as emptyObjectNotSubtypeOfIndexSignatureContainingObject1.ts +// Begin types from Lodash. +interface Dictionary { + [index: string]: T; +} + +interface NumericDictionary { + [index: number]: T; +} + +type ObjectIterator = ( + value: TObject[keyof TObject], + key: string, + collection: TObject +) => TResult; + +type DictionaryIterator = ObjectIterator, TResult>; + +// In lodash.d.ts this function has many overloads, but this seems to be the problematic one. +function mapValues( + obj: Dictionary | NumericDictionary | null | undefined, + callback: DictionaryIterator +): Dictionary { + return null as any; +} +// End types from Lodash. + +interface Foo { + foo: string; +} + +interface Bar { + bar: string; +} + +export function fooToBar( + foos: Record +): Record { + const wat = mapValues(foos, f => f.foo); + const result = foos == null ? {} : mapValues(foos, f => f.foo); + // This line _should_ fail, because `result` is not the right type. + return result; +} From 288851066bdfaba4822b7ce2b92829b22d05c79a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 26 Feb 2019 13:43:41 -0800 Subject: [PATCH 60/64] Dont create a union type to infer conditional type branches (#30010) --- src/compiler/checker.ts | 3 +- ...onalTypeRelaxingConstraintAssignability.js | 39 ++++++++++ ...ypeRelaxingConstraintAssignability.symbols | 73 +++++++++++++++++++ ...lTypeRelaxingConstraintAssignability.types | 64 ++++++++++++++++ ...onalTypeRelaxingConstraintAssignability.ts | 24 ++++++ 5 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.js create mode 100644 tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.symbols create mode 100644 tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.types create mode 100644 tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4777092a7fdae..002fdecc0cd39 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14519,7 +14519,8 @@ namespace ts { inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target)); } else if (target.flags & TypeFlags.Conditional) { - inferFromTypes(source, getUnionType([getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)])); + inferFromTypes(source, getTrueTypeFromConditionalType(target)); + inferFromTypes(source, getFalseTypeFromConditionalType(target)); } else if (target.flags & TypeFlags.UnionOrIntersection) { for (const t of (target).types) { diff --git a/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.js b/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.js new file mode 100644 index 0000000000000..f066b18d5c64f --- /dev/null +++ b/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.js @@ -0,0 +1,39 @@ +//// [conditionalTypeRelaxingConstraintAssignability.ts] +export type ElChildren = + | ElChildren.Void + | ElChildren.Text; +export namespace ElChildren { + export type Void = undefined; + export type Text = string; +} + +type Relax = C extends ElChildren.Text ? ElChildren.Text : C; + +export class Elem< + C extends ElChildren, + > { + constructor( + private children_: Relax, + ) { + } +} + +new Elem(undefined as ElChildren.Void); +new Elem('' as ElChildren.Text); +new Elem('' as ElChildren.Void | ElChildren.Text); // error +new Elem('' as ElChildren); // error + +//// [conditionalTypeRelaxingConstraintAssignability.js] +"use strict"; +exports.__esModule = true; +var Elem = /** @class */ (function () { + function Elem(children_) { + this.children_ = children_; + } + return Elem; +}()); +exports.Elem = Elem; +new Elem(undefined); +new Elem(''); +new Elem(''); // error +new Elem(''); // error diff --git a/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.symbols b/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.symbols new file mode 100644 index 0000000000000..7ce85b0fbfaf8 --- /dev/null +++ b/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.symbols @@ -0,0 +1,73 @@ +=== tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts === +export type ElChildren = +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) + + | ElChildren.Void +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>Void : Symbol(ElChildren.Void, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 3, 29)) + + | ElChildren.Text; +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>Text : Symbol(ElChildren.Text, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 4, 31)) + +export namespace ElChildren { +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) + + export type Void = undefined; +>Void : Symbol(Void, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 3, 29)) + + export type Text = string; +>Text : Symbol(Text, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 4, 31)) +} + +type Relax = C extends ElChildren.Text ? ElChildren.Text : C; +>Relax : Symbol(Relax, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 6, 1)) +>C : Symbol(C, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 8, 11)) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>C : Symbol(C, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 8, 11)) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>Text : Symbol(ElChildren.Text, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 4, 31)) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>Text : Symbol(ElChildren.Text, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 4, 31)) +>C : Symbol(C, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 8, 11)) + +export class Elem< +>Elem : Symbol(Elem, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 8, 83)) + + C extends ElChildren, +>C : Symbol(C, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 10, 18)) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) + + > { + constructor( + private children_: Relax, +>children_ : Symbol(Elem.children_, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 13, 14)) +>Relax : Symbol(Relax, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 6, 1)) +>C : Symbol(C, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 10, 18)) + + ) { + } +} + +new Elem(undefined as ElChildren.Void); +>Elem : Symbol(Elem, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 8, 83)) +>undefined : Symbol(undefined) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>Void : Symbol(ElChildren.Void, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 3, 29)) + +new Elem('' as ElChildren.Text); +>Elem : Symbol(Elem, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 8, 83)) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>Text : Symbol(ElChildren.Text, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 4, 31)) + +new Elem('' as ElChildren.Void | ElChildren.Text); // error +>Elem : Symbol(Elem, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 8, 83)) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>Void : Symbol(ElChildren.Void, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 3, 29)) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) +>Text : Symbol(ElChildren.Text, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 4, 31)) + +new Elem('' as ElChildren); // error +>Elem : Symbol(Elem, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 8, 83)) +>ElChildren : Symbol(ElChildren, Decl(conditionalTypeRelaxingConstraintAssignability.ts, 0, 0), Decl(conditionalTypeRelaxingConstraintAssignability.ts, 2, 20)) + diff --git a/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.types b/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.types new file mode 100644 index 0000000000000..c827e26bddb99 --- /dev/null +++ b/tests/baselines/reference/conditionalTypeRelaxingConstraintAssignability.types @@ -0,0 +1,64 @@ +=== tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts === +export type ElChildren = +>ElChildren : ElChildren + + | ElChildren.Void +>ElChildren : any + + | ElChildren.Text; +>ElChildren : any + +export namespace ElChildren { + export type Void = undefined; +>Void : undefined + + export type Text = string; +>Text : string +} + +type Relax = C extends ElChildren.Text ? ElChildren.Text : C; +>Relax : Relax +>ElChildren : any +>ElChildren : any + +export class Elem< +>Elem : Elem + + C extends ElChildren, + > { + constructor( + private children_: Relax, +>children_ : Relax + + ) { + } +} + +new Elem(undefined as ElChildren.Void); +>new Elem(undefined as ElChildren.Void) : Elem +>Elem : typeof Elem +>undefined as ElChildren.Void : undefined +>undefined : undefined +>ElChildren : any + +new Elem('' as ElChildren.Text); +>new Elem('' as ElChildren.Text) : Elem +>Elem : typeof Elem +>'' as ElChildren.Text : string +>'' : "" +>ElChildren : any + +new Elem('' as ElChildren.Void | ElChildren.Text); // error +>new Elem('' as ElChildren.Void | ElChildren.Text) : Elem +>Elem : typeof Elem +>'' as ElChildren.Void | ElChildren.Text : ElChildren +>'' : "" +>ElChildren : any +>ElChildren : any + +new Elem('' as ElChildren); // error +>new Elem('' as ElChildren) : Elem +>Elem : typeof Elem +>'' as ElChildren : ElChildren +>'' : "" + diff --git a/tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts b/tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts new file mode 100644 index 0000000000000..2f18e464e3b1d --- /dev/null +++ b/tests/cases/compiler/conditionalTypeRelaxingConstraintAssignability.ts @@ -0,0 +1,24 @@ +// @strict: true +export type ElChildren = + | ElChildren.Void + | ElChildren.Text; +export namespace ElChildren { + export type Void = undefined; + export type Text = string; +} + +type Relax = C extends ElChildren.Text ? ElChildren.Text : C; + +export class Elem< + C extends ElChildren, + > { + constructor( + private children_: Relax, + ) { + } +} + +new Elem(undefined as ElChildren.Void); +new Elem('' as ElChildren.Text); +new Elem('' as ElChildren.Void | ElChildren.Text); // error +new Elem('' as ElChildren); // error \ No newline at end of file From 3e4b9c07d28c5a5347d297fe4da669a0b0fa4d5c Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 26 Feb 2019 14:01:03 -0800 Subject: [PATCH 61/64] Revert "Do not wrap npm path with quotes" This reverts commit 1ed5e1c63b71e0a4e7fd0493a37e43a7ef518ebb. --- src/typingsInstaller/nodeTypingsInstaller.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/typingsInstaller/nodeTypingsInstaller.ts b/src/typingsInstaller/nodeTypingsInstaller.ts index 2facb1223d01c..1d75218c88323 100644 --- a/src/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/typingsInstaller/nodeTypingsInstaller.ts @@ -89,6 +89,10 @@ namespace ts.server.typingsInstaller { log); this.npmPath = npmLocation !== undefined ? npmLocation : getDefaultNPMLocation(process.argv[0]); + // If the NPM path contains spaces and isn't wrapped in quotes, do so. + if (stringContains(this.npmPath, " ") && this.npmPath[0] !== `"`) { + this.npmPath = `"${this.npmPath}"`; + } if (this.log.isEnabled()) { this.log.writeLine(`Process id: ${process.pid}`); this.log.writeLine(`NPM location: ${this.npmPath} (explicit '${Arguments.NpmLocation}' ${npmLocation === undefined ? "not " : ""} provided)`); From fd10c12116b7caf5fe8766812c3c26fac4f43c9c Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 26 Feb 2019 14:01:42 -0800 Subject: [PATCH 62/64] Revert "Use execFileSync in typing installer" This reverts commit bc386c11fd3f026ca84ec556b1b8fb4a2eee0038. --- .../unittests/tsserver/typingsInstaller.ts | 12 ++++++------ src/typingsInstaller/nodeTypingsInstaller.ts | 16 ++++++++-------- src/typingsInstallerCore/typingsInstaller.ts | 17 +++++------------ 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/testRunner/unittests/tsserver/typingsInstaller.ts b/src/testRunner/unittests/tsserver/typingsInstaller.ts index 5d648ba23a20a..76df9934682fd 100644 --- a/src/testRunner/unittests/tsserver/typingsInstaller.ts +++ b/src/testRunner/unittests/tsserver/typingsInstaller.ts @@ -1684,9 +1684,9 @@ namespace ts.projectSystem { TI.getNpmCommandForInstallation(npmPath, tsVersion, packageNames, packageNames.length - Math.ceil(packageNames.length / 2)).command ]; it("works when the command is too long to install all packages at once", () => { - const commands: [string, string[]][] = []; - const hasError = TI.installNpmPackages(npmPath, tsVersion, packageNames, (file, args) => { - commands.push([file, args]); + const commands: string[] = []; + const hasError = TI.installNpmPackages(npmPath, tsVersion, packageNames, command => { + commands.push(command); return false; }); assert.isFalse(hasError); @@ -1694,9 +1694,9 @@ namespace ts.projectSystem { }); it("installs remaining packages when one of the partial command fails", () => { - const commands: [string, string[]][] = []; - const hasError = TI.installNpmPackages(npmPath, tsVersion, packageNames, (file, args) => { - commands.push([file, args]); + const commands: string[] = []; + const hasError = TI.installNpmPackages(npmPath, tsVersion, packageNames, command => { + commands.push(command); return commands.length === 1; }); assert.isTrue(hasError); diff --git a/src/typingsInstaller/nodeTypingsInstaller.ts b/src/typingsInstaller/nodeTypingsInstaller.ts index 1d75218c88323..62bdcfce2603b 100644 --- a/src/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/typingsInstaller/nodeTypingsInstaller.ts @@ -70,10 +70,10 @@ namespace ts.server.typingsInstaller { cwd: string; encoding: "utf-8"; } - type ExecFileSync = (file: string, args: string[], options: ExecSyncOptions) => string; + type ExecSync = (command: string, options: ExecSyncOptions) => string; export class NodeTypingsInstaller extends TypingsInstaller { - private readonly nodeExecFileSync: ExecFileSync; + private readonly nodeExecSync: ExecSync; private readonly npmPath: string; readonly typesRegistry: Map>; @@ -97,7 +97,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`Process id: ${process.pid}`); this.log.writeLine(`NPM location: ${this.npmPath} (explicit '${Arguments.NpmLocation}' ${npmLocation === undefined ? "not " : ""} provided)`); } - ({ execFileSync: this.nodeExecFileSync } = require("child_process")); + ({ execSync: this.nodeExecSync } = require("child_process")); this.ensurePackageDirectoryExists(globalTypingsCacheLocation); @@ -105,7 +105,7 @@ namespace ts.server.typingsInstaller { if (this.log.isEnabled()) { this.log.writeLine(`Updating ${typesRegistryPackageName} npm package...`); } - this.execFileSyncAndLog(this.npmPath, ["install", "--ignore-scripts", `${typesRegistryPackageName}@${this.latestDistTag}`], { cwd: globalTypingsCacheLocation }); + this.execSyncAndLog(`${this.npmPath} install --ignore-scripts ${typesRegistryPackageName}@${this.latestDistTag}`, { cwd: globalTypingsCacheLocation }); if (this.log.isEnabled()) { this.log.writeLine(`Updated ${typesRegistryPackageName} npm package`); } @@ -189,7 +189,7 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`#${requestId} with arguments'${JSON.stringify(packageNames)}'.`); } const start = Date.now(); - const hasError = installNpmPackages(this.npmPath, version, packageNames, (file, args) => this.execFileSyncAndLog(file, args, { cwd })); + const hasError = installNpmPackages(this.npmPath, version, packageNames, command => this.execSyncAndLog(command, { cwd })); if (this.log.isEnabled()) { this.log.writeLine(`npm install #${requestId} took: ${Date.now() - start} ms`); } @@ -197,12 +197,12 @@ namespace ts.server.typingsInstaller { } /** Returns 'true' in case of error. */ - private execFileSyncAndLog(file: string, args: string[], options: Pick): boolean { + private execSyncAndLog(command: string, options: Pick): boolean { if (this.log.isEnabled()) { - this.log.writeLine(`Exec: ${file} ${args.join(" ")}`); + this.log.writeLine(`Exec: ${command}`); } try { - const stdout = this.nodeExecFileSync(file, args, { ...options, encoding: "utf-8" }); + const stdout = this.nodeExecSync(command, { ...options, encoding: "utf-8" }); if (this.log.isEnabled()) { this.log.writeLine(` Succeeded. stdout:${indent(sys.newLine, stdout)}`); } diff --git a/src/typingsInstallerCore/typingsInstaller.ts b/src/typingsInstallerCore/typingsInstaller.ts index 3d0858d7dfe34..df83f1a677c39 100644 --- a/src/typingsInstallerCore/typingsInstaller.ts +++ b/src/typingsInstallerCore/typingsInstaller.ts @@ -31,35 +31,28 @@ namespace ts.server.typingsInstaller { } /*@internal*/ - export function installNpmPackages(npmPath: string, tsVersion: string, packageNames: string[], install: (file: string, args: string[]) => boolean) { + export function installNpmPackages(npmPath: string, tsVersion: string, packageNames: string[], install: (command: string) => boolean) { let hasError = false; for (let remaining = packageNames.length; remaining > 0;) { const result = getNpmCommandForInstallation(npmPath, tsVersion, packageNames, remaining); remaining = result.remaining; - hasError = install(result.command[0], result.command[1]) || hasError; + hasError = install(result.command) || hasError; } return hasError; } - function getUserAgent(tsVersion: string) { - return `--user-agent="typesInstaller/${tsVersion}"`; - } - const npmInstall = "install", ignoreScripts = "--ignore-scripts", saveDev = "--save-dev"; - const commandBaseLength = npmInstall.length + ignoreScripts.length + saveDev.length + getUserAgent("").length + 5; /*@internal*/ export function getNpmCommandForInstallation(npmPath: string, tsVersion: string, packageNames: string[], remaining: number) { const sliceStart = packageNames.length - remaining; - let packages: string[], toSlice = remaining; + let command: string, toSlice = remaining; while (true) { - packages = toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice); - const commandLength = npmPath.length + commandBaseLength + packages.join(" ").length + tsVersion.length; - if (commandLength < 8000) { + command = `${npmPath} install --ignore-scripts ${(toSlice === packageNames.length ? packageNames : packageNames.slice(sliceStart, sliceStart + toSlice)).join(" ")} --save-dev --user-agent="typesInstaller/${tsVersion}"`; + if (command.length < 8000) { break; } toSlice = toSlice - Math.floor(toSlice / 2); } - const command: [string, string[]] = [npmPath, [npmInstall, ignoreScripts, ...packages, saveDev, getUserAgent(tsVersion)]]; return { command, remaining: remaining - toSlice }; } From aedffe049d74ba1893d92dbec41b0f389609c364 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 27 Feb 2019 11:50:04 -0800 Subject: [PATCH 63/64] Revert "Merge pull request #27697 from mattmccutchen/issue-27118" This reverts commit 2dfb6202ed03e04ba1dcc330eea219c50fe48c66, reversing changes made to bbf559b9c7fd21b984d7cb538140c74e3d6a6b45. --- src/compiler/checker.ts | 9 +- .../reference/conditionalTypes2.errors.txt | 122 ++- .../baselines/reference/conditionalTypes2.js | 121 ++- .../reference/conditionalTypes2.symbols | 870 +++++++++--------- .../reference/conditionalTypes2.types | 115 ++- .../types/conditional/conditionalTypes2.ts | 57 +- 6 files changed, 687 insertions(+), 607 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7e6cb97a9302e..80853ca2eaf3e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12724,11 +12724,10 @@ namespace ts { else if (source.flags & TypeFlags.Conditional) { if (target.flags & TypeFlags.Conditional) { // Two conditional types 'T1 extends U1 ? X1 : Y1' and 'T2 extends U2 ? X2 : Y2' are related if - // they have the same distributivity, T1 and T2 are identical types, U1 and U2 are identical - // types, X1 is related to X2, and Y1 is related to Y2. - if ((source).root.isDistributive === (target).root.isDistributive && - isTypeIdenticalTo((source).extendsType, (target).extendsType) && - isTypeIdenticalTo((source).checkType, (target).checkType)) { + // one of T1 and T2 is related to the other, U1 and U2 are identical types, X1 is related to X2, + // and Y1 is related to Y2. + if (isTypeIdenticalTo((source).extendsType, (target).extendsType) && + (isRelatedTo((source).checkType, (target).checkType) || isRelatedTo((target).checkType, (source).checkType))) { if (result = isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), reportErrors)) { result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors); } diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index 343a0a8412cfb..a1a23b6da1870 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -1,38 +1,29 @@ -tests/cases/conformance/types/conditional/conditionalTypes2.ts(16,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. - Types of property 'foo' are incompatible. - Type 'B extends string ? B : number' is not assignable to type 'A extends string ? A : number'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(17,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. - Types of property 'foo' are incompatible. - Type 'A extends string ? A : number' is not assignable to type 'B extends string ? B : number'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(21,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. - Types of property 'foo' are incompatible. - Type 'B extends string ? keyof B : number' is not assignable to type 'A extends string ? keyof A : number'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(22,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. - Types of property 'foo' are incompatible. - Type 'A extends string ? keyof A : number' is not assignable to type 'B extends string ? keyof B : number'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(26,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(15,5): error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. + Type 'A' is not assignable to type 'B'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(19,5): error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. + Type 'A' is not assignable to type 'B'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(24,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(27,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. + Type 'keyof B' is not assignable to type 'keyof A'. + Type 'string | number | symbol' is not assignable to type 'keyof A'. + Type 'string' is not assignable to type 'keyof A'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. + Type 'A' is not assignable to type 'B'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(73,12): error TS2345: Argument of type 'Extract, Bar>' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(76,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(74,12): error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(77,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. +tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. Type 'T extends Bar ? T : never' is not assignable to type '{ foo: string; bat: string; }'. Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(165,5): error TS2322: Type 'MyElement' is not assignable to type 'MyElement'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(170,5): error TS2322: Type 'MyAcceptor' is not assignable to type 'MyAcceptor'. -tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2322: Type 'Dist' is not assignable to type 'Aux<{ a: T; }>'. -==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (12 errors) ==== - // #27118: Conditional types are now invariant in the check type. - +==== tests/cases/conformance/types/conditional/conditionalTypes2.ts (7 errors) ==== interface Covariant { foo: T extends string ? T : number; } @@ -46,29 +37,19 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2 } function f1(a: Covariant, b: Covariant) { - a = b; // Error - ~ -!!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type 'B extends string ? B : number' is not assignable to type 'A extends string ? A : number'. + a = b; b = a; // Error ~ !!! error TS2322: Type 'Covariant' is not assignable to type 'Covariant'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type 'A extends string ? A : number' is not assignable to type 'B extends string ? B : number'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. } function f2(a: Contravariant, b: Contravariant) { a = b; // Error ~ !!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type 'B extends string ? keyof B : number' is not assignable to type 'A extends string ? keyof A : number'. - b = a; // Error - ~ -!!! error TS2322: Type 'Contravariant' is not assignable to type 'Contravariant'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type 'A extends string ? keyof A : number' is not assignable to type 'B extends string ? keyof B : number'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. + b = a; } function f3(a: Invariant, b: Invariant) { @@ -77,11 +58,15 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2 !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'B extends string ? keyof B : B' is not assignable to type 'A extends string ? keyof A : A'. +!!! error TS2322: Type 'keyof B' is not assignable to type 'keyof A'. +!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'keyof A'. +!!! error TS2322: Type 'string' is not assignable to type 'keyof A'. b = a; // Error ~ !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. !!! error TS2322: Types of property 'foo' are incompatible. !!! error TS2322: Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. } // Extract is a T that is known to be a Function @@ -135,13 +120,13 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2 !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. !!! error TS2345: Type 'Extract' is not assignable to type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Bar & Foo' but required in type '{ foo: string; bat: string; }'. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. fooBat(y); // Error ~ !!! error TS2345: Argument of type 'Extract' is not assignable to parameter of type '{ foo: string; bat: string; }'. !!! error TS2345: Property 'bat' is missing in type 'Foo & Bar' but required in type '{ foo: string; bat: string; }'. -!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:64:43: 'bat' is declared here. +!!! related TS2728 tests/cases/conformance/types/conditional/conditionalTypes2.ts:62:43: 'bat' is declared here. fooBat(z); // Error ~ !!! error TS2345: Argument of type 'Extract2' is not assignable to parameter of type '{ foo: string; bat: string; }'. @@ -149,6 +134,38 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2 !!! error TS2345: Type 'Bar & Foo & T' is not assignable to type '{ foo: string; bat: string; }'. } + // Repros from #22860 + + class Opt { + toVector(): Vector { + return undefined; + } + } + + interface Seq { + tail(): Opt>; + } + + class Vector implements Seq { + tail(): Opt> { + return undefined; + } + partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; + partition2(predicate:(x:T)=>boolean): [Vector,Vector]; + partition2(predicate:(v:T)=>boolean): [Vector,Vector] { + return undefined; + } + } + + interface A1 { + bat: B1>; + } + + interface B1 extends A1 { + bat: B1>; + boom: T extends any ? true : true + } + // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -229,29 +246,4 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(177,5): error TS2 }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; - - // Repros from #27118 - - type MyElement = [A] extends [[infer E]] ? E : never; - function oops(arg: MyElement): MyElement { - return arg; // Unsound, should be error - ~~~~~~~~~~~ -!!! error TS2322: Type 'MyElement' is not assignable to type 'MyElement'. - } - - type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; - function oops2(arg: MyAcceptor): MyAcceptor { - return arg; // Unsound, should be error - ~~~~~~~~~~~ -!!! error TS2322: Type 'MyAcceptor' is not assignable to type 'MyAcceptor'. - } - - type Dist = T extends number ? number : string; - type Aux = A["a"] extends number ? number : string; - type Nondist = Aux<{a: T}>; - function oops3(arg: Dist): Nondist { - return arg; // Unsound, should be error - ~~~~~~~~~~~ -!!! error TS2322: Type 'Dist' is not assignable to type 'Aux<{ a: T; }>'. - } \ No newline at end of file diff --git a/tests/baselines/reference/conditionalTypes2.js b/tests/baselines/reference/conditionalTypes2.js index c59c996711dfb..4f4f35e821afb 100644 --- a/tests/baselines/reference/conditionalTypes2.js +++ b/tests/baselines/reference/conditionalTypes2.js @@ -1,6 +1,4 @@ //// [conditionalTypes2.ts] -// #27118: Conditional types are now invariant in the check type. - interface Covariant { foo: T extends string ? T : number; } @@ -14,13 +12,13 @@ interface Invariant { } function f1(a: Covariant, b: Covariant) { - a = b; // Error + a = b; b = a; // Error } function f2(a: Contravariant, b: Contravariant) { a = b; // Error - b = a; // Error + b = a; } function f3(a: Invariant, b: Invariant) { @@ -78,6 +76,38 @@ function f21(x: Extract, Bar>, y: Extract, z: E fooBat(z); // Error } +// Repros from #22860 + +class Opt { + toVector(): Vector { + return undefined; + } +} + +interface Seq { + tail(): Opt>; +} + +class Vector implements Seq { + tail(): Opt> { + return undefined; + } + partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; + partition2(predicate:(x:T)=>boolean): [Vector,Vector]; + partition2(predicate:(v:T)=>boolean): [Vector,Vector] { + return undefined; + } +} + +interface A1 { + bat: B1>; +} + +interface B1 extends A1 { + bat: B1>; + boom: T extends any ? true : true +} + // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -158,37 +188,17 @@ type ProductComplementComplement = { }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; - -// Repros from #27118 - -type MyElement = [A] extends [[infer E]] ? E : never; -function oops(arg: MyElement): MyElement { - return arg; // Unsound, should be error -} - -type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; -function oops2(arg: MyAcceptor): MyAcceptor { - return arg; // Unsound, should be error -} - -type Dist = T extends number ? number : string; -type Aux = A["a"] extends number ? number : string; -type Nondist = Aux<{a: T}>; -function oops3(arg: Dist): Nondist { - return arg; // Unsound, should be error -} //// [conditionalTypes2.js] "use strict"; -// #27118: Conditional types are now invariant in the check type. function f1(a, b) { - a = b; // Error + a = b; b = a; // Error } function f2(a, b) { a = b; // Error - b = a; // Error + b = a; } function f3(a, b) { a = b; // Error @@ -229,21 +239,32 @@ function f21(x, y, z) { fooBat(y); // Error fooBat(z); // Error } +// Repros from #22860 +var Opt = /** @class */ (function () { + function Opt() { + } + Opt.prototype.toVector = function () { + return undefined; + }; + return Opt; +}()); +var Vector = /** @class */ (function () { + function Vector() { + } + Vector.prototype.tail = function () { + return undefined; + }; + Vector.prototype.partition2 = function (predicate) { + return undefined; + }; + return Vector; +}()); function foo(value) { if (isFunction(value)) { toString1(value); toString2(value); } } -function oops(arg) { - return arg; // Unsound, should be error -} -function oops2(arg) { - return arg; // Unsound, should be error -} -function oops3(arg) { - return arg; // Unsound, should be error -} //// [conditionalTypes2.d.ts] @@ -281,6 +302,24 @@ declare function fooBat(x: { declare type Extract2 = T extends U ? T extends V ? T : never : never; declare function f20(x: Extract, Bar>, y: Extract, z: Extract2): void; declare function f21(x: Extract, Bar>, y: Extract, z: Extract2): void; +declare class Opt { + toVector(): Vector; +} +interface Seq { + tail(): Opt>; +} +declare class Vector implements Seq { + tail(): Opt>; + partition2(predicate: (v: T) => v is U): [Vector, Vector>]; + partition2(predicate: (x: T) => boolean): [Vector, Vector]; +} +interface A1 { + bat: B1>; +} +interface B1 extends A1 { + bat: B1>; + boom: T extends any ? true : true; +} declare function toString1(value: object | Function): string; declare function toString2(value: Function): string; declare function foo(value: T): void; @@ -353,15 +392,3 @@ declare type ProductComplementComplement = { }; declare type PCCA = ProductComplementComplement['a']; declare type PCCB = ProductComplementComplement['b']; -declare type MyElement = [A] extends [[infer E]] ? E : never; -declare function oops(arg: MyElement): MyElement; -declare type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; -declare function oops2(arg: MyAcceptor): MyAcceptor; -declare type Dist = T extends number ? number : string; -declare type Aux = A["a"] extends number ? number : string; -declare type Nondist = Aux<{ - a: T; -}>; -declare function oops3(arg: Dist): Nondist; diff --git a/tests/baselines/reference/conditionalTypes2.symbols b/tests/baselines/reference/conditionalTypes2.symbols index 7bbf837eeced4..b164d26e45089 100644 --- a/tests/baselines/reference/conditionalTypes2.symbols +++ b/tests/baselines/reference/conditionalTypes2.symbols @@ -1,655 +1,687 @@ === tests/cases/conformance/types/conditional/conditionalTypes2.ts === -// #27118: Conditional types are now invariant in the check type. - interface Covariant { >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) foo: T extends string ? T : number; ->foo : Symbol(Covariant.foo, Decl(conditionalTypes2.ts, 2, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 2, 20)) +>foo : Symbol(Covariant.foo, Decl(conditionalTypes2.ts, 0, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 0, 20)) } interface Contravariant { ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) foo: T extends string ? keyof T : number; ->foo : Symbol(Contravariant.foo, Decl(conditionalTypes2.ts, 6, 28)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 6, 24)) +>foo : Symbol(Contravariant.foo, Decl(conditionalTypes2.ts, 4, 28)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 4, 24)) } interface Invariant { ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) foo: T extends string ? keyof T : T; ->foo : Symbol(Invariant.foo, Decl(conditionalTypes2.ts, 10, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 10, 20)) +>foo : Symbol(Invariant.foo, Decl(conditionalTypes2.ts, 8, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 8, 20)) } function f1(a: Covariant, b: Covariant) { ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 12, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 14, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 10, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 12, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 14, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 12, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) >Covariant : Symbol(Covariant, Decl(conditionalTypes2.ts, 0, 0)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 14, 14)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 12, 14)) - a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) + a = b; +>a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 14, 44)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 14, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 12, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 12, 28)) } function f2(a: Contravariant, b: Contravariant) { ->f2 : Symbol(f2, Decl(conditionalTypes2.ts, 17, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 19, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 19, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) ->Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 4, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 19, 14)) +>f2 : Symbol(f2, Decl(conditionalTypes2.ts, 15, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 17, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 17, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) +>Contravariant : Symbol(Contravariant, Decl(conditionalTypes2.ts, 2, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 17, 14)) a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) - b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 19, 48)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 19, 28)) + b = a; +>b : Symbol(b, Decl(conditionalTypes2.ts, 17, 48)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 17, 28)) } function f3(a: Invariant, b: Invariant) { ->f3 : Symbol(f3, Decl(conditionalTypes2.ts, 22, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 24, 14)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 24, 12)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) ->Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 8, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 24, 14)) +>f3 : Symbol(f3, Decl(conditionalTypes2.ts, 20, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 22, 14)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 22, 12)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) +>Invariant : Symbol(Invariant, Decl(conditionalTypes2.ts, 6, 1)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 22, 14)) a = b; // Error ->a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) b = a; // Error ->b : Symbol(b, Decl(conditionalTypes2.ts, 24, 44)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 24, 28)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 22, 44)) +>a : Symbol(a, Decl(conditionalTypes2.ts, 22, 28)) } // Extract is a T that is known to be a Function function isFunction(value: T): value is Extract { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 30, 20)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 28, 20)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) return typeof value === "function"; ->value : Symbol(value, Decl(conditionalTypes2.ts, 30, 23)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 28, 23)) } function getFunction(item: T) { ->getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 32, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 34, 21)) ->item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 34, 21)) +>getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 30, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 32, 21)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 32, 21)) if (isFunction(item)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) ->item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) return item; ->item : Symbol(item, Decl(conditionalTypes2.ts, 34, 24)) +>item : Symbol(item, Decl(conditionalTypes2.ts, 32, 24)) } throw new Error(); >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } function f10(x: T) { ->f10 : Symbol(f10, Decl(conditionalTypes2.ts, 39, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) +>f10 : Symbol(f10, Decl(conditionalTypes2.ts, 37, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) if (isFunction(x)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) const f: Function = x; ->f : Symbol(f, Decl(conditionalTypes2.ts, 43, 13)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 41, 13)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) const t: T = x; ->t : Symbol(t, Decl(conditionalTypes2.ts, 44, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 41, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 41, 16)) +>t : Symbol(t, Decl(conditionalTypes2.ts, 42, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 39, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 39, 16)) } } function f11(x: string | (() => string) | undefined) { ->f11 : Symbol(f11, Decl(conditionalTypes2.ts, 46, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) +>f11 : Symbol(f11, Decl(conditionalTypes2.ts, 44, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) if (isFunction(x)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) x(); ->x : Symbol(x, Decl(conditionalTypes2.ts, 48, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 46, 13)) } } function f12(x: string | (() => string) | undefined) { ->f12 : Symbol(f12, Decl(conditionalTypes2.ts, 52, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 54, 13)) +>f12 : Symbol(f12, Decl(conditionalTypes2.ts, 50, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 52, 13)) const f = getFunction(x); // () => string ->f : Symbol(f, Decl(conditionalTypes2.ts, 55, 9)) ->getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 32, 1)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 54, 13)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 53, 9)) +>getFunction : Symbol(getFunction, Decl(conditionalTypes2.ts, 30, 1)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 52, 13)) f(); ->f : Symbol(f, Decl(conditionalTypes2.ts, 55, 9)) +>f : Symbol(f, Decl(conditionalTypes2.ts, 53, 9)) } type Foo = { foo: string }; ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 59, 12)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 57, 12)) type Bar = { bar: string }; ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) ->bar : Symbol(bar, Decl(conditionalTypes2.ts, 60, 12)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>bar : Symbol(bar, Decl(conditionalTypes2.ts, 58, 12)) declare function fooBar(x: { foo: string, bar: string }): void; ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 62, 24)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 62, 28)) ->bar : Symbol(bar, Decl(conditionalTypes2.ts, 62, 41)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 60, 24)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 60, 28)) +>bar : Symbol(bar, Decl(conditionalTypes2.ts, 60, 41)) declare function fooBat(x: { foo: string, bat: string }): void; ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 63, 24)) ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 63, 28)) ->bat : Symbol(bat, Decl(conditionalTypes2.ts, 63, 41)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 61, 24)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 61, 28)) +>bat : Symbol(bat, Decl(conditionalTypes2.ts, 61, 41)) type Extract2 = T extends U ? T extends V ? T : never : never; ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 65, 16)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 65, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) ->U : Symbol(U, Decl(conditionalTypes2.ts, 65, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 65, 19)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 65, 14)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 63, 16)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 63, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 63, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 63, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 63, 14)) function f20(x: Extract, Bar>, y: Extract, z: Extract2) { ->f20 : Symbol(f20, Decl(conditionalTypes2.ts, 65, 71)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 67, 16)) +>f20 : Symbol(f20, Decl(conditionalTypes2.ts, 63, 71)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 65, 16)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 67, 49)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 65, 49)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 67, 75)) ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 67, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 65, 75)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 65, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) fooBar(x); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 67, 16)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 65, 16)) fooBar(y); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 67, 49)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 65, 49)) fooBar(z); ->fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 60, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 67, 75)) +>fooBar : Symbol(fooBar, Decl(conditionalTypes2.ts, 58, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 65, 75)) } function f21(x: Extract, Bar>, y: Extract, z: Extract2) { ->f21 : Symbol(f21, Decl(conditionalTypes2.ts, 71, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 73, 16)) +>f21 : Symbol(f21, Decl(conditionalTypes2.ts, 69, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 71, 16)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 73, 49)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 71, 49)) >Extract : Symbol(Extract, Decl(lib.es5.d.ts, --, --)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 73, 75)) ->Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 63, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 73, 13)) ->Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 57, 1)) ->Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 59, 27)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 71, 75)) +>Extract2 : Symbol(Extract2, Decl(conditionalTypes2.ts, 61, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 71, 13)) +>Foo : Symbol(Foo, Decl(conditionalTypes2.ts, 55, 1)) +>Bar : Symbol(Bar, Decl(conditionalTypes2.ts, 57, 27)) fooBat(x); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) ->x : Symbol(x, Decl(conditionalTypes2.ts, 73, 16)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 71, 16)) fooBat(y); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) ->y : Symbol(y, Decl(conditionalTypes2.ts, 73, 49)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) +>y : Symbol(y, Decl(conditionalTypes2.ts, 71, 49)) fooBat(z); // Error ->fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 62, 63)) ->z : Symbol(z, Decl(conditionalTypes2.ts, 73, 75)) +>fooBat : Symbol(fooBat, Decl(conditionalTypes2.ts, 60, 63)) +>z : Symbol(z, Decl(conditionalTypes2.ts, 71, 75)) +} + +// Repros from #22860 + +class Opt { +>Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 79, 10)) + + toVector(): Vector { +>toVector : Symbol(Opt.toVector, Decl(conditionalTypes2.ts, 79, 14)) +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 79, 10)) + + return undefined; +>undefined : Symbol(undefined) + } +} + +interface Seq { +>Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 85, 14)) + + tail(): Opt>; +>tail : Symbol(Seq.tail, Decl(conditionalTypes2.ts, 85, 18)) +>Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) +>Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 85, 14)) +} + +class Vector implements Seq { +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) +>Seq : Symbol(Seq, Decl(conditionalTypes2.ts, 83, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) + + tail(): Opt> { +>tail : Symbol(Vector.tail, Decl(conditionalTypes2.ts, 89, 35)) +>Opt : Symbol(Opt, Decl(conditionalTypes2.ts, 75, 1)) +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) + + return undefined; +>undefined : Symbol(undefined) + } + partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; +>partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) +>predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 93, 28)) +>v : Symbol(v, Decl(conditionalTypes2.ts, 93, 39)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) +>v : Symbol(v, Decl(conditionalTypes2.ts, 93, 39)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) +>Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 93, 15)) + + partition2(predicate:(x:T)=>boolean): [Vector,Vector]; +>partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) +>predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 94, 15)) +>x : Symbol(x, Decl(conditionalTypes2.ts, 94, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) + + partition2(predicate:(v:T)=>boolean): [Vector,Vector] { +>partition2 : Symbol(Vector.partition2, Decl(conditionalTypes2.ts, 92, 5), Decl(conditionalTypes2.ts, 93, 88), Decl(conditionalTypes2.ts, 94, 64)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 95, 15)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) +>predicate : Symbol(predicate, Decl(conditionalTypes2.ts, 95, 28)) +>v : Symbol(v, Decl(conditionalTypes2.ts, 95, 39)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 89, 13)) +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) +>U : Symbol(U, Decl(conditionalTypes2.ts, 95, 15)) +>Vector : Symbol(Vector, Decl(conditionalTypes2.ts, 87, 1)) + + return undefined; +>undefined : Symbol(undefined) + } +} + +interface A1 { +>A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 100, 13)) + + bat: B1>; +>bat : Symbol(A1.bat, Decl(conditionalTypes2.ts, 100, 17)) +>B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) +>A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 100, 13)) +} + +interface B1 extends A1 { +>B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) +>A1 : Symbol(A1, Decl(conditionalTypes2.ts, 98, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) + + bat: B1>; +>bat : Symbol(B1.bat, Decl(conditionalTypes2.ts, 104, 31)) +>B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) +>B1 : Symbol(B1, Decl(conditionalTypes2.ts, 102, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) + + boom: T extends any ? true : true +>boom : Symbol(B1.boom, Decl(conditionalTypes2.ts, 105, 19)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 104, 13)) } // Repro from #22899 declare function toString1(value: object | Function): string ; ->toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 77, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 81, 27)) +>toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 107, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 111, 27)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) declare function toString2(value: Function): string ; ->toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 81, 62)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 82, 27)) +>toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 111, 62)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 112, 27)) >Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) function foo(value: T) { ->foo : Symbol(foo, Decl(conditionalTypes2.ts, 82, 53)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 84, 13)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 84, 13)) +>foo : Symbol(foo, Decl(conditionalTypes2.ts, 112, 53)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 13)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 114, 13)) if (isFunction(value)) { ->isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 27, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) +>isFunction : Symbol(isFunction, Decl(conditionalTypes2.ts, 25, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) toString1(value); ->toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 77, 1)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) +>toString1 : Symbol(toString1, Decl(conditionalTypes2.ts, 107, 1)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) toString2(value); ->toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 81, 62)) ->value : Symbol(value, Decl(conditionalTypes2.ts, 84, 16)) +>toString2 : Symbol(toString2, Decl(conditionalTypes2.ts, 111, 62)) +>value : Symbol(value, Decl(conditionalTypes2.ts, 114, 16)) } } // Repro from #23052 type A = ->A : Symbol(A, Decl(conditionalTypes2.ts, 89, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 93, 12)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 119, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 123, 12)) T extends object ->T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) ? { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: A; } ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 95, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 95, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 89, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 95, 9)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 93, 12)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 125, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 125, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 119, 1)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 125, 9)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 123, 12)) : T extends V ? T : never; ->T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 93, 9)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 93, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 123, 9)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 123, 7)) type B = ->B : Symbol(B, Decl(conditionalTypes2.ts, 96, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 126, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) T extends object ->T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) ? { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: B; } ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 100, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 100, 17)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 96, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 100, 9)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 130, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 130, 17)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 126, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 130, 9)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) : T extends V ? T : never; ->T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 98, 9)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 98, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 128, 9)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 128, 7)) type C = ->C : Symbol(C, Decl(conditionalTypes2.ts, 101, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 103, 12)) +>C : Symbol(C, Decl(conditionalTypes2.ts, 131, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 133, 12)) { [Q in { [P in keyof T]: T[P] extends V ? P : P; }[keyof T]]: C; }; ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 104, 5)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) ->P : Symbol(P, Decl(conditionalTypes2.ts, 104, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) ->C : Symbol(C, Decl(conditionalTypes2.ts, 101, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 103, 7)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 104, 5)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 103, 9)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 103, 12)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 134, 5)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) +>P : Symbol(P, Decl(conditionalTypes2.ts, 134, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) +>C : Symbol(C, Decl(conditionalTypes2.ts, 131, 30)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 133, 7)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 134, 5)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 133, 9)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 133, 12)) // Repro from #23100 type A2 = ->A2 : Symbol(A2, Decl(conditionalTypes2.ts, 104, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 108, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 108, 13)) +>A2 : Symbol(A2, Decl(conditionalTypes2.ts, 134, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 138, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 138, 13)) T extends object ? T extends any[] ? T : { [Q in keyof T]: A2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 109, 48)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) ->A2 : Symbol(A2, Decl(conditionalTypes2.ts, 104, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 109, 48)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 108, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 108, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 108, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 139, 48)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>A2 : Symbol(A2, Decl(conditionalTypes2.ts, 134, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 139, 48)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 138, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 138, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 138, 8)) type B2 = ->B2 : Symbol(B2, Decl(conditionalTypes2.ts, 109, 85)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 111, 10)) +>B2 : Symbol(B2, Decl(conditionalTypes2.ts, 139, 85)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 141, 10)) T extends object ? T extends any[] ? T : { [Q in keyof T]: B2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 112, 48)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) ->B2 : Symbol(B2, Decl(conditionalTypes2.ts, 109, 85)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 112, 48)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 111, 10)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 111, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 142, 48)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>B2 : Symbol(B2, Decl(conditionalTypes2.ts, 139, 85)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 142, 48)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 141, 10)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 141, 8)) type C2 = ->C2 : Symbol(C2, Decl(conditionalTypes2.ts, 112, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 114, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 114, 13)) +>C2 : Symbol(C2, Decl(conditionalTypes2.ts, 142, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 144, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 144, 13)) T extends object ? { [Q in keyof T]: C2; } : T; ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 115, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) ->C2 : Symbol(C2, Decl(conditionalTypes2.ts, 112, 82)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) ->Q : Symbol(Q, Decl(conditionalTypes2.ts, 115, 26)) ->V : Symbol(V, Decl(conditionalTypes2.ts, 114, 10)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 114, 13)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 114, 8)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 145, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) +>C2 : Symbol(C2, Decl(conditionalTypes2.ts, 142, 82)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) +>Q : Symbol(Q, Decl(conditionalTypes2.ts, 145, 26)) +>V : Symbol(V, Decl(conditionalTypes2.ts, 144, 10)) +>E : Symbol(E, Decl(conditionalTypes2.ts, 144, 13)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 144, 8)) // Repro from #28654 type MaybeTrue = true extends T["b"] ? "yes" : "no"; ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 119, 15)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 119, 26)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 119, 15)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 149, 15)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 149, 26)) +>T : Symbol(T, Decl(conditionalTypes2.ts, 149, 15)) type T0 = MaybeTrue<{ b: never }> // "no" ->T0 : Symbol(T0, Decl(conditionalTypes2.ts, 119, 78)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 121, 21)) +>T0 : Symbol(T0, Decl(conditionalTypes2.ts, 149, 78)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 151, 21)) type T1 = MaybeTrue<{ b: false }>; // "no" ->T1 : Symbol(T1, Decl(conditionalTypes2.ts, 121, 33)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 122, 21)) +>T1 : Symbol(T1, Decl(conditionalTypes2.ts, 151, 33)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 152, 21)) type T2 = MaybeTrue<{ b: true }>; // "yes" ->T2 : Symbol(T2, Decl(conditionalTypes2.ts, 122, 34)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 123, 21)) +>T2 : Symbol(T2, Decl(conditionalTypes2.ts, 152, 34)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 153, 21)) type T3 = MaybeTrue<{ b: boolean }>; // "yes" ->T3 : Symbol(T3, Decl(conditionalTypes2.ts, 123, 33)) ->MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 115, 63)) ->b : Symbol(b, Decl(conditionalTypes2.ts, 124, 21)) +>T3 : Symbol(T3, Decl(conditionalTypes2.ts, 153, 33)) +>MaybeTrue : Symbol(MaybeTrue, Decl(conditionalTypes2.ts, 145, 63)) +>b : Symbol(b, Decl(conditionalTypes2.ts, 154, 21)) // Repro from #28824 type Union = 'a' | 'b'; ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) type Product = { f1: A, f2: B}; ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 129, 13)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 129, 29)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 129, 36)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 129, 13)) ->f2 : Symbol(f2, Decl(conditionalTypes2.ts, 129, 43)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 129, 29)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 159, 13)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 159, 29)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 159, 36)) +>A : Symbol(A, Decl(conditionalTypes2.ts, 159, 13)) +>f2 : Symbol(f2, Decl(conditionalTypes2.ts, 159, 43)) +>B : Symbol(B, Decl(conditionalTypes2.ts, 159, 29)) type ProductUnion = Product<'a', 0> | Product<'b', 1>; ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) ->Product : Symbol(Product, Decl(conditionalTypes2.ts, 128, 23)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) +>Product : Symbol(Product, Decl(conditionalTypes2.ts, 158, 23)) // {a: "b"; b: "a"} type UnionComplement = { ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) [K in Union]: Exclude ->K : Symbol(K, Decl(conditionalTypes2.ts, 134, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 164, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 134, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 164, 3)) }; type UCA = UnionComplement['a']; ->UCA : Symbol(UCA, Decl(conditionalTypes2.ts, 135, 2)) ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) +>UCA : Symbol(UCA, Decl(conditionalTypes2.ts, 165, 2)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) type UCB = UnionComplement['b']; ->UCB : Symbol(UCB, Decl(conditionalTypes2.ts, 136, 32)) ->UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 130, 54)) +>UCB : Symbol(UCB, Decl(conditionalTypes2.ts, 166, 32)) +>UnionComplement : Symbol(UnionComplement, Decl(conditionalTypes2.ts, 160, 54)) // {a: "a"; b: "b"} type UnionComplementComplement = { ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) [K in Union]: Exclude> ->K : Symbol(K, Decl(conditionalTypes2.ts, 141, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 171, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 141, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 171, 3)) }; type UCCA = UnionComplementComplement['a']; ->UCCA : Symbol(UCCA, Decl(conditionalTypes2.ts, 142, 2)) ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) +>UCCA : Symbol(UCCA, Decl(conditionalTypes2.ts, 172, 2)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) type UCCB = UnionComplementComplement['b']; ->UCCB : Symbol(UCCB, Decl(conditionalTypes2.ts, 143, 43)) ->UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 137, 32)) +>UCCB : Symbol(UCCB, Decl(conditionalTypes2.ts, 173, 43)) +>UnionComplementComplement : Symbol(UnionComplementComplement, Decl(conditionalTypes2.ts, 167, 32)) // {a: Product<'b', 1>; b: Product<'a', 0>} type ProductComplement = { ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) [K in Union]: Exclude ->K : Symbol(K, Decl(conditionalTypes2.ts, 148, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 178, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 148, 39)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 148, 3)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 178, 39)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 178, 3)) }; type PCA = ProductComplement['a']; ->PCA : Symbol(PCA, Decl(conditionalTypes2.ts, 149, 2)) ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) +>PCA : Symbol(PCA, Decl(conditionalTypes2.ts, 179, 2)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) type PCB = ProductComplement['b']; ->PCB : Symbol(PCB, Decl(conditionalTypes2.ts, 150, 34)) ->ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 144, 43)) +>PCB : Symbol(PCB, Decl(conditionalTypes2.ts, 180, 34)) +>ProductComplement : Symbol(ProductComplement, Decl(conditionalTypes2.ts, 174, 43)) // {a: Product<'a', 0>; b: Product<'b', 1>} type ProductComplementComplement = { ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) [K in Union]: Exclude> ->K : Symbol(K, Decl(conditionalTypes2.ts, 155, 3)) ->Union : Symbol(Union, Decl(conditionalTypes2.ts, 124, 36)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 185, 3)) +>Union : Symbol(Union, Decl(conditionalTypes2.ts, 154, 36)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) >Exclude : Symbol(Exclude, Decl(lib.es5.d.ts, --, --)) ->ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 129, 51)) ->f1 : Symbol(f1, Decl(conditionalTypes2.ts, 155, 61)) ->K : Symbol(K, Decl(conditionalTypes2.ts, 155, 3)) +>ProductUnion : Symbol(ProductUnion, Decl(conditionalTypes2.ts, 159, 51)) +>f1 : Symbol(f1, Decl(conditionalTypes2.ts, 185, 61)) +>K : Symbol(K, Decl(conditionalTypes2.ts, 185, 3)) }; type PCCA = ProductComplementComplement['a']; ->PCCA : Symbol(PCCA, Decl(conditionalTypes2.ts, 156, 2)) ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) +>PCCA : Symbol(PCCA, Decl(conditionalTypes2.ts, 186, 2)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) type PCCB = ProductComplementComplement['b']; ->PCCB : Symbol(PCCB, Decl(conditionalTypes2.ts, 157, 45)) ->ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 151, 34)) - -// Repros from #27118 - -type MyElement = [A] extends [[infer E]] ? E : never; ->MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 162, 15)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 162, 15)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 162, 39)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 162, 39)) - -function oops(arg: MyElement): MyElement { ->oops : Symbol(oops, Decl(conditionalTypes2.ts, 162, 56)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 163, 16)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) ->arg : Symbol(arg, Decl(conditionalTypes2.ts, 163, 30)) ->MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 163, 14)) ->MyElement : Symbol(MyElement, Decl(conditionalTypes2.ts, 158, 45)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 163, 16)) - - return arg; // Unsound, should be error ->arg : Symbol(arg, Decl(conditionalTypes2.ts, 163, 30)) -} - -type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; ->MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 167, 16)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 167, 16)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 167, 40)) ->arg : Symbol(arg, Decl(conditionalTypes2.ts, 167, 48)) ->E : Symbol(E, Decl(conditionalTypes2.ts, 167, 40)) - -function oops2(arg: MyAcceptor): MyAcceptor { ->oops2 : Symbol(oops2, Decl(conditionalTypes2.ts, 167, 72)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 168, 17)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) ->arg : Symbol(arg, Decl(conditionalTypes2.ts, 168, 31)) ->MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) ->B : Symbol(B, Decl(conditionalTypes2.ts, 168, 17)) ->MyAcceptor : Symbol(MyAcceptor, Decl(conditionalTypes2.ts, 165, 1)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 168, 15)) - - return arg; // Unsound, should be error ->arg : Symbol(arg, Decl(conditionalTypes2.ts, 168, 31)) -} - -type Dist = T extends number ? number : string; ->Dist : Symbol(Dist, Decl(conditionalTypes2.ts, 170, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 172, 10)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 172, 10)) - -type Aux = A["a"] extends number ? number : string; ->Aux : Symbol(Aux, Decl(conditionalTypes2.ts, 172, 50)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 173, 9)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 173, 20)) ->A : Symbol(A, Decl(conditionalTypes2.ts, 173, 9)) - -type Nondist = Aux<{a: T}>; ->Nondist : Symbol(Nondist, Decl(conditionalTypes2.ts, 173, 77)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 174, 13)) ->Aux : Symbol(Aux, Decl(conditionalTypes2.ts, 172, 50)) ->a : Symbol(a, Decl(conditionalTypes2.ts, 174, 23)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 174, 13)) - -function oops3(arg: Dist): Nondist { ->oops3 : Symbol(oops3, Decl(conditionalTypes2.ts, 174, 30)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) ->arg : Symbol(arg, Decl(conditionalTypes2.ts, 175, 18)) ->Dist : Symbol(Dist, Decl(conditionalTypes2.ts, 170, 1)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) ->Nondist : Symbol(Nondist, Decl(conditionalTypes2.ts, 173, 77)) ->T : Symbol(T, Decl(conditionalTypes2.ts, 175, 15)) - - return arg; // Unsound, should be error ->arg : Symbol(arg, Decl(conditionalTypes2.ts, 175, 18)) -} +>PCCB : Symbol(PCCB, Decl(conditionalTypes2.ts, 187, 45)) +>ProductComplementComplement : Symbol(ProductComplementComplement, Decl(conditionalTypes2.ts, 181, 34)) diff --git a/tests/baselines/reference/conditionalTypes2.types b/tests/baselines/reference/conditionalTypes2.types index 3cffe6ab48e2c..aac6ba47475c6 100644 --- a/tests/baselines/reference/conditionalTypes2.types +++ b/tests/baselines/reference/conditionalTypes2.types @@ -1,6 +1,4 @@ === tests/cases/conformance/types/conditional/conditionalTypes2.ts === -// #27118: Conditional types are now invariant in the check type. - interface Covariant { foo: T extends string ? T : number; >foo : T extends string ? T : number @@ -21,7 +19,7 @@ function f1(a: Covariant, b: Covariant) { >a : Covariant >b : Covariant - a = b; // Error + a = b; >a = b : Covariant >a : Covariant >b : Covariant @@ -42,7 +40,7 @@ function f2(a: Contravariant, b: Contravariant) { >a : Contravariant >b : Contravariant - b = a; // Error + b = a; >b = a : Contravariant >b : Contravariant >a : Contravariant @@ -209,6 +207,71 @@ function f21(x: Extract, Bar>, y: Extract, z: E >z : Extract2 } +// Repros from #22860 + +class Opt { +>Opt : Opt + + toVector(): Vector { +>toVector : () => Vector + + return undefined; +>undefined : any +>undefined : undefined + } +} + +interface Seq { + tail(): Opt>; +>tail : () => Opt> +} + +class Vector implements Seq { +>Vector : Vector + + tail(): Opt> { +>tail : () => Opt> + + return undefined; +>undefined : any +>undefined : undefined + } + partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; +>partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } +>predicate : (v: T) => v is U +>v : T + + partition2(predicate:(x:T)=>boolean): [Vector,Vector]; +>partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } +>predicate : (x: T) => boolean +>x : T + + partition2(predicate:(v:T)=>boolean): [Vector,Vector] { +>partition2 : { (predicate: (v: T) => v is U): [Vector, Vector>]; (predicate: (x: T) => boolean): [Vector, Vector]; } +>predicate : (v: T) => boolean +>v : T + + return undefined; +>undefined : any +>undefined : undefined + } +} + +interface A1 { + bat: B1>; +>bat : B1> +} + +interface B1 extends A1 { + bat: B1>; +>bat : B1> + + boom: T extends any ? true : true +>boom : T extends any ? true : true +>true : true +>true : true +} + // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -368,47 +431,3 @@ type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; >PCCB : Product<"b", 1> -// Repros from #27118 - -type MyElement = [A] extends [[infer E]] ? E : never; ->MyElement : MyElement - -function oops(arg: MyElement): MyElement { ->oops : (arg: MyElement) => MyElement ->arg : MyElement - - return arg; // Unsound, should be error ->arg : MyElement -} - -type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; ->MyAcceptor : MyAcceptor ->arg : E - -function oops2(arg: MyAcceptor): MyAcceptor { ->oops2 : (arg: MyAcceptor) => MyAcceptor ->arg : MyAcceptor - - return arg; // Unsound, should be error ->arg : MyAcceptor -} - -type Dist = T extends number ? number : string; ->Dist : Dist - -type Aux = A["a"] extends number ? number : string; ->Aux : Aux ->a : unknown - -type Nondist = Aux<{a: T}>; ->Nondist : Aux<{ a: T; }> ->a : T - -function oops3(arg: Dist): Nondist { ->oops3 : (arg: Dist) => Aux<{ a: T; }> ->arg : Dist - - return arg; // Unsound, should be error ->arg : Dist -} - diff --git a/tests/cases/conformance/types/conditional/conditionalTypes2.ts b/tests/cases/conformance/types/conditional/conditionalTypes2.ts index 5d73c58fe7f37..4b65b5ddeb202 100644 --- a/tests/cases/conformance/types/conditional/conditionalTypes2.ts +++ b/tests/cases/conformance/types/conditional/conditionalTypes2.ts @@ -1,8 +1,6 @@ // @strict: true // @declaration: true -// #27118: Conditional types are now invariant in the check type. - interface Covariant { foo: T extends string ? T : number; } @@ -16,13 +14,13 @@ interface Invariant { } function f1(a: Covariant, b: Covariant) { - a = b; // Error + a = b; b = a; // Error } function f2(a: Contravariant, b: Contravariant) { a = b; // Error - b = a; // Error + b = a; } function f3(a: Invariant, b: Invariant) { @@ -80,6 +78,38 @@ function f21(x: Extract, Bar>, y: Extract, z: E fooBat(z); // Error } +// Repros from #22860 + +class Opt { + toVector(): Vector { + return undefined; + } +} + +interface Seq { + tail(): Opt>; +} + +class Vector implements Seq { + tail(): Opt> { + return undefined; + } + partition2(predicate:(v:T)=>v is U): [Vector,Vector>]; + partition2(predicate:(x:T)=>boolean): [Vector,Vector]; + partition2(predicate:(v:T)=>boolean): [Vector,Vector] { + return undefined; + } +} + +interface A1 { + bat: B1>; +} + +interface B1 extends A1 { + bat: B1>; + boom: T extends any ? true : true +} + // Repro from #22899 declare function toString1(value: object | Function): string ; @@ -160,22 +190,3 @@ type ProductComplementComplement = { }; type PCCA = ProductComplementComplement['a']; type PCCB = ProductComplementComplement['b']; - -// Repros from #27118 - -type MyElement = [A] extends [[infer E]] ? E : never; -function oops(arg: MyElement): MyElement { - return arg; // Unsound, should be error -} - -type MyAcceptor = [A] extends [[infer E]] ? (arg: E) => void : never; -function oops2(arg: MyAcceptor): MyAcceptor { - return arg; // Unsound, should be error -} - -type Dist = T extends number ? number : string; -type Aux = A["a"] extends number ? number : string; -type Nondist = Aux<{a: T}>; -function oops3(arg: Dist): Nondist { - return arg; // Unsound, should be error -} From f77b43ca090b1c402859e79a31d54238a478c143 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Wed, 27 Feb 2019 12:42:30 -0800 Subject: [PATCH 64/64] Update baselines --- .../reference/conditionalTypes2.errors.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/baselines/reference/conditionalTypes2.errors.txt b/tests/baselines/reference/conditionalTypes2.errors.txt index a1a23b6da1870..6cf81cf573039 100644 --- a/tests/baselines/reference/conditionalTypes2.errors.txt +++ b/tests/baselines/reference/conditionalTypes2.errors.txt @@ -8,6 +8,13 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(24,5): error TS23 Type 'keyof B' is not assignable to type 'keyof A'. Type 'string | number | symbol' is not assignable to type 'keyof A'. Type 'string' is not assignable to type 'keyof A'. + Type 'string' is not assignable to type 'number | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "length" | "substr" | "valueOf"'. + Type 'keyof B' is not assignable to type 'number | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "length" | "substr" | "valueOf"'. + Type 'string | number | symbol' is not assignable to type 'number | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "length" | "substr" | "valueOf"'. + Type 'string' is not assignable to type 'number | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "length" | "substr" | "valueOf"'. + Type 'keyof B' is not assignable to type '"valueOf"'. + Type 'string | number | symbol' is not assignable to type '"valueOf"'. + Type 'string' is not assignable to type '"valueOf"'. tests/cases/conformance/types/conditional/conditionalTypes2.ts(25,5): error TS2322: Type 'Invariant' is not assignable to type 'Invariant'. Types of property 'foo' are incompatible. Type 'A extends string ? keyof A : A' is not assignable to type 'B extends string ? keyof B : B'. @@ -61,6 +68,13 @@ tests/cases/conformance/types/conditional/conditionalTypes2.ts(75,12): error TS2 !!! error TS2322: Type 'keyof B' is not assignable to type 'keyof A'. !!! error TS2322: Type 'string | number | symbol' is not assignable to type 'keyof A'. !!! error TS2322: Type 'string' is not assignable to type 'keyof A'. +!!! error TS2322: Type 'string' is not assignable to type 'number | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "length" | "substr" | "valueOf"'. +!!! error TS2322: Type 'keyof B' is not assignable to type 'number | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "length" | "substr" | "valueOf"'. +!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'number | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "length" | "substr" | "valueOf"'. +!!! error TS2322: Type 'string' is not assignable to type 'number | "toString" | "charAt" | "charCodeAt" | "concat" | "indexOf" | "lastIndexOf" | "localeCompare" | "match" | "replace" | "search" | "slice" | "split" | "substring" | "toLowerCase" | "toLocaleLowerCase" | "toUpperCase" | "toLocaleUpperCase" | "trim" | "length" | "substr" | "valueOf"'. +!!! error TS2322: Type 'keyof B' is not assignable to type '"valueOf"'. +!!! error TS2322: Type 'string | number | symbol' is not assignable to type '"valueOf"'. +!!! error TS2322: Type 'string' is not assignable to type '"valueOf"'. b = a; // Error ~ !!! error TS2322: Type 'Invariant' is not assignable to type 'Invariant'.