diff --git a/.gitignore b/.gitignore index eb0df177040..0b29eebf521 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ internal/ .idea yarn.lock package-lock.json +.parallelperf.* diff --git a/Gulpfile.ts b/Gulpfile.ts index 676d07ec570..873ea0991bd 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -674,11 +674,10 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: }); function failWithStatus(err?: any, status?: number) { - if (err) { - console.log(err); + if (err || status) { + process.exit(typeof status === "number" ? status : 2); } - done(err || status); - process.exit(status); + done(); } function lintThenFinish() { @@ -979,8 +978,9 @@ gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => { .pipe(gulp.dest(builtLocalDirectory)); }); -gulp.task("tsc-instrumented", "Builds an instrumented tsc.js", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => { - exec(host, [instrumenterJsPath, "record", "iocapture", builtLocalCompiler], done, done); +gulp.task("tsc-instrumented", "Builds an instrumented tsc.js - run with --test=[testname]", ["local", loggedIOJsPath, instrumenterJsPath, servicesFile], (done) => { + const test = cmdLineOptions["tests"] || "iocapture"; + exec(host, [instrumenterJsPath, "record", test, builtLocalCompiler], done, done); }); gulp.task("update-sublime", "Updates the sublime plugin's tsserver", ["local", serverFile], () => { @@ -1051,10 +1051,11 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: const fileMatcher = cmdLineOptions["files"]; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; - const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; + : "Gulpfile.ts 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; + const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`; console.log("Linting: " + cmd); child_process.execSync(cmd, { stdio: [0, 1, 2] }); + if (fold.isTravis()) console.log(fold.end("lint")); }); gulp.task("default", "Runs 'local'", ["local"]); diff --git a/Jakefile.js b/Jakefile.js index 6fd2f549015..8a4c67ac84b 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -138,7 +138,10 @@ var harnessSources = harnessCoreSources.concat([ "projectErrors.ts", "matchFiles.ts", "initializeTSConfig.ts", - "extractMethods.ts", + "extractConstants.ts", + "extractFunctions.ts", + "extractRanges.ts", + "extractTestHelpers.ts", "printer.ts", "textChanges.ts", "telemetry.ts", @@ -1104,9 +1107,10 @@ var instrumenterPath = harnessDirectory + 'instrumenter.ts'; var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js'; compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true, { lib: "es6", types: ["node"], noOutFile: true, outDir: builtLocalDirectory }); -desc("Builds an instrumented tsc.js"); +desc("Builds an instrumented tsc.js - run with test=[testname]"); task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function () { - var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename; + var test = process.env.test || process.env.tests || process.env.t || "iocapture"; + var cmd = host + ' ' + instrumenterJsPath + " record " + test + " " + builtLocalDirectory + compilerFilename; console.log(cmd); var ex = jake.createExec([cmd]); ex.addListener("cmdEnd", function () { @@ -1121,7 +1125,7 @@ task("update-sublime", ["local", serverFile], function () { jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); }); -var tslintRuleDir = "scripts/tslint"; +var tslintRuleDir = "scripts/tslint/rules"; var tslintRules = [ "booleanTriviaRule", "debugAssertRule", @@ -1137,13 +1141,27 @@ var tslintRulesFiles = tslintRules.map(function (p) { return path.join(tslintRuleDir, p + ".ts"); }); var tslintRulesOutFiles = tslintRules.map(function (p) { - return path.join(builtLocalDirectory, "tslint", p + ".js"); + return path.join(builtLocalDirectory, "tslint/rules", p + ".js"); +}); +var tslintFormattersDir = "scripts/tslint/formatters"; +var tslintFormatters = [ + "autolinkableStylishFormatter", +]; +var tslintFormatterFiles = tslintFormatters.map(function (p) { + return path.join(tslintFormattersDir, p + ".ts"); +}); +var tslintFormattersOutFiles = tslintFormatters.map(function (p) { + return path.join(builtLocalDirectory, "tslint/formatters", p + ".js"); }); desc("Compiles tslint rules to js"); -task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"])); +task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(tslintFormattersOutFiles).concat(["build-rules-end"])); tslintRulesFiles.forEach(function (ruleFile, i) { compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, - { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint"), lib: "es6" }); + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint/rules"), lib: "es6" }); +}); +tslintFormatterFiles.forEach(function (ruleFile, i) { + compileFile(tslintFormattersOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint/formatters"), lib: "es6" }); }); desc("Emit the start of the build-rules fold"); @@ -1211,8 +1229,8 @@ task("lint", ["build-rules"], () => { const fileMatcher = process.env.f || process.env.file || process.env.files; const files = fileMatcher ? `src/**/${fileMatcher}` - : "Gulpfile.ts 'scripts/tslint/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; - const cmd = `node node_modules/tslint/bin/tslint ${files} --format stylish`; + : "Gulpfile.ts 'scripts/tslint/**/*.ts' 'src/**/*.ts' --exclude src/lib/es5.d.ts --exclude 'src/lib/*.generated.d.ts'"; + const cmd = `node node_modules/tslint/bin/tslint ${files} --formatters-dir ./built/local/tslint/formatters --format autolinkableStylish`; console.log("Linting: " + cmd); jake.exec([cmd], { interactive: true }, () => { if (fold.isTravis()) console.log(fold.end("lint")); diff --git a/lib/lib.d.ts b/lib/lib.d.ts index c99bf56ef43..7074d06c1a9 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -147,7 +147,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor | undefined; /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly @@ -1597,7 +1597,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1608,7 +1608,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1655,7 +1655,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1764,8 +1764,8 @@ interface Int8Array { interface Int8ArrayConstructor { readonly prototype: Int8Array; new(length: number): Int8Array; - new(array: ArrayLike): Int8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array; /** * The size in bytes of each element in the array. @@ -1864,7 +1864,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1875,7 +1875,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1922,7 +1922,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2032,8 +2032,8 @@ interface Uint8Array { interface Uint8ArrayConstructor { readonly prototype: Uint8Array; new(length: number): Uint8Array; - new(array: ArrayLike): Uint8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array; /** * The size in bytes of each element in the array. @@ -2131,7 +2131,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2142,7 +2142,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2189,7 +2189,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2299,8 +2299,8 @@ interface Uint8ClampedArray { interface Uint8ClampedArrayConstructor { readonly prototype: Uint8ClampedArray; new(length: number): Uint8ClampedArray; - new(array: ArrayLike): Uint8ClampedArray; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8ClampedArray; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray; /** * The size in bytes of each element in the array. @@ -2386,7 +2386,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; + filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2397,7 +2397,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2408,7 +2408,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2454,7 +2454,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2564,8 +2564,8 @@ interface Int16Array { interface Int16ArrayConstructor { readonly prototype: Int16Array; new(length: number): Int16Array; - new(array: ArrayLike): Int16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array; /** * The size in bytes of each element in the array. @@ -2664,7 +2664,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2675,7 +2675,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2722,7 +2722,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2832,8 +2832,8 @@ interface Uint16Array { interface Uint16ArrayConstructor { readonly prototype: Uint16Array; new(length: number): Uint16Array; - new(array: ArrayLike): Uint16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array; /** * The size in bytes of each element in the array. @@ -2931,7 +2931,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2942,7 +2942,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3099,8 +3099,8 @@ interface Int32Array { interface Int32ArrayConstructor { readonly prototype: Int32Array; new(length: number): Int32Array; - new(array: ArrayLike): Int32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array; /** * The size in bytes of each element in the array. @@ -3198,7 +3198,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3209,7 +3209,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3255,7 +3255,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3365,8 +3365,8 @@ interface Uint32Array { interface Uint32ArrayConstructor { readonly prototype: Uint32Array; new(length: number): Uint32Array; - new(array: ArrayLike): Uint32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array; /** * The size in bytes of each element in the array. @@ -3464,7 +3464,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3475,7 +3475,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3522,7 +3522,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3632,8 +3632,8 @@ interface Float32Array { interface Float32ArrayConstructor { readonly prototype: Float32Array; new(length: number): Float32Array; - new(array: ArrayLike): Float32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array; /** * The size in bytes of each element in the array. @@ -3732,7 +3732,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3743,7 +3743,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3790,7 +3790,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3900,8 +3900,8 @@ interface Float64Array { interface Float64ArrayConstructor { readonly prototype: Float64Array; new(length: number): Float64Array; - new(array: ArrayLike): Float64Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float64Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array; /** * The size in bytes of each element in the array. @@ -4088,11 +4088,11 @@ interface Date { ///////////////////////////// interface Account { - displayName?: string; - id?: string; + displayName: string; + id: string; imageURL?: string; name?: string; - rpDisplayName?: string; + rpDisplayName: string; } interface Algorithm { @@ -4119,11 +4119,11 @@ interface CacheQueryOptions { } interface ClientData { - challenge?: string; + challenge: string; extensions?: WebAuthnExtensions; - hashAlg?: string | Algorithm; - origin?: string; - rpId?: string; + hashAlg: string | Algorithm; + origin: string; + rpId: string; tokenBinding?: string; } @@ -4171,9 +4171,9 @@ interface CustomEventInit extends EventInit { } interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; + x?: number | null; + y?: number | null; + z?: number | null; } interface DeviceLightEventInit extends EventInit { @@ -4181,30 +4181,30 @@ interface DeviceLightEventInit extends EventInit { } interface DeviceMotionEventInit extends EventInit { - acceleration?: DeviceAccelerationDict; - accelerationIncludingGravity?: DeviceAccelerationDict; - interval?: number; - rotationRate?: DeviceRotationRateDict; + acceleration?: DeviceAccelerationDict | null; + accelerationIncludingGravity?: DeviceAccelerationDict | null; + interval?: number | null; + rotationRate?: DeviceRotationRateDict | null; } interface DeviceOrientationEventInit extends EventInit { absolute?: boolean; - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DOMRectInit { - height?: any; - width?: any; - x?: any; - y?: any; + height?: number; + width?: number; + x?: number; + y?: number; } interface DoubleRange { @@ -4245,15 +4245,15 @@ interface EventModifierInit extends UIEventInit { } interface ExceptionInformation { - domain?: string; + domain?: string | null; } interface FocusEventInit extends UIEventInit { - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; } interface FocusNavigationEventInit extends EventInit { - navigationReason?: string; + navigationReason?: string | null; originHeight?: number; originLeft?: number; originTop?: number; @@ -4268,7 +4268,7 @@ interface FocusNavigationOrigin { } interface GamepadEventInit extends EventInit { - gamepad?: Gamepad; + gamepad?: Gamepad | null; } interface GetNotificationOptions { @@ -4276,8 +4276,8 @@ interface GetNotificationOptions { } interface HashChangeEventInit extends EventInit { - newURL?: string; - oldURL?: string; + newURL?: string | null; + oldURL?: string | null; } interface IDBIndexParameters { @@ -4287,19 +4287,20 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface IntersectionObserverEntryInit { - boundingClientRect?: DOMRectInit; - intersectionRect?: DOMRectInit; - rootBounds?: DOMRectInit; - target?: Element; - time?: number; + isIntersecting: boolean; + boundingClientRect: DOMRectInit; + intersectionRect: DOMRectInit; + rootBounds: DOMRectInit; + target: Element; + time: number; } interface IntersectionObserverInit { - root?: Element; + root?: Element | null; rootMargin?: string; threshold?: number | number[]; } @@ -4321,12 +4322,12 @@ interface LongRange { } interface MediaEncryptedEventInit extends EventInit { - initData?: ArrayBuffer; + initData?: ArrayBuffer | null; initDataType?: string; } interface MediaKeyMessageEventInit extends EventInit { - message?: ArrayBuffer; + message?: ArrayBuffer | null; messageType?: MediaKeyMessageType; } @@ -4349,7 +4350,7 @@ interface MediaStreamConstraints { } interface MediaStreamErrorEventInit extends EventInit { - error?: MediaStreamError; + error?: MediaStreamError | null; } interface MediaStreamEventInit extends EventInit { @@ -4357,7 +4358,7 @@ interface MediaStreamEventInit extends EventInit { } interface MediaStreamTrackEventInit extends EventInit { - track?: MediaStreamTrack; + track?: MediaStreamTrack | null; } interface MediaTrackCapabilities { @@ -4434,7 +4435,7 @@ interface MouseEventInit extends EventModifierInit { buttons?: number; clientX?: number; clientY?: number; - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; screenX?: number; screenY?: number; } @@ -4442,8 +4443,8 @@ interface MouseEventInit extends EventModifierInit { interface MSAccountInfo { accountImageUri?: string; accountName?: string; - rpDisplayName?: string; - userDisplayName?: string; + rpDisplayName: string; + userDisplayName: string; userId?: string; } @@ -4526,7 +4527,7 @@ interface MSCredentialParameters { interface MSCredentialSpec { id?: string; - type?: MSCredentialType; + type: MSCredentialType; } interface MSDelay { @@ -4736,8 +4737,8 @@ interface MsZoomToOptions { contentX?: number; contentY?: number; scaleFactor?: number; - viewportX?: string; - viewportY?: string; + viewportX?: string | null; + viewportY?: string | null; } interface MutationObserverInit { @@ -4763,9 +4764,9 @@ interface ObjectURLOptions { } interface PaymentCurrencyAmount { - currency?: string; + currency: string; currencySystem?: string; - value?: string; + value: string; } interface PaymentDetails { @@ -4779,19 +4780,19 @@ interface PaymentDetails { interface PaymentDetailsModifier { additionalDisplayItems?: PaymentItem[]; data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; total?: PaymentItem; } interface PaymentItem { - amount?: PaymentCurrencyAmount; - label?: string; + amount: PaymentCurrencyAmount; + label: string; pending?: boolean; } interface PaymentMethodData { data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; } interface PaymentOptions { @@ -4806,9 +4807,9 @@ interface PaymentRequestUpdateEventInit extends EventInit { } interface PaymentShippingOption { - amount?: PaymentCurrencyAmount; - id?: string; - label?: string; + amount: PaymentCurrencyAmount; + id: string; + label: string; selected?: boolean; } @@ -4856,7 +4857,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -4868,7 +4869,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -4953,15 +4954,15 @@ interface RTCIceGatherOptions { } interface RTCIceParameters { - iceLite?: boolean; + iceLite?: boolean | null; password?: string; usernameFragment?: string; } interface RTCIceServer { - credential?: string; + credential?: string | null; urls?: any; - username?: string; + username?: string | null; } interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { @@ -5171,9 +5172,9 @@ interface RTCTransportStats extends RTCStats { } interface ScopedCredentialDescriptor { - id?: any; + id: any; transports?: Transport[]; - type?: ScopedCredentialType; + type: ScopedCredentialType; } interface ScopedCredentialOptions { @@ -5184,29 +5185,29 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - algorithm?: string | Algorithm; - type?: ScopedCredentialType; + algorithm: string | Algorithm; + type: ScopedCredentialType; } interface ServiceWorkerMessageEventInit extends EventInit { data?: any; lastEventId?: string; origin?: string; - ports?: MessagePort[]; - source?: ServiceWorker | MessagePort; + ports?: MessagePort[] | null; + source?: ServiceWorker | MessagePort | null; } interface SpeechSynthesisEventInit extends EventInit { charIndex?: number; elapsedTime?: number; name?: string; - utterance?: SpeechSynthesisUtterance; + utterance?: SpeechSynthesisUtterance | null; } interface StoreExceptionsInformation extends ExceptionInformation { - detailURI?: string; - explanationString?: string; - siteName?: string; + detailURI?: string | null; + explanationString?: string | null; + siteName?: string | null; } interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { @@ -5214,7 +5215,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat } interface TrackEventInit extends EventInit { - track?: VideoTrack | AudioTrack | TextTrack; + track?: VideoTrack | AudioTrack | TextTrack | null; } interface TransitionEventInit extends EventInit { @@ -5224,7 +5225,7 @@ interface TransitionEventInit extends EventInit { interface UIEventInit extends EventInit { detail?: number; - view?: Window; + view?: Window | null; } interface WebAuthnExtensions { @@ -5604,9 +5605,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -5618,7 +5619,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -6723,7 +6724,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ readonly compatMode: string; cookie: string; - readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly currentScript: HTMLScriptElement | SVGScriptElement | null; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -7462,7 +7463,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -7968,7 +7969,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface History { @@ -8128,7 +8129,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. */ declare: boolean; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -8366,7 +8367,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -8799,7 +8800,7 @@ interface HTMLFieldSetElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. @@ -9378,7 +9379,7 @@ interface HTMLInputElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -9545,7 +9546,7 @@ interface HTMLLabelElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the object to which the given label object is assigned. */ @@ -9567,7 +9568,7 @@ interface HTMLLegendElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -10001,7 +10002,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -10100,7 +10101,7 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -10139,7 +10140,7 @@ interface HTMLOptionElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -10183,7 +10184,7 @@ declare var HTMLOptionsCollection: { interface HTMLOutputElement extends HTMLElement { defaultValue: string; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; readonly htmlFor: DOMSettableTokenList; name: string; readonly type: string; @@ -10272,7 +10273,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Defines the maximum, or "done" value for a progress element. */ @@ -10358,7 +10359,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the number of objects in a collection. */ @@ -10829,7 +10830,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the maximum number of characters that the user can enter in a text control. */ @@ -11295,6 +11296,7 @@ interface IntersectionObserverEntry { readonly rootBounds: ClientRect; readonly target: Element; readonly time: number; + readonly isIntersecting: boolean; } declare var IntersectionObserverEntry: { @@ -11396,7 +11398,7 @@ interface MediaDevicesEventMap { interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; - enumerateDevices(): any; + enumerateDevices(): Promise; getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; @@ -13142,6 +13144,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -13595,8 +13598,8 @@ interface ServiceWorkerContainer extends EventTarget { oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; readonly ready: Promise; - getRegistration(clientURL?: USVString): Promise; - getRegistrations(): any; + getRegistration(): Promise; + getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -13632,7 +13635,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -15657,7 +15660,7 @@ declare var SVGZoomEvent: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -15965,6 +15968,7 @@ interface ValidityState { readonly typeMismatch: boolean; readonly valid: boolean; readonly valueMissing: boolean; + readonly tooShort: boolean; } declare var ValidityState: { @@ -17826,13 +17830,13 @@ interface NavigatorUserMedia { interface NodeSelector { querySelector(selectors: K): ElementTagNameMap[K] | null; - querySelector(selectors: string): Element | null; + querySelector(selectors: string): E | null; querySelectorAll(selectors: K): ElementListTagNameMap[K]; - querySelectorAll(selectors: string): NodeListOf; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; + getRandomValues(array: T): T; } interface SVGAnimatedPoints { @@ -17907,17 +17911,37 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -18008,8 +18032,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } @@ -18285,6 +18308,44 @@ interface TouchEventInit extends EventModifierInit { changedTouches?: Touch[]; } +interface HTMLDialogElement extends HTMLElement { + open: boolean; + returnValue: string; + close(returnValue?: string): void; + show(): void; + showModal(): void; +} + +declare var HTMLDialogElement: { + prototype: HTMLDialogElement; + new(): HTMLDialogElement; +}; + +interface HTMLMainElement extends HTMLElement { +} + +declare var HTMLMainElement: { + prototype: HTMLMainElement; + new(): HTMLMainElement; +}; + +interface HTMLDetailsElement extends HTMLElement { + open: boolean; +} + +declare var HTMLDetailsElement: { + prototype: HTMLDetailsElement; + new(): HTMLDetailsElement; +}; + +interface HTMLSummaryElement extends HTMLElement { +} + +declare var HTMLSummaryElement: { + prototype: HTMLSummaryElement; + new(): HTMLSummaryElement; +}; + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DecodeErrorCallback { @@ -18774,7 +18835,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; -type HeadersInit = any; +type HeadersInit = Headers | string[][]; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -19078,10 +19139,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -19107,8 +19176,9 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -19116,7 +19186,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -19148,8 +19218,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -19157,7 +19226,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index c96d5463b9c..948510a2bc3 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -24,11 +24,11 @@ and limitations under the License. ///////////////////////////// interface Account { - displayName?: string; - id?: string; + displayName: string; + id: string; imageURL?: string; name?: string; - rpDisplayName?: string; + rpDisplayName: string; } interface Algorithm { @@ -55,11 +55,11 @@ interface CacheQueryOptions { } interface ClientData { - challenge?: string; + challenge: string; extensions?: WebAuthnExtensions; - hashAlg?: string | Algorithm; - origin?: string; - rpId?: string; + hashAlg: string | Algorithm; + origin: string; + rpId: string; tokenBinding?: string; } @@ -107,9 +107,9 @@ interface CustomEventInit extends EventInit { } interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; + x?: number | null; + y?: number | null; + z?: number | null; } interface DeviceLightEventInit extends EventInit { @@ -117,30 +117,30 @@ interface DeviceLightEventInit extends EventInit { } interface DeviceMotionEventInit extends EventInit { - acceleration?: DeviceAccelerationDict; - accelerationIncludingGravity?: DeviceAccelerationDict; - interval?: number; - rotationRate?: DeviceRotationRateDict; + acceleration?: DeviceAccelerationDict | null; + accelerationIncludingGravity?: DeviceAccelerationDict | null; + interval?: number | null; + rotationRate?: DeviceRotationRateDict | null; } interface DeviceOrientationEventInit extends EventInit { absolute?: boolean; - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DOMRectInit { - height?: any; - width?: any; - x?: any; - y?: any; + height?: number; + width?: number; + x?: number; + y?: number; } interface DoubleRange { @@ -181,15 +181,15 @@ interface EventModifierInit extends UIEventInit { } interface ExceptionInformation { - domain?: string; + domain?: string | null; } interface FocusEventInit extends UIEventInit { - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; } interface FocusNavigationEventInit extends EventInit { - navigationReason?: string; + navigationReason?: string | null; originHeight?: number; originLeft?: number; originTop?: number; @@ -204,7 +204,7 @@ interface FocusNavigationOrigin { } interface GamepadEventInit extends EventInit { - gamepad?: Gamepad; + gamepad?: Gamepad | null; } interface GetNotificationOptions { @@ -212,8 +212,8 @@ interface GetNotificationOptions { } interface HashChangeEventInit extends EventInit { - newURL?: string; - oldURL?: string; + newURL?: string | null; + oldURL?: string | null; } interface IDBIndexParameters { @@ -223,19 +223,20 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface IntersectionObserverEntryInit { - boundingClientRect?: DOMRectInit; - intersectionRect?: DOMRectInit; - rootBounds?: DOMRectInit; - target?: Element; - time?: number; + isIntersecting: boolean; + boundingClientRect: DOMRectInit; + intersectionRect: DOMRectInit; + rootBounds: DOMRectInit; + target: Element; + time: number; } interface IntersectionObserverInit { - root?: Element; + root?: Element | null; rootMargin?: string; threshold?: number | number[]; } @@ -257,12 +258,12 @@ interface LongRange { } interface MediaEncryptedEventInit extends EventInit { - initData?: ArrayBuffer; + initData?: ArrayBuffer | null; initDataType?: string; } interface MediaKeyMessageEventInit extends EventInit { - message?: ArrayBuffer; + message?: ArrayBuffer | null; messageType?: MediaKeyMessageType; } @@ -285,7 +286,7 @@ interface MediaStreamConstraints { } interface MediaStreamErrorEventInit extends EventInit { - error?: MediaStreamError; + error?: MediaStreamError | null; } interface MediaStreamEventInit extends EventInit { @@ -293,7 +294,7 @@ interface MediaStreamEventInit extends EventInit { } interface MediaStreamTrackEventInit extends EventInit { - track?: MediaStreamTrack; + track?: MediaStreamTrack | null; } interface MediaTrackCapabilities { @@ -370,7 +371,7 @@ interface MouseEventInit extends EventModifierInit { buttons?: number; clientX?: number; clientY?: number; - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; screenX?: number; screenY?: number; } @@ -378,8 +379,8 @@ interface MouseEventInit extends EventModifierInit { interface MSAccountInfo { accountImageUri?: string; accountName?: string; - rpDisplayName?: string; - userDisplayName?: string; + rpDisplayName: string; + userDisplayName: string; userId?: string; } @@ -462,7 +463,7 @@ interface MSCredentialParameters { interface MSCredentialSpec { id?: string; - type?: MSCredentialType; + type: MSCredentialType; } interface MSDelay { @@ -672,8 +673,8 @@ interface MsZoomToOptions { contentX?: number; contentY?: number; scaleFactor?: number; - viewportX?: string; - viewportY?: string; + viewportX?: string | null; + viewportY?: string | null; } interface MutationObserverInit { @@ -699,9 +700,9 @@ interface ObjectURLOptions { } interface PaymentCurrencyAmount { - currency?: string; + currency: string; currencySystem?: string; - value?: string; + value: string; } interface PaymentDetails { @@ -715,19 +716,19 @@ interface PaymentDetails { interface PaymentDetailsModifier { additionalDisplayItems?: PaymentItem[]; data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; total?: PaymentItem; } interface PaymentItem { - amount?: PaymentCurrencyAmount; - label?: string; + amount: PaymentCurrencyAmount; + label: string; pending?: boolean; } interface PaymentMethodData { data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; } interface PaymentOptions { @@ -742,9 +743,9 @@ interface PaymentRequestUpdateEventInit extends EventInit { } interface PaymentShippingOption { - amount?: PaymentCurrencyAmount; - id?: string; - label?: string; + amount: PaymentCurrencyAmount; + id: string; + label: string; selected?: boolean; } @@ -792,7 +793,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -804,7 +805,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -889,15 +890,15 @@ interface RTCIceGatherOptions { } interface RTCIceParameters { - iceLite?: boolean; + iceLite?: boolean | null; password?: string; usernameFragment?: string; } interface RTCIceServer { - credential?: string; + credential?: string | null; urls?: any; - username?: string; + username?: string | null; } interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { @@ -1107,9 +1108,9 @@ interface RTCTransportStats extends RTCStats { } interface ScopedCredentialDescriptor { - id?: any; + id: any; transports?: Transport[]; - type?: ScopedCredentialType; + type: ScopedCredentialType; } interface ScopedCredentialOptions { @@ -1120,29 +1121,29 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - algorithm?: string | Algorithm; - type?: ScopedCredentialType; + algorithm: string | Algorithm; + type: ScopedCredentialType; } interface ServiceWorkerMessageEventInit extends EventInit { data?: any; lastEventId?: string; origin?: string; - ports?: MessagePort[]; - source?: ServiceWorker | MessagePort; + ports?: MessagePort[] | null; + source?: ServiceWorker | MessagePort | null; } interface SpeechSynthesisEventInit extends EventInit { charIndex?: number; elapsedTime?: number; name?: string; - utterance?: SpeechSynthesisUtterance; + utterance?: SpeechSynthesisUtterance | null; } interface StoreExceptionsInformation extends ExceptionInformation { - detailURI?: string; - explanationString?: string; - siteName?: string; + detailURI?: string | null; + explanationString?: string | null; + siteName?: string | null; } interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { @@ -1150,7 +1151,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat } interface TrackEventInit extends EventInit { - track?: VideoTrack | AudioTrack | TextTrack; + track?: VideoTrack | AudioTrack | TextTrack | null; } interface TransitionEventInit extends EventInit { @@ -1160,7 +1161,7 @@ interface TransitionEventInit extends EventInit { interface UIEventInit extends EventInit { detail?: number; - view?: Window; + view?: Window | null; } interface WebAuthnExtensions { @@ -1540,9 +1541,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -1554,7 +1555,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -2659,7 +2660,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ readonly compatMode: string; cookie: string; - readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly currentScript: HTMLScriptElement | SVGScriptElement | null; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -3398,7 +3399,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -3904,7 +3905,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface History { @@ -4064,7 +4065,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. */ declare: boolean; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -4302,7 +4303,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -4735,7 +4736,7 @@ interface HTMLFieldSetElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. @@ -5314,7 +5315,7 @@ interface HTMLInputElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -5481,7 +5482,7 @@ interface HTMLLabelElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the object to which the given label object is assigned. */ @@ -5503,7 +5504,7 @@ interface HTMLLegendElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -5937,7 +5938,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -6036,7 +6037,7 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -6075,7 +6076,7 @@ interface HTMLOptionElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -6119,7 +6120,7 @@ declare var HTMLOptionsCollection: { interface HTMLOutputElement extends HTMLElement { defaultValue: string; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; readonly htmlFor: DOMSettableTokenList; name: string; readonly type: string; @@ -6208,7 +6209,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Defines the maximum, or "done" value for a progress element. */ @@ -6294,7 +6295,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the number of objects in a collection. */ @@ -6765,7 +6766,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the maximum number of characters that the user can enter in a text control. */ @@ -7231,6 +7232,7 @@ interface IntersectionObserverEntry { readonly rootBounds: ClientRect; readonly target: Element; readonly time: number; + readonly isIntersecting: boolean; } declare var IntersectionObserverEntry: { @@ -7332,7 +7334,7 @@ interface MediaDevicesEventMap { interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; - enumerateDevices(): any; + enumerateDevices(): Promise; getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; @@ -9078,6 +9080,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -9531,8 +9534,8 @@ interface ServiceWorkerContainer extends EventTarget { oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; readonly ready: Promise; - getRegistration(clientURL?: USVString): Promise; - getRegistrations(): any; + getRegistration(): Promise; + getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -9568,7 +9571,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -11593,7 +11596,7 @@ declare var SVGZoomEvent: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -11901,6 +11904,7 @@ interface ValidityState { readonly typeMismatch: boolean; readonly valid: boolean; readonly valueMissing: boolean; + readonly tooShort: boolean; } declare var ValidityState: { @@ -13762,13 +13766,13 @@ interface NavigatorUserMedia { interface NodeSelector { querySelector(selectors: K): ElementTagNameMap[K] | null; - querySelector(selectors: string): Element | null; + querySelector(selectors: string): E | null; querySelectorAll(selectors: K): ElementListTagNameMap[K]; - querySelectorAll(selectors: string): NodeListOf; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; + getRandomValues(array: T): T; } interface SVGAnimatedPoints { @@ -13843,17 +13847,37 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -13944,8 +13968,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } @@ -14221,6 +14244,44 @@ interface TouchEventInit extends EventModifierInit { changedTouches?: Touch[]; } +interface HTMLDialogElement extends HTMLElement { + open: boolean; + returnValue: string; + close(returnValue?: string): void; + show(): void; + showModal(): void; +} + +declare var HTMLDialogElement: { + prototype: HTMLDialogElement; + new(): HTMLDialogElement; +}; + +interface HTMLMainElement extends HTMLElement { +} + +declare var HTMLMainElement: { + prototype: HTMLMainElement; + new(): HTMLMainElement; +}; + +interface HTMLDetailsElement extends HTMLElement { + open: boolean; +} + +declare var HTMLDetailsElement: { + prototype: HTMLDetailsElement; + new(): HTMLDetailsElement; +}; + +interface HTMLSummaryElement extends HTMLElement { +} + +declare var HTMLSummaryElement: { + prototype: HTMLSummaryElement; + new(): HTMLSummaryElement; +}; + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DecodeErrorCallback { @@ -14710,7 +14771,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; -type HeadersInit = any; +type HeadersInit = Headers | string[][]; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index bf2edb82ca6..610c46abc60 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -30,9 +30,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -43,9 +41,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -76,22 +72,13 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ - from(arrayLike: ArrayLike): Array; + from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; /** * Returns a new array from a set of elements. * @param items A set of elements to include in the new array object. */ - of(...items: T[]): Array; + of(...items: T[]): T[]; } interface DateConstructor { @@ -360,7 +347,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -383,9 +370,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -396,9 +381,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): number; } interface RegExp { diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 551698607ca..edf2dbc7760 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -74,15 +74,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ - from(iterable: Iterable): Array; + from(iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } interface ReadonlyArray { @@ -237,10 +229,6 @@ interface String { [Symbol.iterator](): IterableIterator; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** @@ -266,17 +254,9 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; - - from(arrayLike: Iterable): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** @@ -302,17 +282,9 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; - - from(arrayLike: Iterable): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** @@ -341,17 +313,9 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; - - from(arrayLike: Iterable): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** @@ -379,17 +343,9 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; - - from(arrayLike: Iterable): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** @@ -415,17 +371,9 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; - - from(arrayLike: Iterable): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** @@ -451,17 +399,9 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; - - from(arrayLike: Iterable): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** @@ -487,17 +427,9 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; - - from(arrayLike: Iterable): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** @@ -523,17 +455,9 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; - - from(arrayLike: Iterable): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** @@ -559,9 +483,5 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; - - from(arrayLike: Iterable): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } diff --git a/lib/lib.es2015.reflect.d.ts b/lib/lib.es2015.reflect.d.ts index 2bea5f1e59b..1139f1c2c89 100644 --- a/lib/lib.es2015.reflect.d.ts +++ b/lib/lib.es2015.reflect.d.ts @@ -24,11 +24,11 @@ declare namespace Reflect { function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: object, propertyKey: PropertyKey): boolean; function get(target: object, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined; function getPrototypeOf(target: object): object; function has(target: object, propertyKey: PropertyKey): boolean; function isExtensible(target: object): boolean; - function ownKeys(target: object): Array; + function ownKeys(target: object): PropertyKey[]; function preventExtensions(target: object): boolean; function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: object, proto: any): boolean; diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index f323260bf89..5017ec92da5 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -260,12 +260,6 @@ interface String { split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -274,74 +268,38 @@ interface DataView { readonly [Symbol.toStringTag]: "DataView"; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } diff --git a/lib/lib.es2016.full.d.ts b/lib/lib.es2016.full.d.ts index 07c6a3e8283..522e29a1034 100644 --- a/lib/lib.es2016.full.d.ts +++ b/lib/lib.es2016.full.d.ts @@ -33,9 +33,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -46,9 +44,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -79,22 +75,13 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ - from(arrayLike: ArrayLike): Array; + from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; /** * Returns a new array from a set of elements. * @param items A set of elements to include in the new array object. */ - of(...items: T[]): Array; + of(...items: T[]): T[]; } interface DateConstructor { @@ -363,7 +350,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -386,9 +373,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -399,9 +384,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): number; } interface RegExp { @@ -741,15 +724,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ - from(iterable: Iterable): Array; + from(iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } interface ReadonlyArray { @@ -904,10 +879,6 @@ interface String { [Symbol.iterator](): IterableIterator; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** @@ -933,17 +904,9 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; - - from(arrayLike: Iterable): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** @@ -969,17 +932,9 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; - - from(arrayLike: Iterable): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** @@ -1008,17 +963,9 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; - - from(arrayLike: Iterable): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** @@ -1046,17 +993,9 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; - - from(arrayLike: Iterable): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** @@ -1082,17 +1021,9 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; - - from(arrayLike: Iterable): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** @@ -1118,17 +1049,9 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; - - from(arrayLike: Iterable): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** @@ -1154,17 +1077,9 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; - - from(arrayLike: Iterable): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** @@ -1190,17 +1105,9 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; - - from(arrayLike: Iterable): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** @@ -1226,11 +1133,7 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; - - from(arrayLike: Iterable): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } @@ -1468,11 +1371,11 @@ declare namespace Reflect { function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: object, propertyKey: PropertyKey): boolean; function get(target: object, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined; function getPrototypeOf(target: object): object; function has(target: object, propertyKey: PropertyKey): boolean; function isExtensible(target: object): boolean; - function ownKeys(target: object): Array; + function ownKeys(target: object): PropertyKey[]; function preventExtensions(target: object): boolean; function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: object, proto: any): boolean; @@ -1758,12 +1661,6 @@ interface String { split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -1772,74 +1669,38 @@ interface DataView { readonly [Symbol.toStringTag]: "DataView"; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } @@ -1851,11 +1712,11 @@ interface Float64Array { ///////////////////////////// interface Account { - displayName?: string; - id?: string; + displayName: string; + id: string; imageURL?: string; name?: string; - rpDisplayName?: string; + rpDisplayName: string; } interface Algorithm { @@ -1882,11 +1743,11 @@ interface CacheQueryOptions { } interface ClientData { - challenge?: string; + challenge: string; extensions?: WebAuthnExtensions; - hashAlg?: string | Algorithm; - origin?: string; - rpId?: string; + hashAlg: string | Algorithm; + origin: string; + rpId: string; tokenBinding?: string; } @@ -1934,9 +1795,9 @@ interface CustomEventInit extends EventInit { } interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; + x?: number | null; + y?: number | null; + z?: number | null; } interface DeviceLightEventInit extends EventInit { @@ -1944,30 +1805,30 @@ interface DeviceLightEventInit extends EventInit { } interface DeviceMotionEventInit extends EventInit { - acceleration?: DeviceAccelerationDict; - accelerationIncludingGravity?: DeviceAccelerationDict; - interval?: number; - rotationRate?: DeviceRotationRateDict; + acceleration?: DeviceAccelerationDict | null; + accelerationIncludingGravity?: DeviceAccelerationDict | null; + interval?: number | null; + rotationRate?: DeviceRotationRateDict | null; } interface DeviceOrientationEventInit extends EventInit { absolute?: boolean; - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DOMRectInit { - height?: any; - width?: any; - x?: any; - y?: any; + height?: number; + width?: number; + x?: number; + y?: number; } interface DoubleRange { @@ -2008,15 +1869,15 @@ interface EventModifierInit extends UIEventInit { } interface ExceptionInformation { - domain?: string; + domain?: string | null; } interface FocusEventInit extends UIEventInit { - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; } interface FocusNavigationEventInit extends EventInit { - navigationReason?: string; + navigationReason?: string | null; originHeight?: number; originLeft?: number; originTop?: number; @@ -2031,7 +1892,7 @@ interface FocusNavigationOrigin { } interface GamepadEventInit extends EventInit { - gamepad?: Gamepad; + gamepad?: Gamepad | null; } interface GetNotificationOptions { @@ -2039,8 +1900,8 @@ interface GetNotificationOptions { } interface HashChangeEventInit extends EventInit { - newURL?: string; - oldURL?: string; + newURL?: string | null; + oldURL?: string | null; } interface IDBIndexParameters { @@ -2050,19 +1911,20 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface IntersectionObserverEntryInit { - boundingClientRect?: DOMRectInit; - intersectionRect?: DOMRectInit; - rootBounds?: DOMRectInit; - target?: Element; - time?: number; + isIntersecting: boolean; + boundingClientRect: DOMRectInit; + intersectionRect: DOMRectInit; + rootBounds: DOMRectInit; + target: Element; + time: number; } interface IntersectionObserverInit { - root?: Element; + root?: Element | null; rootMargin?: string; threshold?: number | number[]; } @@ -2084,12 +1946,12 @@ interface LongRange { } interface MediaEncryptedEventInit extends EventInit { - initData?: ArrayBuffer; + initData?: ArrayBuffer | null; initDataType?: string; } interface MediaKeyMessageEventInit extends EventInit { - message?: ArrayBuffer; + message?: ArrayBuffer | null; messageType?: MediaKeyMessageType; } @@ -2112,7 +1974,7 @@ interface MediaStreamConstraints { } interface MediaStreamErrorEventInit extends EventInit { - error?: MediaStreamError; + error?: MediaStreamError | null; } interface MediaStreamEventInit extends EventInit { @@ -2120,7 +1982,7 @@ interface MediaStreamEventInit extends EventInit { } interface MediaStreamTrackEventInit extends EventInit { - track?: MediaStreamTrack; + track?: MediaStreamTrack | null; } interface MediaTrackCapabilities { @@ -2197,7 +2059,7 @@ interface MouseEventInit extends EventModifierInit { buttons?: number; clientX?: number; clientY?: number; - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; screenX?: number; screenY?: number; } @@ -2205,8 +2067,8 @@ interface MouseEventInit extends EventModifierInit { interface MSAccountInfo { accountImageUri?: string; accountName?: string; - rpDisplayName?: string; - userDisplayName?: string; + rpDisplayName: string; + userDisplayName: string; userId?: string; } @@ -2289,7 +2151,7 @@ interface MSCredentialParameters { interface MSCredentialSpec { id?: string; - type?: MSCredentialType; + type: MSCredentialType; } interface MSDelay { @@ -2499,8 +2361,8 @@ interface MsZoomToOptions { contentX?: number; contentY?: number; scaleFactor?: number; - viewportX?: string; - viewportY?: string; + viewportX?: string | null; + viewportY?: string | null; } interface MutationObserverInit { @@ -2526,9 +2388,9 @@ interface ObjectURLOptions { } interface PaymentCurrencyAmount { - currency?: string; + currency: string; currencySystem?: string; - value?: string; + value: string; } interface PaymentDetails { @@ -2542,19 +2404,19 @@ interface PaymentDetails { interface PaymentDetailsModifier { additionalDisplayItems?: PaymentItem[]; data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; total?: PaymentItem; } interface PaymentItem { - amount?: PaymentCurrencyAmount; - label?: string; + amount: PaymentCurrencyAmount; + label: string; pending?: boolean; } interface PaymentMethodData { data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; } interface PaymentOptions { @@ -2569,9 +2431,9 @@ interface PaymentRequestUpdateEventInit extends EventInit { } interface PaymentShippingOption { - amount?: PaymentCurrencyAmount; - id?: string; - label?: string; + amount: PaymentCurrencyAmount; + id: string; + label: string; selected?: boolean; } @@ -2619,7 +2481,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -2631,7 +2493,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -2716,15 +2578,15 @@ interface RTCIceGatherOptions { } interface RTCIceParameters { - iceLite?: boolean; + iceLite?: boolean | null; password?: string; usernameFragment?: string; } interface RTCIceServer { - credential?: string; + credential?: string | null; urls?: any; - username?: string; + username?: string | null; } interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { @@ -2934,9 +2796,9 @@ interface RTCTransportStats extends RTCStats { } interface ScopedCredentialDescriptor { - id?: any; + id: any; transports?: Transport[]; - type?: ScopedCredentialType; + type: ScopedCredentialType; } interface ScopedCredentialOptions { @@ -2947,29 +2809,29 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - algorithm?: string | Algorithm; - type?: ScopedCredentialType; + algorithm: string | Algorithm; + type: ScopedCredentialType; } interface ServiceWorkerMessageEventInit extends EventInit { data?: any; lastEventId?: string; origin?: string; - ports?: MessagePort[]; - source?: ServiceWorker | MessagePort; + ports?: MessagePort[] | null; + source?: ServiceWorker | MessagePort | null; } interface SpeechSynthesisEventInit extends EventInit { charIndex?: number; elapsedTime?: number; name?: string; - utterance?: SpeechSynthesisUtterance; + utterance?: SpeechSynthesisUtterance | null; } interface StoreExceptionsInformation extends ExceptionInformation { - detailURI?: string; - explanationString?: string; - siteName?: string; + detailURI?: string | null; + explanationString?: string | null; + siteName?: string | null; } interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { @@ -2977,7 +2839,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat } interface TrackEventInit extends EventInit { - track?: VideoTrack | AudioTrack | TextTrack; + track?: VideoTrack | AudioTrack | TextTrack | null; } interface TransitionEventInit extends EventInit { @@ -2987,7 +2849,7 @@ interface TransitionEventInit extends EventInit { interface UIEventInit extends EventInit { detail?: number; - view?: Window; + view?: Window | null; } interface WebAuthnExtensions { @@ -3367,9 +3229,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -3381,7 +3243,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -4486,7 +4348,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ readonly compatMode: string; cookie: string; - readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly currentScript: HTMLScriptElement | SVGScriptElement | null; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -5225,7 +5087,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -5731,7 +5593,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface History { @@ -5891,7 +5753,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. */ declare: boolean; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -6129,7 +5991,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -6562,7 +6424,7 @@ interface HTMLFieldSetElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. @@ -7141,7 +7003,7 @@ interface HTMLInputElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -7308,7 +7170,7 @@ interface HTMLLabelElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the object to which the given label object is assigned. */ @@ -7330,7 +7192,7 @@ interface HTMLLegendElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7764,7 +7626,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -7863,7 +7725,7 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -7902,7 +7764,7 @@ interface HTMLOptionElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -7946,7 +7808,7 @@ declare var HTMLOptionsCollection: { interface HTMLOutputElement extends HTMLElement { defaultValue: string; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; readonly htmlFor: DOMSettableTokenList; name: string; readonly type: string; @@ -8035,7 +7897,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Defines the maximum, or "done" value for a progress element. */ @@ -8121,7 +7983,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the number of objects in a collection. */ @@ -8592,7 +8454,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the maximum number of characters that the user can enter in a text control. */ @@ -9058,6 +8920,7 @@ interface IntersectionObserverEntry { readonly rootBounds: ClientRect; readonly target: Element; readonly time: number; + readonly isIntersecting: boolean; } declare var IntersectionObserverEntry: { @@ -9159,7 +9022,7 @@ interface MediaDevicesEventMap { interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; - enumerateDevices(): any; + enumerateDevices(): Promise; getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; @@ -10905,6 +10768,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -11358,8 +11222,8 @@ interface ServiceWorkerContainer extends EventTarget { oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; readonly ready: Promise; - getRegistration(clientURL?: USVString): Promise; - getRegistrations(): any; + getRegistration(): Promise; + getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11395,7 +11259,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -13420,7 +13284,7 @@ declare var SVGZoomEvent: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -13728,6 +13592,7 @@ interface ValidityState { readonly typeMismatch: boolean; readonly valid: boolean; readonly valueMissing: boolean; + readonly tooShort: boolean; } declare var ValidityState: { @@ -15589,13 +15454,13 @@ interface NavigatorUserMedia { interface NodeSelector { querySelector(selectors: K): ElementTagNameMap[K] | null; - querySelector(selectors: string): Element | null; + querySelector(selectors: string): E | null; querySelectorAll(selectors: K): ElementListTagNameMap[K]; - querySelectorAll(selectors: string): NodeListOf; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; + getRandomValues(array: T): T; } interface SVGAnimatedPoints { @@ -15670,17 +15535,37 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -15771,8 +15656,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } @@ -16048,6 +15932,44 @@ interface TouchEventInit extends EventModifierInit { changedTouches?: Touch[]; } +interface HTMLDialogElement extends HTMLElement { + open: boolean; + returnValue: string; + close(returnValue?: string): void; + show(): void; + showModal(): void; +} + +declare var HTMLDialogElement: { + prototype: HTMLDialogElement; + new(): HTMLDialogElement; +}; + +interface HTMLMainElement extends HTMLElement { +} + +declare var HTMLMainElement: { + prototype: HTMLMainElement; + new(): HTMLMainElement; +}; + +interface HTMLDetailsElement extends HTMLElement { + open: boolean; +} + +declare var HTMLDetailsElement: { + prototype: HTMLDetailsElement; + new(): HTMLDetailsElement; +}; + +interface HTMLSummaryElement extends HTMLElement { +} + +declare var HTMLSummaryElement: { + prototype: HTMLSummaryElement; + new(): HTMLSummaryElement; +}; + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DecodeErrorCallback { @@ -16537,7 +16459,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; -type HeadersInit = any; +type HeadersInit = Headers | string[][]; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -16841,10 +16763,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -16870,8 +16800,9 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -16879,7 +16810,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -16911,8 +16842,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -16920,7 +16850,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; diff --git a/lib/lib.es2017.full.d.ts b/lib/lib.es2017.full.d.ts index 331f822c6fe..96b589afafa 100644 --- a/lib/lib.es2017.full.d.ts +++ b/lib/lib.es2017.full.d.ts @@ -37,9 +37,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -50,9 +48,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -83,22 +79,13 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ - from(arrayLike: ArrayLike): Array; + from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; /** * Returns a new array from a set of elements. * @param items A set of elements to include in the new array object. */ - of(...items: T[]): Array; + of(...items: T[]): T[]; } interface DateConstructor { @@ -367,7 +354,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -390,9 +377,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -403,9 +388,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): number; } interface RegExp { @@ -745,15 +728,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ - from(iterable: Iterable): Array; + from(iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } interface ReadonlyArray { @@ -908,10 +883,6 @@ interface String { [Symbol.iterator](): IterableIterator; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** @@ -937,17 +908,9 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; - - from(arrayLike: Iterable): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** @@ -973,17 +936,9 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; - - from(arrayLike: Iterable): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** @@ -1012,17 +967,9 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; - - from(arrayLike: Iterable): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** @@ -1050,17 +997,9 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; - - from(arrayLike: Iterable): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** @@ -1086,17 +1025,9 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; - - from(arrayLike: Iterable): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** @@ -1122,17 +1053,9 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; - - from(arrayLike: Iterable): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** @@ -1158,17 +1081,9 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; - - from(arrayLike: Iterable): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** @@ -1194,17 +1109,9 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; - - from(arrayLike: Iterable): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** @@ -1230,11 +1137,7 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; - - from(arrayLike: Iterable): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } @@ -1472,11 +1375,11 @@ declare namespace Reflect { function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: object, propertyKey: PropertyKey): boolean; function get(target: object, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined; function getPrototypeOf(target: object): object; function has(target: object, propertyKey: PropertyKey): boolean; function isExtensible(target: object): boolean; - function ownKeys(target: object): Array; + function ownKeys(target: object): PropertyKey[]; function preventExtensions(target: object): boolean; function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: object, proto: any): boolean; @@ -1762,12 +1665,6 @@ interface String { split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -1776,74 +1673,38 @@ interface DataView { readonly [Symbol.toStringTag]: "DataView"; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } @@ -1855,11 +1716,11 @@ interface Float64Array { ///////////////////////////// interface Account { - displayName?: string; - id?: string; + displayName: string; + id: string; imageURL?: string; name?: string; - rpDisplayName?: string; + rpDisplayName: string; } interface Algorithm { @@ -1886,11 +1747,11 @@ interface CacheQueryOptions { } interface ClientData { - challenge?: string; + challenge: string; extensions?: WebAuthnExtensions; - hashAlg?: string | Algorithm; - origin?: string; - rpId?: string; + hashAlg: string | Algorithm; + origin: string; + rpId: string; tokenBinding?: string; } @@ -1938,9 +1799,9 @@ interface CustomEventInit extends EventInit { } interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; + x?: number | null; + y?: number | null; + z?: number | null; } interface DeviceLightEventInit extends EventInit { @@ -1948,30 +1809,30 @@ interface DeviceLightEventInit extends EventInit { } interface DeviceMotionEventInit extends EventInit { - acceleration?: DeviceAccelerationDict; - accelerationIncludingGravity?: DeviceAccelerationDict; - interval?: number; - rotationRate?: DeviceRotationRateDict; + acceleration?: DeviceAccelerationDict | null; + accelerationIncludingGravity?: DeviceAccelerationDict | null; + interval?: number | null; + rotationRate?: DeviceRotationRateDict | null; } interface DeviceOrientationEventInit extends EventInit { absolute?: boolean; - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DOMRectInit { - height?: any; - width?: any; - x?: any; - y?: any; + height?: number; + width?: number; + x?: number; + y?: number; } interface DoubleRange { @@ -2012,15 +1873,15 @@ interface EventModifierInit extends UIEventInit { } interface ExceptionInformation { - domain?: string; + domain?: string | null; } interface FocusEventInit extends UIEventInit { - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; } interface FocusNavigationEventInit extends EventInit { - navigationReason?: string; + navigationReason?: string | null; originHeight?: number; originLeft?: number; originTop?: number; @@ -2035,7 +1896,7 @@ interface FocusNavigationOrigin { } interface GamepadEventInit extends EventInit { - gamepad?: Gamepad; + gamepad?: Gamepad | null; } interface GetNotificationOptions { @@ -2043,8 +1904,8 @@ interface GetNotificationOptions { } interface HashChangeEventInit extends EventInit { - newURL?: string; - oldURL?: string; + newURL?: string | null; + oldURL?: string | null; } interface IDBIndexParameters { @@ -2054,19 +1915,20 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface IntersectionObserverEntryInit { - boundingClientRect?: DOMRectInit; - intersectionRect?: DOMRectInit; - rootBounds?: DOMRectInit; - target?: Element; - time?: number; + isIntersecting: boolean; + boundingClientRect: DOMRectInit; + intersectionRect: DOMRectInit; + rootBounds: DOMRectInit; + target: Element; + time: number; } interface IntersectionObserverInit { - root?: Element; + root?: Element | null; rootMargin?: string; threshold?: number | number[]; } @@ -2088,12 +1950,12 @@ interface LongRange { } interface MediaEncryptedEventInit extends EventInit { - initData?: ArrayBuffer; + initData?: ArrayBuffer | null; initDataType?: string; } interface MediaKeyMessageEventInit extends EventInit { - message?: ArrayBuffer; + message?: ArrayBuffer | null; messageType?: MediaKeyMessageType; } @@ -2116,7 +1978,7 @@ interface MediaStreamConstraints { } interface MediaStreamErrorEventInit extends EventInit { - error?: MediaStreamError; + error?: MediaStreamError | null; } interface MediaStreamEventInit extends EventInit { @@ -2124,7 +1986,7 @@ interface MediaStreamEventInit extends EventInit { } interface MediaStreamTrackEventInit extends EventInit { - track?: MediaStreamTrack; + track?: MediaStreamTrack | null; } interface MediaTrackCapabilities { @@ -2201,7 +2063,7 @@ interface MouseEventInit extends EventModifierInit { buttons?: number; clientX?: number; clientY?: number; - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; screenX?: number; screenY?: number; } @@ -2209,8 +2071,8 @@ interface MouseEventInit extends EventModifierInit { interface MSAccountInfo { accountImageUri?: string; accountName?: string; - rpDisplayName?: string; - userDisplayName?: string; + rpDisplayName: string; + userDisplayName: string; userId?: string; } @@ -2293,7 +2155,7 @@ interface MSCredentialParameters { interface MSCredentialSpec { id?: string; - type?: MSCredentialType; + type: MSCredentialType; } interface MSDelay { @@ -2503,8 +2365,8 @@ interface MsZoomToOptions { contentX?: number; contentY?: number; scaleFactor?: number; - viewportX?: string; - viewportY?: string; + viewportX?: string | null; + viewportY?: string | null; } interface MutationObserverInit { @@ -2530,9 +2392,9 @@ interface ObjectURLOptions { } interface PaymentCurrencyAmount { - currency?: string; + currency: string; currencySystem?: string; - value?: string; + value: string; } interface PaymentDetails { @@ -2546,19 +2408,19 @@ interface PaymentDetails { interface PaymentDetailsModifier { additionalDisplayItems?: PaymentItem[]; data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; total?: PaymentItem; } interface PaymentItem { - amount?: PaymentCurrencyAmount; - label?: string; + amount: PaymentCurrencyAmount; + label: string; pending?: boolean; } interface PaymentMethodData { data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; } interface PaymentOptions { @@ -2573,9 +2435,9 @@ interface PaymentRequestUpdateEventInit extends EventInit { } interface PaymentShippingOption { - amount?: PaymentCurrencyAmount; - id?: string; - label?: string; + amount: PaymentCurrencyAmount; + id: string; + label: string; selected?: boolean; } @@ -2623,7 +2485,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -2635,7 +2497,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -2720,15 +2582,15 @@ interface RTCIceGatherOptions { } interface RTCIceParameters { - iceLite?: boolean; + iceLite?: boolean | null; password?: string; usernameFragment?: string; } interface RTCIceServer { - credential?: string; + credential?: string | null; urls?: any; - username?: string; + username?: string | null; } interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { @@ -2938,9 +2800,9 @@ interface RTCTransportStats extends RTCStats { } interface ScopedCredentialDescriptor { - id?: any; + id: any; transports?: Transport[]; - type?: ScopedCredentialType; + type: ScopedCredentialType; } interface ScopedCredentialOptions { @@ -2951,29 +2813,29 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - algorithm?: string | Algorithm; - type?: ScopedCredentialType; + algorithm: string | Algorithm; + type: ScopedCredentialType; } interface ServiceWorkerMessageEventInit extends EventInit { data?: any; lastEventId?: string; origin?: string; - ports?: MessagePort[]; - source?: ServiceWorker | MessagePort; + ports?: MessagePort[] | null; + source?: ServiceWorker | MessagePort | null; } interface SpeechSynthesisEventInit extends EventInit { charIndex?: number; elapsedTime?: number; name?: string; - utterance?: SpeechSynthesisUtterance; + utterance?: SpeechSynthesisUtterance | null; } interface StoreExceptionsInformation extends ExceptionInformation { - detailURI?: string; - explanationString?: string; - siteName?: string; + detailURI?: string | null; + explanationString?: string | null; + siteName?: string | null; } interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { @@ -2981,7 +2843,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat } interface TrackEventInit extends EventInit { - track?: VideoTrack | AudioTrack | TextTrack; + track?: VideoTrack | AudioTrack | TextTrack | null; } interface TransitionEventInit extends EventInit { @@ -2991,7 +2853,7 @@ interface TransitionEventInit extends EventInit { interface UIEventInit extends EventInit { detail?: number; - view?: Window; + view?: Window | null; } interface WebAuthnExtensions { @@ -3371,9 +3233,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -3385,7 +3247,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -4490,7 +4352,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ readonly compatMode: string; cookie: string; - readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly currentScript: HTMLScriptElement | SVGScriptElement | null; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -5229,7 +5091,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -5735,7 +5597,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface History { @@ -5895,7 +5757,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. */ declare: boolean; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -6133,7 +5995,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -6566,7 +6428,7 @@ interface HTMLFieldSetElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. @@ -7145,7 +7007,7 @@ interface HTMLInputElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -7312,7 +7174,7 @@ interface HTMLLabelElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the object to which the given label object is assigned. */ @@ -7334,7 +7196,7 @@ interface HTMLLegendElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7768,7 +7630,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -7867,7 +7729,7 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -7906,7 +7768,7 @@ interface HTMLOptionElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -7950,7 +7812,7 @@ declare var HTMLOptionsCollection: { interface HTMLOutputElement extends HTMLElement { defaultValue: string; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; readonly htmlFor: DOMSettableTokenList; name: string; readonly type: string; @@ -8039,7 +7901,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Defines the maximum, or "done" value for a progress element. */ @@ -8125,7 +7987,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the number of objects in a collection. */ @@ -8596,7 +8458,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the maximum number of characters that the user can enter in a text control. */ @@ -9062,6 +8924,7 @@ interface IntersectionObserverEntry { readonly rootBounds: ClientRect; readonly target: Element; readonly time: number; + readonly isIntersecting: boolean; } declare var IntersectionObserverEntry: { @@ -9163,7 +9026,7 @@ interface MediaDevicesEventMap { interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; - enumerateDevices(): any; + enumerateDevices(): Promise; getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; @@ -10909,6 +10772,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -11362,8 +11226,8 @@ interface ServiceWorkerContainer extends EventTarget { oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; readonly ready: Promise; - getRegistration(clientURL?: USVString): Promise; - getRegistrations(): any; + getRegistration(): Promise; + getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11399,7 +11263,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -13424,7 +13288,7 @@ declare var SVGZoomEvent: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -13732,6 +13596,7 @@ interface ValidityState { readonly typeMismatch: boolean; readonly valid: boolean; readonly valueMissing: boolean; + readonly tooShort: boolean; } declare var ValidityState: { @@ -15593,13 +15458,13 @@ interface NavigatorUserMedia { interface NodeSelector { querySelector(selectors: K): ElementTagNameMap[K] | null; - querySelector(selectors: string): Element | null; + querySelector(selectors: string): E | null; querySelectorAll(selectors: K): ElementListTagNameMap[K]; - querySelectorAll(selectors: string): NodeListOf; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; + getRandomValues(array: T): T; } interface SVGAnimatedPoints { @@ -15674,17 +15539,37 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -15775,8 +15660,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } @@ -16052,6 +15936,44 @@ interface TouchEventInit extends EventModifierInit { changedTouches?: Touch[]; } +interface HTMLDialogElement extends HTMLElement { + open: boolean; + returnValue: string; + close(returnValue?: string): void; + show(): void; + showModal(): void; +} + +declare var HTMLDialogElement: { + prototype: HTMLDialogElement; + new(): HTMLDialogElement; +}; + +interface HTMLMainElement extends HTMLElement { +} + +declare var HTMLMainElement: { + prototype: HTMLMainElement; + new(): HTMLMainElement; +}; + +interface HTMLDetailsElement extends HTMLElement { + open: boolean; +} + +declare var HTMLDetailsElement: { + prototype: HTMLDetailsElement; + new(): HTMLDetailsElement; +}; + +interface HTMLSummaryElement extends HTMLElement { +} + +declare var HTMLSummaryElement: { + prototype: HTMLSummaryElement; + new(): HTMLSummaryElement; +}; + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DecodeErrorCallback { @@ -16541,7 +16463,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; -type HeadersInit = any; +type HeadersInit = Headers | string[][]; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -16845,10 +16767,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -16874,8 +16804,9 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -16883,7 +16814,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -16915,8 +16846,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -16924,7 +16854,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; diff --git a/lib/lib.es2017.object.d.ts b/lib/lib.es2017.object.d.ts index 00c11be275d..7eecc25680d 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -42,4 +42,10 @@ interface ObjectConstructor { * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. */ entries(o: any): [string, any][]; + + /** + * Returns an object containing all own property descriptors of an object + * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. + */ + getOwnPropertyDescriptors(o: T): {[P in keyof T]: TypedPropertyDescriptor} & { [x: string]: PropertyDescriptor }; } diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index 8353dc1500f..73aa450927d 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -147,7 +147,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor | undefined; /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly @@ -1597,7 +1597,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1608,7 +1608,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1655,7 +1655,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1764,8 +1764,8 @@ interface Int8Array { interface Int8ArrayConstructor { readonly prototype: Int8Array; new(length: number): Int8Array; - new(array: ArrayLike): Int8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array; /** * The size in bytes of each element in the array. @@ -1864,7 +1864,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1875,7 +1875,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1922,7 +1922,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2032,8 +2032,8 @@ interface Uint8Array { interface Uint8ArrayConstructor { readonly prototype: Uint8Array; new(length: number): Uint8Array; - new(array: ArrayLike): Uint8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array; /** * The size in bytes of each element in the array. @@ -2131,7 +2131,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2142,7 +2142,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2189,7 +2189,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2299,8 +2299,8 @@ interface Uint8ClampedArray { interface Uint8ClampedArrayConstructor { readonly prototype: Uint8ClampedArray; new(length: number): Uint8ClampedArray; - new(array: ArrayLike): Uint8ClampedArray; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8ClampedArray; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray; /** * The size in bytes of each element in the array. @@ -2386,7 +2386,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; + filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2397,7 +2397,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2408,7 +2408,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2454,7 +2454,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2564,8 +2564,8 @@ interface Int16Array { interface Int16ArrayConstructor { readonly prototype: Int16Array; new(length: number): Int16Array; - new(array: ArrayLike): Int16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array; /** * The size in bytes of each element in the array. @@ -2664,7 +2664,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2675,7 +2675,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2722,7 +2722,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2832,8 +2832,8 @@ interface Uint16Array { interface Uint16ArrayConstructor { readonly prototype: Uint16Array; new(length: number): Uint16Array; - new(array: ArrayLike): Uint16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array; /** * The size in bytes of each element in the array. @@ -2931,7 +2931,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2942,7 +2942,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3099,8 +3099,8 @@ interface Int32Array { interface Int32ArrayConstructor { readonly prototype: Int32Array; new(length: number): Int32Array; - new(array: ArrayLike): Int32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array; /** * The size in bytes of each element in the array. @@ -3198,7 +3198,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3209,7 +3209,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3255,7 +3255,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3365,8 +3365,8 @@ interface Uint32Array { interface Uint32ArrayConstructor { readonly prototype: Uint32Array; new(length: number): Uint32Array; - new(array: ArrayLike): Uint32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array; /** * The size in bytes of each element in the array. @@ -3464,7 +3464,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3475,7 +3475,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3522,7 +3522,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3632,8 +3632,8 @@ interface Float32Array { interface Float32ArrayConstructor { readonly prototype: Float32Array; new(length: number): Float32Array; - new(array: ArrayLike): Float32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array; /** * The size in bytes of each element in the array. @@ -3732,7 +3732,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3743,7 +3743,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3790,7 +3790,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3900,8 +3900,8 @@ interface Float64Array { interface Float64ArrayConstructor { readonly prototype: Float64Array; new(length: number): Float64Array; - new(array: ArrayLike): Float64Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float64Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array; /** * The size in bytes of each element in the array. diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index b44acacc872..a84a66e1293 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -147,7 +147,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, p: string): PropertyDescriptor | undefined; /** * Returns the names of the own properties of an object. The own properties of an object are those that are defined directly @@ -1597,7 +1597,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1608,7 +1608,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1655,7 +1655,7 @@ interface Int8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; + map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1764,8 +1764,8 @@ interface Int8Array { interface Int8ArrayConstructor { readonly prototype: Int8Array; new(length: number): Int8Array; - new(array: ArrayLike): Int8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int8Array; /** * The size in bytes of each element in the array. @@ -1864,7 +1864,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1875,7 +1875,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1922,7 +1922,7 @@ interface Uint8Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; + map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2032,8 +2032,8 @@ interface Uint8Array { interface Uint8ArrayConstructor { readonly prototype: Uint8Array; new(length: number): Uint8Array; - new(array: ArrayLike): Uint8Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8Array; /** * The size in bytes of each element in the array. @@ -2131,7 +2131,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2142,7 +2142,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2189,7 +2189,7 @@ interface Uint8ClampedArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; + map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2299,8 +2299,8 @@ interface Uint8ClampedArray { interface Uint8ClampedArrayConstructor { readonly prototype: Uint8ClampedArray; new(length: number): Uint8ClampedArray; - new(array: ArrayLike): Uint8ClampedArray; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint8ClampedArray; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint8ClampedArray; /** * The size in bytes of each element in the array. @@ -2386,7 +2386,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; + filter(callbackfn: (value: number, index: number, array: Int16Array) => any, thisArg?: any): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2397,7 +2397,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2408,7 +2408,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2454,7 +2454,7 @@ interface Int16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; + map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2564,8 +2564,8 @@ interface Int16Array { interface Int16ArrayConstructor { readonly prototype: Int16Array; new(length: number): Int16Array; - new(array: ArrayLike): Int16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int16Array; /** * The size in bytes of each element in the array. @@ -2664,7 +2664,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2675,7 +2675,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2722,7 +2722,7 @@ interface Uint16Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; + map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2832,8 +2832,8 @@ interface Uint16Array { interface Uint16ArrayConstructor { readonly prototype: Uint16Array; new(length: number): Uint16Array; - new(array: ArrayLike): Uint16Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint16Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint16Array; /** * The size in bytes of each element in the array. @@ -2931,7 +2931,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2942,7 +2942,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3099,8 +3099,8 @@ interface Int32Array { interface Int32ArrayConstructor { readonly prototype: Int32Array; new(length: number): Int32Array; - new(array: ArrayLike): Int32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Int32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Int32Array; /** * The size in bytes of each element in the array. @@ -3198,7 +3198,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3209,7 +3209,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3255,7 +3255,7 @@ interface Uint32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; + map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3365,8 +3365,8 @@ interface Uint32Array { interface Uint32ArrayConstructor { readonly prototype: Uint32Array; new(length: number): Uint32Array; - new(array: ArrayLike): Uint32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Uint32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Uint32Array; /** * The size in bytes of each element in the array. @@ -3464,7 +3464,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3475,7 +3475,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3522,7 +3522,7 @@ interface Float32Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; + map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3632,8 +3632,8 @@ interface Float32Array { interface Float32ArrayConstructor { readonly prototype: Float32Array; new(length: number): Float32Array; - new(array: ArrayLike): Float32Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float32Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float32Array; /** * The size in bytes of each element in the array. @@ -3732,7 +3732,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3743,7 +3743,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3790,7 +3790,7 @@ interface Float64Array { * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ - map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; + map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3900,8 +3900,8 @@ interface Float64Array { interface Float64ArrayConstructor { readonly prototype: Float64Array; new(length: number): Float64Array; - new(array: ArrayLike): Float64Array; - new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array; + new(arrayOrArrayBuffer: ArrayLike | ArrayBufferLike): Float64Array; + new(buffer: ArrayBufferLike, byteOffset: number, length?: number): Float64Array; /** * The size in bytes of each element in the array. @@ -4094,9 +4094,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -4107,9 +4105,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -4140,22 +4136,13 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ - from(arrayLike: ArrayLike): Array; + from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; /** * Returns a new array from a set of elements. * @param items A set of elements to include in the new array object. */ - of(...items: T[]): Array; + of(...items: T[]): T[]; } interface DateConstructor { @@ -4424,7 +4411,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -4447,9 +4434,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -4460,9 +4445,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): number; } interface RegExp { @@ -4802,15 +4785,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ - from(iterable: Iterable): Array; + from(iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } interface ReadonlyArray { @@ -4965,10 +4940,6 @@ interface String { [Symbol.iterator](): IterableIterator; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** @@ -4994,17 +4965,9 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; - - from(arrayLike: Iterable): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** @@ -5030,17 +4993,9 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; - - from(arrayLike: Iterable): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** @@ -5069,17 +5024,9 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; - - from(arrayLike: Iterable): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** @@ -5107,17 +5054,9 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; - - from(arrayLike: Iterable): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** @@ -5143,17 +5082,9 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; - - from(arrayLike: Iterable): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** @@ -5179,17 +5110,9 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; - - from(arrayLike: Iterable): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** @@ -5215,17 +5138,9 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; - - from(arrayLike: Iterable): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** @@ -5251,17 +5166,9 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; - - from(arrayLike: Iterable): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** @@ -5287,11 +5194,7 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; - - from(arrayLike: Iterable): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } @@ -5529,11 +5432,11 @@ declare namespace Reflect { function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: object, propertyKey: PropertyKey): boolean; function get(target: object, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined; function getPrototypeOf(target: object): object; function has(target: object, propertyKey: PropertyKey): boolean; function isExtensible(target: object): boolean; - function ownKeys(target: object): Array; + function ownKeys(target: object): PropertyKey[]; function preventExtensions(target: object): boolean; function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: object, proto: any): boolean; @@ -5819,12 +5722,6 @@ interface String { split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -5833,74 +5730,38 @@ interface DataView { readonly [Symbol.toStringTag]: "DataView"; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } @@ -5912,11 +5773,11 @@ interface Float64Array { ///////////////////////////// interface Account { - displayName?: string; - id?: string; + displayName: string; + id: string; imageURL?: string; name?: string; - rpDisplayName?: string; + rpDisplayName: string; } interface Algorithm { @@ -5943,11 +5804,11 @@ interface CacheQueryOptions { } interface ClientData { - challenge?: string; + challenge: string; extensions?: WebAuthnExtensions; - hashAlg?: string | Algorithm; - origin?: string; - rpId?: string; + hashAlg: string | Algorithm; + origin: string; + rpId: string; tokenBinding?: string; } @@ -5995,9 +5856,9 @@ interface CustomEventInit extends EventInit { } interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; + x?: number | null; + y?: number | null; + z?: number | null; } interface DeviceLightEventInit extends EventInit { @@ -6005,30 +5866,30 @@ interface DeviceLightEventInit extends EventInit { } interface DeviceMotionEventInit extends EventInit { - acceleration?: DeviceAccelerationDict; - accelerationIncludingGravity?: DeviceAccelerationDict; - interval?: number; - rotationRate?: DeviceRotationRateDict; + acceleration?: DeviceAccelerationDict | null; + accelerationIncludingGravity?: DeviceAccelerationDict | null; + interval?: number | null; + rotationRate?: DeviceRotationRateDict | null; } interface DeviceOrientationEventInit extends EventInit { absolute?: boolean; - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DOMRectInit { - height?: any; - width?: any; - x?: any; - y?: any; + height?: number; + width?: number; + x?: number; + y?: number; } interface DoubleRange { @@ -6069,15 +5930,15 @@ interface EventModifierInit extends UIEventInit { } interface ExceptionInformation { - domain?: string; + domain?: string | null; } interface FocusEventInit extends UIEventInit { - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; } interface FocusNavigationEventInit extends EventInit { - navigationReason?: string; + navigationReason?: string | null; originHeight?: number; originLeft?: number; originTop?: number; @@ -6092,7 +5953,7 @@ interface FocusNavigationOrigin { } interface GamepadEventInit extends EventInit { - gamepad?: Gamepad; + gamepad?: Gamepad | null; } interface GetNotificationOptions { @@ -6100,8 +5961,8 @@ interface GetNotificationOptions { } interface HashChangeEventInit extends EventInit { - newURL?: string; - oldURL?: string; + newURL?: string | null; + oldURL?: string | null; } interface IDBIndexParameters { @@ -6111,19 +5972,20 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface IntersectionObserverEntryInit { - boundingClientRect?: DOMRectInit; - intersectionRect?: DOMRectInit; - rootBounds?: DOMRectInit; - target?: Element; - time?: number; + isIntersecting: boolean; + boundingClientRect: DOMRectInit; + intersectionRect: DOMRectInit; + rootBounds: DOMRectInit; + target: Element; + time: number; } interface IntersectionObserverInit { - root?: Element; + root?: Element | null; rootMargin?: string; threshold?: number | number[]; } @@ -6145,12 +6007,12 @@ interface LongRange { } interface MediaEncryptedEventInit extends EventInit { - initData?: ArrayBuffer; + initData?: ArrayBuffer | null; initDataType?: string; } interface MediaKeyMessageEventInit extends EventInit { - message?: ArrayBuffer; + message?: ArrayBuffer | null; messageType?: MediaKeyMessageType; } @@ -6173,7 +6035,7 @@ interface MediaStreamConstraints { } interface MediaStreamErrorEventInit extends EventInit { - error?: MediaStreamError; + error?: MediaStreamError | null; } interface MediaStreamEventInit extends EventInit { @@ -6181,7 +6043,7 @@ interface MediaStreamEventInit extends EventInit { } interface MediaStreamTrackEventInit extends EventInit { - track?: MediaStreamTrack; + track?: MediaStreamTrack | null; } interface MediaTrackCapabilities { @@ -6258,7 +6120,7 @@ interface MouseEventInit extends EventModifierInit { buttons?: number; clientX?: number; clientY?: number; - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; screenX?: number; screenY?: number; } @@ -6266,8 +6128,8 @@ interface MouseEventInit extends EventModifierInit { interface MSAccountInfo { accountImageUri?: string; accountName?: string; - rpDisplayName?: string; - userDisplayName?: string; + rpDisplayName: string; + userDisplayName: string; userId?: string; } @@ -6350,7 +6212,7 @@ interface MSCredentialParameters { interface MSCredentialSpec { id?: string; - type?: MSCredentialType; + type: MSCredentialType; } interface MSDelay { @@ -6560,8 +6422,8 @@ interface MsZoomToOptions { contentX?: number; contentY?: number; scaleFactor?: number; - viewportX?: string; - viewportY?: string; + viewportX?: string | null; + viewportY?: string | null; } interface MutationObserverInit { @@ -6587,9 +6449,9 @@ interface ObjectURLOptions { } interface PaymentCurrencyAmount { - currency?: string; + currency: string; currencySystem?: string; - value?: string; + value: string; } interface PaymentDetails { @@ -6603,19 +6465,19 @@ interface PaymentDetails { interface PaymentDetailsModifier { additionalDisplayItems?: PaymentItem[]; data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; total?: PaymentItem; } interface PaymentItem { - amount?: PaymentCurrencyAmount; - label?: string; + amount: PaymentCurrencyAmount; + label: string; pending?: boolean; } interface PaymentMethodData { data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; } interface PaymentOptions { @@ -6630,9 +6492,9 @@ interface PaymentRequestUpdateEventInit extends EventInit { } interface PaymentShippingOption { - amount?: PaymentCurrencyAmount; - id?: string; - label?: string; + amount: PaymentCurrencyAmount; + id: string; + label: string; selected?: boolean; } @@ -6680,7 +6542,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -6692,7 +6554,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -6777,15 +6639,15 @@ interface RTCIceGatherOptions { } interface RTCIceParameters { - iceLite?: boolean; + iceLite?: boolean | null; password?: string; usernameFragment?: string; } interface RTCIceServer { - credential?: string; + credential?: string | null; urls?: any; - username?: string; + username?: string | null; } interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { @@ -6995,9 +6857,9 @@ interface RTCTransportStats extends RTCStats { } interface ScopedCredentialDescriptor { - id?: any; + id: any; transports?: Transport[]; - type?: ScopedCredentialType; + type: ScopedCredentialType; } interface ScopedCredentialOptions { @@ -7008,29 +6870,29 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - algorithm?: string | Algorithm; - type?: ScopedCredentialType; + algorithm: string | Algorithm; + type: ScopedCredentialType; } interface ServiceWorkerMessageEventInit extends EventInit { data?: any; lastEventId?: string; origin?: string; - ports?: MessagePort[]; - source?: ServiceWorker | MessagePort; + ports?: MessagePort[] | null; + source?: ServiceWorker | MessagePort | null; } interface SpeechSynthesisEventInit extends EventInit { charIndex?: number; elapsedTime?: number; name?: string; - utterance?: SpeechSynthesisUtterance; + utterance?: SpeechSynthesisUtterance | null; } interface StoreExceptionsInformation extends ExceptionInformation { - detailURI?: string; - explanationString?: string; - siteName?: string; + detailURI?: string | null; + explanationString?: string | null; + siteName?: string | null; } interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { @@ -7038,7 +6900,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat } interface TrackEventInit extends EventInit { - track?: VideoTrack | AudioTrack | TextTrack; + track?: VideoTrack | AudioTrack | TextTrack | null; } interface TransitionEventInit extends EventInit { @@ -7048,7 +6910,7 @@ interface TransitionEventInit extends EventInit { interface UIEventInit extends EventInit { detail?: number; - view?: Window; + view?: Window | null; } interface WebAuthnExtensions { @@ -7428,9 +7290,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -7442,7 +7304,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -8547,7 +8409,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ readonly compatMode: string; cookie: string; - readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly currentScript: HTMLScriptElement | SVGScriptElement | null; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -9286,7 +9148,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -9792,7 +9654,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface History { @@ -9952,7 +9814,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. */ declare: boolean; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -10190,7 +10052,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -10623,7 +10485,7 @@ interface HTMLFieldSetElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. @@ -11202,7 +11064,7 @@ interface HTMLInputElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -11369,7 +11231,7 @@ interface HTMLLabelElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the object to which the given label object is assigned. */ @@ -11391,7 +11253,7 @@ interface HTMLLegendElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -11825,7 +11687,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -11924,7 +11786,7 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -11963,7 +11825,7 @@ interface HTMLOptionElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -12007,7 +11869,7 @@ declare var HTMLOptionsCollection: { interface HTMLOutputElement extends HTMLElement { defaultValue: string; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; readonly htmlFor: DOMSettableTokenList; name: string; readonly type: string; @@ -12096,7 +11958,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Defines the maximum, or "done" value for a progress element. */ @@ -12182,7 +12044,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the number of objects in a collection. */ @@ -12653,7 +12515,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the maximum number of characters that the user can enter in a text control. */ @@ -13119,6 +12981,7 @@ interface IntersectionObserverEntry { readonly rootBounds: ClientRect; readonly target: Element; readonly time: number; + readonly isIntersecting: boolean; } declare var IntersectionObserverEntry: { @@ -13220,7 +13083,7 @@ interface MediaDevicesEventMap { interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; - enumerateDevices(): any; + enumerateDevices(): Promise; getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; @@ -14966,6 +14829,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -15419,8 +15283,8 @@ interface ServiceWorkerContainer extends EventTarget { oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; readonly ready: Promise; - getRegistration(clientURL?: USVString): Promise; - getRegistrations(): any; + getRegistration(): Promise; + getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -15456,7 +15320,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -17481,7 +17345,7 @@ declare var SVGZoomEvent: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -17789,6 +17653,7 @@ interface ValidityState { readonly typeMismatch: boolean; readonly valid: boolean; readonly valueMissing: boolean; + readonly tooShort: boolean; } declare var ValidityState: { @@ -19650,13 +19515,13 @@ interface NavigatorUserMedia { interface NodeSelector { querySelector(selectors: K): ElementTagNameMap[K] | null; - querySelector(selectors: string): Element | null; + querySelector(selectors: string): E | null; querySelectorAll(selectors: K): ElementListTagNameMap[K]; - querySelectorAll(selectors: string): NodeListOf; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; + getRandomValues(array: T): T; } interface SVGAnimatedPoints { @@ -19731,17 +19596,37 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -19832,8 +19717,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } @@ -20109,6 +19993,44 @@ interface TouchEventInit extends EventModifierInit { changedTouches?: Touch[]; } +interface HTMLDialogElement extends HTMLElement { + open: boolean; + returnValue: string; + close(returnValue?: string): void; + show(): void; + showModal(): void; +} + +declare var HTMLDialogElement: { + prototype: HTMLDialogElement; + new(): HTMLDialogElement; +}; + +interface HTMLMainElement extends HTMLElement { +} + +declare var HTMLMainElement: { + prototype: HTMLMainElement; + new(): HTMLMainElement; +}; + +interface HTMLDetailsElement extends HTMLElement { + open: boolean; +} + +declare var HTMLDetailsElement: { + prototype: HTMLDetailsElement; + new(): HTMLDetailsElement; +}; + +interface HTMLSummaryElement extends HTMLElement { +} + +declare var HTMLSummaryElement: { + prototype: HTMLSummaryElement; + new(): HTMLSummaryElement; +}; + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DecodeErrorCallback { @@ -20598,7 +20520,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; -type HeadersInit = any; +type HeadersInit = Headers | string[][]; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -20902,10 +20824,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -20931,8 +20861,9 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -20940,7 +20871,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -20972,8 +20903,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -20981,7 +20911,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; diff --git a/lib/lib.esnext.full.d.ts b/lib/lib.esnext.full.d.ts index f7b59da3002..4ee476dfd1a 100644 --- a/lib/lib.esnext.full.d.ts +++ b/lib/lib.esnext.full.d.ts @@ -34,9 +34,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -47,9 +45,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -80,22 +76,13 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U): Array; - from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - - /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ - from(arrayLike: ArrayLike): Array; + from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; /** * Returns a new array from a set of elements. * @param items A set of elements to include in the new array object. */ - of(...items: T[]): Array; + of(...items: T[]): T[]; } interface DateConstructor { @@ -364,7 +351,7 @@ interface ObjectConstructor { * @param o Object that contains the property. * @param p Name of the property. */ - getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor(o: any, propertyKey: PropertyKey): PropertyDescriptor | undefined; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -387,9 +374,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; - find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; - find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -400,9 +385,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean): number; - findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; - findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; + findIndex(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): number; } interface RegExp { @@ -742,15 +725,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U): Array; - from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; - from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; - - /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ - from(iterable: Iterable): Array; + from(iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } interface ReadonlyArray { @@ -905,10 +880,6 @@ interface String { [Symbol.iterator](): IterableIterator; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** @@ -934,17 +905,9 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; - - from(arrayLike: Iterable): Int8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** @@ -970,17 +933,9 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; - - from(arrayLike: Iterable): Uint8Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** @@ -1009,17 +964,9 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; - - from(arrayLike: Iterable): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** @@ -1047,17 +994,9 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; - - from(arrayLike: Iterable): Int16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** @@ -1083,17 +1022,9 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; - - from(arrayLike: Iterable): Uint16Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** @@ -1119,17 +1050,9 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Int32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; - - from(arrayLike: Iterable): Int32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** @@ -1155,17 +1078,9 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; - - from(arrayLike: Iterable): Uint32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** @@ -1191,17 +1106,9 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float32Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; - - from(arrayLike: Iterable): Float32Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** @@ -1227,11 +1134,7 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number): Float64Array; - from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; - from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; - - from(arrayLike: Iterable): Float64Array; + from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } @@ -1469,11 +1372,11 @@ declare namespace Reflect { function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; function deleteProperty(target: object, propertyKey: PropertyKey): boolean; function get(target: object, propertyKey: PropertyKey, receiver?: any): any; - function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor | undefined; function getPrototypeOf(target: object): object; function has(target: object, propertyKey: PropertyKey): boolean; function isExtensible(target: object): boolean; - function ownKeys(target: object): Array; + function ownKeys(target: object): PropertyKey[]; function preventExtensions(target: object): boolean; function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: object, proto: any): boolean; @@ -1759,12 +1662,6 @@ interface String { split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -1773,74 +1670,38 @@ interface DataView { readonly [Symbol.toStringTag]: "DataView"; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } @@ -1852,11 +1713,11 @@ interface Float64Array { ///////////////////////////// interface Account { - displayName?: string; - id?: string; + displayName: string; + id: string; imageURL?: string; name?: string; - rpDisplayName?: string; + rpDisplayName: string; } interface Algorithm { @@ -1883,11 +1744,11 @@ interface CacheQueryOptions { } interface ClientData { - challenge?: string; + challenge: string; extensions?: WebAuthnExtensions; - hashAlg?: string | Algorithm; - origin?: string; - rpId?: string; + hashAlg: string | Algorithm; + origin: string; + rpId: string; tokenBinding?: string; } @@ -1935,9 +1796,9 @@ interface CustomEventInit extends EventInit { } interface DeviceAccelerationDict { - x?: number; - y?: number; - z?: number; + x?: number | null; + y?: number | null; + z?: number | null; } interface DeviceLightEventInit extends EventInit { @@ -1945,30 +1806,30 @@ interface DeviceLightEventInit extends EventInit { } interface DeviceMotionEventInit extends EventInit { - acceleration?: DeviceAccelerationDict; - accelerationIncludingGravity?: DeviceAccelerationDict; - interval?: number; - rotationRate?: DeviceRotationRateDict; + acceleration?: DeviceAccelerationDict | null; + accelerationIncludingGravity?: DeviceAccelerationDict | null; + interval?: number | null; + rotationRate?: DeviceRotationRateDict | null; } interface DeviceOrientationEventInit extends EventInit { absolute?: boolean; - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DeviceRotationRateDict { - alpha?: number; - beta?: number; - gamma?: number; + alpha?: number | null; + beta?: number | null; + gamma?: number | null; } interface DOMRectInit { - height?: any; - width?: any; - x?: any; - y?: any; + height?: number; + width?: number; + x?: number; + y?: number; } interface DoubleRange { @@ -2009,15 +1870,15 @@ interface EventModifierInit extends UIEventInit { } interface ExceptionInformation { - domain?: string; + domain?: string | null; } interface FocusEventInit extends UIEventInit { - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; } interface FocusNavigationEventInit extends EventInit { - navigationReason?: string; + navigationReason?: string | null; originHeight?: number; originLeft?: number; originTop?: number; @@ -2032,7 +1893,7 @@ interface FocusNavigationOrigin { } interface GamepadEventInit extends EventInit { - gamepad?: Gamepad; + gamepad?: Gamepad | null; } interface GetNotificationOptions { @@ -2040,8 +1901,8 @@ interface GetNotificationOptions { } interface HashChangeEventInit extends EventInit { - newURL?: string; - oldURL?: string; + newURL?: string | null; + oldURL?: string | null; } interface IDBIndexParameters { @@ -2051,19 +1912,20 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface IntersectionObserverEntryInit { - boundingClientRect?: DOMRectInit; - intersectionRect?: DOMRectInit; - rootBounds?: DOMRectInit; - target?: Element; - time?: number; + isIntersecting: boolean; + boundingClientRect: DOMRectInit; + intersectionRect: DOMRectInit; + rootBounds: DOMRectInit; + target: Element; + time: number; } interface IntersectionObserverInit { - root?: Element; + root?: Element | null; rootMargin?: string; threshold?: number | number[]; } @@ -2085,12 +1947,12 @@ interface LongRange { } interface MediaEncryptedEventInit extends EventInit { - initData?: ArrayBuffer; + initData?: ArrayBuffer | null; initDataType?: string; } interface MediaKeyMessageEventInit extends EventInit { - message?: ArrayBuffer; + message?: ArrayBuffer | null; messageType?: MediaKeyMessageType; } @@ -2113,7 +1975,7 @@ interface MediaStreamConstraints { } interface MediaStreamErrorEventInit extends EventInit { - error?: MediaStreamError; + error?: MediaStreamError | null; } interface MediaStreamEventInit extends EventInit { @@ -2121,7 +1983,7 @@ interface MediaStreamEventInit extends EventInit { } interface MediaStreamTrackEventInit extends EventInit { - track?: MediaStreamTrack; + track?: MediaStreamTrack | null; } interface MediaTrackCapabilities { @@ -2198,7 +2060,7 @@ interface MouseEventInit extends EventModifierInit { buttons?: number; clientX?: number; clientY?: number; - relatedTarget?: EventTarget; + relatedTarget?: EventTarget | null; screenX?: number; screenY?: number; } @@ -2206,8 +2068,8 @@ interface MouseEventInit extends EventModifierInit { interface MSAccountInfo { accountImageUri?: string; accountName?: string; - rpDisplayName?: string; - userDisplayName?: string; + rpDisplayName: string; + userDisplayName: string; userId?: string; } @@ -2290,7 +2152,7 @@ interface MSCredentialParameters { interface MSCredentialSpec { id?: string; - type?: MSCredentialType; + type: MSCredentialType; } interface MSDelay { @@ -2500,8 +2362,8 @@ interface MsZoomToOptions { contentX?: number; contentY?: number; scaleFactor?: number; - viewportX?: string; - viewportY?: string; + viewportX?: string | null; + viewportY?: string | null; } interface MutationObserverInit { @@ -2527,9 +2389,9 @@ interface ObjectURLOptions { } interface PaymentCurrencyAmount { - currency?: string; + currency: string; currencySystem?: string; - value?: string; + value: string; } interface PaymentDetails { @@ -2543,19 +2405,19 @@ interface PaymentDetails { interface PaymentDetailsModifier { additionalDisplayItems?: PaymentItem[]; data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; total?: PaymentItem; } interface PaymentItem { - amount?: PaymentCurrencyAmount; - label?: string; + amount: PaymentCurrencyAmount; + label: string; pending?: boolean; } interface PaymentMethodData { data?: any; - supportedMethods?: string[]; + supportedMethods: string[]; } interface PaymentOptions { @@ -2570,9 +2432,9 @@ interface PaymentRequestUpdateEventInit extends EventInit { } interface PaymentShippingOption { - amount?: PaymentCurrencyAmount; - id?: string; - label?: string; + amount: PaymentCurrencyAmount; + id: string; + label: string; selected?: boolean; } @@ -2620,7 +2482,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -2632,7 +2494,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -2717,15 +2579,15 @@ interface RTCIceGatherOptions { } interface RTCIceParameters { - iceLite?: boolean; + iceLite?: boolean | null; password?: string; usernameFragment?: string; } interface RTCIceServer { - credential?: string; + credential?: string | null; urls?: any; - username?: string; + username?: string | null; } interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { @@ -2935,9 +2797,9 @@ interface RTCTransportStats extends RTCStats { } interface ScopedCredentialDescriptor { - id?: any; + id: any; transports?: Transport[]; - type?: ScopedCredentialType; + type: ScopedCredentialType; } interface ScopedCredentialOptions { @@ -2948,29 +2810,29 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - algorithm?: string | Algorithm; - type?: ScopedCredentialType; + algorithm: string | Algorithm; + type: ScopedCredentialType; } interface ServiceWorkerMessageEventInit extends EventInit { data?: any; lastEventId?: string; origin?: string; - ports?: MessagePort[]; - source?: ServiceWorker | MessagePort; + ports?: MessagePort[] | null; + source?: ServiceWorker | MessagePort | null; } interface SpeechSynthesisEventInit extends EventInit { charIndex?: number; elapsedTime?: number; name?: string; - utterance?: SpeechSynthesisUtterance; + utterance?: SpeechSynthesisUtterance | null; } interface StoreExceptionsInformation extends ExceptionInformation { - detailURI?: string; - explanationString?: string; - siteName?: string; + detailURI?: string | null; + explanationString?: string | null; + siteName?: string | null; } interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { @@ -2978,7 +2840,7 @@ interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformat } interface TrackEventInit extends EventInit { - track?: VideoTrack | AudioTrack | TextTrack; + track?: VideoTrack | AudioTrack | TextTrack | null; } interface TransitionEventInit extends EventInit { @@ -2988,7 +2850,7 @@ interface TransitionEventInit extends EventInit { interface UIEventInit extends EventInit { detail?: number; - view?: Window; + view?: Window | null; } interface WebAuthnExtensions { @@ -3368,9 +3230,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -3382,7 +3244,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -4487,7 +4349,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ readonly compatMode: string; cookie: string; - readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly currentScript: HTMLScriptElement | SVGScriptElement | null; readonly defaultView: Window; /** * Sets or gets a value that indicates whether the document can be edited. @@ -5226,7 +5088,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -5732,7 +5594,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface History { @@ -5892,7 +5754,7 @@ interface HTMLAppletElement extends HTMLElement { * Sets or retrieves a character string that can be used to implement your own declare functionality for the object. */ declare: boolean; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -6130,7 +5992,7 @@ interface HTMLButtonElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -6563,7 +6425,7 @@ interface HTMLFieldSetElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; name: string; /** * Returns the error message that would be displayed if the user submits the form, or an empty string if no error message. It also triggers the standard error message, such as "this is a required field". The result is that the user sees validation messages without actually submitting. @@ -7142,7 +7004,7 @@ interface HTMLInputElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Overrides the action attribute (where the data on a form is sent) on the parent form element. */ @@ -7309,7 +7171,7 @@ interface HTMLLabelElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the object to which the given label object is assigned. */ @@ -7331,7 +7193,7 @@ interface HTMLLegendElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -7765,7 +7627,7 @@ interface HTMLObjectElement extends HTMLElement, GetSVGDocument { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the height of the object. */ @@ -7864,7 +7726,7 @@ interface HTMLOptGroupElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -7903,7 +7765,7 @@ interface HTMLOptionElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the ordinal position of an option in a list box. */ @@ -7947,7 +7809,7 @@ declare var HTMLOptionsCollection: { interface HTMLOutputElement extends HTMLElement { defaultValue: string; - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; readonly htmlFor: DOMSettableTokenList; name: string; readonly type: string; @@ -8036,7 +7898,7 @@ interface HTMLProgressElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Defines the maximum, or "done" value for a progress element. */ @@ -8122,7 +7984,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the number of objects in a collection. */ @@ -8593,7 +8455,7 @@ interface HTMLTextAreaElement extends HTMLElement { /** * Retrieves a reference to the form that the object is embedded in. */ - readonly form: HTMLFormElement; + readonly form: HTMLFormElement | null; /** * Sets or retrieves the maximum number of characters that the user can enter in a text control. */ @@ -9059,6 +8921,7 @@ interface IntersectionObserverEntry { readonly rootBounds: ClientRect; readonly target: Element; readonly time: number; + readonly isIntersecting: boolean; } declare var IntersectionObserverEntry: { @@ -9160,7 +9023,7 @@ interface MediaDevicesEventMap { interface MediaDevices extends EventTarget { ondevicechange: (this: MediaDevices, ev: Event) => any; - enumerateDevices(): any; + enumerateDevices(): Promise; getSupportedConstraints(): MediaTrackSupportedConstraints; getUserMedia(constraints: MediaStreamConstraints): Promise; addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; @@ -10906,6 +10769,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -11359,8 +11223,8 @@ interface ServiceWorkerContainer extends EventTarget { oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; readonly ready: Promise; - getRegistration(clientURL?: USVString): Promise; - getRegistrations(): any; + getRegistration(): Promise; + getRegistrations(): Promise; register(scriptURL: USVString, options?: RegistrationOptions): Promise; addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11396,7 +11260,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -13421,7 +13285,7 @@ declare var SVGZoomEvent: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -13729,6 +13593,7 @@ interface ValidityState { readonly typeMismatch: boolean; readonly valid: boolean; readonly valueMissing: boolean; + readonly tooShort: boolean; } declare var ValidityState: { @@ -15590,13 +15455,13 @@ interface NavigatorUserMedia { interface NodeSelector { querySelector(selectors: K): ElementTagNameMap[K] | null; - querySelector(selectors: string): Element | null; + querySelector(selectors: string): E | null; querySelectorAll(selectors: K): ElementListTagNameMap[K]; - querySelectorAll(selectors: string): NodeListOf; + querySelectorAll(selectors: string): NodeListOf; } interface RandomSource { - getRandomValues(array: ArrayBufferView): ArrayBufferView; + getRandomValues(array: T): T; } interface SVGAnimatedPoints { @@ -15671,17 +15536,37 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -15772,8 +15657,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } @@ -16049,6 +15933,44 @@ interface TouchEventInit extends EventModifierInit { changedTouches?: Touch[]; } +interface HTMLDialogElement extends HTMLElement { + open: boolean; + returnValue: string; + close(returnValue?: string): void; + show(): void; + showModal(): void; +} + +declare var HTMLDialogElement: { + prototype: HTMLDialogElement; + new(): HTMLDialogElement; +}; + +interface HTMLMainElement extends HTMLElement { +} + +declare var HTMLMainElement: { + prototype: HTMLMainElement; + new(): HTMLMainElement; +}; + +interface HTMLDetailsElement extends HTMLElement { + open: boolean; +} + +declare var HTMLDetailsElement: { + prototype: HTMLDetailsElement; + new(): HTMLDetailsElement; +}; + +interface HTMLSummaryElement extends HTMLElement { +} + +declare var HTMLSummaryElement: { + prototype: HTMLSummaryElement; + new(): HTMLSummaryElement; +}; + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface DecodeErrorCallback { @@ -16538,7 +16460,7 @@ type GLsizeiptr = number; type GLubyte = number; type GLuint = number; type GLushort = number; -type HeadersInit = any; +type HeadersInit = Headers | string[][]; type IDBKeyPath = string; type KeyFormat = string; type KeyType = string; @@ -16842,10 +16764,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -16871,8 +16801,9 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -16880,7 +16811,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -16912,8 +16843,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -16921,7 +16851,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; diff --git a/lib/lib.scripthost.d.ts b/lib/lib.scripthost.d.ts index 47cfaa7fb8c..149653a8971 100644 --- a/lib/lib.scripthost.d.ts +++ b/lib/lib.scripthost.d.ts @@ -221,10 +221,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -250,8 +258,9 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -259,7 +268,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -291,8 +300,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -300,7 +308,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index 997b007a879..f87d32110a6 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -57,7 +57,7 @@ interface IDBIndexParameters { interface IDBObjectStoreParameters { autoIncrement?: boolean; - keyPath?: IDBKeyPath; + keyPath?: IDBKeyPath | null; } interface KeyAlgorithm { @@ -94,7 +94,7 @@ interface RequestInit { body?: any; cache?: RequestCache; credentials?: RequestCredentials; - headers?: any; + headers?: Headers | string[][]; integrity?: string; keepalive?: boolean; method?: string; @@ -106,7 +106,7 @@ interface RequestInit { } interface ResponseInit { - headers?: any; + headers?: Headers | string[][]; status?: number; statusText?: string; } @@ -123,18 +123,18 @@ interface ExtendableMessageEventInit extends ExtendableEventInit { data?: any; origin?: string; lastEventId?: string; - source?: Client | ServiceWorker | MessagePort; - ports?: MessagePort[]; + source?: Client | ServiceWorker | MessagePort | null; + ports?: MessagePort[] | null; } interface FetchEventInit extends ExtendableEventInit { - request?: Request; - clientId?: string; + request: Request; + clientId?: string | null; isReload?: boolean; } interface NotificationEventInit extends ExtendableEventInit { - notification?: Notification; + notification: Notification; action?: string; } @@ -143,7 +143,7 @@ interface PushEventInit extends ExtendableEventInit { } interface SyncEventInit extends ExtendableEventInit { - tag?: string; + tag: string; lastChance?: boolean; } @@ -195,9 +195,9 @@ interface Cache { add(request: RequestInfo): Promise; addAll(requests: RequestInfo[]): Promise; delete(request: RequestInfo, options?: CacheQueryOptions): Promise; - keys(request?: RequestInfo, options?: CacheQueryOptions): any; + keys(request?: RequestInfo, options?: CacheQueryOptions): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; - matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): Promise; put(request: RequestInfo, response: Response): Promise; } @@ -209,7 +209,7 @@ declare var Cache: { interface CacheStorage { delete(cacheName: string): Promise; has(cacheName: string): Promise; - keys(): any; + keys(): Promise; match(request: RequestInfo, options?: CacheQueryOptions): Promise; open(cacheName: string): Promise; } @@ -334,7 +334,7 @@ interface DOMException { declare var DOMException: { prototype: DOMException; - new(): DOMException; + new(message?: string, name?: string): DOMException; readonly ABORT_ERR: number; readonly DATA_CLONE_ERR: number; readonly DOMSTRING_SIZE_ERR: number; @@ -490,7 +490,7 @@ interface Headers { declare var Headers: { prototype: Headers; - new(init?: any): Headers; + new(init?: Headers | string[][] | object): Headers; }; interface IDBCursor { @@ -980,6 +980,7 @@ interface Response extends Object, Body { readonly statusText: string; readonly type: ResponseType; readonly url: string; + readonly redirected: boolean; clone(): Response; } @@ -1020,7 +1021,7 @@ interface ServiceWorkerRegistration extends EventTarget { readonly scope: USVString; readonly sync: SyncManager; readonly waiting: ServiceWorker | null; - getNotifications(filter?: GetNotificationOptions): any; + getNotifications(filter?: GetNotificationOptions): Promise; showNotification(title: string, options?: NotificationOptions): Promise; unregister(): Promise; update(): Promise; @@ -1034,7 +1035,7 @@ declare var ServiceWorkerRegistration: { }; interface SyncManager { - getTags(): any; + getTags(): Promise; register(tag: string): Promise; } @@ -1268,13 +1269,13 @@ interface XMLHttpRequestEventTargetEventMap { } interface XMLHttpRequestEventTarget { - onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; - onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; - onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; - ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onabort: (this: XMLHttpRequest, ev: Event) => any; + onerror: (this: XMLHttpRequest, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequest, ev: Event) => any; + onloadend: (this: XMLHttpRequest, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequest, ev: Event) => any; + onprogress: (this: XMLHttpRequest, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequest, ev: ProgressEvent) => any; addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -1294,7 +1295,7 @@ declare var Client: { interface Clients { claim(): Promise; get(id: string): Promise; - matchAll(options?: ClientQueryOptions): any; + matchAll(options?: ClientQueryOptions): Promise; openWindow(url: USVString): Promise; } @@ -1519,6 +1520,26 @@ interface WorkerUtils extends Object, WindowBase64 { setTimeout(handler: any, timeout?: any, ...args: any[]): number; } +interface BroadcastChannel extends EventTarget { + readonly name: string; + onmessage: (ev: MessageEvent) => any; + onmessageerror: (ev: MessageEvent) => any; + close(): void; + postMessage(message: any): void; + addEventListener(type: K, listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var BroadcastChannel: { + prototype: BroadcastChannel; + new(name: string): BroadcastChannel; +}; + +interface BroadcastChannelEventMap { + message: MessageEvent; + messageerror: MessageEvent; +} + interface ErrorEventInit { message?: string; filename?: string; @@ -1582,8 +1603,7 @@ interface BlobPropertyBag { endings?: string; } -interface FilePropertyBag { - type?: string; +interface FilePropertyBag extends BlobPropertyBag { lastModified?: number; } diff --git a/lib/tsc.js b/lib/tsc.js index cf9717975cf..a6650351530 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -695,6 +695,7 @@ var ts; TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 6368] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; @@ -1055,6 +1056,7 @@ var ts; EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; + EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); var ExternalEmitHelpers; (function (ExternalEmitHelpers) { @@ -1087,7 +1089,8 @@ var ts; EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; EmitHint[EmitHint["Expression"] = 1] = "Expression"; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; - EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; + EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; @@ -1154,6 +1157,12 @@ var ts; ts.versionMajorMinor = "2.6"; ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); +(function (ts) { + function isExternalModuleNameRelative(moduleName) { + return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; +})(ts || (ts = {})); (function (ts) { ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; @@ -1785,6 +1794,26 @@ var ts; return to; } ts.addRange = addRange; + function pushIfUnique(array, toAdd) { + if (contains(array, toAdd)) { + return false; + } + else { + array.push(toAdd); + return true; + } + } + ts.pushIfUnique = pushIfUnique; + function appendIfUnique(array, toAdd) { + if (array) { + pushIfUnique(array, toAdd); + return array; + } + else { + return [toAdd]; + } + } + ts.appendIfUnique = appendIfUnique; function stableSort(array, comparer) { if (comparer === void 0) { comparer = compareValues; } return array @@ -1931,6 +1960,16 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getOwnValues(sparseArray) { + var values = []; + for (var key in sparseArray) { + if (hasOwnProperty.call(sparseArray, key)) { + values.push(sparseArray[key]); + } + } + return values; + } + ts.getOwnValues = getOwnValues; function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { @@ -2095,6 +2134,8 @@ var ts; ts.cast = cast; function noop() { } ts.noop = noop; + function identity(x) { return x; } + ts.identity = identity; function notImplemented() { throw new Error("Not implemented"); } @@ -2171,12 +2212,11 @@ var ts; } ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { - var end = start + length; Debug.assertGreaterThanOrEqual(start, 0); Debug.assertGreaterThanOrEqual(length, 0); if (file) { Debug.assertLessThanOrEqual(start, file.text.length); - Debug.assertLessThanOrEqual(end, file.text.length); + Debug.assertLessThanOrEqual(start + length, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2418,12 +2458,8 @@ var ts; return /^\.\.?($|[\\/])/.test(path); } ts.pathIsRelative = pathIsRelative; - function isExternalModuleNameRelative(moduleName) { - return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function moduleHasNonRelativeName(moduleName) { - return !isExternalModuleNameRelative(moduleName); + return !ts.isExternalModuleNameRelative(moduleName); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; function getEmitScriptTarget(compilerOptions) { @@ -2460,7 +2496,7 @@ var ts; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { @@ -3086,6 +3122,10 @@ var ts; throw e; } Debug.fail = fail; + function assertNever(member, message, stackCrawlMark) { + return fail(message || "Illegal value: " + member, stackCrawlMark || assertNever); + } + Debug.assertNever = assertNever; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -3223,6 +3263,12 @@ var ts; return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; + function and(f, g) { + return function (arg) { return f(arg) && g(arg); }; + } + ts.and = and; + function assertTypeIsNever(_) { } + ts.assertTypeIsNever = assertTypeIsNever; })(ts || (ts = {})); var ts; (function (ts) { @@ -3787,8 +3833,8 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asteri_1202", "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_defaul_1203", "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), @@ -4108,7 +4154,9 @@ var ts; Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), - Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), + Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."), + The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, ts.DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4181,6 +4229,7 @@ var ts; A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"), + The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -4298,7 +4347,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), - Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), + Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."), @@ -4403,17 +4452,16 @@ var ts; Resolving_real_path_for_0_result_1: diag(6130, ts.DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."), Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, ts.DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."), File_name_0_has_a_1_extension_stripping_it: diag(6132, ts.DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."), - _0_is_declared_but_never_used: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6133", "'{0}' is declared but never used."), + _0_is_declared_but_its_value_is_never_read: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read."), Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."), Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."), The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, ts.DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."), Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, ts.DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."), - Property_0_is_declared_but_never_used: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_never_used_6138", "Property '{0}' is declared but never used."), + Property_0_is_declared_but_its_value_is_never_read: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read."), Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."), Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, ts.DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."), Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, ts.DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."), Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."), - Module_0_was_resolved_to_1_but_allowJs_is_not_set: diag(6143, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", "Module '{0}' was resolved to '{1}', but '--allowJs' is not set."), Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."), Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."), Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."), @@ -4504,6 +4552,7 @@ var ts; Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."), Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."), JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, ts.DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."), + JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, ts.DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."), Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), @@ -4551,7 +4600,7 @@ var ts; Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), - Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), + Extract_to_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_95004", "Extract to {0}"), }; })(ts || (ts = {})); var ts; @@ -4779,7 +4828,7 @@ var ts; ts.Debug.assert(res < lineStarts[line + 1]); } else if (debugText !== undefined) { - ts.Debug.assert(res < debugText.length); + ts.Debug.assert(res <= debugText.length); } return res; } @@ -6169,7 +6218,6 @@ var ts; } ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriter = createSingleLineStringWriter(); - var stringWriterAcquired = false; function createSingleLineStringWriter() { var str = ""; var writeText = function (text) { return str += text; }; @@ -6193,15 +6241,14 @@ var ts; }; } function usingSingleLineStringWriter(action) { + var oldString = stringWriter.string(); try { - ts.Debug.assert(!stringWriterAcquired); - stringWriterAcquired = true; action(stringWriter); return stringWriter.string(); } finally { stringWriter.clear(); - stringWriterAcquired = false; + stringWriter.writeKeyword(oldString); } } ts.usingSingleLineStringWriter = usingSingleLineStringWriter; @@ -6235,7 +6282,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.version === b.version; + return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; @@ -6357,7 +6404,7 @@ var ts; if (ts.isJSDocNode(node)) { return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } if (node.kind === 286 && node._children.length > 0) { @@ -6394,6 +6441,15 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; + function indexOfNode(nodeArray, node) { + return ts.binarySearch(nodeArray, node, compareNodePos); + } + ts.indexOfNode = indexOfNode; + function compareNodePos(_a, _b) { + var aPos = _a.pos; + var bPos = _b.pos; + return aPos < bPos ? -1 : bPos < aPos ? 1 : 0; + } function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -6421,6 +6477,7 @@ var ts; case 16: return "}" + escapeText(node.text, 96) + "`"; case 8: + case 12: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -6518,6 +6575,34 @@ var ts; return false; } ts.isBlockScope = isBlockScope; + function isDeclarationWithTypeParameters(node) { + switch (node.kind) { + case 155: + case 156: + case 150: + case 157: + case 160: + case 161: + case 273: + case 229: + case 199: + case 230: + case 231: + case 282: + case 228: + case 151: + case 152: + case 153: + case 154: + case 186: + case 187: + return true; + default: + ts.assertTypeIsNever(node); + return false; + } + } + ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function getEnclosingBlockScopeContainer(node) { var current = node.parent; while (current) { @@ -7165,59 +7250,62 @@ var ts; case 8: case 9: case 99: - var parent = node.parent; - switch (parent.kind) { - case 226: - case 146: - case 149: - case 148: - case 264: - case 261: - case 176: - return parent.initializer === node; - case 210: - case 211: - case 212: - case 213: - case 219: - case 220: - case 221: - case 257: - case 223: - return parent.expression === node; - case 214: - var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || - forStatement.condition === node || - forStatement.incrementor === node; - case 215: - case 216: - var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || - forInStatement.expression === node; - case 184: - case 202: - return node === parent.expression; - case 205: - return node === parent.expression; - case 144: - return node === parent.expression; - case 147: - case 256: - case 255: - case 263: - return true; - case 201: - return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - default: - if (isPartOfExpression(parent)) { - return true; - } - } + return isInExpressionContext(node); + default: + return false; } - return false; } ts.isPartOfExpression = isPartOfExpression; + function isInExpressionContext(node) { + var parent = node.parent; + switch (parent.kind) { + case 226: + case 146: + case 149: + case 148: + case 264: + case 261: + case 176: + return parent.initializer === node; + case 210: + case 211: + case 212: + case 213: + case 219: + case 220: + case 221: + case 257: + case 223: + return parent.expression === node; + case 214: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || + forStatement.condition === node || + forStatement.incrementor === node; + case 215: + case 216: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || + forInStatement.expression === node; + case 184: + case 202: + return node === parent.expression; + case 205: + return node === parent.expression; + case 144: + return node === parent.expression; + case 147: + case 256: + case 255: + case 263: + return true; + case 201: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + return isPartOfExpression(parent); + } + } + ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { return node.kind === 237 && node.moduleReference.kind === 248; } @@ -7381,14 +7469,6 @@ var ts; node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function hasJSDocParameterTags(node) { - return !!getFirstJSDocTag(node, 279); - } - ts.hasJSDocParameterTags = hasJSDocParameterTags; - function getFirstJSDocTag(node, kind) { - var tags = getJSDocTags(node); - return ts.find(tags, function (doc) { return doc.kind === kind; }); - } function getAllJSDocs(node) { if (ts.isJSDocTypedefTag(node)) { return [node.parent]; @@ -7396,14 +7476,6 @@ var ts; return getJSDocCommentsAndTags(node); } ts.getAllJSDocs = getAllJSDocs; - function getJSDocTags(node) { - var tags = node.jsDocCache; - if (tags === undefined) { - node.jsDocCache = tags = ts.flatMap(getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); - } - return tags; - } - ts.getJSDocTags = getJSDocTags; function getJSDocCommentsAndTags(node) { var result; getJSDocCommentsAndTagsWorker(node); @@ -7435,22 +7507,17 @@ var ts; getJSDocCommentsAndTagsWorker(parent); } if (node.kind === 146) { - result = ts.addRange(result, getJSDocParameterTags(node)); + result = ts.addRange(result, ts.getJSDocParameterTags(node)); } - if (isVariableLike(node) && node.initializer) { + if (isVariableLike(node) && node.initializer && ts.hasJSDocNodes(node.initializer)) { result = ts.addRange(result, node.initializer.jsDoc); } - result = ts.addRange(result, node.jsDoc); + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); + } } } - function getJSDocParameterTags(param) { - if (param.name && ts.isIdentifier(param.name)) { - var name_1 = param.name.escapedText; - return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); - } - return undefined; - } - ts.getJSDocParameterTags = getJSDocParameterTags; + ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getParameterSymbolFromJSDoc(node) { if (node.symbol) { return node.symbol; @@ -7476,38 +7543,6 @@ var ts; return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; - function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 281); - if (!tag && node.kind === 146) { - var paramTags = getJSDocParameterTags(node); - if (paramTags) { - tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); - } - } - return tag && tag.typeExpression && tag.typeExpression.type; - } - ts.getJSDocType = getJSDocType; - function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 277); - } - ts.getJSDocAugmentsTag = getJSDocAugmentsTag; - function getJSDocClassTag(node) { - return getFirstJSDocTag(node, 278); - } - ts.getJSDocClassTag = getJSDocClassTag; - function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 280); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocReturnType(node) { - var returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - ts.getJSDocReturnType = getJSDocReturnType; - function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 282); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { return isRestParameter(ts.lastOrUndefined(s.parameters)); } @@ -7519,7 +7554,7 @@ var ts; function isRestParameter(node) { if (isInJavaScriptFile(node)) { if (node.type && node.type.kind === 274 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274; })) { + ts.forEach(ts.getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274; })) { return true; } } @@ -7920,9 +7955,9 @@ var ts; || kind === 265; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); + function nodeIsSynthesized(range) { + return ts.positionIsSynthesized(range.pos) + || ts.positionIsSynthesized(range.end); } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFile(sourceFile) { @@ -8186,13 +8221,17 @@ var ts; "\u2029": "\\u2029", "\u0085": "\\u0085" }); + var escapedNullRegExp = /\\0[0-9]/g; function escapeString(s, quoteChar) { var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp : quoteChar === 39 ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; - return s.replace(escapedCharsRegExp, getReplacement); + return s.replace(escapedCharsRegExp, getReplacement).replace(escapedNullRegExp, nullReplacement); } ts.escapeString = escapeString; + function nullReplacement(c) { + return "\\x00" + c.charAt(c.length - 1); + } function getReplacement(c) { return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } @@ -8472,7 +8511,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocType(node); + return ts.getJSDocType(node); } } ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode; @@ -8481,7 +8520,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocReturnType(node); + return ts.getJSDocReturnType(node); } } ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode; @@ -8490,7 +8529,7 @@ var ts; return node.typeParameters; } if (isInJavaScriptFile(node)) { - var templateTag = getJSDocTemplateTag(node); + var templateTag = ts.getJSDocTemplateTag(node); return templateTag && templateTag.typeParameters; } } @@ -9049,6 +9088,41 @@ var ts; return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; + function isWriteOnlyAccess(node) { + return accessKind(node) === 1; + } + ts.isWriteOnlyAccess = isWriteOnlyAccess; + function isWriteAccess(node) { + return accessKind(node) !== 0; + } + ts.isWriteAccess = isWriteAccess; + var AccessKind; + (function (AccessKind) { + AccessKind[AccessKind["Read"] = 0] = "Read"; + AccessKind[AccessKind["Write"] = 1] = "Write"; + AccessKind[AccessKind["ReadWrite"] = 2] = "ReadWrite"; + })(AccessKind || (AccessKind = {})); + function accessKind(node) { + var parent = node.parent; + if (!parent) + return 0; + switch (parent.kind) { + case 193: + case 192: + var operator = parent.operator; + return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; + case 194: + var _a = parent, left = _a.left, operatorToken = _a.operatorToken; + return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; + case 179: + return parent.name !== node ? 0 : accessKind(parent); + default: + return 0; + } + function writeOrReadWrite() { + return parent.parent && parent.parent.kind === 210 ? 1 : 2; + } + } })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -9327,6 +9401,56 @@ var ts; return id; } ts.unescapeIdentifier = unescapeIdentifier; + function nameForNamelessJSDocTypedef(declaration) { + var hostNode = declaration.parent.parent; + if (!hostNode) { + return undefined; + } + if (ts.isDeclaration(hostNode)) { + return getDeclarationIdentifier(hostNode); + } + switch (hostNode.kind) { + case 208: + if (hostNode.declarationList && + hostNode.declarationList.declarations[0]) { + return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); + } + return undefined; + case 210: + var expr = hostNode.expression; + switch (expr.kind) { + case 179: + return expr.name; + case 180: + var arg = expr.argumentExpression; + if (ts.isIdentifier(arg)) { + return arg; + } + } + return undefined; + case 1: + return undefined; + case 185: { + return getDeclarationIdentifier(hostNode.expression); + } + case 222: { + if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { + return getDeclarationIdentifier(hostNode.statement); + } + return undefined; + } + default: + ts.Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!"); + } + } + function getDeclarationIdentifier(node) { + var name = getNameOfDeclaration(node); + return ts.isIdentifier(name) ? name : undefined; + } + function getNameOfJSDocTypedef(declaration) { + return declaration.name || nameForNamelessJSDocTypedef(declaration); + } + ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef; function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; @@ -9346,11 +9470,78 @@ var ts; return undefined; } } + else if (declaration.kind === 283) { + return getNameOfJSDocTypedef(declaration); + } else { return declaration.name; } } ts.getNameOfDeclaration = getNameOfDeclaration; + function getJSDocParameterTags(param) { + if (param.name && ts.isIdentifier(param.name)) { + var name_1 = param.name.escapedText; + return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); + } + return undefined; + } + ts.getJSDocParameterTags = getJSDocParameterTags; + function hasJSDocParameterTags(node) { + return !!getFirstJSDocTag(node, 279); + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 277); + } + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + function getJSDocClassTag(node) { + return getFirstJSDocTag(node, 278); + } + ts.getJSDocClassTag = getJSDocClassTag; + function getJSDocReturnTag(node) { + return getFirstJSDocTag(node, 280); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getFirstJSDocTag(node, 282); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getJSDocTypeTag(node) { + var tag = getFirstJSDocTag(node, 281); + if (tag && tag.typeExpression && tag.typeExpression.type) { + return tag; + } + return undefined; + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 281); + if (!tag && node.kind === 146) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + function getJSDocReturnType(node) { + var returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + ts.getJSDocReturnType = getJSDocReturnType; + function getJSDocTags(node) { + var tags = node.jsDocCache; + if (tags === undefined) { + node.jsDocCache = tags = ts.flatMap(ts.getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); + } + return tags; + } + ts.getJSDocTags = getJSDocTags; + function getFirstJSDocTag(node, kind) { + var tags = getJSDocTags(node); + return ts.find(tags, function (doc) { return doc.kind === kind; }); + } })(ts || (ts = {})); (function (ts) { function isNumericLiteral(node) { @@ -9983,8 +10174,7 @@ var ts; } ts.isToken = isToken; function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + return array.hasOwnProperty("pos") && array.hasOwnProperty("end"); } ts.isNodeArray = isNodeArray; function isLiteralKind(kind) { @@ -10069,16 +10259,27 @@ var ts; return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { + function isFunctionLikeDeclaration(node) { + return node && isFunctionLikeDeclarationKind(node.kind); + } + ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; + function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 152: - case 186: case 228: - case 187: case 151: - case 150: + case 152: case 153: case 154: + case 186: + case 187: + return true; + default: + return false; + } + } + function isFunctionLikeKind(kind) { + switch (kind) { + case 150: case 155: case 156: case 157: @@ -10086,10 +10287,15 @@ var ts; case 273: case 161: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - return false; } ts.isFunctionLikeKind = isFunctionLikeKind; + function isFunctionOrModuleBlock(node) { + return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent); + } + ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; return kind === 152 @@ -10243,52 +10449,61 @@ var ts; || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; - function isLeftHandSideExpressionKind(kind) { - return kind === 179 - || kind === 180 - || kind === 182 - || kind === 181 - || kind === 249 - || kind === 250 - || kind === 183 - || kind === 177 - || kind === 185 - || kind === 178 - || kind === 199 - || kind === 186 - || kind === 71 - || kind === 12 - || kind === 8 - || kind === 9 - || kind === 13 - || kind === 196 - || kind === 86 - || kind === 95 - || kind === 99 - || kind === 101 - || kind === 97 - || kind === 91 - || kind === 203 - || kind === 204; - } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 192 - || kind === 193 - || kind === 188 - || kind === 189 - || kind === 190 - || kind === 191 - || kind === 184 - || isLeftHandSideExpressionKind(kind); + function isLeftHandSideExpressionKind(kind) { + switch (kind) { + case 179: + case 180: + case 182: + case 181: + case 249: + case 250: + case 183: + case 177: + case 185: + case 178: + case 199: + case 186: + case 71: + case 12: + case 8: + case 9: + case 13: + case 196: + case 86: + case 95: + case 99: + case 101: + case 97: + case 203: + case 204: + case 91: + return true; + default: + return false; + } } function isUnaryExpression(node) { return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionKind(kind) { + switch (kind) { + case 192: + case 193: + case 188: + case 189: + case 190: + case 191: + case 184: + return true; + default: + return isLeftHandSideExpressionKind(kind); + } + } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { case 193: @@ -10301,21 +10516,26 @@ var ts; } } ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; - function isExpressionKind(kind) { - return kind === 195 - || kind === 197 - || kind === 187 - || kind === 194 - || kind === 198 - || kind === 202 - || kind === 200 - || kind === 289 - || isUnaryExpressionKind(kind); - } function isExpression(node) { return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isExpression = isExpression; + function isExpressionKind(kind) { + switch (kind) { + case 195: + case 197: + case 187: + case 194: + case 198: + case 202: + case 200: + case 289: + case 288: + return true; + default: + return isUnaryExpressionKind(kind); + } + } function isAssertionExpression(node) { var kind = node.kind; return kind === 184 @@ -10556,6 +10776,10 @@ var ts; return node.kind >= 276 && node.kind <= 285; } ts.isJSDocTag = isJSDocTag; + function hasJSDocNodes(node) { + return !!node.jsDoc && node.jsDoc.length > 0; + } + ts.hasJSDocNodes = hasJSDocNodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -10977,9 +11201,11 @@ var ts; visitNode(cbNode, node.typeExpression); } case 285: - for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { - var tag = _a[_i]; - visitNode(cbNode, tag); + if (node.jsDocPropertyTags) { + for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { + var tag = _a[_i]; + visitNode(cbNode, tag); + } } return; case 288: @@ -11159,7 +11385,7 @@ var ts; var saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDoc) { + if (ts.hasJSDocNodes(n)) { for (var _i = 0, _a = n.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; jsDoc.parent = n; @@ -11279,9 +11505,6 @@ var ts; function getNodePos() { return scanner.getStartPos(); } - function getNodeEnd() { - return scanner.getStartPos(); - } function token() { return currentToken; } @@ -11404,13 +11627,11 @@ var ts; kind === 71 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } - function createNodeArray(elements, pos) { - var array = (elements || []); - if (!(pos >= 0)) { - pos = getNodePos(); - } + function createNodeArray(elements, pos, end) { + var length = elements.length; + var array = (length >= 1 && length <= 4 ? elements.slice() : elements); array.pos = pos; - array.end = pos; + array.end = end === undefined ? scanner.getStartPos() : end; return array; } function finishNode(node, end) { @@ -11458,7 +11679,8 @@ var ts; nextToken(); return finishNode(node); } - return createMissingNode(71, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var reportAtCurrentPosition = token() === 1; + return createMissingNode(71, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -11691,20 +11913,20 @@ var ts; function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); - result.push(element); + list.push(element); continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - result.end = getNodeEnd(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); @@ -11910,12 +12132,13 @@ var ts; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var commaStart = -1; while (true) { if (isListElement(kind, false)) { var startPos = scanner.getStartPos(); - result.push(parseListElement(kind, parseElement)); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(26)) { continue; @@ -11940,15 +12163,15 @@ var ts; break; } } + parsingContext = saveParsingContext; + var result = createNodeArray(list, listPos); if (commaStart >= 0) { result.hasTrailingComma = true; } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; return result; } function createMissingList() { - return createNodeArray(); + return createNodeArray([], getNodePos()); } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -11990,12 +12213,12 @@ var ts; var template = createNode(196); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); - var templateSpans = createNodeArray(); + var list = []; + var listPos = getNodePos(); do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 15); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; + list.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(list).literal.kind === 15); + template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { @@ -12090,7 +12313,7 @@ var ts; var result = createNode(273); nextToken(); fillSignature(56, 4 | 32, result); - return finishNode(result); + return addJSDocComment(finishNode(result)); } var node = createNode(159); node.typeName = parseIdentifierName(); @@ -12148,9 +12371,10 @@ var ts; return token() === 24 || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 || isStartOfType(); + token() === 57 || + isStartOfType(true); } - function parseParameter() { + function parseParameter(requireEqualsToken) { var node = createNode(146); if (token() === 99) { node.name = createIdentifier(true); @@ -12166,37 +12390,33 @@ var ts; } node.questionToken = parseOptionalToken(55); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseInitializer(true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(true); - } function fillSignature(returnToken, flags, signature) { if (!(flags & 32)) { signature.typeParameters = parseTypeParameters(); } signature.parameters = parseParameterList(flags); - var returnTokenRequired = returnToken === 36; - if (returnTokenRequired) { + signature.type = parseReturnType(returnToken, !!(flags & 4)); + } + function parseReturnType(returnToken, isType) { + return shouldParseReturnType(returnToken, isType) ? parseTypeOrTypePredicate() : undefined; + } + function shouldParseReturnType(returnToken, isType) { + if (returnToken === 36) { parseExpected(returnToken); - signature.type = parseTypeOrTypePredicate(); + return true; } - else if (parseOptional(returnToken)) { - signature.type = parseTypeOrTypePredicate(); + else if (parseOptional(56)) { + return true; } - else if (flags & 4) { - var start = scanner.getTokenPos(); - var length_1 = scanner.getTextPos() - start; - var backwardToken = parseOptional(returnToken === 56 ? 36 : 56); - if (backwardToken) { - signature.type = parseTypeOrTypePredicate(); - parseErrorAtPosition(start, length_1, ts.Diagnostics._0_expected, ts.tokenToString(returnToken)); - } + else if (isType && token() === 36) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56)); + nextToken(); + return true; } + return false; } function parseParameterList(flags) { if (parseExpected(19)) { @@ -12204,7 +12424,7 @@ var ts; var savedAwaitContext = inAwaitContext(); setYieldContext(!!(flags & 1)); setAwaitContext(!!(flags & 2)); - var result = parseDelimitedList(16, flags & 32 ? parseJSDocParameter : parseParameter); + var result = parseDelimitedList(16, flags & 32 ? parseJSDocParameter : function () { return parseParameter(!!(flags & 8)); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); if (!parseExpected(20) && (flags & 8)) { @@ -12268,7 +12488,7 @@ var ts; node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); @@ -12400,7 +12620,7 @@ var ts; parseExpected(94); } fillSignature(36, 4, node); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseKeywordAndNoDot() { var node = parseTokenNode(); @@ -12414,16 +12634,9 @@ var ts; unaryMinusExpression.operator = 38; nextToken(); } - var expression; - switch (token()) { - case 9: - case 8: - expression = parseLiteralLikeNode(token()); - break; - case 101: - case 86: - expression = parseTokenNode(); - } + var expression = token() === 101 || token() === 86 + ? parseTokenNode() + : parseLiteralLikeNode(token()); if (negative) { unaryMinusExpression.operand = expression; finishNode(unaryMinusExpression); @@ -12456,6 +12669,7 @@ var ts; return parseJSDocNodeWithType(274); case 51: return parseJSDocNodeWithType(271); + case 13: case 9: case 8: case 101: @@ -12487,7 +12701,7 @@ var ts; return parseTypeReference(); } } - function isStartOfType() { + function isStartOfType(inStartOfParameter) { switch (token()) { case 119: case 136: @@ -12512,11 +12726,14 @@ var ts; case 86: case 134: case 39: + case 55: + case 51: + case 24: return true; case 38: - return lookAhead(nextTokenIsNumericLiteral); + return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case 19: - return lookAhead(isStartOfParenthesizedOrFunctionType); + return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } @@ -12582,13 +12799,12 @@ var ts; parseOptional(operator); var type = parseConstituentType(); if (token() === operator) { - var types = createNodeArray([type], type.pos); + var types = [type]; while (parseOptional(operator)) { types.push(parseConstituentType()); } - types.end = getNodeEnd(); var node = createNode(kind, type.pos); - node.types = types; + node.types = createNodeArray(types, type.pos); type = finishNode(node); } return type; @@ -12748,11 +12964,16 @@ var ts; } return expr; } - function parseInitializer(inParameter) { + function parseInitializer(inParameter, requireEqualsToken) { if (token() !== 58) { if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17) || !isStartOfExpression()) { return undefined; } + if (inParameter && requireEqualsToken) { + var result = createMissingNode(71, true, ts.Diagnostics._0_expected, "="); + result.escapedText = "= not found"; + return result; + } } parseExpected(58); return parseAssignmentExpressionOrHigher(); @@ -12813,8 +13034,7 @@ var ts; var parameter = createNode(146, identifier.pos); parameter.name = identifier; finishNode(parameter); - node.parameters = createNodeArray([parameter], parameter.pos); - node.parameters.end = parameter.end; + node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); node.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); @@ -12921,8 +13141,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { if (token() === 120) { - var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === 1) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); return parseSimpleArrowFunctionExpression(expr, asyncModifier); @@ -12951,7 +13170,8 @@ var ts; if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 36 && token() !== 17) { + if (!allowAmbiguity && ((token() !== 36 && token() !== 17) || + ts.find(node.parameters, function (p) { return p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"; }))) { return undefined; } return node; @@ -13293,7 +13513,8 @@ var ts; ts.Debug.fail("Unknown JSX child kind " + token()); } function parseJsxChildren(openingTagName) { - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var saveParsingContext = parsingContext; parsingContext |= 1 << 14; while (true) { @@ -13310,12 +13531,11 @@ var ts; } var child = parseJsxChild(); if (child) { - result.push(child); + list.push(child); } } - result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseJsxAttributes() { var jsxAttributes = createNode(254); @@ -14194,7 +14414,7 @@ var ts; var node = createNode(176); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { @@ -14210,7 +14430,7 @@ var ts; node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingPattern() { @@ -14244,7 +14464,7 @@ var ts; node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseInitializer(false); + node.initializer = parseNonParameterInitializer(); } return finishNode(node); } @@ -14408,7 +14628,8 @@ var ts; return false; } function parseDecorators() { - var decorators; + var list; + var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); if (!parseOptional(57)) { @@ -14417,20 +14638,13 @@ var ts; var decorator = createNode(147, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); - if (!decorators) { - decorators = createNodeArray([decorator], decoratorStart); - } - else { - decorators.push(decorator); - } + (list || (list = [])).push(decorator); } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; + return list && createNodeArray(list, listPos); } function parseModifiers(permitInvalidConstAsModifier) { - var modifiers; + var list; + var listPos = getNodePos(); while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); @@ -14445,17 +14659,9 @@ var ts; } } var modifier = finishNode(createNode(modifierKind, modifierStart)); - if (!modifiers) { - modifiers = createNodeArray([modifier], modifierStart); - } - else { - modifiers.push(modifier); - } + (list || (list = [])).push(modifier); } - if (modifiers) { - modifiers.end = scanner.getStartPos(); - } - return modifiers; + return list && createNodeArray(list, listPos); } function parseModifiersForArrowFunction() { var modifiers; @@ -14465,7 +14671,6 @@ var ts; nextToken(); var modifier = finishNode(createNode(modifierKind, modifierStart)); modifiers = createNodeArray([modifier], modifierStart); - modifiers.end = scanner.getStartPos(); } return modifiers; } @@ -14960,9 +15165,11 @@ var ts; return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - function parseJSDocTypeExpression() { + function parseJSDocTypeExpression(requireBraces) { var result = createNode(267, scanner.getTokenPos()); - parseExpected(17); + if (!parseExpected(17) && requireBraces) { + return undefined; + } result.type = doInsideOfContext(1048576, parseType); parseExpected(18); fixupParentReferences(result); @@ -15019,6 +15226,8 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; + var tagsPos; + var tagsEnd; var comments = []; var result; if (!isJsDocStart(content, start)) { @@ -15127,7 +15336,7 @@ var ts; } function createJSDocComment() { var result = createNode(275, start); - result.tags = tags; + result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -15250,21 +15459,17 @@ var ts; function addTag(tag, comments) { tag.comment = comments.join(""); if (!tags) { - tags = createNodeArray([tag], tag.pos); + tags = [tag]; + tagsPos = tag.pos; } else { tags.push(tag); } - tags.end = tag.end; + tagsEnd = tag.end; } function tryParseTypeExpression() { - return tryParse(function () { - skipWhitespace(); - if (token() !== 17) { - return undefined; - } - return parseJSDocTypeExpression(); - }); + skipWhitespace(); + return token() === 17 ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { var isBracketed = parseOptional(21); @@ -15354,11 +15559,11 @@ var ts; var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); + result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); + var typeExpression = parseJSDocTypeExpression(true); var result = createNode(277, atToken.pos); result.atToken = atToken; result.tagName = tagName; @@ -15393,19 +15598,18 @@ var ts; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { var child = void 0; var jsdocTypeLiteral = void 0; - var alreadyHasTypeTag = false; + var childTypeTag = void 0; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildParameterOrPropertyTag(0); })) { if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(285, start_3); } if (child.kind === 281) { - if (alreadyHasTypeTag) { + if (childTypeTag) { break; } else { - jsdocTypeLiteral.jsDocTypeTag = child; - alreadyHasTypeTag = true; + childTypeTag = child; } } else { @@ -15419,7 +15623,9 @@ var ts; if (typeExpression && typeExpression.type.kind === 164) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = finishNode(jsdocTypeLiteral); + typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + childTypeTag.typeExpression : + finishNode(jsdocTypeLiteral); } } return finishNode(typedefTag); @@ -15513,7 +15719,8 @@ var ts; if (ts.forEach(tags, function (t) { return t.kind === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var typeParameters = createNodeArray(); + var typeParameters = []; + var typeParametersPos = getNodePos(); while (true) { var name = parseJSDocIdentifierName(); skipWhitespace(); @@ -15536,9 +15743,8 @@ var ts; var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; + result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); - typeParameters.end = result.end; return result; } function nextJSDocToken() { @@ -15630,7 +15836,7 @@ var ts; ts.Debug.assert(text === newText.substring(node.pos, node.end)); } forEachChild(node, visitNode, visitArray); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDocComment = _a[_i]; forEachChild(jsDocComment, visitNode, visitArray); @@ -16013,9 +16219,11 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; if (!symbol.declarations) { - symbol.declarations = []; + symbol.declarations = [node]; + } + else { + symbol.declarations.push(node); } - symbol.declarations.push(node); if (symbolFlags & 1952 && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -16079,17 +16287,8 @@ var ts; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; case 283: - var parentNode = node.parent && node.parent.parent; - var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 208) { - if (parentNode.declarationList.declarations.length > 0) { - var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (ts.isIdentifier(nameIdentifier)) { - nameFromParentNode = nameIdentifier.escapedText; - } - } - } - return nameFromParentNode; + var name_2 = ts.getNameOfJSDocTypedef(node); + return typeof name_2 !== "undefined" ? name_2.escapedText : undefined; } } function getDisplayName(node) { @@ -16290,7 +16489,7 @@ var ts; ts.forEachChild(node, bind, bindEach); } function bindChildrenWorker(node) { - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { if (ts.isInJavaScriptFile(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var j = _a[_i]; @@ -17030,9 +17229,6 @@ var ts; lastContainer = next; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - return declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { case 233: return declareModuleMember(node, symbolFlags, symbolExcludes); @@ -17194,6 +17390,9 @@ var ts; } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); + if (symbolFlags & 8) { + symbol.parent = container.symbol; + } addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { @@ -17351,7 +17550,7 @@ var ts; inStrictMode = saveInStrictMode; } function bindJSDocTypedefTagIfAny(node) { - if (!node.jsDoc) { + if (!ts.hasJSDocNodes(node)) { return; } for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -18528,31 +18727,38 @@ var ts; return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } - var visitedTypes = ts.createMap(); - var visitedSymbols = ts.createMap(); + var visitedTypes = []; + var visitedSymbols = []; return { walkType: function (type) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitType(type); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitType(type); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, walkSymbol: function (symbol) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitSymbol(symbol); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitSymbol(symbol); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, }; function visitType(type) { if (!type) { return; } - var typeIdString = type.id.toString(); - if (visitedTypes.has(typeIdString)) { + if (visitedTypes[type.id]) { return; } - visitedTypes.set(typeIdString, type); + visitedTypes[type.id] = type; var shouldBail = visitSymbol(type.symbol); if (shouldBail) return; @@ -18585,23 +18791,15 @@ var ts; visitIndexedAccessType(type); } } - function visitTypeList(types) { - if (!types) { - return; - } - for (var i = 0; i < types.length; i++) { - visitType(types[i]); - } - } function visitTypeReference(type) { visitType(type.target); - visitTypeList(type.typeArguments); + ts.forEach(type.typeArguments, visitType); } function visitTypeParameter(type) { visitType(getConstraintFromTypeParameter(type)); } function visitUnionOrIntersectionType(type) { - visitTypeList(type.types); + ts.forEach(type.types, visitType); } function visitIndexType(type) { visitType(type.type); @@ -18621,7 +18819,7 @@ var ts; if (signature.typePredicate) { visitType(signature.typePredicate.type); } - visitTypeList(signature.typeParameters); + ts.forEach(signature.typeParameters, visitType); for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; visitSymbol(parameter); @@ -18631,8 +18829,8 @@ var ts; } function visitInterfaceType(interfaceT) { visitObjectType(interfaceT); - visitTypeList(interfaceT.typeParameters); - visitTypeList(getBaseTypes(interfaceT)); + ts.forEach(interfaceT.typeParameters, visitType); + ts.forEach(getBaseTypes(interfaceT), visitType); visitType(interfaceT.thisType); } function visitObjectType(type) { @@ -18658,11 +18856,11 @@ var ts; if (!symbol) { return; } - var symbolIdString = ts.getSymbolId(symbol).toString(); - if (visitedSymbols.has(symbolIdString)) { + var symbolId = ts.getSymbolId(symbol); + if (visitedSymbols[symbolId]) { return; } - visitedSymbols.set(symbolIdString, symbol); + visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { return true; } @@ -18710,7 +18908,7 @@ var ts; return undefined; } ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); - return resolved.path; + return { fileName: resolved.path, packageId: resolved.packageId }; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { @@ -18813,12 +19011,12 @@ var ts; var resolvedTypeReferenceDirective; if (resolved) { if (!options.preserveSymlinks) { - resolved = realPath(resolved, host, traceEnabled); + resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); } if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -19115,7 +19313,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension, packageId: undefined }; + return noPackageId({ path: path_1, ext: extension }); } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -19277,31 +19475,40 @@ var ts; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } + var _a = considerPackageJson + ? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state) + : { packageJsonContent: undefined, packageId: undefined }, packageJsonContent = _a.packageJsonContent, packageId = _a.packageId; + return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent)); + } + function loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent) { + var fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - var packageId; - if (considerPackageJson) { - var packageJsonPath = pathToPackageJson(candidate); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var jsonContent = readJson(packageJsonPath, state.host); - if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { - packageId = { name: jsonContent.name, version: jsonContent.version }; - } - var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); - if (fromPackageJson) { - return withPackageId(packageId, fromPackageJson); - } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, _a) { + var host = _a.host, traceEnabled = _a.traceEnabled; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); + var packageJsonPath = pathToPackageJson(nodeModuleDirectory); + if (directoryExists && host.fileExists(packageJsonPath)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); + var packageJsonContent = readJson(packageJsonPath, host); + var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" + ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version } + : undefined; + return { packageJsonContent: packageJsonContent, packageId: packageId }; + } + else { + if (directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + failedLookupLocations.push(packageJsonPath); + return { packageJsonContent: undefined, packageId: undefined }; } - return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); @@ -19344,9 +19551,20 @@ var ts; return ts.combinePaths(directory, "package.json"); } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { + var _a = getPackageName(moduleName), packageName = _a.packageName, rest = _a.rest; + var packageRootPath = ts.combinePaths(nodeModulesFolder, packageName); + var _b = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state), packageJsonContent = _b.packageJsonContent, packageId = _b.packageId; var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + var pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent); + return withPackageId(packageId, pathAndExtension); + } + function getPackageName(moduleName) { + var idx = moduleName.indexOf(ts.directorySeparator); + if (moduleName[0] === "@") { + idx = moduleName.indexOf(ts.directorySeparator, idx + 1); + } + return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); @@ -19527,6 +19745,7 @@ var ts; var enumCount = 0; var symbolInstantiationDepth = 0; var emptySymbols = ts.createSymbolTable(); + var identityMapper = ts.identity; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -19679,12 +19898,13 @@ var ts; return tryFindAmbientModule(moduleName, false); }, getApparentType: getApparentType, - getAllPossiblePropertiesOfType: getAllPossiblePropertiesOfType, + isArrayLikeType: isArrayLikeType, + getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, resolveName: function (name, location, meaning) { - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined); + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false); }, getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; @@ -19763,7 +19983,8 @@ var ts; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; var flowLoopCount = 0; - var visitedFlowCount = 0; + var sharedFlowCount = 0; + var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var resolutionTargets = []; @@ -19778,8 +19999,8 @@ var ts; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; - var visitedFlowNodes = []; - var visitedFlowTypes = []; + var sharedFlowNodes = []; + var sharedFlowTypes = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -19908,6 +20129,7 @@ var ts; })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -19989,7 +20211,7 @@ var ts; } function cloneSymbol(symbol) { var result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations.slice(0); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; @@ -20217,10 +20439,10 @@ var ts; }); } } - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, suggestedNameNotFoundMessage) { - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, suggestedNameNotFoundMessage) { + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, getSymbol, suggestedNameNotFoundMessage); } - function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, lookup, suggestedNameNotFoundMessage) { + function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, lookup, suggestedNameNotFoundMessage) { var originalLocation = location; var result; var lastLocation; @@ -20376,10 +20598,16 @@ var ts; lastLocation = location; location = location.parent; } - if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { + if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { + if (lastLocation) { + ts.Debug.assert(lastLocation.kind === 265); + if (lastLocation.commonJsModuleIndicator && name === "exports") { + return lastLocation.symbol; + } + } result = lookup(globals, name, meaning); } if (!result) { @@ -20491,7 +20719,7 @@ var ts; } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { if (meaning === 1920) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined, false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -20515,7 +20743,7 @@ var ts; error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined, false)); if (symbol && !(symbol.flags & 1024)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -20525,14 +20753,14 @@ var ts; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { if (meaning & (107455 & ~1024 & ~793064)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } else if (meaning & (793064 & ~1024 & ~107455)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -20560,11 +20788,17 @@ var ts; return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 237) { + switch (node.kind) { + case 237: return node; - } - return ts.findAncestor(node, ts.isImportDeclaration); + case 239: + return node.parent; + case 240: + return node.parent.parent; + case 242: + return node.parent.parent.parent; + default: + return undefined; } } function getDeclarationOfAliasSymbol(symbol) { @@ -20774,7 +21008,7 @@ var ts; var symbol; if (name.kind === 71) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name); + symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name, true); if (!symbol) { return undefined; } @@ -20813,7 +21047,7 @@ var ts; undefined; } else { - ts.Debug.fail("Unknown entity name kind."); + ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -20861,13 +21095,13 @@ var ts; return getMergedSymbol(pattern.symbol); } } - if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } else if (noImplicitAny && moduleNotFoundError) { - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + var errorInfo = !resolvedModule.isExternalLibraryImport ? undefined : ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } @@ -20966,10 +21200,9 @@ var ts; moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || emptySymbols; function visit(symbol) { - if (!(symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol))) { + if (!(symbol && symbol.flags & 1952 && ts.pushIfUnique(visitedSymbols, symbol))) { return; } - visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); var exportStars = symbol.exports.get("__export"); if (exportStars) { @@ -21108,55 +21341,51 @@ var ts; return rightMeaning === 107455 ? 107455 : 1920; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - return getAccessibleSymbolChainFromSymbolTableWorker(symbols, []); + if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { + return undefined; } - function getAccessibleSymbolChainFromSymbolTableWorker(symbols, visitedSymbolTables) { - if (ts.contains(visitedSymbolTables, symbols)) { + var visitedSymbolTables = []; + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function getAccessibleSymbolChainFromSymbolTable(symbols) { + if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - visitedSymbolTables.push(symbols); var result = trySymbolTable(symbols); visitedSymbolTables.pop(); return result; - function canQualifySymbol(symbolFromSymbolTable, meaning) { - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - function trySymbolTable(symbols) { - if (isAccessible(symbols.get(symbol.escapedName))) { - return [symbol]; - } - return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 - && symbolFromSymbolTable.escapedName !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) { - if (!useOnlyExternalAliasing || - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { - return [symbolFromSymbolTable]; - } - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTableWorker(resolvedImportedSymbol.exports, visitedSymbolTables) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } } - if (symbol && !isPropertyOrMethodDeclarationSymbol(symbol)) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function canQualifySymbol(symbolFromSymbolTable, meaning) { + return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) || + !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + function isUMDExportSymbol(symbol) { + return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + } + function trySymbolTable(symbols) { + if (isAccessible(symbols.get(symbol.escapedName))) { + return [symbol]; + } + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 2097152 + && symbolFromSymbolTable.escapedName !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246) + && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) + && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { + return [symbolFromSymbolTable]; + } + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + }); } } function needsQualification(symbol, enclosingDeclaration, meaning) { @@ -21259,14 +21488,7 @@ var ts; isDeclarationVisible(anyImportSyntax.parent)) { if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } + aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, anyImportSyntax); } return true; } @@ -21288,7 +21510,7 @@ var ts; meaning = 793064; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false); return (symbol && hasVisibleDeclarations(symbol, true)) || { accessibility: 1, errorSymbolName: ts.getTextOfNode(firstIdentifier), @@ -21321,7 +21543,7 @@ var ts; var writer = ts.createTextWriter(""); var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(3, typeNode, sourceFile, writer); + printer.writeNode(4, typeNode, sourceFile, writer); var result = writer.getText(); var maxLength = compilerOptions.noErrorTruncation || flags & 8 ? undefined : 100; if (maxLength && result.length >= maxLength) { @@ -21603,13 +21825,13 @@ var ts; var i = 0; var qualifiedName = void 0; if (outerTypeParameters) { - var length_2 = outerTypeParameters.length; - while (i < length_2) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice); @@ -21862,29 +22084,6 @@ var ts; } } } - function getNameOfSymbol(symbol, context) { - var declaration = ts.firstOrUndefined(symbol.declarations); - if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - return ts.declarationNameToString(name); - } - if (declaration.parent && declaration.parent.kind === 226) { - return ts.declarationNameToString(declaration.parent.name); - } - if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { - context.encounteredError = true; - } - switch (declaration.kind) { - case 199: - return "(Anonymous class)"; - case 186: - case 187: - return "(Anonymous function)"; - } - } - return ts.unescapeLeadingUnderscores(symbol.escapedName); - } } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { return ts.usingSingleLineStringWriter(function (writer) { @@ -21942,9 +22141,9 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { - return type.flags & 32 ? "\"" + ts.escapeString(type.value) + "\"" : "" + type.value; + return type.flags & 32 ? '"' + ts.escapeString(type.value) + '"' : "" + type.value; } - function getNameOfSymbol(symbol) { + function getNameOfSymbol(symbol, context) { if (symbol.declarations && symbol.declarations.length) { var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); @@ -21954,6 +22153,9 @@ var ts; if (declaration.parent && declaration.parent.kind === 226) { return ts.declarationNameToString(declaration.parent.name); } + if (context && !context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { + context.encounteredError = true; + } switch (declaration.kind) { case 199: return "(Anonymous class)"; @@ -21962,6 +22164,12 @@ var ts; return "(Anonymous function)"; } } + if (symbol.syntheticLiteralTypeOrigin) { + var stringValue = symbol.syntheticLiteralTypeOrigin.value; + if (!ts.isIdentifierText(stringValue, compilerOptions.target)) { + return "\"" + ts.escapeString(stringValue, 34) + "\""; + } + } return ts.unescapeLeadingUnderscores(symbol.escapedName); } function getSymbolDisplayBuilder() { @@ -22158,13 +22366,13 @@ var ts; var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_3 = outerTypeParameters.length; - while (i < length_3) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_3 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 23); @@ -22682,7 +22890,7 @@ var ts; function collectLinkedAliases(node) { var exportSymbol; if (node.parent && node.parent.kind === 243) { - exportSymbol = resolveName(node.parent, node.escapedText, 107455 | 793064 | 1920 | 2097152, ts.Diagnostics.Cannot_find_name_0, node); + exportSymbol = resolveName(node.parent, node.escapedText, 107455 | 793064 | 1920 | 2097152, ts.Diagnostics.Cannot_find_name_0, node, false); } else if (node.parent.kind === 246) { exportSymbol = getTargetOfExportSpecifier(node.parent, 107455 | 793064 | 1920 | 2097152); @@ -22696,13 +22904,11 @@ var ts; ts.forEach(declarations, function (declaration) { getNodeLinks(declaration).isVisible = true; var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } + ts.pushIfUnique(result, resultNode); if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 | 793064 | 1920, undefined, undefined); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 | 793064 | 1920, undefined, undefined, false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -22713,8 +22919,8 @@ var ts; function pushTypeResolution(target, propertyName) { var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { - var length_4 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_4; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -23325,34 +23531,48 @@ var ts; for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } + typeParameters = ts.appendIfUnique(typeParameters, tp); } return typeParameters; } - function appendOuterTypeParameters(typeParameters, node) { + function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; if (!node) { - return typeParameters; + return undefined; } - if (node.kind === 229 || node.kind === 199 || - node.kind === 228 || node.kind === 186 || - node.kind === 151 || node.kind === 187) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } + switch (node.kind) { + case 229: + case 199: + case 230: + case 155: + case 156: + case 150: + case 160: + case 161: + case 273: + case 228: + case 151: + case 186: + case 187: + case 231: + case 282: + case 172: + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + if (node.kind === 172) { + return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); + } + var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray); + var thisType = includeThisTypes && + (node.kind === 229 || node.kind === 199 || node.kind === 230) && + getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; + return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230); - return appendOuterTypeParameters(undefined, declaration); + return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; @@ -23400,7 +23620,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig; }); + return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJavaScriptFile(location)) : sig; }); } function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { @@ -23474,7 +23694,7 @@ var ts; var valueDecl = type.symbol.valueDeclaration; if (valueDecl && ts.isInJavaScriptFile(valueDecl)) { var augTag = ts.getJSDocAugmentsTag(type.symbol.valueDeclaration); - if (augTag) { + if (augTag && augTag.typeExpression && augTag.typeExpression.type) { baseType = getTypeFromTypeNode(augTag.typeExpression.type); } } @@ -23590,7 +23810,8 @@ var ts; var declaration = ts.find(symbol.declarations, function (d) { return d.kind === 283 || d.kind === 231; }); - var type = getTypeFromTypeNode(declaration.kind === 283 ? declaration.typeExpression : declaration.type); + var typeNode = declaration.kind === 283 ? declaration.typeExpression : declaration.type; + var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -23924,7 +24145,7 @@ var ts; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -23958,9 +24179,7 @@ var ts; if (!match) { return undefined; } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } + result = ts.appendIfUnique(result, match); } return result; } @@ -24136,7 +24355,11 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t, propertySymbol) { + function addMemberForKeyType(t, propertySymbolOrIndex) { + var propertySymbol; + if (typeof propertySymbolOrIndex === "object") { + propertySymbol = propertySymbolOrIndex; + } var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); @@ -24151,6 +24374,7 @@ var ts; prop.syntheticOrigin = propertySymbol; prop.declarations = propertySymbol.declarations; } + prop.syntheticLiteralTypeOrigin = t; members.set(propName, prop); } else if (t.flags & 2) { @@ -24261,26 +24485,22 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getAllPossiblePropertiesOfType(type) { - if (type.flags & 65536) { - var props = ts.createSymbolTable(); - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var memberType = _a[_i]; - if (memberType.flags & 8190) { - continue; - } - for (var _b = 0, _c = getPropertiesOfType(memberType); _b < _c.length; _b++) { - var escapedName = _c[_b].escapedName; - if (!props.has(escapedName)) { - props.set(escapedName, createUnionOrIntersectionProperty(type, escapedName)); - } + function getAllPossiblePropertiesOfTypes(types) { + var unionType = getUnionType(types); + if (!(unionType.flags & 65536)) { + return getPropertiesOfType(unionType); + } + var props = ts.createSymbolTable(); + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var memberType = types_2[_i]; + for (var _a = 0, _b = getPropertiesOfType(memberType); _a < _b.length; _a++) { + var escapedName = _b[_a].escapedName; + if (!props.has(escapedName)) { + props.set(escapedName, createUnionOrIntersectionProperty(unionType, escapedName)); } } - return ts.arrayFrom(props.values()); - } - else { - return getPropertiesOfType(type); } + return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { return type.flags & 16384 ? getConstraintOfTypeParameter(type) : @@ -24342,8 +24562,8 @@ var ts; if (t.flags & 196608) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_2 = types_2[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); @@ -24406,20 +24626,15 @@ var ts; var commonFlags = isUnion ? 0 : 16777216; var syntheticFlag = 4; var checkFlags = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } + props = ts.appendIfUnique(props, prop); checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) | (!(modifiers & 24) ? 64 : 0) | (modifiers & 16 ? 128 : 0) | @@ -24545,12 +24760,7 @@ var ts; var result; ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) { var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - if (!result) { - result = []; - } - result.push(tp); - } + result = ts.appendIfUnique(result, tp); }); return result; } @@ -24586,7 +24796,7 @@ var ts; if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512); return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } function isOptionalParameter(node) { @@ -24636,11 +24846,10 @@ var ts; } return minTypeArgumentCount; } - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScript) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - var isJavaScript = ts.isInJavaScriptFile(location); if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; @@ -24672,7 +24881,7 @@ var ts; var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455, undefined, undefined); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455, undefined, undefined, false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -24860,8 +25069,8 @@ var ts; } return anyType; } - function getSignatureInstantiation(signature, typeArguments) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); + function getSignatureInstantiation(signature, typeArguments, isJavascript) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -24874,12 +25083,20 @@ var ts; return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); } function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); - } - return signature.erasedSignatureCache; + return signature.typeParameters ? + signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : + signature; + } + function createErasedSignature(signature) { + return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); + } + function getCanonicalSignature(signature) { + return signature.typeParameters ? + signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) : + signature; + } + function createCanonicalSignature(signature) { + return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJavaScriptFile(signature.declaration)); } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { @@ -24945,12 +25162,12 @@ var ts; function getTypeListId(types) { var result = ""; if (types) { - var length_5 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_5) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_5 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -24967,8 +25184,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -25004,13 +25221,14 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { + var isJavascript = ts.isInJavaScriptFile(node); + if (!isJavascript && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJavascript)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -25026,7 +25244,7 @@ var ts; var id = getTypeListId(typeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJavaScriptFile(symbol.valueDeclaration))))); } return instantiation; } @@ -25218,7 +25436,7 @@ var ts; return getGlobalSymbol(name, 793064, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); + return resolveName(undefined, name, meaning, diagnostic, name, false); } function getGlobalType(name, arity, reportErrors) { var symbol = getGlobalTypeSymbol(name, reportErrors); @@ -25364,6 +25582,20 @@ var ts; function containsType(types, type) { return binarySearchTypes(types, type) >= 0; } + function isEmptyIntersectionType(type) { + var combined = 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (t.flags & 6368 && combined & 6368) { + return true; + } + combined |= t.flags; + if (combined & 6144 && combined & (32768 | 16777216)) { + return true; + } + } + return false; + } function addTypeToUnion(typeSet, type) { var flags = type.flags; if (flags & 65536) { @@ -25380,7 +25612,7 @@ var ts; if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } - else if (!(flags & 8192)) { + else if (!(flags & 8192 || flags & 131072 && isEmptyIntersectionType(type))) { if (flags & 2) typeSet.containsString = true; if (flags & 4) @@ -25398,14 +25630,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -25413,8 +25645,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -25538,8 +25770,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -25685,20 +25917,6 @@ var ts; } return anyType; } - function getIndexedAccessForMappedType(type, indexType, accessNode) { - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(type))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); - return unknownType; - } - if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { - error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - } - } - var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); - var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); - } function isGenericObjectType(type) { return type.flags & 540672 ? true : getObjectFlags(type) & 32 ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : @@ -25738,12 +25956,15 @@ var ts; getIntersectionType(stringIndexTypes) ]); } + if (isGenericMappedType(objectType)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [type.indexType]); + var objectTypeMapper = objectType.mapper; + var templateMapper = objectTypeMapper ? combineTypeMappers(objectTypeMapper, mapper) : mapper; + return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); + } return undefined; } function getIndexedAccessType(objectType, indexType, accessNode) { - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180) && isGenericObjectType(objectType)) { if (objectType.flags & 1) { return objectType; @@ -25756,7 +25977,7 @@ var ts; return type; } var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 65536 && !(indexType.flags & 8190)) { + if (indexType.flags & 65536 && !(indexType.flags & 8)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -25832,7 +26053,10 @@ var ts; return mapType(right, function (t) { return getSpreadType(left, t); }); } if (right.flags & 16777216) { - return emptyObjectType; + return nonPrimitiveType; + } + if (right.flags & (136 | 84 | 262178 | 272)) { + return left; } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); @@ -26052,10 +26276,6 @@ var ts; function instantiateSignatures(signatures, mapper) { return instantiateList(signatures, mapper, instantiateSignature); } - function instantiateCached(type, mapper, instantiator) { - var instantiations = mapper.instantiations || (mapper.instantiations = []); - return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); - } function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -26074,19 +26294,15 @@ var ts; } function createTypeMapper(sources, targets) { ts.Debug.assert(targets === undefined || sources.length === targets.length); - var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : makeArrayTypeMapper(sources, targets); - mapper.mappedTypes = sources; - return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } function createBackreferenceMapper(typeParameters, index) { - var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; - mapper.mappedTypes = typeParameters; - return mapper; + return function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; } function isInferenceContext(mapper) { return !!mapper.signature; @@ -26096,18 +26312,11 @@ var ts; createInferenceContext(mapper.signature, mapper.flags | 2, mapper.compareTypes, mapper.inferences) : mapper; } - function identityMapper(type) { - return type; - } function combineTypeMappers(mapper1, mapper2) { - var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); - return mapper; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function createReplacementMapper(source, target, baseMapper) { - var mapper = function (t) { return t === source ? target : baseMapper(t); }; - mapper.mappedTypes = baseMapper.mappedTypes; - return mapper; + return function (t) { return t === source ? target : baseMapper(t); }; } function cloneTypeParameter(typeParameter) { var result = createType(16384); @@ -26165,15 +26374,50 @@ var ts; if (symbol.valueDeclaration) { result.valueDeclaration = symbol.valueDeclaration; } + if (symbol.isRestParameter) { + result.isRestParameter = symbol.isRestParameter; + } return result; } - function instantiateAnonymousType(type, mapper) { - var result = createObjectType(16 | 64, type.symbol); - result.target = type.objectFlags & 64 ? type.target : type; - result.mapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); - return result; + function getAnonymousTypeInstantiation(type, mapper) { + var target = type.objectFlags & 64 ? type.target : type; + var symbol = target.symbol; + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (!typeParameters) { + var declaration_1 = symbol.declarations[0]; + var outerTypeParameters = getOuterTypeParameters(declaration_1, true) || ts.emptyArray; + typeParameters = symbol.flags & 2048 && !target.aliasTypeArguments ? + ts.filter(outerTypeParameters, function (tp) { return isTypeParameterReferencedWithin(tp, declaration_1); }) : + outerTypeParameters; + links.typeParameters = typeParameters; + if (typeParameters.length) { + links.instantiations = ts.createMap(); + links.instantiations.set(getTypeListId(typeParameters), target); + } + } + if (typeParameters.length) { + var combinedMapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; + var typeArguments = ts.map(typeParameters, combinedMapper); + var id = getTypeListId(typeArguments); + var result = links.instantiations.get(id); + if (!result) { + var newMapper = createTypeMapper(typeParameters, typeArguments); + result = target.objectFlags & 32 ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + links.instantiations.set(id, result); + } + return result; + } + return type; + } + function isTypeParameterReferencedWithin(tp, node) { + return tp.isThisType ? ts.forEachChild(node, checkThis) : ts.forEachChild(node, checkIdentifier); + function checkThis(node) { + return node.kind === 169 || ts.forEachChild(node, checkThis); + } + function checkIdentifier(node) { + return node.kind === 71 && ts.isPartOfTypeNode(node) && getTypeFromTypeNode(node) === tp || ts.forEachChild(node, checkIdentifier); + } } function instantiateMappedType(type, mapper) { var constraintType = getConstraintTypeFromMappedType(type); @@ -26184,134 +26428,58 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + return instantiateAnonymousType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); } } } - return instantiateMappedObjectType(type, mapper); + return instantiateAnonymousType(type, mapper); } function isMappableType(type) { return type.flags & (16384 | 32768 | 131072 | 524288); } - function instantiateMappedObjectType(type, mapper) { - var result = createObjectType(32 | 64, type.symbol); - result.declaration = type.declaration; - result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + function instantiateAnonymousType(type, mapper) { + var result = createObjectType(type.objectFlags | 64, type.symbol); + if (type.objectFlags & 32) { + result.declaration = type.declaration; + } + result.target = type; + result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { - if (!(symbol.declarations && symbol.declarations.length)) { - return false; - } - var mappedTypes = mapper.mappedTypes; - return !!ts.findAncestor(symbol.declarations[0], function (node) { - if (node.kind === 233 || node.kind === 265) { - return "quit"; - } - switch (node.kind) { - case 160: - case 161: - case 228: - case 151: - case 150: - case 152: - case 155: - case 156: - case 157: - case 153: - case 154: - case 186: - case 187: - case 229: - case 199: - case 230: - case 231: - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (typeParameters) { - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var d = typeParameters_1[_i]; - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) { - return true; - } - } - } - if (ts.isClassLike(node) || node.kind === 230) { - var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; - if (thisType && ts.contains(mappedTypes, thisType)) { - return true; - } - } - break; - case 172: - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { - return true; - } - break; - case 273: - var func = node; - for (var _a = 0, _b = func.parameters; _a < _b.length; _a++) { - var p = _b[_a]; - if (ts.contains(mappedTypes, getTypeOfNode(p))) { - return true; - } - } - break; - } - }); - } - function isTopLevelTypeAlias(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 265 || parentKind === 234; - } - return false; - } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { - if (type.aliasTypeArguments) { - return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + if (type.flags & 16384) { + return mapper(type); + } + if (type.flags & 32768) { + if (type.objectFlags & 16) { + return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ? + getAnonymousTypeInstantiation(type, mapper) : type; + } + if (type.objectFlags & 32) { + return getAnonymousTypeInstantiation(type, mapper); + } + if (type.objectFlags & 4) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } - return type; } - return instantiateTypeNoAlias(type, mapper); - } - return type; - } - function instantiateTypeNoAlias(type, mapper) { - if (type.flags & 16384) { - return mapper(type); - } - if (type.flags & 32768) { - if (type.objectFlags & 16) { - return type.symbol && - type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && - (type.objectFlags & 64 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateCached(type, mapper, instantiateAnonymousType) : type; + if (type.flags & 65536 && !(type.flags & 8190)) { + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 32) { - return instantiateCached(type, mapper, instantiateMappedType); + if (type.flags & 131072) { + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 4) { - return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); + if (type.flags & 262144) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - } - if (type.flags & 65536 && !(type.flags & 8190)) { - return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 131072) { - return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 262144) { - return getIndexType(instantiateType(type.type, mapper)); - } - if (type.flags & 524288) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } return type; } @@ -26323,6 +26491,7 @@ var ts; switch (node.kind) { case 186: case 187: + case 151: return isContextSensitiveFunctionLikeDeclaration(node); case 178: return ts.forEach(node.properties, isContextSensitive); @@ -26336,9 +26505,6 @@ var ts; (isContextSensitive(node.left) || isContextSensitive(node.right)); case 261: return isContextSensitive(node.initializer); - case 151: - case 150: - return isContextSensitiveFunctionLikeDeclaration(node); case 185: return isContextSensitive(node.expression); case 254: @@ -26425,7 +26591,8 @@ var ts; if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { return 0; } - if (source.typeParameters) { + if (source.typeParameters && source.typeParameters !== target.typeParameters) { + target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } var result = -1; @@ -26668,6 +26835,13 @@ var ts; var targetStack; var maybeCount = 0; var depth = 0; + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); var expandingFlags = 0; var overflow = false; var isIntersectionConstituent = false; @@ -26851,10 +27025,21 @@ var ts; } else { var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; })) { - errorNode = prop.valueDeclaration; + var propDeclaration = prop.valueDeclaration; + ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); + errorNode = propDeclaration; + if (ts.isIdentifier(propDeclaration.name)) { + suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + } + } + if (suggestion !== undefined) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2, symbolToString(prop), typeToString(target), ts.unescapeLeadingUnderscores(suggestion)); + } + else { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } } return { value: true }; @@ -27061,7 +27246,7 @@ var ts; } } else if (target.flags & 524288) { - var constraint = getConstraintOfType(target); + var constraint = getConstraintOfIndexedAccess(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -27094,7 +27279,7 @@ var ts; } } else if (source.flags & 524288) { - var constraint = getConstraintOfType(source); + var constraint = getConstraintOfIndexedAccess(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -27169,22 +27354,21 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); + var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); + if (unmatchedProperty) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + } + return 0; + } var result = -1; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var targetProp = properties_3[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 16777216) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0; - } - } - else if (!(targetProp.flags & 4194304)) { + if (!(targetProp.flags & 4194304)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp && sourceProp !== targetProp) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { @@ -27456,9 +27640,10 @@ var ts; return type.flags & 16384 && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return getObjectFlags(type) & 4 && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + return getObjectFlags(type) & 4 && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } - function getTypeReferenceId(type, typeParameters) { + function getTypeReferenceId(type, typeParameters, depth) { + if (depth === void 0) { depth = 0; } var result = "" + type.target.id; for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { var t = _a[_i]; @@ -27470,6 +27655,9 @@ var ts; } result += "=" + index; } + else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; + } else { result += "-" + t.id; } @@ -27635,8 +27823,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27672,7 +27860,7 @@ var ts; return !!getPropertyOfType(type, "0"); } function isUnitType(type) { - return (type.flags & (224 | 2048 | 4096)) !== 0; + return !!(type.flags & 6368); } function isLiteralType(type) { return type.flags & 8 ? true : @@ -27700,8 +27888,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -27913,7 +28101,6 @@ var ts; function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; - context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; @@ -27951,7 +28138,7 @@ var ts; } function couldContainTypeVariables(type) { var objectFlags = getObjectFlags(type); - return !!(type.flags & 540672 || + return !!(type.flags & (540672 | 262144) || objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 2048 | 32) || objectFlags & 32 || @@ -28005,18 +28192,18 @@ var ts; return inference.candidates && getUnionType(inference.candidates, true); } } - function isPossiblyAssignableTo(source, target) { + function getUnmatchedProperty(source, target, requireOptionalProperties) { var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; - if (!(targetProp.flags & (16777216 | 4194304))) { - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (requireOptionalProperties || !(targetProp.flags & 16777216)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!sourceProp) { - return false; + return targetProp; } } } - return true; + return undefined; } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } @@ -28092,6 +28279,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 262144 && target.flags & 262144) { + inferFromTypes(source.type, target.type); + } + else if (source.flags & 524288 && target.flags & 524288) { + inferFromTypes(source.objectType, target.objectType); + inferFromTypes(source.indexType, target.indexType); + } else if (target.flags & 196608) { var targetTypes = target.types; var typeVariableCount = 0; @@ -28113,7 +28307,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 196608) { + else if (source.flags & 65536) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -28122,7 +28316,7 @@ var ts; } else { source = getApparentType(source); - if (source.flags & 32768) { + if (source.flags & (32768 | 131072)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -28157,6 +28351,10 @@ var ts; return undefined; } function inferFromObjectTypes(source, target) { + if (isGenericMappedType(source) && isGenericMappedType(target)) { + inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + } if (getObjectFlags(target) & 32) { var constraintType = getConstraintTypeFromMappedType(target); if (constraintType.flags & 262144) { @@ -28178,7 +28376,7 @@ var ts; return; } } - if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + if (!getUnmatchedProperty(source, target, false) || !getUnmatchedProperty(target, source, false)) { inferFromProperties(source, target); inferFromSignatures(source, target, 0); inferFromSignatures(source, target, 1); @@ -28189,7 +28387,7 @@ var ts; var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -28235,8 +28433,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28307,7 +28505,8 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = !ts.nodeIsMissing(node) && resolveName(node, node.escapedText, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + links.resolvedSymbol = !ts.nodeIsMissing(node) && + resolveName(node, node.escapedText, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node, !ts.isWriteOnlyAccess(node), ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } @@ -28471,8 +28670,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -28729,8 +28928,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -28799,8 +28998,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -28849,69 +29048,87 @@ var ts; } return false; } + function reportFlowControlError(node) { + var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); + var sourceFile = ts.getSourceFileOfNode(node); + var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; + var flowDepth = 0; + if (flowAnalysisDisabled) { + return unknownType; + } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810175)) { return declaredType; } - var visitedFlowStart = visitedFlowCount; + var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); - visitedFlowCount = visitedFlowStart; + sharedFlowCount = sharedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); if (reference.parent.kind === 203 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; function getTypeAtFlowNode(flow) { + if (flowDepth === 2500) { + flowAnalysisDisabled = true; + reportFlowControlError(reference); + return unknownType; + } + flowDepth++; while (true) { - if (flow.flags & 1024) { - for (var i = visitedFlowStart; i < visitedFlowCount; i++) { - if (visitedFlowNodes[i] === flow) { - return visitedFlowTypes[i]; + var flags = flow.flags; + if (flags & 1024) { + for (var i = sharedFlowStart; i < sharedFlowCount; i++) { + if (sharedFlowNodes[i] === flow) { + flowDepth--; + return sharedFlowTypes[i]; } } } var type = void 0; - if (flow.flags & 4096) { + if (flags & 4096) { flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flow.flags & 2048) { + else if (flags & 2048) { flow = flow.antecedent; continue; } - else if (flow.flags & 16) { + else if (flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 96) { + else if (flags & 96) { type = getTypeAtFlowCondition(flow); } - else if (flow.flags & 128) { + else if (flags & 128) { type = getTypeAtSwitchClause(flow); } - else if (flow.flags & 12) { + else if (flags & 12) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flow.flags & 4 ? + type = flags & 4 ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flow.flags & 256) { + else if (flags & 256) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 2) { + else if (flags & 2) { var container = flow.container; if (container && container !== flowContainer && reference.kind !== 179 && reference.kind !== 99) { flow = container.flowNode; @@ -28922,11 +29139,12 @@ var ts; else { type = convertAutoToAny(declaredType); } - if (flow.flags & 1024) { - visitedFlowNodes[visitedFlowCount] = flow; - visitedFlowTypes[visitedFlowCount] = type; - visitedFlowCount++; + if (flags & 1024) { + sharedFlowNodes[sharedFlowCount] = flow; + sharedFlowTypes[sharedFlowCount] = type; + sharedFlowCount++; } + flowDepth--; return type; } } @@ -28955,30 +29173,32 @@ var ts; return undefined; } function getTypeAtFlowArrayMutation(flow) { - var node = flow.node; - var expr = node.kind === 181 ? - node.expression.expression : - node.left.expression; - if (isMatchingReference(reference, getReferenceCandidate(expr))) { - var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); - if (getObjectFlags(type) & 256) { - var evolvedType_1 = type; - if (node.kind === 181) { - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var arg = _a[_i]; - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + if (declaredType === autoType || declaredType === autoArrayType) { + var node = flow.node; + var expr = node.kind === 181 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (getObjectFlags(type) & 256) { + var evolvedType_1 = type; + if (node.kind === 181) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } } - } - else { - var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84)) { - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + else { + var indexType = getTypeOfExpression(node.left.argumentExpression); + if (isTypeAssignableToKind(indexType, 84)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); } - return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + return flowType; } - return flowType; } return undefined; } @@ -29024,9 +29244,7 @@ var ts; if (type === declaredType && declaredType === initialType) { return type; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); if (!isTypeSubsetOf(type, declaredType)) { subtypeReduction = true; } @@ -29073,9 +29291,7 @@ var ts; if (cached_1) { return cached_1; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); if (!isTypeSubsetOf(type, declaredType)) { subtypeReduction = true; } @@ -29849,7 +30065,8 @@ var ts; } } } - if (noImplicitThis || ts.isInJavaScriptFile(func)) { + var inJs = ts.isInJavaScriptFile(func); + if (noImplicitThis || inJs) { var containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { var contextualType = getApparentTypeOfContextualType(containingLiteral); @@ -29868,10 +30085,18 @@ var ts; } return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } - if (func.parent.kind === 194 && func.parent.operatorToken.kind === 58) { - var target = func.parent.left; + var parent = func.parent; + if (parent.kind === 194 && parent.operatorToken.kind === 58) { + var target = parent.left; if (target.kind === 179 || target.kind === 180) { - return checkExpressionCached(target.expression); + var expression = target.expression; + if (inJs && ts.isIdentifier(expression)) { + var sourceFile = ts.getSourceFileOfNode(parent); + if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) { + return undefined; + } + } + return checkExpressionCached(expression); } } } @@ -30025,7 +30250,7 @@ var ts; else if (operator === 54) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { - type = getTypeOfExpression(binaryExpression.left); + type = getTypeOfExpression(binaryExpression.left, true); } return type; } @@ -30071,16 +30296,10 @@ var ts; } return undefined; } - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getApparentTypeOfContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1) - || getIteratedTypeOrElementType(type, undefined, false, false, false); - } - return undefined; + function getContextualTypeForElementExpression(arrayContextualType, index) { + return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) + || getIndexTypeOfContextualType(arrayContextualType, 1) + || getIteratedTypeOrElementType(arrayContextualType, undefined, false, false, false)); } function getContextualTypeForConditionalOperand(node) { var conditional = node.parent; @@ -30154,15 +30373,20 @@ var ts; return getContextualTypeForObjectLiteralElement(parent); case 263: return getApparentTypeOfContextualType(parent.parent); - case 177: - return getContextualTypeForElementExpression(node); + case 177: { + var arrayLiteral = parent; + var type = getApparentTypeOfContextualType(arrayLiteral); + return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); + } case 195: return getContextualTypeForConditionalOperand(node); case 205: ts.Debug.assert(parent.parent.kind === 196); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 185: - return getContextualType(parent); + case 185: { + var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); + } case 256: return getContextualTypeForJsxExpression(parent); case 253: @@ -30225,8 +30449,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -30264,8 +30488,9 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); - for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { - var e = elements_1[_i]; + var contextualType = getApparentTypeOfContextualType(node); + for (var index = 0; index < elements.length; index++) { + var e = elements[index]; if (inDestructuringPattern && e.kind === 198) { var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || @@ -30275,7 +30500,8 @@ var ts; } } else { - var type = checkExpressionForMutableLocation(e, checkMode); + var elementContextualType = getContextualTypeForElementExpression(contextualType, index); + var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === 198; @@ -30286,15 +30512,15 @@ var ts; type.pattern = node; return type; } - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - var pattern = contextualType.pattern; + var contextualType_1 = getApparentTypeOfContextualType(node); + if (contextualType_1 && contextualTypeIsTupleLikeType(contextualType_1)) { + var pattern = contextualType_1.pattern; if (pattern && (pattern.kind === 175 || pattern.kind === 177)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.typeArguments[i]); + elementTypes.push(contextualType_1.typeArguments[i]); } else { if (patternElement.kind !== 200) { @@ -30380,6 +30606,7 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; + var literalName = void 0; if (memberDecl.kind === 261 || memberDecl.kind === 262 || ts.isObjectLiteralMethod(memberDecl)) { @@ -30389,6 +30616,12 @@ var ts; } var type = void 0; if (memberDecl.kind === 261) { + if (memberDecl.name.kind === 144) { + var t = checkComputedPropertyName(memberDecl.name); + if (t.flags & 224) { + literalName = ts.escapeLeadingUnderscores("" + t.value); + } + } type = checkPropertyAssignment(memberDecl, checkMode); } else if (memberDecl.kind === 151) { @@ -30403,14 +30636,14 @@ var ts; type = jsdocType; } typeFlags |= type.flags; - var prop = createSymbol(4 | member.flags, member.escapedName); + var prop = createSymbol(4 | member.flags, literalName || member.escapedName); if (inDestructuringPattern) { var isOptional = (memberDecl.kind === 261 && hasDefaultValue(memberDecl.initializer)) || (memberDecl.kind === 262 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; } } @@ -30457,7 +30690,7 @@ var ts; ts.Debug.assert(memberDecl.kind === 153 || memberDecl.kind === 154); checkNodeDeferred(memberDecl); } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -30515,7 +30748,8 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048 | 16777216) || + return !!(type.flags & (1 | 16777216) || + getFalsyFlags(type) & 7392 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -30705,8 +30939,9 @@ var ts; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { var signature = signatures_3[_i]; if (signature.typeParameters) { - var typeArguments = fillMissingTypeArguments(undefined, signature.typeParameters, 0); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + var isJavascript = ts.isInJavaScriptFile(node); + var typeArguments = fillMissingTypeArguments(undefined, signature.typeParameters, 0, isJavascript); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); } else { instantiatedSignatures.push(signature); @@ -30989,7 +31224,7 @@ var ts; checkJsxPreconditions(node); var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(); - var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace); + var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace, true); if (reactSym) { reactSym.isReferenced = true; if (reactSym.flags & 2097152 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { @@ -31165,19 +31400,8 @@ var ts; } return unknownType; } - if (prop.valueDeclaration) { - if (isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - if (prop.valueDeclaration.kind === 229 && - node.parent && node.parent.kind !== 159 && - !ts.isInAmbientContext(prop.valueDeclaration) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - } - markPropertyAsReferenced(prop); + checkPropertyNotUsedBeforeDeclaration(prop, node, right); + markPropertyAsReferenced(prop, node); getNodeLinks(node).resolvedSymbol = prop; checkPropertyAccessibility(node, left, apparentType, prop); var propType = getDeclaredOrApparentType(prop, node); @@ -31196,6 +31420,56 @@ var ts; var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { + var valueDeclaration = prop.valueDeclaration; + if (!valueDeclaration) { + return; + } + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) + && !isPropertyDeclaredInAncestorClass(prop)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + else if (valueDeclaration.kind === 229 && + node.parent.kind !== 159 && + !ts.isInAmbientContext(valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + } + function isInPropertyInitializer(node) { + return !!ts.findAncestor(node, function (node) { + switch (node.kind) { + case 149: + return true; + case 261: + return false; + default: + return ts.isPartOfExpression(node) ? false : "quit"; + } + }); + } + function isPropertyDeclaredInAncestorClass(prop) { + var classType = getTypeOfSymbol(prop.parent); + while (true) { + classType = getSuperClass(classType); + if (!classType) { + return false; + } + var superProperty = getPropertyOfObjectType(classType, prop.escapedName); + if (superProperty && superProperty.valueDeclaration) { + return true; + } + } + } + function getSuperClass(classType) { + var x = getBaseTypes(classType); + if (x.length === 0) { + return undefined; + } + ts.Debug.assert(x.length === 1); + return x[0]; + } function reportNonexistentProperty(propNode, containingType) { var errorInfo; if (containingType.flags & 65536 && !(containingType.flags & 8190)) { @@ -31208,8 +31482,8 @@ var ts; } } var suggestion = getSuggestionForNonexistentProperty(propNode, containingType); - if (suggestion) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); + if (suggestion !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), ts.unescapeLeadingUnderscores(suggestion)); } else { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); @@ -31221,7 +31495,7 @@ var ts; return suggestion && suggestion.escapedName; } function getSuggestionForNonexistentSymbol(location, name, meaning) { - var result = resolveNameHelper(location, name, meaning, undefined, name, function (symbols, name, meaning) { + var result = resolveNameHelper(location, name, meaning, undefined, name, false, function (symbols, name, meaning) { var symbol = getSymbol(symbols, name, meaning); if (symbol) { return symbol; @@ -31281,11 +31555,12 @@ var ts; } return bestCandidate; } - function markPropertyAsReferenced(prop) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly) { if (prop && noUnusedIdentifiers && (prop.flags & 106500) && - prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8) + && !(nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly))) { if (ts.getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } @@ -31294,15 +31569,6 @@ var ts; } } } - function isInPropertyInitializer(node) { - while (node) { - if (node.parent && node.parent.kind === 149 && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } function isValidPropertyAccess(node, propertyName) { var left = node.kind === 179 ? node.expression @@ -31493,7 +31759,6 @@ var ts; var argCount; var typeArguments; var callIsIncomplete; - var isDecorator; var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { return true; @@ -31515,7 +31780,6 @@ var ts; } } else if (node.kind === 147) { - isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); } @@ -31564,7 +31828,7 @@ var ts; if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 4); } - return getSignatureInstantiation(signature, getInferredTypes(context)); + return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJavaScriptFile(contextualSignature.declaration)); } function inferTypeArguments(node, signature, args, excludeArgument, context) { for (var _i = 0, _a = context.inferences; _i < _a.length; _i++) { @@ -31573,13 +31837,13 @@ var ts; inference.inferredType = undefined; } } - if (ts.isExpression(node)) { + if (node.kind !== 147) { var contextualType = getContextualType(node); if (contextualType) { var instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 4); @@ -31999,8 +32263,9 @@ var ts; candidate = originalCandidate; if (candidate.typeParameters) { var typeArgumentTypes = void 0; + var isJavascript = ts.isInJavaScriptFile(candidate.declaration); if (typeArguments) { - typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript); if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false)) { candidateForTypeArgumentError = originalCandidate; break; @@ -32009,7 +32274,7 @@ var ts; else { typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); } if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { candidateForArgumentError = candidate; @@ -32115,11 +32380,6 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasModifier(valueDecl, 128)) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); - return resolveErrorCall(node); - } if (isTypeAny(expressionType)) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -32131,6 +32391,11 @@ var ts; if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); } + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && ts.hasModifier(valueDecl, 128)) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } var callSignatures = getSignaturesOfType(expressionType, 0); @@ -32244,8 +32509,8 @@ var ts; if (elementType.flags & 65536) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var type = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -32270,7 +32535,7 @@ var ts; case 250: return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } - ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); + ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); @@ -32284,16 +32549,30 @@ var ts; return result; } function isJavaScriptConstructor(node) { - if (ts.isInJavaScriptFile(node)) { + if (node && ts.isInJavaScriptFile(node)) { if (ts.getJSDocClassTag(node)) return true; var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : - ts.isVariableDeclaration(node) && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : + ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; return symbol && symbol.members !== undefined; } return false; } + function getJavaScriptClassType(symbol) { + if (ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = getSymbolOfNode(symbol.valueDeclaration.initializer); + } + if (isJavaScriptConstructor(symbol.valueDeclaration)) { + return getInferredClassType(symbol); + } + if (symbol.flags & 3) { + var valueType = getTypeOfSymbol(symbol); + if (valueType.symbol && !isInferredClassType(valueType) && isJavaScriptConstructor(valueType.symbol.valueDeclaration)) { + return getInferredClassType(valueType.symbol); + } + } + } function getInferredClassType(symbol) { var links = getSymbolLinks(symbol); if (!links.inferredClassType) { @@ -32322,13 +32601,11 @@ var ts; var funcSymbol = node.expression.kind === 71 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { - funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + var type = funcSymbol && getJavaScriptClassType(funcSymbol); + if (type) { + return type; } - if (funcSymbol && funcSymbol.flags & 16 && (funcSymbol.members || ts.getJSDocClassTag(funcSymbol.valueDeclaration))) { - return getInferredClassType(funcSymbol); - } - else if (noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -32389,7 +32666,7 @@ var ts; } if (!ts.isIdentifier(node.expression)) throw ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455, undefined, undefined); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455, undefined, undefined, true); if (!resolvedRequire) { return true; } @@ -32495,7 +32772,7 @@ var ts; } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { + if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } @@ -32625,9 +32902,7 @@ var ts; ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } }); return aggregatedTypes; @@ -32671,9 +32946,7 @@ var ts; if (type.flags & 8192) { hasReturnOfTypeNever = true; } - else if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } else { hasReturnWithNoExpression = true; @@ -32684,9 +32957,7 @@ var ts; return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { - if (!ts.contains(aggregatedTypes, undefinedType)) { - aggregatedTypes.push(undefinedType); - } + ts.pushIfUnique(aggregatedTypes, undefinedType); } return aggregatedTypes; } @@ -32939,8 +33210,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -33438,20 +33709,6 @@ var ts; var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } - function checkLiteralExpression(node) { - switch (node.kind) { - case 13: - case 9: - return getFreshTypeOfLiteralType(getLiteralType(node.text)); - case 8: - checkGrammarNumericLiteral(node); - return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101: - return trueType; - case 86: - return falseType; - } - } function checkTemplateExpression(node) { ts.forEach(node.templateSpans, function (templateSpan) { checkExpression(templateSpan.expression); @@ -33503,9 +33760,13 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, checkMode) { + function checkExpressionForMutableLocation(node, checkMode, contextualType) { + if (arguments.length === 2) { + contextualType = getContextualType(node); + } var type = checkExpression(node, checkMode); - return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); + var shouldWiden = isTypeAssertion(node) || isLiteralContextualType(contextualType); + return shouldWiden ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, checkMode) { if (node.name.kind === 144) { @@ -33573,12 +33834,9 @@ var ts; return type; } function checkParenthesizedExpression(node, checkMode) { - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - var typecasts = ts.flatMap(node.jsDoc, function (doc) { return ts.filter(doc.tags, function (tag) { return tag.kind === 281; }); }); - if (typecasts && typecasts.length) { - var cast_1 = typecasts[0]; - return checkAssertionWorker(cast_1, cast_1.typeExpression.type, node.expression, checkMode); - } + var tag = ts.isInJavaScriptFile(node) ? ts.getJSDocTypeTag(node) : undefined; + if (tag) { + return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -33594,10 +33852,14 @@ var ts; return nullWideningType; case 13: case 9: + return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8: + checkGrammarNumericLiteral(node); + return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101: + return trueType; case 86: - return checkLiteralExpression(node); + return falseType; case 196: return checkTemplateExpression(node); case 12: @@ -34146,7 +34408,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, ts.isInJavaScriptFile(typeArgumentNodes[i])); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -34214,6 +34476,10 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && + getObjectFlags(objectType) & 32 && objectType.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + } return type; } if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 84)) { @@ -34479,6 +34745,7 @@ var ts; switch (d.kind) { case 230: case 231: + case 283: return 2; case 233: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 @@ -34488,6 +34755,8 @@ var ts; case 232: return 2 | 1; case 237: + case 240: + case 239: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -34677,8 +34946,11 @@ var ts; markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node)); } function markEntityNameOrEntityExpressionAsReference(typeName) { - var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.escapedText, (typeName.kind === 71 ? 793064 : 1920) | 2097152, undefined, undefined); + if (!typeName) + return; + var rootName = getFirstIdentifier(typeName); + var meaning = (typeName.kind === 71 ? 793064 : 1920) | 2097152; + var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true); if (rootSymbol && rootSymbol.flags & 2097152 && symbolIsValue(rootSymbol) @@ -34784,22 +35056,12 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } - function checkJSDoc(node) { - if (!ts.isInJavaScriptFile(node)) { - return; - } - ts.forEach(node.jsDoc, checkSourceElement); - } - function checkJSDocComment(node) { - if (node.tags) { - for (var _i = 0, _a = node.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - checkSourceElement(tag); - } + function checkJSDocTypedefTag(node) { + if (!node.typeExpression) { + error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags); } } function checkFunctionOrMethodDeclaration(node) { - checkJSDoc(node); checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); @@ -34904,11 +35166,11 @@ var ts; !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { - error(name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(local.escapedName)); + error(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(local.escapedName)); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return errorUnusedLocal(ts.getNameOfDeclaration(d) || d, ts.unescapeLeadingUnderscores(local.escapedName)); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d, ts.unescapeLeadingUnderscores(local.escapedName)); }); } } }); @@ -34921,15 +35183,17 @@ var ts; } return false; } - function errorUnusedLocal(node, name) { + function errorUnusedLocal(declaration, name) { + var node = ts.getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 226 && ts.isForInOrOfStatement(declaration.parent.parent)) { + var declaration_2 = ts.getRootDeclaration(node.parent); + if ((declaration_2.kind === 226 && ts.isForInOrOfStatement(declaration_2.parent.parent)) || + declaration_2.kind === 145) { return; } } if (!isRemovedPropertyFromObjectSpread(node.kind === 71 ? node.parent : node)) { - error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + error(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name); } } function parameterNameStartsWithUnderscore(parameterName) { @@ -34945,14 +35209,14 @@ var ts; var member = _a[_i]; if (member.kind === 151 || member.kind === 149) { if (!member.symbol.isReferenced && ts.hasModifier(member, 8)) { - error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); + error(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { - error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); + error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } } @@ -34970,8 +35234,8 @@ var ts; } for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { var typeParameter = _a[_i]; - if (!getMergedSymbol(typeParameter.symbol).isReferenced) { - error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); + if (!getMergedSymbol(typeParameter.symbol).isReferenced && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } } @@ -34984,7 +35248,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - errorUnusedLocal(ts.getNameOfDeclaration(declaration), ts.unescapeLeadingUnderscores(local.escapedName)); + errorUnusedLocal(declaration, ts.unescapeLeadingUnderscores(local.escapedName)); } } } @@ -34995,7 +35259,14 @@ var ts; if (node.kind === 207) { checkGrammarStatementInAmbientContext(node); } - ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionOrModuleBlock(node)) { + var saveFlowAnalysisDisabled = flowAnalysisDisabled; + ts.forEach(node.statements, checkSourceElement); + flowAnalysisDisabled = saveFlowAnalysisDisabled; + } + else { + ts.forEach(node.statements, checkSourceElement); + } if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -35125,7 +35396,7 @@ var ts; if (symbol.flags & 1) { if (!ts.isIdentifier(node.name)) throw ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { @@ -35161,7 +35432,7 @@ var ts; return visit(n.expression); } else if (n.kind === 71) { - var symbol = resolveName(n, n.escapedText, 107455 | 2097152, undefined, undefined); + var symbol = resolveName(n, n.escapedText, 107455 | 2097152, undefined, undefined, false); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; } @@ -35222,7 +35493,7 @@ var ts; var parentType = getTypeForBindingElementParent(parent); var name = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); - markPropertyAsReferenced(property); + markPropertyAsReferenced(property, undefined); if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); } @@ -36627,8 +36898,8 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + if (modulekind >= ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -36655,7 +36926,7 @@ var ts; if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } - if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015) { + if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015 && modulekind !== ts.ModuleKind.ESNext) { checkExternalEmitHelpers(node, 32768); } } @@ -36672,7 +36943,7 @@ var ts; checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; - var symbol = resolveName(exportedName, exportedName.escapedText, 107455 | 793064 | 1920 | 2097152, undefined, undefined); + var symbol = resolveName(exportedName, exportedName.escapedText, 107455 | 793064 | 1920 | 2097152, undefined, undefined, true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.unescapeLeadingUnderscores(exportedName.escapedText)); } @@ -36705,9 +36976,12 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); + if (ts.isInAmbientContext(node) && !ts.isEntityNameExpression(node.expression)) { + grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); + } if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES2015) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); + if (modulekind >= ts.ModuleKind.ES2015) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); @@ -36737,7 +37011,7 @@ var ts; if (flags & (1920 | 64 | 384)) { return; } - var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor); if (flags & 524288 && exportedDeclarationsCount <= 2) { return; } @@ -36752,15 +37026,24 @@ var ts; }); links.exportsChecked = true; } - function isNotOverload(declaration) { - return (declaration.kind !== 228 && declaration.kind !== 151) || - !!declaration.body; - } + } + function isNotAccessor(declaration) { + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 228 && declaration.kind !== 151) || + !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } + if (ts.isInJavaScriptFile(node) && node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var tags = _a[_i].tags; + ts.forEach(tags, checkSourceElement); + } + } var kind = node.kind; if (cancellationToken) { switch (kind) { @@ -36812,8 +37095,8 @@ var ts; case 168: case 170: return checkSourceElement(node.type); - case 275: - return checkJSDocComment(node); + case 283: + return checkJSDocTypedefTag(node); case 279: return checkSourceElement(node.typeExpression); case 273: @@ -36943,6 +37226,7 @@ var ts; ts.clear(potentialNewTargetCollisions); deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; + flowAnalysisDisabled = false; ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalModule(node)) { @@ -37272,11 +37556,13 @@ var ts; return sig.thisParameter; } } - case 97: - var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); - return type.symbol; + if (ts.isInExpressionContext(node)) { + return checkExpression(node).symbol; + } case 169: - return getTypeFromTypeNode(node).symbol; + return getTypeFromThisTypeNode(node).symbol; + case 97: + return checkExpression(node).symbol; case 123: var constructorDeclaration = node.parent; if (constructorDeclaration && constructorDeclaration.kind === 152) { @@ -37290,13 +37576,17 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 180 && node.parent.argumentExpression === node) { - var objectType = getTypeOfExpression(node.parent.expression); - return getPropertyOfType(objectType, node.text); - } - break; + var objectType = ts.isElementAccessExpression(node.parent) + ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined + : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) + ? getTypeFromTypeNode(node.parent.parent.objectType) + : undefined; + return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); + case 79: + return getSymbolOfNode(node.parent); + default: + return undefined; } - return undefined; } function getShorthandAssignmentValueSymbol(location) { if (location && location.kind === 262) { @@ -37407,9 +37697,9 @@ var ts; function getRootSymbols(symbol) { if (ts.getCheckFlags(symbol) & 6) { var symbols_4 = []; - var name_2 = symbol.escapedName; + var name_3 = symbol.escapedName; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_2); + var symbol = getPropertyOfType(t, name_3); if (symbol) { symbols_4.push(symbol); } @@ -37510,7 +37800,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (!!resolveName(container.parent, symbol.escapedName, 107455, undefined, undefined)) { + if (resolveName(container.parent, symbol.escapedName, 107455, undefined, undefined, false)) { links.isDeclarationWithCollidingName = true; } else if (nodeLinks_1.flags & 131072) { @@ -37653,6 +37943,14 @@ var ts; return type.flags & 32768 && getSignaturesOfType(type, 0).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { + typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + if (!typeName) + return ts.TypeReferenceSerializationKind.Unknown; + if (location) { + location = ts.getParseTreeNode(location); + if (!location) + return ts.TypeReferenceSerializationKind.Unknown; + } var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); if (valueSymbol && valueSymbol === typeSymbol) { @@ -37736,7 +38034,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 107455 | 1048576 | 2097152, undefined, undefined); + return resolveName(location, reference.escapedText, 107455 | 1048576 | 2097152, undefined, undefined, true); } function getReferencedValueDeclaration(reference) { if (!ts.isGeneratedIdentifier(reference)) { @@ -38012,7 +38310,7 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -38034,12 +38332,6 @@ var ts; case 113: case 112: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 113) { - lastProtected = modifier; - } - else if (modifier.kind === 112) { - lastPrivate = modifier; - } if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } @@ -38531,7 +38823,7 @@ var ts; currentKind = SetAccessor; } else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -38791,7 +39083,7 @@ var ts; } } } - if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { checkESModuleMarker(node.name); } @@ -38806,8 +39098,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var element = elements_1[_i]; if (!ts.isOmittedExpression(element)) { return checkESModuleMarker(element.name); } @@ -38822,8 +39114,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var element = elements_3[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -39272,7 +39564,7 @@ var ts; || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer - ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node; } ts.updateParameter = updateParameter; @@ -39888,13 +40180,26 @@ var ts; return node; } ts.createArrowFunction = createArrowFunction; - function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { + function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody, bodyOrUndefined) { + var equalsGreaterThanToken; + var body; + if (bodyOrUndefined === undefined) { + equalsGreaterThanToken = node.equalsGreaterThanToken; + body = ts.cast(equalsGreaterThanTokenOrBody, ts.isConciseBody); + } + else { + equalsGreaterThanToken = ts.cast(equalsGreaterThanTokenOrBody, function (n) { + return n.kind === 36; + }); + body = bodyOrUndefined; + } return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type + || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } ts.updateArrowFunction = updateArrowFunction; @@ -39999,11 +40304,23 @@ var ts; return node; } ts.createConditional = createConditional; - function updateConditional(node, condition, whenTrue, whenFalse) { + function updateConditional(node, condition) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + if (args.length === 2) { + var whenTrue_1 = args[0], whenFalse_1 = args[1]; + return updateConditional(node, condition, node.questionToken, whenTrue_1, node.colonToken, whenFalse_1); + } + ts.Debug.assert(args.length === 4); + var questionToken = args[0], whenTrue = args[1], colonToken = args[2], whenFalse = args[3]; return node.condition !== condition + || node.questionToken !== questionToken || node.whenTrue !== whenTrue + || node.colonToken !== colonToken || node.whenFalse !== whenFalse - ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node) : node; } ts.updateConditional = updateConditional; @@ -40021,6 +40338,30 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; + function createTemplateHead(text) { + var node = createSynthesizedNode(14); + node.text = text; + return node; + } + ts.createTemplateHead = createTemplateHead; + function createTemplateMiddle(text) { + var node = createSynthesizedNode(15); + node.text = text; + return node; + } + ts.createTemplateMiddle = createTemplateMiddle; + function createTemplateTail(text) { + var node = createSynthesizedNode(16); + node.text = text; + return node; + } + ts.createTemplateTail = createTemplateTail; + function createNoSubstitutionTemplateLiteral(text) { + var node = createSynthesizedNode(13); + node.text = text; + return node; + } + ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { var node = createSynthesizedNode(197); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; @@ -41108,6 +41449,10 @@ var ts; return createCall(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []); } ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression; + function createImmediatelyInvokedArrowFunction(statements, param, paramValue) { + return createCall(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []); + } + ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { return createBinary(left, 26, right); } @@ -41303,9 +41648,7 @@ var ts; var emitNode = getOrCreateEmitNode(node); for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { var helper = helpers_1[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } + emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper); } } return node; @@ -41338,9 +41681,7 @@ var ts; var helper = sourceEmitHelpers[i]; if (predicate(helper)) { helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } + targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper); } else if (helpersRemoved > 0) { sourceEmitHelpers[i - helpersRemoved] = helper; @@ -42058,11 +42399,9 @@ var ts; return recreateOuterExpressions(expression, mutableCall, 4); } } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { - return ts.setTextRange(ts.createParen(expression), expression); - } + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { + return ts.setTextRange(ts.createParen(expression), expression); } return expression; } @@ -42198,9 +42537,17 @@ var ts; case 288: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } + function isIgnorableParen(node) { + return node.kind === 185 + && ts.nodeIsSynthesized(node) + && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) + && ts.nodeIsSynthesized(ts.getCommentRange(node)) + && !ts.some(ts.getSyntheticLeadingComments(node)) + && !ts.some(ts.getSyntheticTrailingComments(node)); + } function recreateOuterExpressions(outerExpression, innerExpression, kinds) { if (kinds === void 0) { kinds = 7; } - if (outerExpression && isOuterExpression(outerExpression, kinds)) { + if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression)); } return innerExpression; @@ -42226,7 +42573,8 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var create = hasExportStarsToExportValues && moduleKind !== ts.ModuleKind.System - && moduleKind !== ts.ModuleKind.ES2015; + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { @@ -42656,7 +43004,7 @@ var ts; case 186: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 188: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: @@ -42672,7 +43020,7 @@ var ts; case 194: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 195: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 196: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 197: @@ -43426,7 +43774,7 @@ var ts; } else { var name = node.name; - if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { + if (name && !uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); uniqueExports.set(ts.unescapeLeadingUnderscores(name.escapedText), true); exportedNames = ts.append(exportedNames, name); @@ -43719,7 +44067,7 @@ var ts; } function createDestructuringPropertyAccess(flattenContext, value, propertyName) { if (ts.isComputedPropertyName(propertyName)) { - var argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, false, propertyName); + var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName); return ts.createElementAccess(value, argumentExpression); } else if (ts.isStringOrNumericLiteral(propertyName)) { @@ -43902,6 +44250,21 @@ var ts; return saveStateAndInvoke(node, sourceElementVisitorWorker); } function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 238: + case 237: + case 243: + case 244: + return visitEllidableStatement(node); + default: + return visitorWorker(node); + } + } + function visitEllidableStatement(node) { + var parsed = ts.getParseTreeNode(node); + if (parsed !== node) { + return node; + } switch (node.kind) { case 238: return visitImportDeclaration(node); @@ -43912,7 +44275,7 @@ var ts; case 244: return visitExportDeclaration(node); default: - return visitorWorker(node); + ts.Debug.fail("Unhandled ellided statement"); } } function namespaceElementVisitor(node) { @@ -44062,7 +44425,7 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && - !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { @@ -44126,8 +44489,10 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, context.endLexicalEnvironment()); + var iife = ts.createImmediatelyInvokedArrowFunction(statements); + ts.setEmitFlags(iife, 33554432); var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, ts.createImmediatelyInvokedFunctionExpression(statements)) + ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, iife) ])); ts.setOriginalNode(varStatement, node); ts.setCommentRange(varStatement, node); @@ -44733,7 +45098,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; - name.parent = currentScope; + name.parent = ts.getParseTreeNode(currentScope); if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -44863,7 +45228,7 @@ var ts; return updated; } function visitArrowFunction(node) { - var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.visitFunctionBody(node.body, visitor, context)); return updated; } function visitParameter(node) { @@ -44999,6 +45364,7 @@ var ts; return isExportOfNamespace(node) || (isExternalModuleExport(node) && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { @@ -45458,7 +45824,6 @@ var ts; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var currentSourceFile; var enabledSubstitutions; var enclosingSuperContainerFlags = 0; var previousOnEmitNode = context.onEmitNode; @@ -45470,10 +45835,8 @@ var ts; if (node.isDeclarationFile) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -45516,7 +45879,7 @@ var ts; : ts.visitFunctionBody(node.body, visitor, context)); } function visitArrowFunction(node) { - return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -45806,8 +46169,8 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { - var e = elements_4[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; if (e.kind === 263) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); @@ -45825,7 +46188,7 @@ var ts; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } else { - chunkObject.push(e); + chunkObject.push(ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } } } @@ -46015,7 +46378,7 @@ var ts; function visitArrowFunction(node) { var savedEnclosingFunctionFlags = enclosingFunctionFlags; enclosingFunctionFlags = ts.getFunctionFlags(node); - var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; return updated; } @@ -46840,58 +47203,12 @@ var ts; && node.kind === 219 && !node.expression; } - function isClassLikeVariableStatement(node) { - if (!ts.isVariableStatement(node)) - return false; - var variable = ts.singleOrUndefined(node.declarationList.declarations); - return variable - && variable.initializer - && ts.isIdentifier(variable.name) - && (ts.isClassLike(variable.initializer) - || (ts.isAssignmentExpression(variable.initializer) - && ts.isIdentifier(variable.initializer.left) - && ts.isClassLike(variable.initializer.right))); - } - function isTypeScriptClassWrapper(node) { - var call = ts.tryCast(node, ts.isCallExpression); - if (!call || ts.isParseTreeNode(call) || - ts.some(call.typeArguments) || - ts.some(call.arguments)) { - return false; - } - var func = ts.tryCast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression); - if (!func || ts.isParseTreeNode(func) || - ts.some(func.typeParameters) || - ts.some(func.parameters) || - func.type || - !func.body) { - return false; - } - var statements = func.body.statements; - if (statements.length < 2) { - return false; - } - var firstStatement = statements[0]; - if (ts.isParseTreeNode(firstStatement) || - !ts.isClassLike(firstStatement) && - !isClassLikeVariableStatement(firstStatement)) { - return false; - } - var lastStatement = ts.elementAt(statements, -1); - var returnStatement = ts.tryCast(ts.isVariableStatement(lastStatement) ? ts.elementAt(statements, -2) : lastStatement, ts.isReturnStatement); - if (!returnStatement || - !returnStatement.expression || - !ts.isIdentifier(ts.skipOuterExpressions(returnStatement.expression))) { - return false; - } - return true; - } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 207))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) - || isTypeScriptClassWrapper(node); + || (ts.getEmitFlags(node) & 33554432) !== 0; } function visitor(node) { if (shouldVisitNode(node)) { @@ -48371,7 +48688,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - if (isTypeScriptClassWrapper(node)) { + if (ts.getEmitFlags(node) & 33554432) { return visitTypeScriptClassWrapper(node); } if (node.transformFlags & 64) { @@ -48380,7 +48697,7 @@ var ts; return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitTypeScriptClassWrapper(node) { - var body = ts.cast(ts.skipOuterExpressions(node.expression), ts.isFunctionExpression).body; + var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); var classStatements = ts.visitNodes(body.statements, visitor, ts.isStatement, 0, 1); var remainingStatements = ts.visitNodes(body.statements, visitor, ts.isStatement, 1, body.statements.length - 1); var varStatement = ts.cast(ts.firstOrUndefined(classStatements), ts.isVariableStatement); @@ -48870,7 +49187,6 @@ var ts; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - var currentSourceFile; var renamedCatchVariables; var renamedCatchVariableDeclarations; var inGeneratorFunctionBody; @@ -48901,10 +49217,8 @@ var ts; if (node.isDeclarationFile || (node.transformFlags & 512) === 0) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -50578,6 +50892,7 @@ var ts; } function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ ts.createVariableStatement(undefined, [ @@ -50588,13 +50903,13 @@ var ts; ]), ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") - ])) + ]))) ]))) ], true), undefined)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ @@ -50659,17 +50974,20 @@ var ts; } function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 | 1536); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536); - statements.push(statement); + var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, importCallExpressionVisitor); + if (expressionResult) { + if (emitAsReturn) { + var statement = ts.createReturn(expressionResult); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 | 1536); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536); + statements.push(statement); + } } } } @@ -51003,7 +51321,7 @@ var ts; return statements; } if (ts.hasModifier(decl, 1)) { - var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; + var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : ts.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); } if (decl.name) { @@ -51712,7 +52030,8 @@ var ts; } function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; - return ts.createCall(exportFunction, undefined, [exportName, value]); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536); + return ts.setCommentRange(ts.createCall(exportFunction, undefined, [exportName, value]), value); } function nestedElementVisitor(node) { switch (node.kind) { @@ -54843,8 +55162,13 @@ var ts; comments.reset(); setWriter(undefined); } + function emitIfPresent(node) { + if (node) { + emit(node); + } + } function emit(node) { - pipelineEmitWithNotification(3, node); + pipelineEmitWithNotification(4, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -54882,7 +55206,8 @@ var ts; case 0: return pipelineEmitSourceFile(node); case 2: return pipelineEmitIdentifierName(node); case 1: return pipelineEmitExpression(node); - case 3: return pipelineEmitUnspecified(node); + case 3: return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + case 4: return pipelineEmitUnspecified(node); } } function pipelineEmitSourceFile(node) { @@ -54893,6 +55218,11 @@ var ts; ts.Debug.assertNode(node, ts.isIdentifier); emitIdentifier(node); } + function emitMappedTypeParameter(node) { + emit(node.name); + write(" in "); + emit(node.constraint); + } function pipelineEmitUnspecified(node) { var kind = node.kind; if (ts.isKeyword(kind)) { @@ -55236,9 +55566,9 @@ var ts; function emitParameter(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } @@ -55250,7 +55580,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); write(";"); } @@ -55258,7 +55588,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); write(";"); @@ -55267,7 +55597,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); @@ -55276,9 +55606,9 @@ var ts; function emitMethodDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.asteriskToken, "*"); + emitIfPresent(node.asteriskToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } function emitConstructor(node) { @@ -55348,9 +55678,8 @@ var ts; } function emitTypeLiteral(node) { write("{"); - if (node.members.length > 0) { - emitList(node, node.members, ts.getEmitFlags(node) & 1 ? 448 : 65); - } + var flags = ts.getEmitFlags(node) & 1 ? 448 : 65; + emitList(node, node.members, flags | 262144); write("}"); } function emitArrayType(node) { @@ -55397,13 +55726,14 @@ var ts; writeLine(); increaseIndent(); } - writeIfPresent(node.readonlyToken, "readonly "); + if (node.readonlyToken) { + emit(node.readonlyToken); + write(" "); + } write("["); - emit(node.typeParameter.name); - write(" in "); - emit(node.typeParameter.constraint); + pipelineEmitWithNotification(3, node.typeParameter); write("]"); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); write(": "); emit(node.type); write(";"); @@ -55443,36 +55773,25 @@ var ts; } function emitBindingElement(node) { emitWithSuffix(node.propertyName, ": "); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); } function emitArrayLiteralExpression(node) { var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else { - var preferNewLine = node.multiLine ? 32768 : 0; - emitExpressionList(node, elements, 4466 | preferNewLine); - } + var preferNewLine = node.multiLine ? 32768 : 0; + emitExpressionList(node, elements, 4466 | preferNewLine); } function emitObjectLiteralExpression(node) { - var properties = node.properties; - if (properties.length === 0) { - write("{}"); + var indentedFlag = ts.getEmitFlags(node) & 65536; + if (indentedFlag) { + increaseIndent(); } - else { - var indentedFlag = ts.getEmitFlags(node) & 65536; - if (indentedFlag) { - increaseIndent(); - } - var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; - emitList(node, properties, 978 | allowTrailingComma | preferNewLine); - if (indentedFlag) { - decreaseIndent(); - } + var preferNewLine = node.multiLine ? 32768 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; + emitList(node, node.properties, 263122 | allowTrailingComma | preferNewLine); + if (indentedFlag) { + decreaseIndent(); } } function emitPropertyAccessExpression(node) { @@ -55554,7 +55873,8 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParametersForArrow(node, node.parameters); emitWithPrefix(": ", node.type); - write(" =>"); + write(" "); + emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { write("delete "); @@ -55609,12 +55929,12 @@ var ts; var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); increaseIndentIf(indentBeforeQuestion, " "); - write("?"); + emit(node.questionToken); increaseIndentIf(indentAfterQuestion, " "); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); increaseIndentIf(indentBeforeColon, " "); - write(":"); + emit(node.colonToken); increaseIndentIf(indentAfterColon, " "); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); @@ -55624,7 +55944,8 @@ var ts; emitList(node, node.templateSpans, 131072); } function emitYieldExpression(node) { - write(node.asteriskToken ? "yield*" : "yield"); + write("yield"); + emit(node.asteriskToken); emitExpressionWithPrefix(" ", node.expression); } function emitSpreadExpression(node) { @@ -55659,27 +55980,16 @@ var ts; emit(node.literal); } function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - writeToken(17, node.pos, node); - write(" "); - writeToken(18, node.statements.end, node); - } - else { - writeToken(17, node.pos, node); - emitBlockStatements(node); - increaseIndent(); - emitLeadingCommentsOfPosition(node.statements.end); - decreaseIndent(); - writeToken(18, node.statements.end, node); - } + writeToken(17, node.pos, node); + emitBlockStatements(node, !node.multiLine && isEmptyBlock(node)); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); + writeToken(18, node.statements.end, node); } - function emitBlockStatements(node) { - if (ts.getEmitFlags(node) & 1) { - emitList(node, node.statements, 384); - } - else { - emitList(node, node.statements, 65); - } + function emitBlockStatements(node, forceSingleLine) { + var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 384 : 65; + emitList(node, node.statements, format); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -55857,7 +56167,9 @@ var ts; function emitFunctionDeclarationOrExpression(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.asteriskToken ? "function* " : "function "); + write("function"); + emitIfPresent(node.asteriskToken); + write(" "); emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -55875,7 +56187,7 @@ var ts; if (ts.getEmitFlags(node) & 524288) { emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3, body, emitBlockCallback); + onEmitNode(4, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -55885,7 +56197,7 @@ var ts; pushNameGenerationScope(); emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3, body, emitBlockCallback); + onEmitNode(4, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -56023,7 +56335,9 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - write(node.flags & 16 ? "namespace " : "module "); + if (~node.flags & 512) { + write(node.flags & 16 ? "namespace " : "module "); + } emit(node.name); var body = node.body; while (body.kind === 233) { @@ -56035,16 +56349,11 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isEmptyBlock(node)) { - write("{ }"); - } - else { - pushNameGenerationScope(); - write("{"); - emitBlockStatements(node); - write("}"); - popNameGenerationScope(); - } + pushNameGenerationScope(); + write("{"); + emitBlockStatements(node, isEmptyBlock(node)); + write("}"); + popNameGenerationScope(); } function emitCaseBlock(node) { writeToken(17, node.pos); @@ -56187,9 +56496,7 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); - if (node.dotDotDotToken) { - write("..."); - } + emitIfPresent(node.dotDotDotToken); emitExpression(node.expression); write("}"); } @@ -56220,13 +56527,12 @@ var ts; if (statements.length > 0) { emitTrailingCommentsOfPosition(statements.pos); } + var format = 81985; if (emitAsSingleStatement) { write(" "); - emit(statements[0]); - } - else { - emitList(parentNode, statements, 81985); + format &= ~(1 | 64); } + emitList(parentNode, statements, format); } function emitHeritageClause(node) { write(" "); @@ -56419,7 +56725,7 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emit(parameters[0]); + emitList(parentNode, parameters, 1360 & ~1024); } else { emitParameters(parentNode, parameters); @@ -56441,8 +56747,14 @@ var ts; if (isUndefined && format & 8192) { return; } - var isEmpty = isUndefined || children.length === 0 || start >= children.length || count === 0; + var isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & 16384) { + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } return; } if (format & 7680) { @@ -56455,7 +56767,7 @@ var ts; if (format & 1) { writeLine(); } - else if (format & 128) { + else if (format & 128 && !(format & 262144)) { write(" "); } } @@ -56514,7 +56826,7 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } - if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + if (previousSibling && delimiter && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) { emitLeadingCommentsOfPosition(previousSibling.end); } if (format & 64) { @@ -56551,11 +56863,6 @@ var ts; write(text); } } - function writeIfPresent(node, text) { - if (node) { - write(text); - } - } function writeToken(token, pos, contextNode) { return onEmitSourceMapOfToken ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) @@ -56565,7 +56872,7 @@ var ts; if (onBeforeEmitToken) { onBeforeEmitToken(node); } - writeTokenText(node.kind); + write(ts.tokenToString(node.kind)); if (onAfterEmitToken) { onAfterEmitToken(node); } @@ -56714,10 +57021,6 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); - } function isEmptyBlock(block) { return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); @@ -56961,6 +57264,8 @@ var ts; ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 448] = "SingleLineTypeLiteralMembers"; @@ -56970,7 +57275,7 @@ var ts; ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; @@ -57164,7 +57469,7 @@ var ts; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -57188,7 +57493,7 @@ var ts; var redForegroundEscapeSequence = "\u001b[91m"; var yellowForegroundEscapeSequence = "\u001b[93m"; var blueForegroundEscapeSequence = "\u001b[93m"; - var gutterStyleSequence = "\u001b[100;30m"; + var gutterStyleSequence = "\u001b[30;47m"; var gutterSeparator = " "; var resetEscapeSequence = "\u001b[0m"; var ellipsis = "..."; @@ -57213,9 +57518,9 @@ var ts; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; if (diagnostic.file) { - var start = diagnostic.start, length_6 = diagnostic.length, file = diagnostic.file; + var start = diagnostic.start, length_5 = diagnostic.length, file = diagnostic.file; var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; - var _b = ts.getLineAndCharacterOfPosition(file, start + length_6), lastLine = _b.line, lastLineChar = _b.character; + var _b = ts.getLineAndCharacterOfPosition(file, start + length_5), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; @@ -57223,10 +57528,10 @@ var ts; if (hasMoreThanFiveLines) { gutterWidth = Math.max(ellipsis.length, gutterWidth); } - output += ts.sys.newLine; + output += host.getNewLine(); for (var i = firstLine; i <= lastLine; i++) { if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); @@ -57235,7 +57540,7 @@ var ts; lineContent = lineContent.replace(/\s+$/g, ""); lineContent = lineContent.replace("\t", " "); output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + ts.sys.newLine; + output += lineContent + host.getNewLine(); output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; output += redForegroundEscapeSequence; if (i === firstLine) { @@ -57250,15 +57555,15 @@ var ts; output += lineContent.replace(/./g, "~"); } output += resetEscapeSequence; - output += ts.sys.newLine; + output += host.getNewLine(); } - output += ts.sys.newLine; + output += host.getNewLine(); output += relativeFileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } var categoryColor = getCategoryFormat(diagnostic.category); var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine); - output += ts.sys.newLine; + output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); + output += host.getNewLine(); } return output; } @@ -57324,6 +57629,8 @@ var ts; ts.performance.mark("beforeProgram"); host = host || createCompilerHost(options); var skipDefaultLib = options.noLib; + var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); + var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName()); var programDiagnostics = ts.createDiagnosticCollection(); var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); @@ -57373,12 +57680,11 @@ var ts; } if (!skipDefaultLib) { if (!options.lib) { - processRootFile(host.getDefaultLibFileName(options), true); + processRootFile(getDefaultLibraryFileName(), true); } else { - var libDirectory_1 = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(host.getDefaultLibFileName(options)); ts.forEach(options.lib, function (libFileName) { - processRootFile(ts.combinePaths(libDirectory_1, libFileName), true); + processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true); }); } } @@ -57411,6 +57717,7 @@ var ts; getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + isSourceFileDefaultLibrary: isSourceFileDefaultLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, sourceFileToPackageName: sourceFileToPackageName, @@ -57634,7 +57941,7 @@ var ts; var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var moduleNames = getModuleNames(newSourceFile); var oldProgramState = { program: oldProgram, file: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); @@ -57701,6 +58008,15 @@ var ts; function isSourceFileFromExternalLibrary(file) { return sourceFilesFoundSearchingNodeModules.get(file.path); } + function isSourceFileDefaultLibrary(file) { + if (file.hasNoDefaultLib) { + return true; + } + if (defaultLibraryPath && defaultLibraryPath.length !== 0) { + return ts.containsPath(defaultLibraryPath, file.path, currentDirectory, !host.useCaseSensitiveFileNames()); + } + return ts.compareStrings(file.fileName, getDefaultLibraryFileName(), !host.useCaseSensitiveFileNames()) === 0; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } @@ -57815,9 +58131,7 @@ var ts; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - return ts.isSourceFileJavaScript(sourceFile) - ? ts.filter(diagnostics, shouldReportDiagnostic) - : diagnostics; + return ts.filter(diagnostics, shouldReportDiagnostic); }); } function shouldReportDiagnostic(diagnostic) { @@ -58033,16 +58347,15 @@ var ts; return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); + processSourceFile(ts.normalizePath(fileName), isDefaultLib, undefined); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function getTextOfLiteral(literal) { - return literal.text; + return a.kind === 9 + ? b.kind === 9 && a.text === b.text + : b.kind === 71 && a.escapedText === b.escapedText; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -58158,8 +58471,8 @@ var ts; return sourceFileWithAddedExtension; } } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, undefined); }, function (diagnostic) { + function processSourceFile(fileName, isDefaultLib, packageId, refFile, refPos, refEnd) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -58225,7 +58538,7 @@ var ts; } }); if (packageId) { - var packageIdKey = packageId.name + "@" + packageId.version; + var packageIdKey = packageId.name + "/" + packageId.subModuleName + "@" + packageId.version; var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); @@ -58272,7 +58585,7 @@ var ts; function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, undefined, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -58294,7 +58607,7 @@ var ts; var saveResolution = true; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } else { if (previousResolution) { @@ -58307,7 +58620,7 @@ var ts; saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } } @@ -58336,8 +58649,7 @@ var ts; function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { - var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9; }); - var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var moduleNames = getModuleNames(file); var oldProgramState = { program: oldProgram, file: file, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState); ts.Debug.assert(resolutions.length === moduleNames.length); @@ -58348,13 +58660,19 @@ var ts; continue; } var isFromNodeModulesSearch = resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var isJsFile = !ts.extensionIsTypeScript(resolution.extension); + var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; var resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { currentNodeModulesDepth++; } var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; - var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; + var shouldAddFile = resolvedFileName + && !getResolutionDiagnostic(options, resolution) + && !options.noResolve + && i < file.imports.length + && !elideImport + && !(isJsFile && !options.allowJs); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -58669,7 +58987,7 @@ var ts; return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + return options.allowJs || !options.noImplicitAny ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } } ts.getResolutionDiagnostic = getResolutionDiagnostic; @@ -58677,6 +58995,17 @@ var ts; ts.Debug.assert(names.every(function (name) { return name !== undefined; }), "A name is undefined.", function () { return JSON.stringify(names); }); return names; } + function getModuleNames(_a) { + var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations; + var res = imports.map(function (i) { return i.text; }); + for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { + var aug = moduleAugmentations_1[_i]; + if (aug.kind === 9) { + res.push(aug.text); + } + } + return res; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -59612,7 +59941,7 @@ var ts; errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } var value = convertPropertyValueToJson(element.initializer, option); - if (typeof keyText !== "undefined" && typeof value !== "undefined") { + if (typeof keyText !== "undefined") { result[keyText] = value; if (jsonConversionNotifier && (parentOption || knownOptions === knownRootOptions)) { @@ -59647,7 +59976,7 @@ var ts; reportInvalidOptionValue(option && option.type !== "boolean"); return false; case 95: - reportInvalidOptionValue(!!option); + reportInvalidOptionValue(option && option.name === "extends"); return null; case 9: if (!isDoubleQuotedString(valueExpression)) { @@ -59703,6 +60032,8 @@ var ts; } function isCompilerOptionsValue(option, value) { if (option) { + if (isNullOrUndefined(value)) + return true; if (option.type === "list") { return ts.isArray(value); } @@ -59855,6 +60186,12 @@ var ts; } } ts.setConfigFileInOptions = setConfigFileInOptions; + function isNullOrUndefined(x) { + return x === undefined || x === null; + } + function directoryOfCombinedPath(fileName, basePath) { + return ts.getDirectoryPath(ts.toPath(fileName, basePath, ts.identity)); + } function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { if (existingOptions === void 0) { existingOptions = {}; } if (resolutionStack === void 0) { resolutionStack = []; } @@ -59878,7 +60215,7 @@ var ts; }; function getFileNames() { var fileNames; - if (ts.hasProperty(raw, "files")) { + if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw["files"])) { if (ts.isArray(raw["files"])) { fileNames = raw["files"]; if (fileNames.length === 0) { @@ -59890,7 +60227,7 @@ var ts; } } var includeSpecs; - if (ts.hasProperty(raw, "include")) { + if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw["include"])) { if (ts.isArray(raw["include"])) { includeSpecs = raw["include"]; } @@ -59899,7 +60236,7 @@ var ts; } } var excludeSpecs; - if (ts.hasProperty(raw, "exclude")) { + if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw["exclude"])) { if (ts.isArray(raw["exclude"])) { excludeSpecs = raw["exclude"]; } @@ -59916,7 +60253,7 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !ts.hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); } @@ -59978,7 +60315,8 @@ var ts; errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, ts.createCompilerDiagnostic); + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, ts.createCompilerDiagnostic); } } return { raw: json, options: options, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath }; @@ -60000,7 +60338,8 @@ var ts; onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) { switch (key) { case "extends": - extendedConfigPath = getExtendsConfigPath(value, host, basePath, getCanonicalFileName, errors, function (message, arg0) { + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(value, host, newBase, getCanonicalFileName, errors, function (message, arg0) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0); }); return; @@ -60154,6 +60493,8 @@ var ts; } } function normalizeOptionValue(option, basePath, value) { + if (isNullOrUndefined(value)) + return undefined; if (option.type === "list") { var listOption_1 = option; if (listOption_1.element.isFilePath || typeof listOption_1.element.type !== "string") { @@ -60176,6 +60517,8 @@ var ts; return value; } function convertJsonOptionOfCustomType(opt, value, errors) { + if (isNullOrUndefined(value)) + return undefined; var key = value.toLowerCase(); var val = opt.type.get(key); if (val !== undefined) { @@ -60212,7 +60555,7 @@ var ts; if (fileNames) { for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); + var file = ts.getNormalizedAbsolutePath(fileName, basePath); literalFileMap.set(keyMapper(file), file); } } @@ -60461,7 +60804,6 @@ var ts; var commandLine = ts.parseCommandLine(args); var configFileName; var cachedConfigFileText; - var configFileWatcher; var directoryWatcher; var cachedProgram; var rootFileNames; @@ -60536,7 +60878,7 @@ var ts; return ts.sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped); } if (configFileName) { - configFileWatcher = ts.sys.watchFile(configFileName, configFileChanged); + ts.sys.watchFile(configFileName, configFileChanged); } if (ts.sys.watchDirectory && configFileName) { var directory = ts.getDirectoryPath(configFileName); @@ -60750,15 +61092,15 @@ var ts; return { program: program, exitStatus: exitStatus }; function compileProgram() { var diagnostics; - diagnostics = program.getSyntacticDiagnostics(); + diagnostics = program.getSyntacticDiagnostics().slice(); if (diagnostics.length === 0) { diagnostics = program.getOptionsDiagnostics().concat(program.getGlobalDiagnostics()); if (diagnostics.length === 0) { - diagnostics = program.getSemanticDiagnostics(); + diagnostics = program.getSemanticDiagnostics().slice(); } } var emitOutput = program.emit(); - diagnostics = diagnostics.concat(emitOutput.diagnostics); + ts.addRange(diagnostics, emitOutput.diagnostics); reportDiagnostics(ts.sortAndDeduplicateDiagnostics(diagnostics), compilerHost); reportEmittedFiles(emitOutput.emittedFiles); if (emitOutput.emitSkipped && diagnostics.length > 0) { diff --git a/lib/tsserver.js b/lib/tsserver.js index c18f6507caa..cf8cbbea281 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -705,6 +705,7 @@ var ts; TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 6368] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; @@ -1065,6 +1066,7 @@ var ts; EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; + EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); var ExternalEmitHelpers; (function (ExternalEmitHelpers) { @@ -1097,7 +1099,8 @@ var ts; EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; EmitHint[EmitHint["Expression"] = 1] = "Expression"; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; - EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; + EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; @@ -1164,6 +1167,12 @@ var ts; ts.versionMajorMinor = "2.6"; ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); +(function (ts) { + function isExternalModuleNameRelative(moduleName) { + return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; +})(ts || (ts = {})); (function (ts) { ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; @@ -1795,6 +1804,26 @@ var ts; return to; } ts.addRange = addRange; + function pushIfUnique(array, toAdd) { + if (contains(array, toAdd)) { + return false; + } + else { + array.push(toAdd); + return true; + } + } + ts.pushIfUnique = pushIfUnique; + function appendIfUnique(array, toAdd) { + if (array) { + pushIfUnique(array, toAdd); + return array; + } + else { + return [toAdd]; + } + } + ts.appendIfUnique = appendIfUnique; function stableSort(array, comparer) { if (comparer === void 0) { comparer = compareValues; } return array @@ -1941,6 +1970,16 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getOwnValues(sparseArray) { + var values = []; + for (var key in sparseArray) { + if (hasOwnProperty.call(sparseArray, key)) { + values.push(sparseArray[key]); + } + } + return values; + } + ts.getOwnValues = getOwnValues; function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { @@ -2105,6 +2144,8 @@ var ts; ts.cast = cast; function noop() { } ts.noop = noop; + function identity(x) { return x; } + ts.identity = identity; function notImplemented() { throw new Error("Not implemented"); } @@ -2181,12 +2222,11 @@ var ts; } ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { - var end = start + length; Debug.assertGreaterThanOrEqual(start, 0); Debug.assertGreaterThanOrEqual(length, 0); if (file) { Debug.assertLessThanOrEqual(start, file.text.length); - Debug.assertLessThanOrEqual(end, file.text.length); + Debug.assertLessThanOrEqual(start + length, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2428,12 +2468,8 @@ var ts; return /^\.\.?($|[\\/])/.test(path); } ts.pathIsRelative = pathIsRelative; - function isExternalModuleNameRelative(moduleName) { - return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function moduleHasNonRelativeName(moduleName) { - return !isExternalModuleNameRelative(moduleName); + return !ts.isExternalModuleNameRelative(moduleName); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; function getEmitScriptTarget(compilerOptions) { @@ -2470,7 +2506,7 @@ var ts; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { @@ -3096,6 +3132,10 @@ var ts; throw e; } Debug.fail = fail; + function assertNever(member, message, stackCrawlMark) { + return fail(message || "Illegal value: " + member, stackCrawlMark || assertNever); + } + Debug.assertNever = assertNever; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -3233,6 +3273,12 @@ var ts; return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; + function and(f, g) { + return function (arg) { return f(arg) && g(arg); }; + } + ts.and = and; + function assertTypeIsNever(_) { } + ts.assertTypeIsNever = assertTypeIsNever; })(ts || (ts = {})); var ts; (function (ts) { @@ -3797,8 +3843,8 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asteri_1202", "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_defaul_1203", "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), @@ -4118,7 +4164,9 @@ var ts; Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), - Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), + Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."), + The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, ts.DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4191,6 +4239,7 @@ var ts; A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"), + The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -4308,7 +4357,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), - Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), + Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."), @@ -4413,17 +4462,16 @@ var ts; Resolving_real_path_for_0_result_1: diag(6130, ts.DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."), Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, ts.DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."), File_name_0_has_a_1_extension_stripping_it: diag(6132, ts.DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."), - _0_is_declared_but_never_used: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6133", "'{0}' is declared but never used."), + _0_is_declared_but_its_value_is_never_read: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read."), Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."), Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."), The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, ts.DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."), Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, ts.DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."), - Property_0_is_declared_but_never_used: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_never_used_6138", "Property '{0}' is declared but never used."), + Property_0_is_declared_but_its_value_is_never_read: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read."), Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."), Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, ts.DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."), Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, ts.DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."), Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."), - Module_0_was_resolved_to_1_but_allowJs_is_not_set: diag(6143, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", "Module '{0}' was resolved to '{1}', but '--allowJs' is not set."), Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."), Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."), Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."), @@ -4514,6 +4562,7 @@ var ts; Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."), Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."), JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, ts.DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."), + JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, ts.DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."), Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), @@ -4561,7 +4610,7 @@ var ts; Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), - Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), + Extract_to_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_95004", "Extract to {0}"), }; })(ts || (ts = {})); var ts; @@ -4591,7 +4640,7 @@ var ts; return undefined; } ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); - return resolved.path; + return { fileName: resolved.path, packageId: resolved.packageId }; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { @@ -4694,12 +4743,12 @@ var ts; var resolvedTypeReferenceDirective; if (resolved) { if (!options.preserveSymlinks) { - resolved = realPath(resolved, host, traceEnabled); + resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); } if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -4996,7 +5045,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension, packageId: undefined }; + return noPackageId({ path: path_1, ext: extension }); } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -5158,31 +5207,40 @@ var ts; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } + var _a = considerPackageJson + ? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state) + : { packageJsonContent: undefined, packageId: undefined }, packageJsonContent = _a.packageJsonContent, packageId = _a.packageId; + return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent)); + } + function loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent) { + var fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - var packageId; - if (considerPackageJson) { - var packageJsonPath = pathToPackageJson(candidate); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var jsonContent = readJson(packageJsonPath, state.host); - if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { - packageId = { name: jsonContent.name, version: jsonContent.version }; - } - var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); - if (fromPackageJson) { - return withPackageId(packageId, fromPackageJson); - } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, _a) { + var host = _a.host, traceEnabled = _a.traceEnabled; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); + var packageJsonPath = pathToPackageJson(nodeModuleDirectory); + if (directoryExists && host.fileExists(packageJsonPath)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); + var packageJsonContent = readJson(packageJsonPath, host); + var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" + ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version } + : undefined; + return { packageJsonContent: packageJsonContent, packageId: packageId }; + } + else { + if (directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + failedLookupLocations.push(packageJsonPath); + return { packageJsonContent: undefined, packageId: undefined }; } - return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); @@ -5225,9 +5283,20 @@ var ts; return ts.combinePaths(directory, "package.json"); } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { + var _a = getPackageName(moduleName), packageName = _a.packageName, rest = _a.rest; + var packageRootPath = ts.combinePaths(nodeModulesFolder, packageName); + var _b = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state), packageJsonContent = _b.packageJsonContent, packageId = _b.packageId; var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + var pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent); + return withPackageId(packageId, pathAndExtension); + } + function getPackageName(moduleName) { + var idx = moduleName.indexOf(ts.directorySeparator); + if (moduleName[0] === "@") { + idx = moduleName.indexOf(ts.directorySeparator, idx + 1); + } + return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); @@ -5386,7 +5455,6 @@ var ts; } ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriter = createSingleLineStringWriter(); - var stringWriterAcquired = false; function createSingleLineStringWriter() { var str = ""; var writeText = function (text) { return str += text; }; @@ -5410,15 +5478,14 @@ var ts; }; } function usingSingleLineStringWriter(action) { + var oldString = stringWriter.string(); try { - ts.Debug.assert(!stringWriterAcquired); - stringWriterAcquired = true; action(stringWriter); return stringWriter.string(); } finally { stringWriter.clear(); - stringWriterAcquired = false; + stringWriter.writeKeyword(oldString); } } ts.usingSingleLineStringWriter = usingSingleLineStringWriter; @@ -5452,7 +5519,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.version === b.version; + return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; @@ -5574,7 +5641,7 @@ var ts; if (ts.isJSDocNode(node)) { return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } if (node.kind === 286 && node._children.length > 0) { @@ -5611,6 +5678,15 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; + function indexOfNode(nodeArray, node) { + return ts.binarySearch(nodeArray, node, compareNodePos); + } + ts.indexOfNode = indexOfNode; + function compareNodePos(_a, _b) { + var aPos = _a.pos; + var bPos = _b.pos; + return aPos < bPos ? -1 : bPos < aPos ? 1 : 0; + } function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -5638,6 +5714,7 @@ var ts; case 16: return "}" + escapeText(node.text, 96) + "`"; case 8: + case 12: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -5735,6 +5812,34 @@ var ts; return false; } ts.isBlockScope = isBlockScope; + function isDeclarationWithTypeParameters(node) { + switch (node.kind) { + case 155: + case 156: + case 150: + case 157: + case 160: + case 161: + case 273: + case 229: + case 199: + case 230: + case 231: + case 282: + case 228: + case 151: + case 152: + case 153: + case 154: + case 186: + case 187: + return true; + default: + ts.assertTypeIsNever(node); + return false; + } + } + ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function getEnclosingBlockScopeContainer(node) { var current = node.parent; while (current) { @@ -6382,59 +6487,62 @@ var ts; case 8: case 9: case 99: - var parent = node.parent; - switch (parent.kind) { - case 226: - case 146: - case 149: - case 148: - case 264: - case 261: - case 176: - return parent.initializer === node; - case 210: - case 211: - case 212: - case 213: - case 219: - case 220: - case 221: - case 257: - case 223: - return parent.expression === node; - case 214: - var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || - forStatement.condition === node || - forStatement.incrementor === node; - case 215: - case 216: - var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || - forInStatement.expression === node; - case 184: - case 202: - return node === parent.expression; - case 205: - return node === parent.expression; - case 144: - return node === parent.expression; - case 147: - case 256: - case 255: - case 263: - return true; - case 201: - return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - default: - if (isPartOfExpression(parent)) { - return true; - } - } + return isInExpressionContext(node); + default: + return false; } - return false; } ts.isPartOfExpression = isPartOfExpression; + function isInExpressionContext(node) { + var parent = node.parent; + switch (parent.kind) { + case 226: + case 146: + case 149: + case 148: + case 264: + case 261: + case 176: + return parent.initializer === node; + case 210: + case 211: + case 212: + case 213: + case 219: + case 220: + case 221: + case 257: + case 223: + return parent.expression === node; + case 214: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || + forStatement.condition === node || + forStatement.incrementor === node; + case 215: + case 216: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || + forInStatement.expression === node; + case 184: + case 202: + return node === parent.expression; + case 205: + return node === parent.expression; + case 144: + return node === parent.expression; + case 147: + case 256: + case 255: + case 263: + return true; + case 201: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + return isPartOfExpression(parent); + } + } + ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { return node.kind === 237 && node.moduleReference.kind === 248; } @@ -6598,14 +6706,6 @@ var ts; node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function hasJSDocParameterTags(node) { - return !!getFirstJSDocTag(node, 279); - } - ts.hasJSDocParameterTags = hasJSDocParameterTags; - function getFirstJSDocTag(node, kind) { - var tags = getJSDocTags(node); - return ts.find(tags, function (doc) { return doc.kind === kind; }); - } function getAllJSDocs(node) { if (ts.isJSDocTypedefTag(node)) { return [node.parent]; @@ -6613,14 +6713,6 @@ var ts; return getJSDocCommentsAndTags(node); } ts.getAllJSDocs = getAllJSDocs; - function getJSDocTags(node) { - var tags = node.jsDocCache; - if (tags === undefined) { - node.jsDocCache = tags = ts.flatMap(getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); - } - return tags; - } - ts.getJSDocTags = getJSDocTags; function getJSDocCommentsAndTags(node) { var result; getJSDocCommentsAndTagsWorker(node); @@ -6652,22 +6744,17 @@ var ts; getJSDocCommentsAndTagsWorker(parent); } if (node.kind === 146) { - result = ts.addRange(result, getJSDocParameterTags(node)); + result = ts.addRange(result, ts.getJSDocParameterTags(node)); } - if (isVariableLike(node) && node.initializer) { + if (isVariableLike(node) && node.initializer && ts.hasJSDocNodes(node.initializer)) { result = ts.addRange(result, node.initializer.jsDoc); } - result = ts.addRange(result, node.jsDoc); + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); + } } } - function getJSDocParameterTags(param) { - if (param.name && ts.isIdentifier(param.name)) { - var name_1 = param.name.escapedText; - return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); - } - return undefined; - } - ts.getJSDocParameterTags = getJSDocParameterTags; + ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getParameterSymbolFromJSDoc(node) { if (node.symbol) { return node.symbol; @@ -6693,38 +6780,6 @@ var ts; return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; - function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 281); - if (!tag && node.kind === 146) { - var paramTags = getJSDocParameterTags(node); - if (paramTags) { - tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); - } - } - return tag && tag.typeExpression && tag.typeExpression.type; - } - ts.getJSDocType = getJSDocType; - function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 277); - } - ts.getJSDocAugmentsTag = getJSDocAugmentsTag; - function getJSDocClassTag(node) { - return getFirstJSDocTag(node, 278); - } - ts.getJSDocClassTag = getJSDocClassTag; - function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 280); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocReturnType(node) { - var returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - ts.getJSDocReturnType = getJSDocReturnType; - function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 282); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { return isRestParameter(ts.lastOrUndefined(s.parameters)); } @@ -6736,7 +6791,7 @@ var ts; function isRestParameter(node) { if (isInJavaScriptFile(node)) { if (node.type && node.type.kind === 274 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274; })) { + ts.forEach(ts.getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274; })) { return true; } } @@ -7137,9 +7192,9 @@ var ts; || kind === 265; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); + function nodeIsSynthesized(range) { + return ts.positionIsSynthesized(range.pos) + || ts.positionIsSynthesized(range.end); } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFile(sourceFile) { @@ -7403,13 +7458,17 @@ var ts; "\u2029": "\\u2029", "\u0085": "\\u0085" }); + var escapedNullRegExp = /\\0[0-9]/g; function escapeString(s, quoteChar) { var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp : quoteChar === 39 ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; - return s.replace(escapedCharsRegExp, getReplacement); + return s.replace(escapedCharsRegExp, getReplacement).replace(escapedNullRegExp, nullReplacement); } ts.escapeString = escapeString; + function nullReplacement(c) { + return "\\x00" + c.charAt(c.length - 1); + } function getReplacement(c) { return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } @@ -7689,7 +7748,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocType(node); + return ts.getJSDocType(node); } } ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode; @@ -7698,7 +7757,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocReturnType(node); + return ts.getJSDocReturnType(node); } } ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode; @@ -7707,7 +7766,7 @@ var ts; return node.typeParameters; } if (isInJavaScriptFile(node)) { - var templateTag = getJSDocTemplateTag(node); + var templateTag = ts.getJSDocTemplateTag(node); return templateTag && templateTag.typeParameters; } } @@ -8266,6 +8325,41 @@ var ts; return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; + function isWriteOnlyAccess(node) { + return accessKind(node) === 1; + } + ts.isWriteOnlyAccess = isWriteOnlyAccess; + function isWriteAccess(node) { + return accessKind(node) !== 0; + } + ts.isWriteAccess = isWriteAccess; + var AccessKind; + (function (AccessKind) { + AccessKind[AccessKind["Read"] = 0] = "Read"; + AccessKind[AccessKind["Write"] = 1] = "Write"; + AccessKind[AccessKind["ReadWrite"] = 2] = "ReadWrite"; + })(AccessKind || (AccessKind = {})); + function accessKind(node) { + var parent = node.parent; + if (!parent) + return 0; + switch (parent.kind) { + case 193: + case 192: + var operator = parent.operator; + return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; + case 194: + var _a = parent, left = _a.left, operatorToken = _a.operatorToken; + return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; + case 179: + return parent.name !== node ? 0 : accessKind(parent); + default: + return 0; + } + function writeOrReadWrite() { + return parent.parent && parent.parent.kind === 210 ? 1 : 2; + } + } })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -8544,6 +8638,56 @@ var ts; return id; } ts.unescapeIdentifier = unescapeIdentifier; + function nameForNamelessJSDocTypedef(declaration) { + var hostNode = declaration.parent.parent; + if (!hostNode) { + return undefined; + } + if (ts.isDeclaration(hostNode)) { + return getDeclarationIdentifier(hostNode); + } + switch (hostNode.kind) { + case 208: + if (hostNode.declarationList && + hostNode.declarationList.declarations[0]) { + return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); + } + return undefined; + case 210: + var expr = hostNode.expression; + switch (expr.kind) { + case 179: + return expr.name; + case 180: + var arg = expr.argumentExpression; + if (ts.isIdentifier(arg)) { + return arg; + } + } + return undefined; + case 1: + return undefined; + case 185: { + return getDeclarationIdentifier(hostNode.expression); + } + case 222: { + if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { + return getDeclarationIdentifier(hostNode.statement); + } + return undefined; + } + default: + ts.Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!"); + } + } + function getDeclarationIdentifier(node) { + var name = getNameOfDeclaration(node); + return ts.isIdentifier(name) ? name : undefined; + } + function getNameOfJSDocTypedef(declaration) { + return declaration.name || nameForNamelessJSDocTypedef(declaration); + } + ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef; function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; @@ -8563,11 +8707,78 @@ var ts; return undefined; } } + else if (declaration.kind === 283) { + return getNameOfJSDocTypedef(declaration); + } else { return declaration.name; } } ts.getNameOfDeclaration = getNameOfDeclaration; + function getJSDocParameterTags(param) { + if (param.name && ts.isIdentifier(param.name)) { + var name_1 = param.name.escapedText; + return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); + } + return undefined; + } + ts.getJSDocParameterTags = getJSDocParameterTags; + function hasJSDocParameterTags(node) { + return !!getFirstJSDocTag(node, 279); + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 277); + } + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + function getJSDocClassTag(node) { + return getFirstJSDocTag(node, 278); + } + ts.getJSDocClassTag = getJSDocClassTag; + function getJSDocReturnTag(node) { + return getFirstJSDocTag(node, 280); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getFirstJSDocTag(node, 282); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getJSDocTypeTag(node) { + var tag = getFirstJSDocTag(node, 281); + if (tag && tag.typeExpression && tag.typeExpression.type) { + return tag; + } + return undefined; + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 281); + if (!tag && node.kind === 146) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + function getJSDocReturnType(node) { + var returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + ts.getJSDocReturnType = getJSDocReturnType; + function getJSDocTags(node) { + var tags = node.jsDocCache; + if (tags === undefined) { + node.jsDocCache = tags = ts.flatMap(ts.getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); + } + return tags; + } + ts.getJSDocTags = getJSDocTags; + function getFirstJSDocTag(node, kind) { + var tags = getJSDocTags(node); + return ts.find(tags, function (doc) { return doc.kind === kind; }); + } })(ts || (ts = {})); (function (ts) { function isNumericLiteral(node) { @@ -9200,8 +9411,7 @@ var ts; } ts.isToken = isToken; function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + return array.hasOwnProperty("pos") && array.hasOwnProperty("end"); } ts.isNodeArray = isNodeArray; function isLiteralKind(kind) { @@ -9286,16 +9496,27 @@ var ts; return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { + function isFunctionLikeDeclaration(node) { + return node && isFunctionLikeDeclarationKind(node.kind); + } + ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; + function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 152: - case 186: case 228: - case 187: case 151: - case 150: + case 152: case 153: case 154: + case 186: + case 187: + return true; + default: + return false; + } + } + function isFunctionLikeKind(kind) { + switch (kind) { + case 150: case 155: case 156: case 157: @@ -9303,10 +9524,15 @@ var ts; case 273: case 161: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - return false; } ts.isFunctionLikeKind = isFunctionLikeKind; + function isFunctionOrModuleBlock(node) { + return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent); + } + ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; return kind === 152 @@ -9460,52 +9686,61 @@ var ts; || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; - function isLeftHandSideExpressionKind(kind) { - return kind === 179 - || kind === 180 - || kind === 182 - || kind === 181 - || kind === 249 - || kind === 250 - || kind === 183 - || kind === 177 - || kind === 185 - || kind === 178 - || kind === 199 - || kind === 186 - || kind === 71 - || kind === 12 - || kind === 8 - || kind === 9 - || kind === 13 - || kind === 196 - || kind === 86 - || kind === 95 - || kind === 99 - || kind === 101 - || kind === 97 - || kind === 91 - || kind === 203 - || kind === 204; - } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 192 - || kind === 193 - || kind === 188 - || kind === 189 - || kind === 190 - || kind === 191 - || kind === 184 - || isLeftHandSideExpressionKind(kind); + function isLeftHandSideExpressionKind(kind) { + switch (kind) { + case 179: + case 180: + case 182: + case 181: + case 249: + case 250: + case 183: + case 177: + case 185: + case 178: + case 199: + case 186: + case 71: + case 12: + case 8: + case 9: + case 13: + case 196: + case 86: + case 95: + case 99: + case 101: + case 97: + case 203: + case 204: + case 91: + return true; + default: + return false; + } } function isUnaryExpression(node) { return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionKind(kind) { + switch (kind) { + case 192: + case 193: + case 188: + case 189: + case 190: + case 191: + case 184: + return true; + default: + return isLeftHandSideExpressionKind(kind); + } + } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { case 193: @@ -9518,21 +9753,26 @@ var ts; } } ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; - function isExpressionKind(kind) { - return kind === 195 - || kind === 197 - || kind === 187 - || kind === 194 - || kind === 198 - || kind === 202 - || kind === 200 - || kind === 289 - || isUnaryExpressionKind(kind); - } function isExpression(node) { return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isExpression = isExpression; + function isExpressionKind(kind) { + switch (kind) { + case 195: + case 197: + case 187: + case 194: + case 198: + case 202: + case 200: + case 289: + case 288: + return true; + default: + return isUnaryExpressionKind(kind); + } + } function isAssertionExpression(node) { var kind = node.kind; return kind === 184 @@ -9773,6 +10013,10 @@ var ts; return node.kind >= 276 && node.kind <= 285; } ts.isJSDocTag = isJSDocTag; + function hasJSDocNodes(node) { + return !!node.jsDoc && node.jsDoc.length > 0; + } + ts.hasJSDocNodes = hasJSDocNodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -9999,7 +10243,7 @@ var ts; ts.Debug.assert(res < lineStarts[line + 1]); } else if (debugText !== undefined) { - ts.Debug.assert(res < debugText.length); + ts.Debug.assert(res <= debugText.length); } return res; } @@ -11790,9 +12034,11 @@ var ts; visitNode(cbNode, node.typeExpression); } case 285: - for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { - var tag = _a[_i]; - visitNode(cbNode, tag); + if (node.jsDocPropertyTags) { + for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { + var tag = _a[_i]; + visitNode(cbNode, tag); + } } return; case 288: @@ -11972,7 +12218,7 @@ var ts; var saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDoc) { + if (ts.hasJSDocNodes(n)) { for (var _i = 0, _a = n.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; jsDoc.parent = n; @@ -12092,9 +12338,6 @@ var ts; function getNodePos() { return scanner.getStartPos(); } - function getNodeEnd() { - return scanner.getStartPos(); - } function token() { return currentToken; } @@ -12217,13 +12460,11 @@ var ts; kind === 71 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } - function createNodeArray(elements, pos) { - var array = (elements || []); - if (!(pos >= 0)) { - pos = getNodePos(); - } + function createNodeArray(elements, pos, end) { + var length = elements.length; + var array = (length >= 1 && length <= 4 ? elements.slice() : elements); array.pos = pos; - array.end = pos; + array.end = end === undefined ? scanner.getStartPos() : end; return array; } function finishNode(node, end) { @@ -12271,7 +12512,8 @@ var ts; nextToken(); return finishNode(node); } - return createMissingNode(71, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var reportAtCurrentPosition = token() === 1; + return createMissingNode(71, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -12504,20 +12746,20 @@ var ts; function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); - result.push(element); + list.push(element); continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - result.end = getNodeEnd(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); @@ -12723,12 +12965,13 @@ var ts; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var commaStart = -1; while (true) { if (isListElement(kind, false)) { var startPos = scanner.getStartPos(); - result.push(parseListElement(kind, parseElement)); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(26)) { continue; @@ -12753,15 +12996,15 @@ var ts; break; } } + parsingContext = saveParsingContext; + var result = createNodeArray(list, listPos); if (commaStart >= 0) { result.hasTrailingComma = true; } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; return result; } function createMissingList() { - return createNodeArray(); + return createNodeArray([], getNodePos()); } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -12803,12 +13046,12 @@ var ts; var template = createNode(196); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); - var templateSpans = createNodeArray(); + var list = []; + var listPos = getNodePos(); do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 15); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; + list.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(list).literal.kind === 15); + template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { @@ -12903,7 +13146,7 @@ var ts; var result = createNode(273); nextToken(); fillSignature(56, 4 | 32, result); - return finishNode(result); + return addJSDocComment(finishNode(result)); } var node = createNode(159); node.typeName = parseIdentifierName(); @@ -12961,9 +13204,10 @@ var ts; return token() === 24 || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 || isStartOfType(); + token() === 57 || + isStartOfType(true); } - function parseParameter() { + function parseParameter(requireEqualsToken) { var node = createNode(146); if (token() === 99) { node.name = createIdentifier(true); @@ -12979,37 +13223,33 @@ var ts; } node.questionToken = parseOptionalToken(55); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseInitializer(true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(true); - } function fillSignature(returnToken, flags, signature) { if (!(flags & 32)) { signature.typeParameters = parseTypeParameters(); } signature.parameters = parseParameterList(flags); - var returnTokenRequired = returnToken === 36; - if (returnTokenRequired) { + signature.type = parseReturnType(returnToken, !!(flags & 4)); + } + function parseReturnType(returnToken, isType) { + return shouldParseReturnType(returnToken, isType) ? parseTypeOrTypePredicate() : undefined; + } + function shouldParseReturnType(returnToken, isType) { + if (returnToken === 36) { parseExpected(returnToken); - signature.type = parseTypeOrTypePredicate(); + return true; } - else if (parseOptional(returnToken)) { - signature.type = parseTypeOrTypePredicate(); + else if (parseOptional(56)) { + return true; } - else if (flags & 4) { - var start = scanner.getTokenPos(); - var length_1 = scanner.getTextPos() - start; - var backwardToken = parseOptional(returnToken === 56 ? 36 : 56); - if (backwardToken) { - signature.type = parseTypeOrTypePredicate(); - parseErrorAtPosition(start, length_1, ts.Diagnostics._0_expected, ts.tokenToString(returnToken)); - } + else if (isType && token() === 36) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56)); + nextToken(); + return true; } + return false; } function parseParameterList(flags) { if (parseExpected(19)) { @@ -13017,7 +13257,7 @@ var ts; var savedAwaitContext = inAwaitContext(); setYieldContext(!!(flags & 1)); setAwaitContext(!!(flags & 2)); - var result = parseDelimitedList(16, flags & 32 ? parseJSDocParameter : parseParameter); + var result = parseDelimitedList(16, flags & 32 ? parseJSDocParameter : function () { return parseParameter(!!(flags & 8)); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); if (!parseExpected(20) && (flags & 8)) { @@ -13081,7 +13321,7 @@ var ts; node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); @@ -13213,7 +13453,7 @@ var ts; parseExpected(94); } fillSignature(36, 4, node); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseKeywordAndNoDot() { var node = parseTokenNode(); @@ -13227,16 +13467,9 @@ var ts; unaryMinusExpression.operator = 38; nextToken(); } - var expression; - switch (token()) { - case 9: - case 8: - expression = parseLiteralLikeNode(token()); - break; - case 101: - case 86: - expression = parseTokenNode(); - } + var expression = token() === 101 || token() === 86 + ? parseTokenNode() + : parseLiteralLikeNode(token()); if (negative) { unaryMinusExpression.operand = expression; finishNode(unaryMinusExpression); @@ -13269,6 +13502,7 @@ var ts; return parseJSDocNodeWithType(274); case 51: return parseJSDocNodeWithType(271); + case 13: case 9: case 8: case 101: @@ -13300,7 +13534,7 @@ var ts; return parseTypeReference(); } } - function isStartOfType() { + function isStartOfType(inStartOfParameter) { switch (token()) { case 119: case 136: @@ -13325,11 +13559,14 @@ var ts; case 86: case 134: case 39: + case 55: + case 51: + case 24: return true; case 38: - return lookAhead(nextTokenIsNumericLiteral); + return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case 19: - return lookAhead(isStartOfParenthesizedOrFunctionType); + return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } @@ -13395,13 +13632,12 @@ var ts; parseOptional(operator); var type = parseConstituentType(); if (token() === operator) { - var types = createNodeArray([type], type.pos); + var types = [type]; while (parseOptional(operator)) { types.push(parseConstituentType()); } - types.end = getNodeEnd(); var node = createNode(kind, type.pos); - node.types = types; + node.types = createNodeArray(types, type.pos); type = finishNode(node); } return type; @@ -13561,11 +13797,16 @@ var ts; } return expr; } - function parseInitializer(inParameter) { + function parseInitializer(inParameter, requireEqualsToken) { if (token() !== 58) { if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17) || !isStartOfExpression()) { return undefined; } + if (inParameter && requireEqualsToken) { + var result = createMissingNode(71, true, ts.Diagnostics._0_expected, "="); + result.escapedText = "= not found"; + return result; + } } parseExpected(58); return parseAssignmentExpressionOrHigher(); @@ -13626,8 +13867,7 @@ var ts; var parameter = createNode(146, identifier.pos); parameter.name = identifier; finishNode(parameter); - node.parameters = createNodeArray([parameter], parameter.pos); - node.parameters.end = parameter.end; + node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); node.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); @@ -13734,8 +13974,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { if (token() === 120) { - var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === 1) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); return parseSimpleArrowFunctionExpression(expr, asyncModifier); @@ -13764,7 +14003,8 @@ var ts; if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 36 && token() !== 17) { + if (!allowAmbiguity && ((token() !== 36 && token() !== 17) || + ts.find(node.parameters, function (p) { return p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"; }))) { return undefined; } return node; @@ -14106,7 +14346,8 @@ var ts; ts.Debug.fail("Unknown JSX child kind " + token()); } function parseJsxChildren(openingTagName) { - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var saveParsingContext = parsingContext; parsingContext |= 1 << 14; while (true) { @@ -14123,12 +14364,11 @@ var ts; } var child = parseJsxChild(); if (child) { - result.push(child); + list.push(child); } } - result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseJsxAttributes() { var jsxAttributes = createNode(254); @@ -15007,7 +15247,7 @@ var ts; var node = createNode(176); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { @@ -15023,7 +15263,7 @@ var ts; node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingPattern() { @@ -15057,7 +15297,7 @@ var ts; node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseInitializer(false); + node.initializer = parseNonParameterInitializer(); } return finishNode(node); } @@ -15221,7 +15461,8 @@ var ts; return false; } function parseDecorators() { - var decorators; + var list; + var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); if (!parseOptional(57)) { @@ -15230,20 +15471,13 @@ var ts; var decorator = createNode(147, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); - if (!decorators) { - decorators = createNodeArray([decorator], decoratorStart); - } - else { - decorators.push(decorator); - } + (list || (list = [])).push(decorator); } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; + return list && createNodeArray(list, listPos); } function parseModifiers(permitInvalidConstAsModifier) { - var modifiers; + var list; + var listPos = getNodePos(); while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); @@ -15258,17 +15492,9 @@ var ts; } } var modifier = finishNode(createNode(modifierKind, modifierStart)); - if (!modifiers) { - modifiers = createNodeArray([modifier], modifierStart); - } - else { - modifiers.push(modifier); - } + (list || (list = [])).push(modifier); } - if (modifiers) { - modifiers.end = scanner.getStartPos(); - } - return modifiers; + return list && createNodeArray(list, listPos); } function parseModifiersForArrowFunction() { var modifiers; @@ -15278,7 +15504,6 @@ var ts; nextToken(); var modifier = finishNode(createNode(modifierKind, modifierStart)); modifiers = createNodeArray([modifier], modifierStart); - modifiers.end = scanner.getStartPos(); } return modifiers; } @@ -15773,9 +15998,11 @@ var ts; return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - function parseJSDocTypeExpression() { + function parseJSDocTypeExpression(requireBraces) { var result = createNode(267, scanner.getTokenPos()); - parseExpected(17); + if (!parseExpected(17) && requireBraces) { + return undefined; + } result.type = doInsideOfContext(1048576, parseType); parseExpected(18); fixupParentReferences(result); @@ -15832,6 +16059,8 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; + var tagsPos; + var tagsEnd; var comments = []; var result; if (!isJsDocStart(content, start)) { @@ -15940,7 +16169,7 @@ var ts; } function createJSDocComment() { var result = createNode(275, start); - result.tags = tags; + result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -16063,21 +16292,17 @@ var ts; function addTag(tag, comments) { tag.comment = comments.join(""); if (!tags) { - tags = createNodeArray([tag], tag.pos); + tags = [tag]; + tagsPos = tag.pos; } else { tags.push(tag); } - tags.end = tag.end; + tagsEnd = tag.end; } function tryParseTypeExpression() { - return tryParse(function () { - skipWhitespace(); - if (token() !== 17) { - return undefined; - } - return parseJSDocTypeExpression(); - }); + skipWhitespace(); + return token() === 17 ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { var isBracketed = parseOptional(21); @@ -16167,11 +16392,11 @@ var ts; var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); + result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); + var typeExpression = parseJSDocTypeExpression(true); var result = createNode(277, atToken.pos); result.atToken = atToken; result.tagName = tagName; @@ -16206,19 +16431,18 @@ var ts; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { var child = void 0; var jsdocTypeLiteral = void 0; - var alreadyHasTypeTag = false; + var childTypeTag = void 0; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildParameterOrPropertyTag(0); })) { if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(285, start_3); } if (child.kind === 281) { - if (alreadyHasTypeTag) { + if (childTypeTag) { break; } else { - jsdocTypeLiteral.jsDocTypeTag = child; - alreadyHasTypeTag = true; + childTypeTag = child; } } else { @@ -16232,7 +16456,9 @@ var ts; if (typeExpression && typeExpression.type.kind === 164) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = finishNode(jsdocTypeLiteral); + typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + childTypeTag.typeExpression : + finishNode(jsdocTypeLiteral); } } return finishNode(typedefTag); @@ -16326,7 +16552,8 @@ var ts; if (ts.forEach(tags, function (t) { return t.kind === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var typeParameters = createNodeArray(); + var typeParameters = []; + var typeParametersPos = getNodePos(); while (true) { var name = parseJSDocIdentifierName(); skipWhitespace(); @@ -16349,9 +16576,8 @@ var ts; var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; + result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); - typeParameters.end = result.end; return result; } function nextJSDocToken() { @@ -16443,7 +16669,7 @@ var ts; ts.Debug.assert(text === newText.substring(node.pos, node.end)); } forEachChild(node, visitNode, visitArray); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDocComment = _a[_i]; forEachChild(jsDocComment, visitNode, visitArray); @@ -16826,9 +17052,11 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; if (!symbol.declarations) { - symbol.declarations = []; + symbol.declarations = [node]; + } + else { + symbol.declarations.push(node); } - symbol.declarations.push(node); if (symbolFlags & 1952 && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -16892,17 +17120,8 @@ var ts; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; case 283: - var parentNode = node.parent && node.parent.parent; - var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 208) { - if (parentNode.declarationList.declarations.length > 0) { - var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (ts.isIdentifier(nameIdentifier)) { - nameFromParentNode = nameIdentifier.escapedText; - } - } - } - return nameFromParentNode; + var name_2 = ts.getNameOfJSDocTypedef(node); + return typeof name_2 !== "undefined" ? name_2.escapedText : undefined; } } function getDisplayName(node) { @@ -17103,7 +17322,7 @@ var ts; ts.forEachChild(node, bind, bindEach); } function bindChildrenWorker(node) { - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { if (ts.isInJavaScriptFile(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var j = _a[_i]; @@ -17843,9 +18062,6 @@ var ts; lastContainer = next; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - return declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { case 233: return declareModuleMember(node, symbolFlags, symbolExcludes); @@ -18007,6 +18223,9 @@ var ts; } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); + if (symbolFlags & 8) { + symbol.parent = container.symbol; + } addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { @@ -18164,7 +18383,7 @@ var ts; inStrictMode = saveInStrictMode; } function bindJSDocTypedefTagIfAny(node) { - if (!node.jsDoc) { + if (!ts.hasJSDocNodes(node)) { return; } for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -19341,31 +19560,38 @@ var ts; return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } - var visitedTypes = ts.createMap(); - var visitedSymbols = ts.createMap(); + var visitedTypes = []; + var visitedSymbols = []; return { walkType: function (type) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitType(type); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitType(type); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, walkSymbol: function (symbol) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitSymbol(symbol); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitSymbol(symbol); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, }; function visitType(type) { if (!type) { return; } - var typeIdString = type.id.toString(); - if (visitedTypes.has(typeIdString)) { + if (visitedTypes[type.id]) { return; } - visitedTypes.set(typeIdString, type); + visitedTypes[type.id] = type; var shouldBail = visitSymbol(type.symbol); if (shouldBail) return; @@ -19398,23 +19624,15 @@ var ts; visitIndexedAccessType(type); } } - function visitTypeList(types) { - if (!types) { - return; - } - for (var i = 0; i < types.length; i++) { - visitType(types[i]); - } - } function visitTypeReference(type) { visitType(type.target); - visitTypeList(type.typeArguments); + ts.forEach(type.typeArguments, visitType); } function visitTypeParameter(type) { visitType(getConstraintFromTypeParameter(type)); } function visitUnionOrIntersectionType(type) { - visitTypeList(type.types); + ts.forEach(type.types, visitType); } function visitIndexType(type) { visitType(type.type); @@ -19434,7 +19652,7 @@ var ts; if (signature.typePredicate) { visitType(signature.typePredicate.type); } - visitTypeList(signature.typeParameters); + ts.forEach(signature.typeParameters, visitType); for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; visitSymbol(parameter); @@ -19444,8 +19662,8 @@ var ts; } function visitInterfaceType(interfaceT) { visitObjectType(interfaceT); - visitTypeList(interfaceT.typeParameters); - visitTypeList(getBaseTypes(interfaceT)); + ts.forEach(interfaceT.typeParameters, visitType); + ts.forEach(getBaseTypes(interfaceT), visitType); visitType(interfaceT.thisType); } function visitObjectType(type) { @@ -19471,11 +19689,11 @@ var ts; if (!symbol) { return; } - var symbolIdString = ts.getSymbolId(symbol).toString(); - if (visitedSymbols.has(symbolIdString)) { + var symbolId = ts.getSymbolId(symbol); + if (visitedSymbols[symbolId]) { return; } - visitedSymbols.set(symbolIdString, symbol); + visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { return true; } @@ -19537,6 +19755,7 @@ var ts; var enumCount = 0; var symbolInstantiationDepth = 0; var emptySymbols = ts.createSymbolTable(); + var identityMapper = ts.identity; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -19689,12 +19908,13 @@ var ts; return tryFindAmbientModule(moduleName, false); }, getApparentType: getApparentType, - getAllPossiblePropertiesOfType: getAllPossiblePropertiesOfType, + isArrayLikeType: isArrayLikeType, + getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, resolveName: function (name, location, meaning) { - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined); + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false); }, getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; @@ -19773,7 +19993,8 @@ var ts; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; var flowLoopCount = 0; - var visitedFlowCount = 0; + var sharedFlowCount = 0; + var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var resolutionTargets = []; @@ -19788,8 +20009,8 @@ var ts; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; - var visitedFlowNodes = []; - var visitedFlowTypes = []; + var sharedFlowNodes = []; + var sharedFlowTypes = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -19918,6 +20139,7 @@ var ts; })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -19999,7 +20221,7 @@ var ts; } function cloneSymbol(symbol) { var result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations.slice(0); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; @@ -20227,10 +20449,10 @@ var ts; }); } } - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, suggestedNameNotFoundMessage) { - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, suggestedNameNotFoundMessage) { + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, getSymbol, suggestedNameNotFoundMessage); } - function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, lookup, suggestedNameNotFoundMessage) { + function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, lookup, suggestedNameNotFoundMessage) { var originalLocation = location; var result; var lastLocation; @@ -20386,10 +20608,16 @@ var ts; lastLocation = location; location = location.parent; } - if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { + if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { + if (lastLocation) { + ts.Debug.assert(lastLocation.kind === 265); + if (lastLocation.commonJsModuleIndicator && name === "exports") { + return lastLocation.symbol; + } + } result = lookup(globals, name, meaning); } if (!result) { @@ -20501,7 +20729,7 @@ var ts; } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { if (meaning === 1920) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined, false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -20525,7 +20753,7 @@ var ts; error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined, false)); if (symbol && !(symbol.flags & 1024)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -20535,14 +20763,14 @@ var ts; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { if (meaning & (107455 & ~1024 & ~793064)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } else if (meaning & (793064 & ~1024 & ~107455)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -20570,11 +20798,17 @@ var ts; return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 237) { + switch (node.kind) { + case 237: return node; - } - return ts.findAncestor(node, ts.isImportDeclaration); + case 239: + return node.parent; + case 240: + return node.parent.parent; + case 242: + return node.parent.parent.parent; + default: + return undefined; } } function getDeclarationOfAliasSymbol(symbol) { @@ -20784,7 +21018,7 @@ var ts; var symbol; if (name.kind === 71) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name); + symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name, true); if (!symbol) { return undefined; } @@ -20823,7 +21057,7 @@ var ts; undefined; } else { - ts.Debug.fail("Unknown entity name kind."); + ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -20871,13 +21105,13 @@ var ts; return getMergedSymbol(pattern.symbol); } } - if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } else if (noImplicitAny && moduleNotFoundError) { - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + var errorInfo = !resolvedModule.isExternalLibraryImport ? undefined : ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } @@ -20976,10 +21210,9 @@ var ts; moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || emptySymbols; function visit(symbol) { - if (!(symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol))) { + if (!(symbol && symbol.flags & 1952 && ts.pushIfUnique(visitedSymbols, symbol))) { return; } - visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); var exportStars = symbol.exports.get("__export"); if (exportStars) { @@ -21118,55 +21351,51 @@ var ts; return rightMeaning === 107455 ? 107455 : 1920; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - return getAccessibleSymbolChainFromSymbolTableWorker(symbols, []); + if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { + return undefined; } - function getAccessibleSymbolChainFromSymbolTableWorker(symbols, visitedSymbolTables) { - if (ts.contains(visitedSymbolTables, symbols)) { + var visitedSymbolTables = []; + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function getAccessibleSymbolChainFromSymbolTable(symbols) { + if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - visitedSymbolTables.push(symbols); var result = trySymbolTable(symbols); visitedSymbolTables.pop(); return result; - function canQualifySymbol(symbolFromSymbolTable, meaning) { - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - function trySymbolTable(symbols) { - if (isAccessible(symbols.get(symbol.escapedName))) { - return [symbol]; - } - return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 - && symbolFromSymbolTable.escapedName !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) { - if (!useOnlyExternalAliasing || - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { - return [symbolFromSymbolTable]; - } - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTableWorker(resolvedImportedSymbol.exports, visitedSymbolTables) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } } - if (symbol && !isPropertyOrMethodDeclarationSymbol(symbol)) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function canQualifySymbol(symbolFromSymbolTable, meaning) { + return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) || + !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + function isUMDExportSymbol(symbol) { + return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + } + function trySymbolTable(symbols) { + if (isAccessible(symbols.get(symbol.escapedName))) { + return [symbol]; + } + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 2097152 + && symbolFromSymbolTable.escapedName !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246) + && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) + && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { + return [symbolFromSymbolTable]; + } + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + }); } } function needsQualification(symbol, enclosingDeclaration, meaning) { @@ -21269,14 +21498,7 @@ var ts; isDeclarationVisible(anyImportSyntax.parent)) { if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } + aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, anyImportSyntax); } return true; } @@ -21298,7 +21520,7 @@ var ts; meaning = 793064; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false); return (symbol && hasVisibleDeclarations(symbol, true)) || { accessibility: 1, errorSymbolName: ts.getTextOfNode(firstIdentifier), @@ -21331,7 +21553,7 @@ var ts; var writer = ts.createTextWriter(""); var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(3, typeNode, sourceFile, writer); + printer.writeNode(4, typeNode, sourceFile, writer); var result = writer.getText(); var maxLength = compilerOptions.noErrorTruncation || flags & 8 ? undefined : 100; if (maxLength && result.length >= maxLength) { @@ -21613,13 +21835,13 @@ var ts; var i = 0; var qualifiedName = void 0; if (outerTypeParameters) { - var length_2 = outerTypeParameters.length; - while (i < length_2) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice); @@ -21872,29 +22094,6 @@ var ts; } } } - function getNameOfSymbol(symbol, context) { - var declaration = ts.firstOrUndefined(symbol.declarations); - if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - return ts.declarationNameToString(name); - } - if (declaration.parent && declaration.parent.kind === 226) { - return ts.declarationNameToString(declaration.parent.name); - } - if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { - context.encounteredError = true; - } - switch (declaration.kind) { - case 199: - return "(Anonymous class)"; - case 186: - case 187: - return "(Anonymous function)"; - } - } - return ts.unescapeLeadingUnderscores(symbol.escapedName); - } } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { return ts.usingSingleLineStringWriter(function (writer) { @@ -21952,9 +22151,9 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { - return type.flags & 32 ? "\"" + ts.escapeString(type.value) + "\"" : "" + type.value; + return type.flags & 32 ? '"' + ts.escapeString(type.value) + '"' : "" + type.value; } - function getNameOfSymbol(symbol) { + function getNameOfSymbol(symbol, context) { if (symbol.declarations && symbol.declarations.length) { var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); @@ -21964,6 +22163,9 @@ var ts; if (declaration.parent && declaration.parent.kind === 226) { return ts.declarationNameToString(declaration.parent.name); } + if (context && !context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { + context.encounteredError = true; + } switch (declaration.kind) { case 199: return "(Anonymous class)"; @@ -21972,6 +22174,12 @@ var ts; return "(Anonymous function)"; } } + if (symbol.syntheticLiteralTypeOrigin) { + var stringValue = symbol.syntheticLiteralTypeOrigin.value; + if (!ts.isIdentifierText(stringValue, compilerOptions.target)) { + return "\"" + ts.escapeString(stringValue, 34) + "\""; + } + } return ts.unescapeLeadingUnderscores(symbol.escapedName); } function getSymbolDisplayBuilder() { @@ -22168,13 +22376,13 @@ var ts; var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_3 = outerTypeParameters.length; - while (i < length_3) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_3 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent, typeArguments, start, i, flags); writePunctuation(writer, 23); @@ -22692,7 +22900,7 @@ var ts; function collectLinkedAliases(node) { var exportSymbol; if (node.parent && node.parent.kind === 243) { - exportSymbol = resolveName(node.parent, node.escapedText, 107455 | 793064 | 1920 | 2097152, ts.Diagnostics.Cannot_find_name_0, node); + exportSymbol = resolveName(node.parent, node.escapedText, 107455 | 793064 | 1920 | 2097152, ts.Diagnostics.Cannot_find_name_0, node, false); } else if (node.parent.kind === 246) { exportSymbol = getTargetOfExportSpecifier(node.parent, 107455 | 793064 | 1920 | 2097152); @@ -22706,13 +22914,11 @@ var ts; ts.forEach(declarations, function (declaration) { getNodeLinks(declaration).isVisible = true; var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } + ts.pushIfUnique(result, resultNode); if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 | 793064 | 1920, undefined, undefined); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 | 793064 | 1920, undefined, undefined, false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -22723,8 +22929,8 @@ var ts; function pushTypeResolution(target, propertyName) { var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { - var length_4 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_4; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -23335,34 +23541,48 @@ var ts; for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } + typeParameters = ts.appendIfUnique(typeParameters, tp); } return typeParameters; } - function appendOuterTypeParameters(typeParameters, node) { + function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; if (!node) { - return typeParameters; + return undefined; } - if (node.kind === 229 || node.kind === 199 || - node.kind === 228 || node.kind === 186 || - node.kind === 151 || node.kind === 187) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } + switch (node.kind) { + case 229: + case 199: + case 230: + case 155: + case 156: + case 150: + case 160: + case 161: + case 273: + case 228: + case 151: + case 186: + case 187: + case 231: + case 282: + case 172: + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + if (node.kind === 172) { + return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); + } + var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray); + var thisType = includeThisTypes && + (node.kind === 229 || node.kind === 199 || node.kind === 230) && + getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; + return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230); - return appendOuterTypeParameters(undefined, declaration); + return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; @@ -23410,7 +23630,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig; }); + return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJavaScriptFile(location)) : sig; }); } function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { @@ -23484,7 +23704,7 @@ var ts; var valueDecl = type.symbol.valueDeclaration; if (valueDecl && ts.isInJavaScriptFile(valueDecl)) { var augTag = ts.getJSDocAugmentsTag(type.symbol.valueDeclaration); - if (augTag) { + if (augTag && augTag.typeExpression && augTag.typeExpression.type) { baseType = getTypeFromTypeNode(augTag.typeExpression.type); } } @@ -23600,7 +23820,8 @@ var ts; var declaration = ts.find(symbol.declarations, function (d) { return d.kind === 283 || d.kind === 231; }); - var type = getTypeFromTypeNode(declaration.kind === 283 ? declaration.typeExpression : declaration.type); + var typeNode = declaration.kind === 283 ? declaration.typeExpression : declaration.type; + var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -23934,7 +24155,7 @@ var ts; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -23968,9 +24189,7 @@ var ts; if (!match) { return undefined; } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } + result = ts.appendIfUnique(result, match); } return result; } @@ -24146,7 +24365,11 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t, propertySymbol) { + function addMemberForKeyType(t, propertySymbolOrIndex) { + var propertySymbol; + if (typeof propertySymbolOrIndex === "object") { + propertySymbol = propertySymbolOrIndex; + } var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); @@ -24161,6 +24384,7 @@ var ts; prop.syntheticOrigin = propertySymbol; prop.declarations = propertySymbol.declarations; } + prop.syntheticLiteralTypeOrigin = t; members.set(propName, prop); } else if (t.flags & 2) { @@ -24271,26 +24495,22 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getAllPossiblePropertiesOfType(type) { - if (type.flags & 65536) { - var props = ts.createSymbolTable(); - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var memberType = _a[_i]; - if (memberType.flags & 8190) { - continue; - } - for (var _b = 0, _c = getPropertiesOfType(memberType); _b < _c.length; _b++) { - var escapedName = _c[_b].escapedName; - if (!props.has(escapedName)) { - props.set(escapedName, createUnionOrIntersectionProperty(type, escapedName)); - } + function getAllPossiblePropertiesOfTypes(types) { + var unionType = getUnionType(types); + if (!(unionType.flags & 65536)) { + return getPropertiesOfType(unionType); + } + var props = ts.createSymbolTable(); + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var memberType = types_2[_i]; + for (var _a = 0, _b = getPropertiesOfType(memberType); _a < _b.length; _a++) { + var escapedName = _b[_a].escapedName; + if (!props.has(escapedName)) { + props.set(escapedName, createUnionOrIntersectionProperty(unionType, escapedName)); } } - return ts.arrayFrom(props.values()); - } - else { - return getPropertiesOfType(type); } + return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { return type.flags & 16384 ? getConstraintOfTypeParameter(type) : @@ -24352,8 +24572,8 @@ var ts; if (t.flags & 196608) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_2 = types_2[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); @@ -24416,20 +24636,15 @@ var ts; var commonFlags = isUnion ? 0 : 16777216; var syntheticFlag = 4; var checkFlags = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } + props = ts.appendIfUnique(props, prop); checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) | (!(modifiers & 24) ? 64 : 0) | (modifiers & 16 ? 128 : 0) | @@ -24555,12 +24770,7 @@ var ts; var result; ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) { var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - if (!result) { - result = []; - } - result.push(tp); - } + result = ts.appendIfUnique(result, tp); }); return result; } @@ -24596,7 +24806,7 @@ var ts; if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512); return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } function isOptionalParameter(node) { @@ -24646,11 +24856,10 @@ var ts; } return minTypeArgumentCount; } - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScript) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - var isJavaScript = ts.isInJavaScriptFile(location); if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; @@ -24682,7 +24891,7 @@ var ts; var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455, undefined, undefined); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455, undefined, undefined, false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -24870,8 +25079,8 @@ var ts; } return anyType; } - function getSignatureInstantiation(signature, typeArguments) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); + function getSignatureInstantiation(signature, typeArguments, isJavascript) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -24884,12 +25093,20 @@ var ts; return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); } function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); - } - return signature.erasedSignatureCache; + return signature.typeParameters ? + signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : + signature; + } + function createErasedSignature(signature) { + return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); + } + function getCanonicalSignature(signature) { + return signature.typeParameters ? + signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) : + signature; + } + function createCanonicalSignature(signature) { + return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJavaScriptFile(signature.declaration)); } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { @@ -24955,12 +25172,12 @@ var ts; function getTypeListId(types) { var result = ""; if (types) { - var length_5 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_5) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_5 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -24977,8 +25194,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -25014,13 +25231,14 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { + var isJavascript = ts.isInJavaScriptFile(node); + if (!isJavascript && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJavascript)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -25036,7 +25254,7 @@ var ts; var id = getTypeListId(typeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJavaScriptFile(symbol.valueDeclaration))))); } return instantiation; } @@ -25228,7 +25446,7 @@ var ts; return getGlobalSymbol(name, 793064, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); + return resolveName(undefined, name, meaning, diagnostic, name, false); } function getGlobalType(name, arity, reportErrors) { var symbol = getGlobalTypeSymbol(name, reportErrors); @@ -25374,6 +25592,20 @@ var ts; function containsType(types, type) { return binarySearchTypes(types, type) >= 0; } + function isEmptyIntersectionType(type) { + var combined = 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (t.flags & 6368 && combined & 6368) { + return true; + } + combined |= t.flags; + if (combined & 6144 && combined & (32768 | 16777216)) { + return true; + } + } + return false; + } function addTypeToUnion(typeSet, type) { var flags = type.flags; if (flags & 65536) { @@ -25390,7 +25622,7 @@ var ts; if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } - else if (!(flags & 8192)) { + else if (!(flags & 8192 || flags & 131072 && isEmptyIntersectionType(type))) { if (flags & 2) typeSet.containsString = true; if (flags & 4) @@ -25408,14 +25640,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -25423,8 +25655,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -25548,8 +25780,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -25695,20 +25927,6 @@ var ts; } return anyType; } - function getIndexedAccessForMappedType(type, indexType, accessNode) { - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(type))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); - return unknownType; - } - if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { - error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - } - } - var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); - var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); - } function isGenericObjectType(type) { return type.flags & 540672 ? true : getObjectFlags(type) & 32 ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : @@ -25748,12 +25966,15 @@ var ts; getIntersectionType(stringIndexTypes) ]); } + if (isGenericMappedType(objectType)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [type.indexType]); + var objectTypeMapper = objectType.mapper; + var templateMapper = objectTypeMapper ? combineTypeMappers(objectTypeMapper, mapper) : mapper; + return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); + } return undefined; } function getIndexedAccessType(objectType, indexType, accessNode) { - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180) && isGenericObjectType(objectType)) { if (objectType.flags & 1) { return objectType; @@ -25766,7 +25987,7 @@ var ts; return type; } var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 65536 && !(indexType.flags & 8190)) { + if (indexType.flags & 65536 && !(indexType.flags & 8)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -25842,7 +26063,10 @@ var ts; return mapType(right, function (t) { return getSpreadType(left, t); }); } if (right.flags & 16777216) { - return emptyObjectType; + return nonPrimitiveType; + } + if (right.flags & (136 | 84 | 262178 | 272)) { + return left; } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); @@ -26062,10 +26286,6 @@ var ts; function instantiateSignatures(signatures, mapper) { return instantiateList(signatures, mapper, instantiateSignature); } - function instantiateCached(type, mapper, instantiator) { - var instantiations = mapper.instantiations || (mapper.instantiations = []); - return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); - } function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -26084,19 +26304,15 @@ var ts; } function createTypeMapper(sources, targets) { ts.Debug.assert(targets === undefined || sources.length === targets.length); - var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : makeArrayTypeMapper(sources, targets); - mapper.mappedTypes = sources; - return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } function createBackreferenceMapper(typeParameters, index) { - var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; - mapper.mappedTypes = typeParameters; - return mapper; + return function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; } function isInferenceContext(mapper) { return !!mapper.signature; @@ -26106,18 +26322,11 @@ var ts; createInferenceContext(mapper.signature, mapper.flags | 2, mapper.compareTypes, mapper.inferences) : mapper; } - function identityMapper(type) { - return type; - } function combineTypeMappers(mapper1, mapper2) { - var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); - return mapper; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function createReplacementMapper(source, target, baseMapper) { - var mapper = function (t) { return t === source ? target : baseMapper(t); }; - mapper.mappedTypes = baseMapper.mappedTypes; - return mapper; + return function (t) { return t === source ? target : baseMapper(t); }; } function cloneTypeParameter(typeParameter) { var result = createType(16384); @@ -26175,15 +26384,50 @@ var ts; if (symbol.valueDeclaration) { result.valueDeclaration = symbol.valueDeclaration; } + if (symbol.isRestParameter) { + result.isRestParameter = symbol.isRestParameter; + } return result; } - function instantiateAnonymousType(type, mapper) { - var result = createObjectType(16 | 64, type.symbol); - result.target = type.objectFlags & 64 ? type.target : type; - result.mapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); - return result; + function getAnonymousTypeInstantiation(type, mapper) { + var target = type.objectFlags & 64 ? type.target : type; + var symbol = target.symbol; + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (!typeParameters) { + var declaration_1 = symbol.declarations[0]; + var outerTypeParameters = getOuterTypeParameters(declaration_1, true) || ts.emptyArray; + typeParameters = symbol.flags & 2048 && !target.aliasTypeArguments ? + ts.filter(outerTypeParameters, function (tp) { return isTypeParameterReferencedWithin(tp, declaration_1); }) : + outerTypeParameters; + links.typeParameters = typeParameters; + if (typeParameters.length) { + links.instantiations = ts.createMap(); + links.instantiations.set(getTypeListId(typeParameters), target); + } + } + if (typeParameters.length) { + var combinedMapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; + var typeArguments = ts.map(typeParameters, combinedMapper); + var id = getTypeListId(typeArguments); + var result = links.instantiations.get(id); + if (!result) { + var newMapper = createTypeMapper(typeParameters, typeArguments); + result = target.objectFlags & 32 ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + links.instantiations.set(id, result); + } + return result; + } + return type; + } + function isTypeParameterReferencedWithin(tp, node) { + return tp.isThisType ? ts.forEachChild(node, checkThis) : ts.forEachChild(node, checkIdentifier); + function checkThis(node) { + return node.kind === 169 || ts.forEachChild(node, checkThis); + } + function checkIdentifier(node) { + return node.kind === 71 && ts.isPartOfTypeNode(node) && getTypeFromTypeNode(node) === tp || ts.forEachChild(node, checkIdentifier); + } } function instantiateMappedType(type, mapper) { var constraintType = getConstraintTypeFromMappedType(type); @@ -26194,134 +26438,58 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + return instantiateAnonymousType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); } } } - return instantiateMappedObjectType(type, mapper); + return instantiateAnonymousType(type, mapper); } function isMappableType(type) { return type.flags & (16384 | 32768 | 131072 | 524288); } - function instantiateMappedObjectType(type, mapper) { - var result = createObjectType(32 | 64, type.symbol); - result.declaration = type.declaration; - result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + function instantiateAnonymousType(type, mapper) { + var result = createObjectType(type.objectFlags | 64, type.symbol); + if (type.objectFlags & 32) { + result.declaration = type.declaration; + } + result.target = type; + result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { - if (!(symbol.declarations && symbol.declarations.length)) { - return false; - } - var mappedTypes = mapper.mappedTypes; - return !!ts.findAncestor(symbol.declarations[0], function (node) { - if (node.kind === 233 || node.kind === 265) { - return "quit"; - } - switch (node.kind) { - case 160: - case 161: - case 228: - case 151: - case 150: - case 152: - case 155: - case 156: - case 157: - case 153: - case 154: - case 186: - case 187: - case 229: - case 199: - case 230: - case 231: - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (typeParameters) { - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var d = typeParameters_1[_i]; - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) { - return true; - } - } - } - if (ts.isClassLike(node) || node.kind === 230) { - var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; - if (thisType && ts.contains(mappedTypes, thisType)) { - return true; - } - } - break; - case 172: - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { - return true; - } - break; - case 273: - var func = node; - for (var _a = 0, _b = func.parameters; _a < _b.length; _a++) { - var p = _b[_a]; - if (ts.contains(mappedTypes, getTypeOfNode(p))) { - return true; - } - } - break; - } - }); - } - function isTopLevelTypeAlias(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 265 || parentKind === 234; - } - return false; - } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { - if (type.aliasTypeArguments) { - return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + if (type.flags & 16384) { + return mapper(type); + } + if (type.flags & 32768) { + if (type.objectFlags & 16) { + return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ? + getAnonymousTypeInstantiation(type, mapper) : type; + } + if (type.objectFlags & 32) { + return getAnonymousTypeInstantiation(type, mapper); + } + if (type.objectFlags & 4) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } - return type; } - return instantiateTypeNoAlias(type, mapper); - } - return type; - } - function instantiateTypeNoAlias(type, mapper) { - if (type.flags & 16384) { - return mapper(type); - } - if (type.flags & 32768) { - if (type.objectFlags & 16) { - return type.symbol && - type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && - (type.objectFlags & 64 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateCached(type, mapper, instantiateAnonymousType) : type; + if (type.flags & 65536 && !(type.flags & 8190)) { + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 32) { - return instantiateCached(type, mapper, instantiateMappedType); + if (type.flags & 131072) { + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 4) { - return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); + if (type.flags & 262144) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - } - if (type.flags & 65536 && !(type.flags & 8190)) { - return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 131072) { - return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 262144) { - return getIndexType(instantiateType(type.type, mapper)); - } - if (type.flags & 524288) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } return type; } @@ -26333,6 +26501,7 @@ var ts; switch (node.kind) { case 186: case 187: + case 151: return isContextSensitiveFunctionLikeDeclaration(node); case 178: return ts.forEach(node.properties, isContextSensitive); @@ -26346,9 +26515,6 @@ var ts; (isContextSensitive(node.left) || isContextSensitive(node.right)); case 261: return isContextSensitive(node.initializer); - case 151: - case 150: - return isContextSensitiveFunctionLikeDeclaration(node); case 185: return isContextSensitive(node.expression); case 254: @@ -26435,7 +26601,8 @@ var ts; if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { return 0; } - if (source.typeParameters) { + if (source.typeParameters && source.typeParameters !== target.typeParameters) { + target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } var result = -1; @@ -26678,6 +26845,13 @@ var ts; var targetStack; var maybeCount = 0; var depth = 0; + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); var expandingFlags = 0; var overflow = false; var isIntersectionConstituent = false; @@ -26861,10 +27035,21 @@ var ts; } else { var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; })) { - errorNode = prop.valueDeclaration; + var propDeclaration = prop.valueDeclaration; + ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); + errorNode = propDeclaration; + if (ts.isIdentifier(propDeclaration.name)) { + suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + } + } + if (suggestion !== undefined) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2, symbolToString(prop), typeToString(target), ts.unescapeLeadingUnderscores(suggestion)); + } + else { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } } return { value: true }; @@ -27071,7 +27256,7 @@ var ts; } } else if (target.flags & 524288) { - var constraint = getConstraintOfType(target); + var constraint = getConstraintOfIndexedAccess(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -27104,7 +27289,7 @@ var ts; } } else if (source.flags & 524288) { - var constraint = getConstraintOfType(source); + var constraint = getConstraintOfIndexedAccess(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -27179,22 +27364,21 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); + var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); + if (unmatchedProperty) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + } + return 0; + } var result = -1; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var targetProp = properties_3[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 16777216) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0; - } - } - else if (!(targetProp.flags & 4194304)) { + if (!(targetProp.flags & 4194304)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp && sourceProp !== targetProp) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { @@ -27466,9 +27650,10 @@ var ts; return type.flags & 16384 && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return getObjectFlags(type) & 4 && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + return getObjectFlags(type) & 4 && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } - function getTypeReferenceId(type, typeParameters) { + function getTypeReferenceId(type, typeParameters, depth) { + if (depth === void 0) { depth = 0; } var result = "" + type.target.id; for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { var t = _a[_i]; @@ -27480,6 +27665,9 @@ var ts; } result += "=" + index; } + else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; + } else { result += "-" + t.id; } @@ -27645,8 +27833,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27682,7 +27870,7 @@ var ts; return !!getPropertyOfType(type, "0"); } function isUnitType(type) { - return (type.flags & (224 | 2048 | 4096)) !== 0; + return !!(type.flags & 6368); } function isLiteralType(type) { return type.flags & 8 ? true : @@ -27710,8 +27898,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -27923,7 +28111,6 @@ var ts; function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; - context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; @@ -27961,7 +28148,7 @@ var ts; } function couldContainTypeVariables(type) { var objectFlags = getObjectFlags(type); - return !!(type.flags & 540672 || + return !!(type.flags & (540672 | 262144) || objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 2048 | 32) || objectFlags & 32 || @@ -28015,18 +28202,18 @@ var ts; return inference.candidates && getUnionType(inference.candidates, true); } } - function isPossiblyAssignableTo(source, target) { + function getUnmatchedProperty(source, target, requireOptionalProperties) { var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; - if (!(targetProp.flags & (16777216 | 4194304))) { - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (requireOptionalProperties || !(targetProp.flags & 16777216)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!sourceProp) { - return false; + return targetProp; } } } - return true; + return undefined; } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } @@ -28102,6 +28289,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 262144 && target.flags & 262144) { + inferFromTypes(source.type, target.type); + } + else if (source.flags & 524288 && target.flags & 524288) { + inferFromTypes(source.objectType, target.objectType); + inferFromTypes(source.indexType, target.indexType); + } else if (target.flags & 196608) { var targetTypes = target.types; var typeVariableCount = 0; @@ -28123,7 +28317,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 196608) { + else if (source.flags & 65536) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -28132,7 +28326,7 @@ var ts; } else { source = getApparentType(source); - if (source.flags & 32768) { + if (source.flags & (32768 | 131072)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -28167,6 +28361,10 @@ var ts; return undefined; } function inferFromObjectTypes(source, target) { + if (isGenericMappedType(source) && isGenericMappedType(target)) { + inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + } if (getObjectFlags(target) & 32) { var constraintType = getConstraintTypeFromMappedType(target); if (constraintType.flags & 262144) { @@ -28188,7 +28386,7 @@ var ts; return; } } - if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + if (!getUnmatchedProperty(source, target, false) || !getUnmatchedProperty(target, source, false)) { inferFromProperties(source, target); inferFromSignatures(source, target, 0); inferFromSignatures(source, target, 1); @@ -28199,7 +28397,7 @@ var ts; var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -28245,8 +28443,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28317,7 +28515,8 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = !ts.nodeIsMissing(node) && resolveName(node, node.escapedText, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + links.resolvedSymbol = !ts.nodeIsMissing(node) && + resolveName(node, node.escapedText, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node, !ts.isWriteOnlyAccess(node), ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } @@ -28481,8 +28680,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -28739,8 +28938,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -28809,8 +29008,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -28859,69 +29058,87 @@ var ts; } return false; } + function reportFlowControlError(node) { + var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); + var sourceFile = ts.getSourceFileOfNode(node); + var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; + var flowDepth = 0; + if (flowAnalysisDisabled) { + return unknownType; + } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810175)) { return declaredType; } - var visitedFlowStart = visitedFlowCount; + var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); - visitedFlowCount = visitedFlowStart; + sharedFlowCount = sharedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); if (reference.parent.kind === 203 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; function getTypeAtFlowNode(flow) { + if (flowDepth === 2500) { + flowAnalysisDisabled = true; + reportFlowControlError(reference); + return unknownType; + } + flowDepth++; while (true) { - if (flow.flags & 1024) { - for (var i = visitedFlowStart; i < visitedFlowCount; i++) { - if (visitedFlowNodes[i] === flow) { - return visitedFlowTypes[i]; + var flags = flow.flags; + if (flags & 1024) { + for (var i = sharedFlowStart; i < sharedFlowCount; i++) { + if (sharedFlowNodes[i] === flow) { + flowDepth--; + return sharedFlowTypes[i]; } } } var type = void 0; - if (flow.flags & 4096) { + if (flags & 4096) { flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flow.flags & 2048) { + else if (flags & 2048) { flow = flow.antecedent; continue; } - else if (flow.flags & 16) { + else if (flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 96) { + else if (flags & 96) { type = getTypeAtFlowCondition(flow); } - else if (flow.flags & 128) { + else if (flags & 128) { type = getTypeAtSwitchClause(flow); } - else if (flow.flags & 12) { + else if (flags & 12) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flow.flags & 4 ? + type = flags & 4 ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flow.flags & 256) { + else if (flags & 256) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 2) { + else if (flags & 2) { var container = flow.container; if (container && container !== flowContainer && reference.kind !== 179 && reference.kind !== 99) { flow = container.flowNode; @@ -28932,11 +29149,12 @@ var ts; else { type = convertAutoToAny(declaredType); } - if (flow.flags & 1024) { - visitedFlowNodes[visitedFlowCount] = flow; - visitedFlowTypes[visitedFlowCount] = type; - visitedFlowCount++; + if (flags & 1024) { + sharedFlowNodes[sharedFlowCount] = flow; + sharedFlowTypes[sharedFlowCount] = type; + sharedFlowCount++; } + flowDepth--; return type; } } @@ -28965,30 +29183,32 @@ var ts; return undefined; } function getTypeAtFlowArrayMutation(flow) { - var node = flow.node; - var expr = node.kind === 181 ? - node.expression.expression : - node.left.expression; - if (isMatchingReference(reference, getReferenceCandidate(expr))) { - var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); - if (getObjectFlags(type) & 256) { - var evolvedType_1 = type; - if (node.kind === 181) { - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var arg = _a[_i]; - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + if (declaredType === autoType || declaredType === autoArrayType) { + var node = flow.node; + var expr = node.kind === 181 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (getObjectFlags(type) & 256) { + var evolvedType_1 = type; + if (node.kind === 181) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } } - } - else { - var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84)) { - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + else { + var indexType = getTypeOfExpression(node.left.argumentExpression); + if (isTypeAssignableToKind(indexType, 84)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); } - return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + return flowType; } - return flowType; } return undefined; } @@ -29034,9 +29254,7 @@ var ts; if (type === declaredType && declaredType === initialType) { return type; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); if (!isTypeSubsetOf(type, declaredType)) { subtypeReduction = true; } @@ -29083,9 +29301,7 @@ var ts; if (cached_1) { return cached_1; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); if (!isTypeSubsetOf(type, declaredType)) { subtypeReduction = true; } @@ -29859,7 +30075,8 @@ var ts; } } } - if (noImplicitThis || ts.isInJavaScriptFile(func)) { + var inJs = ts.isInJavaScriptFile(func); + if (noImplicitThis || inJs) { var containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { var contextualType = getApparentTypeOfContextualType(containingLiteral); @@ -29878,10 +30095,18 @@ var ts; } return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } - if (func.parent.kind === 194 && func.parent.operatorToken.kind === 58) { - var target = func.parent.left; + var parent = func.parent; + if (parent.kind === 194 && parent.operatorToken.kind === 58) { + var target = parent.left; if (target.kind === 179 || target.kind === 180) { - return checkExpressionCached(target.expression); + var expression = target.expression; + if (inJs && ts.isIdentifier(expression)) { + var sourceFile = ts.getSourceFileOfNode(parent); + if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) { + return undefined; + } + } + return checkExpressionCached(expression); } } } @@ -30035,7 +30260,7 @@ var ts; else if (operator === 54) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { - type = getTypeOfExpression(binaryExpression.left); + type = getTypeOfExpression(binaryExpression.left, true); } return type; } @@ -30081,16 +30306,10 @@ var ts; } return undefined; } - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getApparentTypeOfContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1) - || getIteratedTypeOrElementType(type, undefined, false, false, false); - } - return undefined; + function getContextualTypeForElementExpression(arrayContextualType, index) { + return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) + || getIndexTypeOfContextualType(arrayContextualType, 1) + || getIteratedTypeOrElementType(arrayContextualType, undefined, false, false, false)); } function getContextualTypeForConditionalOperand(node) { var conditional = node.parent; @@ -30164,15 +30383,20 @@ var ts; return getContextualTypeForObjectLiteralElement(parent); case 263: return getApparentTypeOfContextualType(parent.parent); - case 177: - return getContextualTypeForElementExpression(node); + case 177: { + var arrayLiteral = parent; + var type = getApparentTypeOfContextualType(arrayLiteral); + return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); + } case 195: return getContextualTypeForConditionalOperand(node); case 205: ts.Debug.assert(parent.parent.kind === 196); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 185: - return getContextualType(parent); + case 185: { + var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); + } case 256: return getContextualTypeForJsxExpression(parent); case 253: @@ -30235,8 +30459,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -30274,8 +30498,9 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); - for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { - var e = elements_1[_i]; + var contextualType = getApparentTypeOfContextualType(node); + for (var index = 0; index < elements.length; index++) { + var e = elements[index]; if (inDestructuringPattern && e.kind === 198) { var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || @@ -30285,7 +30510,8 @@ var ts; } } else { - var type = checkExpressionForMutableLocation(e, checkMode); + var elementContextualType = getContextualTypeForElementExpression(contextualType, index); + var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === 198; @@ -30296,15 +30522,15 @@ var ts; type.pattern = node; return type; } - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - var pattern = contextualType.pattern; + var contextualType_1 = getApparentTypeOfContextualType(node); + if (contextualType_1 && contextualTypeIsTupleLikeType(contextualType_1)) { + var pattern = contextualType_1.pattern; if (pattern && (pattern.kind === 175 || pattern.kind === 177)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.typeArguments[i]); + elementTypes.push(contextualType_1.typeArguments[i]); } else { if (patternElement.kind !== 200) { @@ -30390,6 +30616,7 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; + var literalName = void 0; if (memberDecl.kind === 261 || memberDecl.kind === 262 || ts.isObjectLiteralMethod(memberDecl)) { @@ -30399,6 +30626,12 @@ var ts; } var type = void 0; if (memberDecl.kind === 261) { + if (memberDecl.name.kind === 144) { + var t = checkComputedPropertyName(memberDecl.name); + if (t.flags & 224) { + literalName = ts.escapeLeadingUnderscores("" + t.value); + } + } type = checkPropertyAssignment(memberDecl, checkMode); } else if (memberDecl.kind === 151) { @@ -30413,14 +30646,14 @@ var ts; type = jsdocType; } typeFlags |= type.flags; - var prop = createSymbol(4 | member.flags, member.escapedName); + var prop = createSymbol(4 | member.flags, literalName || member.escapedName); if (inDestructuringPattern) { var isOptional = (memberDecl.kind === 261 && hasDefaultValue(memberDecl.initializer)) || (memberDecl.kind === 262 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; } } @@ -30467,7 +30700,7 @@ var ts; ts.Debug.assert(memberDecl.kind === 153 || memberDecl.kind === 154); checkNodeDeferred(memberDecl); } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -30525,7 +30758,8 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048 | 16777216) || + return !!(type.flags & (1 | 16777216) || + getFalsyFlags(type) & 7392 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -30715,8 +30949,9 @@ var ts; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { var signature = signatures_3[_i]; if (signature.typeParameters) { - var typeArguments = fillMissingTypeArguments(undefined, signature.typeParameters, 0); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + var isJavascript = ts.isInJavaScriptFile(node); + var typeArguments = fillMissingTypeArguments(undefined, signature.typeParameters, 0, isJavascript); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); } else { instantiatedSignatures.push(signature); @@ -30999,7 +31234,7 @@ var ts; checkJsxPreconditions(node); var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(); - var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace); + var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace, true); if (reactSym) { reactSym.isReferenced = true; if (reactSym.flags & 2097152 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { @@ -31175,19 +31410,8 @@ var ts; } return unknownType; } - if (prop.valueDeclaration) { - if (isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - if (prop.valueDeclaration.kind === 229 && - node.parent && node.parent.kind !== 159 && - !ts.isInAmbientContext(prop.valueDeclaration) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - } - markPropertyAsReferenced(prop); + checkPropertyNotUsedBeforeDeclaration(prop, node, right); + markPropertyAsReferenced(prop, node); getNodeLinks(node).resolvedSymbol = prop; checkPropertyAccessibility(node, left, apparentType, prop); var propType = getDeclaredOrApparentType(prop, node); @@ -31206,6 +31430,56 @@ var ts; var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { + var valueDeclaration = prop.valueDeclaration; + if (!valueDeclaration) { + return; + } + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) + && !isPropertyDeclaredInAncestorClass(prop)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + else if (valueDeclaration.kind === 229 && + node.parent.kind !== 159 && + !ts.isInAmbientContext(valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + } + function isInPropertyInitializer(node) { + return !!ts.findAncestor(node, function (node) { + switch (node.kind) { + case 149: + return true; + case 261: + return false; + default: + return ts.isPartOfExpression(node) ? false : "quit"; + } + }); + } + function isPropertyDeclaredInAncestorClass(prop) { + var classType = getTypeOfSymbol(prop.parent); + while (true) { + classType = getSuperClass(classType); + if (!classType) { + return false; + } + var superProperty = getPropertyOfObjectType(classType, prop.escapedName); + if (superProperty && superProperty.valueDeclaration) { + return true; + } + } + } + function getSuperClass(classType) { + var x = getBaseTypes(classType); + if (x.length === 0) { + return undefined; + } + ts.Debug.assert(x.length === 1); + return x[0]; + } function reportNonexistentProperty(propNode, containingType) { var errorInfo; if (containingType.flags & 65536 && !(containingType.flags & 8190)) { @@ -31218,8 +31492,8 @@ var ts; } } var suggestion = getSuggestionForNonexistentProperty(propNode, containingType); - if (suggestion) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); + if (suggestion !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), ts.unescapeLeadingUnderscores(suggestion)); } else { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); @@ -31231,7 +31505,7 @@ var ts; return suggestion && suggestion.escapedName; } function getSuggestionForNonexistentSymbol(location, name, meaning) { - var result = resolveNameHelper(location, name, meaning, undefined, name, function (symbols, name, meaning) { + var result = resolveNameHelper(location, name, meaning, undefined, name, false, function (symbols, name, meaning) { var symbol = getSymbol(symbols, name, meaning); if (symbol) { return symbol; @@ -31291,11 +31565,12 @@ var ts; } return bestCandidate; } - function markPropertyAsReferenced(prop) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly) { if (prop && noUnusedIdentifiers && (prop.flags & 106500) && - prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8) + && !(nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly))) { if (ts.getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } @@ -31304,15 +31579,6 @@ var ts; } } } - function isInPropertyInitializer(node) { - while (node) { - if (node.parent && node.parent.kind === 149 && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } function isValidPropertyAccess(node, propertyName) { var left = node.kind === 179 ? node.expression @@ -31503,7 +31769,6 @@ var ts; var argCount; var typeArguments; var callIsIncomplete; - var isDecorator; var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { return true; @@ -31525,7 +31790,6 @@ var ts; } } else if (node.kind === 147) { - isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); } @@ -31574,7 +31838,7 @@ var ts; if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 4); } - return getSignatureInstantiation(signature, getInferredTypes(context)); + return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJavaScriptFile(contextualSignature.declaration)); } function inferTypeArguments(node, signature, args, excludeArgument, context) { for (var _i = 0, _a = context.inferences; _i < _a.length; _i++) { @@ -31583,13 +31847,13 @@ var ts; inference.inferredType = undefined; } } - if (ts.isExpression(node)) { + if (node.kind !== 147) { var contextualType = getContextualType(node); if (contextualType) { var instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 4); @@ -32009,8 +32273,9 @@ var ts; candidate = originalCandidate; if (candidate.typeParameters) { var typeArgumentTypes = void 0; + var isJavascript = ts.isInJavaScriptFile(candidate.declaration); if (typeArguments) { - typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript); if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false)) { candidateForTypeArgumentError = originalCandidate; break; @@ -32019,7 +32284,7 @@ var ts; else { typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); } if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { candidateForArgumentError = candidate; @@ -32125,11 +32390,6 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasModifier(valueDecl, 128)) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); - return resolveErrorCall(node); - } if (isTypeAny(expressionType)) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -32141,6 +32401,11 @@ var ts; if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); } + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && ts.hasModifier(valueDecl, 128)) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } var callSignatures = getSignaturesOfType(expressionType, 0); @@ -32254,8 +32519,8 @@ var ts; if (elementType.flags & 65536) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var type = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -32280,7 +32545,7 @@ var ts; case 250: return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } - ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); + ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); @@ -32294,16 +32559,30 @@ var ts; return result; } function isJavaScriptConstructor(node) { - if (ts.isInJavaScriptFile(node)) { + if (node && ts.isInJavaScriptFile(node)) { if (ts.getJSDocClassTag(node)) return true; var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : - ts.isVariableDeclaration(node) && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : + ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; return symbol && symbol.members !== undefined; } return false; } + function getJavaScriptClassType(symbol) { + if (ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = getSymbolOfNode(symbol.valueDeclaration.initializer); + } + if (isJavaScriptConstructor(symbol.valueDeclaration)) { + return getInferredClassType(symbol); + } + if (symbol.flags & 3) { + var valueType = getTypeOfSymbol(symbol); + if (valueType.symbol && !isInferredClassType(valueType) && isJavaScriptConstructor(valueType.symbol.valueDeclaration)) { + return getInferredClassType(valueType.symbol); + } + } + } function getInferredClassType(symbol) { var links = getSymbolLinks(symbol); if (!links.inferredClassType) { @@ -32332,13 +32611,11 @@ var ts; var funcSymbol = node.expression.kind === 71 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { - funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + var type = funcSymbol && getJavaScriptClassType(funcSymbol); + if (type) { + return type; } - if (funcSymbol && funcSymbol.flags & 16 && (funcSymbol.members || ts.getJSDocClassTag(funcSymbol.valueDeclaration))) { - return getInferredClassType(funcSymbol); - } - else if (noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -32399,7 +32676,7 @@ var ts; } if (!ts.isIdentifier(node.expression)) throw ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455, undefined, undefined); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455, undefined, undefined, true); if (!resolvedRequire) { return true; } @@ -32505,7 +32782,7 @@ var ts; } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { + if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } @@ -32635,9 +32912,7 @@ var ts; ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } }); return aggregatedTypes; @@ -32681,9 +32956,7 @@ var ts; if (type.flags & 8192) { hasReturnOfTypeNever = true; } - else if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } else { hasReturnWithNoExpression = true; @@ -32694,9 +32967,7 @@ var ts; return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { - if (!ts.contains(aggregatedTypes, undefinedType)) { - aggregatedTypes.push(undefinedType); - } + ts.pushIfUnique(aggregatedTypes, undefinedType); } return aggregatedTypes; } @@ -32949,8 +33220,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -33448,20 +33719,6 @@ var ts; var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } - function checkLiteralExpression(node) { - switch (node.kind) { - case 13: - case 9: - return getFreshTypeOfLiteralType(getLiteralType(node.text)); - case 8: - checkGrammarNumericLiteral(node); - return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101: - return trueType; - case 86: - return falseType; - } - } function checkTemplateExpression(node) { ts.forEach(node.templateSpans, function (templateSpan) { checkExpression(templateSpan.expression); @@ -33513,9 +33770,13 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, checkMode) { + function checkExpressionForMutableLocation(node, checkMode, contextualType) { + if (arguments.length === 2) { + contextualType = getContextualType(node); + } var type = checkExpression(node, checkMode); - return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); + var shouldWiden = isTypeAssertion(node) || isLiteralContextualType(contextualType); + return shouldWiden ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, checkMode) { if (node.name.kind === 144) { @@ -33583,12 +33844,9 @@ var ts; return type; } function checkParenthesizedExpression(node, checkMode) { - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - var typecasts = ts.flatMap(node.jsDoc, function (doc) { return ts.filter(doc.tags, function (tag) { return tag.kind === 281; }); }); - if (typecasts && typecasts.length) { - var cast_1 = typecasts[0]; - return checkAssertionWorker(cast_1, cast_1.typeExpression.type, node.expression, checkMode); - } + var tag = ts.isInJavaScriptFile(node) ? ts.getJSDocTypeTag(node) : undefined; + if (tag) { + return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -33604,10 +33862,14 @@ var ts; return nullWideningType; case 13: case 9: + return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8: + checkGrammarNumericLiteral(node); + return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101: + return trueType; case 86: - return checkLiteralExpression(node); + return falseType; case 196: return checkTemplateExpression(node); case 12: @@ -34156,7 +34418,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, ts.isInJavaScriptFile(typeArgumentNodes[i])); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -34224,6 +34486,10 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && + getObjectFlags(objectType) & 32 && objectType.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + } return type; } if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 84)) { @@ -34489,6 +34755,7 @@ var ts; switch (d.kind) { case 230: case 231: + case 283: return 2; case 233: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 @@ -34498,6 +34765,8 @@ var ts; case 232: return 2 | 1; case 237: + case 240: + case 239: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -34687,8 +34956,11 @@ var ts; markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node)); } function markEntityNameOrEntityExpressionAsReference(typeName) { - var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.escapedText, (typeName.kind === 71 ? 793064 : 1920) | 2097152, undefined, undefined); + if (!typeName) + return; + var rootName = getFirstIdentifier(typeName); + var meaning = (typeName.kind === 71 ? 793064 : 1920) | 2097152; + var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true); if (rootSymbol && rootSymbol.flags & 2097152 && symbolIsValue(rootSymbol) @@ -34794,22 +35066,12 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } - function checkJSDoc(node) { - if (!ts.isInJavaScriptFile(node)) { - return; - } - ts.forEach(node.jsDoc, checkSourceElement); - } - function checkJSDocComment(node) { - if (node.tags) { - for (var _i = 0, _a = node.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - checkSourceElement(tag); - } + function checkJSDocTypedefTag(node) { + if (!node.typeExpression) { + error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags); } } function checkFunctionOrMethodDeclaration(node) { - checkJSDoc(node); checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); @@ -34914,11 +35176,11 @@ var ts; !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { - error(name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(local.escapedName)); + error(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(local.escapedName)); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return errorUnusedLocal(ts.getNameOfDeclaration(d) || d, ts.unescapeLeadingUnderscores(local.escapedName)); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d, ts.unescapeLeadingUnderscores(local.escapedName)); }); } } }); @@ -34931,15 +35193,17 @@ var ts; } return false; } - function errorUnusedLocal(node, name) { + function errorUnusedLocal(declaration, name) { + var node = ts.getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 226 && ts.isForInOrOfStatement(declaration.parent.parent)) { + var declaration_2 = ts.getRootDeclaration(node.parent); + if ((declaration_2.kind === 226 && ts.isForInOrOfStatement(declaration_2.parent.parent)) || + declaration_2.kind === 145) { return; } } if (!isRemovedPropertyFromObjectSpread(node.kind === 71 ? node.parent : node)) { - error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + error(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name); } } function parameterNameStartsWithUnderscore(parameterName) { @@ -34955,14 +35219,14 @@ var ts; var member = _a[_i]; if (member.kind === 151 || member.kind === 149) { if (!member.symbol.isReferenced && ts.hasModifier(member, 8)) { - error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); + error(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { - error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); + error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } } @@ -34980,8 +35244,8 @@ var ts; } for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { var typeParameter = _a[_i]; - if (!getMergedSymbol(typeParameter.symbol).isReferenced) { - error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); + if (!getMergedSymbol(typeParameter.symbol).isReferenced && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } } @@ -34994,7 +35258,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - errorUnusedLocal(ts.getNameOfDeclaration(declaration), ts.unescapeLeadingUnderscores(local.escapedName)); + errorUnusedLocal(declaration, ts.unescapeLeadingUnderscores(local.escapedName)); } } } @@ -35005,7 +35269,14 @@ var ts; if (node.kind === 207) { checkGrammarStatementInAmbientContext(node); } - ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionOrModuleBlock(node)) { + var saveFlowAnalysisDisabled = flowAnalysisDisabled; + ts.forEach(node.statements, checkSourceElement); + flowAnalysisDisabled = saveFlowAnalysisDisabled; + } + else { + ts.forEach(node.statements, checkSourceElement); + } if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -35135,7 +35406,7 @@ var ts; if (symbol.flags & 1) { if (!ts.isIdentifier(node.name)) throw ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { @@ -35171,7 +35442,7 @@ var ts; return visit(n.expression); } else if (n.kind === 71) { - var symbol = resolveName(n, n.escapedText, 107455 | 2097152, undefined, undefined); + var symbol = resolveName(n, n.escapedText, 107455 | 2097152, undefined, undefined, false); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; } @@ -35232,7 +35503,7 @@ var ts; var parentType = getTypeForBindingElementParent(parent); var name = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); - markPropertyAsReferenced(property); + markPropertyAsReferenced(property, undefined); if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); } @@ -36637,8 +36908,8 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + if (modulekind >= ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -36665,7 +36936,7 @@ var ts; if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } - if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015) { + if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015 && modulekind !== ts.ModuleKind.ESNext) { checkExternalEmitHelpers(node, 32768); } } @@ -36682,7 +36953,7 @@ var ts; checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; - var symbol = resolveName(exportedName, exportedName.escapedText, 107455 | 793064 | 1920 | 2097152, undefined, undefined); + var symbol = resolveName(exportedName, exportedName.escapedText, 107455 | 793064 | 1920 | 2097152, undefined, undefined, true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.unescapeLeadingUnderscores(exportedName.escapedText)); } @@ -36715,9 +36986,12 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); + if (ts.isInAmbientContext(node) && !ts.isEntityNameExpression(node.expression)) { + grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); + } if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES2015) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); + if (modulekind >= ts.ModuleKind.ES2015) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); @@ -36747,7 +37021,7 @@ var ts; if (flags & (1920 | 64 | 384)) { return; } - var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor); if (flags & 524288 && exportedDeclarationsCount <= 2) { return; } @@ -36762,15 +37036,24 @@ var ts; }); links.exportsChecked = true; } - function isNotOverload(declaration) { - return (declaration.kind !== 228 && declaration.kind !== 151) || - !!declaration.body; - } + } + function isNotAccessor(declaration) { + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 228 && declaration.kind !== 151) || + !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } + if (ts.isInJavaScriptFile(node) && node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var tags = _a[_i].tags; + ts.forEach(tags, checkSourceElement); + } + } var kind = node.kind; if (cancellationToken) { switch (kind) { @@ -36822,8 +37105,8 @@ var ts; case 168: case 170: return checkSourceElement(node.type); - case 275: - return checkJSDocComment(node); + case 283: + return checkJSDocTypedefTag(node); case 279: return checkSourceElement(node.typeExpression); case 273: @@ -36953,6 +37236,7 @@ var ts; ts.clear(potentialNewTargetCollisions); deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; + flowAnalysisDisabled = false; ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalModule(node)) { @@ -37282,11 +37566,13 @@ var ts; return sig.thisParameter; } } - case 97: - var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); - return type.symbol; + if (ts.isInExpressionContext(node)) { + return checkExpression(node).symbol; + } case 169: - return getTypeFromTypeNode(node).symbol; + return getTypeFromThisTypeNode(node).symbol; + case 97: + return checkExpression(node).symbol; case 123: var constructorDeclaration = node.parent; if (constructorDeclaration && constructorDeclaration.kind === 152) { @@ -37300,13 +37586,17 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 180 && node.parent.argumentExpression === node) { - var objectType = getTypeOfExpression(node.parent.expression); - return getPropertyOfType(objectType, node.text); - } - break; + var objectType = ts.isElementAccessExpression(node.parent) + ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined + : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) + ? getTypeFromTypeNode(node.parent.parent.objectType) + : undefined; + return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); + case 79: + return getSymbolOfNode(node.parent); + default: + return undefined; } - return undefined; } function getShorthandAssignmentValueSymbol(location) { if (location && location.kind === 262) { @@ -37417,9 +37707,9 @@ var ts; function getRootSymbols(symbol) { if (ts.getCheckFlags(symbol) & 6) { var symbols_4 = []; - var name_2 = symbol.escapedName; + var name_3 = symbol.escapedName; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_2); + var symbol = getPropertyOfType(t, name_3); if (symbol) { symbols_4.push(symbol); } @@ -37520,7 +37810,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (!!resolveName(container.parent, symbol.escapedName, 107455, undefined, undefined)) { + if (resolveName(container.parent, symbol.escapedName, 107455, undefined, undefined, false)) { links.isDeclarationWithCollidingName = true; } else if (nodeLinks_1.flags & 131072) { @@ -37663,6 +37953,14 @@ var ts; return type.flags & 32768 && getSignaturesOfType(type, 0).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { + typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + if (!typeName) + return ts.TypeReferenceSerializationKind.Unknown; + if (location) { + location = ts.getParseTreeNode(location); + if (!location) + return ts.TypeReferenceSerializationKind.Unknown; + } var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); if (valueSymbol && valueSymbol === typeSymbol) { @@ -37746,7 +38044,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 107455 | 1048576 | 2097152, undefined, undefined); + return resolveName(location, reference.escapedText, 107455 | 1048576 | 2097152, undefined, undefined, true); } function getReferencedValueDeclaration(reference) { if (!ts.isGeneratedIdentifier(reference)) { @@ -38022,7 +38320,7 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -38044,12 +38342,6 @@ var ts; case 113: case 112: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 113) { - lastProtected = modifier; - } - else if (modifier.kind === 112) { - lastPrivate = modifier; - } if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } @@ -38541,7 +38833,7 @@ var ts; currentKind = SetAccessor; } else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -38801,7 +39093,7 @@ var ts; } } } - if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { checkESModuleMarker(node.name); } @@ -38816,8 +39108,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var element = elements_1[_i]; if (!ts.isOmittedExpression(element)) { return checkESModuleMarker(element.name); } @@ -38832,8 +39124,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var element = elements_3[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -39282,7 +39574,7 @@ var ts; || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer - ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node; } ts.updateParameter = updateParameter; @@ -39898,13 +40190,26 @@ var ts; return node; } ts.createArrowFunction = createArrowFunction; - function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { + function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody, bodyOrUndefined) { + var equalsGreaterThanToken; + var body; + if (bodyOrUndefined === undefined) { + equalsGreaterThanToken = node.equalsGreaterThanToken; + body = ts.cast(equalsGreaterThanTokenOrBody, ts.isConciseBody); + } + else { + equalsGreaterThanToken = ts.cast(equalsGreaterThanTokenOrBody, function (n) { + return n.kind === 36; + }); + body = bodyOrUndefined; + } return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type + || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } ts.updateArrowFunction = updateArrowFunction; @@ -40009,11 +40314,23 @@ var ts; return node; } ts.createConditional = createConditional; - function updateConditional(node, condition, whenTrue, whenFalse) { + function updateConditional(node, condition) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + if (args.length === 2) { + var whenTrue_1 = args[0], whenFalse_1 = args[1]; + return updateConditional(node, condition, node.questionToken, whenTrue_1, node.colonToken, whenFalse_1); + } + ts.Debug.assert(args.length === 4); + var questionToken = args[0], whenTrue = args[1], colonToken = args[2], whenFalse = args[3]; return node.condition !== condition + || node.questionToken !== questionToken || node.whenTrue !== whenTrue + || node.colonToken !== colonToken || node.whenFalse !== whenFalse - ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node) : node; } ts.updateConditional = updateConditional; @@ -40031,6 +40348,30 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; + function createTemplateHead(text) { + var node = createSynthesizedNode(14); + node.text = text; + return node; + } + ts.createTemplateHead = createTemplateHead; + function createTemplateMiddle(text) { + var node = createSynthesizedNode(15); + node.text = text; + return node; + } + ts.createTemplateMiddle = createTemplateMiddle; + function createTemplateTail(text) { + var node = createSynthesizedNode(16); + node.text = text; + return node; + } + ts.createTemplateTail = createTemplateTail; + function createNoSubstitutionTemplateLiteral(text) { + var node = createSynthesizedNode(13); + node.text = text; + return node; + } + ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { var node = createSynthesizedNode(197); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; @@ -41118,6 +41459,10 @@ var ts; return createCall(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []); } ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression; + function createImmediatelyInvokedArrowFunction(statements, param, paramValue) { + return createCall(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []); + } + ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { return createBinary(left, 26, right); } @@ -41313,9 +41658,7 @@ var ts; var emitNode = getOrCreateEmitNode(node); for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { var helper = helpers_1[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } + emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper); } } return node; @@ -41348,9 +41691,7 @@ var ts; var helper = sourceEmitHelpers[i]; if (predicate(helper)) { helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } + targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper); } else if (helpersRemoved > 0) { sourceEmitHelpers[i - helpersRemoved] = helper; @@ -42068,11 +42409,9 @@ var ts; return recreateOuterExpressions(expression, mutableCall, 4); } } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { - return ts.setTextRange(ts.createParen(expression), expression); - } + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { + return ts.setTextRange(ts.createParen(expression), expression); } return expression; } @@ -42208,9 +42547,17 @@ var ts; case 288: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } + function isIgnorableParen(node) { + return node.kind === 185 + && ts.nodeIsSynthesized(node) + && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) + && ts.nodeIsSynthesized(ts.getCommentRange(node)) + && !ts.some(ts.getSyntheticLeadingComments(node)) + && !ts.some(ts.getSyntheticTrailingComments(node)); + } function recreateOuterExpressions(outerExpression, innerExpression, kinds) { if (kinds === void 0) { kinds = 7; } - if (outerExpression && isOuterExpression(outerExpression, kinds)) { + if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression)); } return innerExpression; @@ -42236,7 +42583,8 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var create = hasExportStarsToExportValues && moduleKind !== ts.ModuleKind.System - && moduleKind !== ts.ModuleKind.ES2015; + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { @@ -42666,7 +43014,7 @@ var ts; case 186: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 188: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: @@ -42682,7 +43030,7 @@ var ts; case 194: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 195: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 196: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 197: @@ -43436,7 +43784,7 @@ var ts; } else { var name = node.name; - if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { + if (name && !uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); uniqueExports.set(ts.unescapeLeadingUnderscores(name.escapedText), true); exportedNames = ts.append(exportedNames, name); @@ -43729,7 +44077,7 @@ var ts; } function createDestructuringPropertyAccess(flattenContext, value, propertyName) { if (ts.isComputedPropertyName(propertyName)) { - var argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, false, propertyName); + var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName); return ts.createElementAccess(value, argumentExpression); } else if (ts.isStringOrNumericLiteral(propertyName)) { @@ -43912,6 +44260,21 @@ var ts; return saveStateAndInvoke(node, sourceElementVisitorWorker); } function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 238: + case 237: + case 243: + case 244: + return visitEllidableStatement(node); + default: + return visitorWorker(node); + } + } + function visitEllidableStatement(node) { + var parsed = ts.getParseTreeNode(node); + if (parsed !== node) { + return node; + } switch (node.kind) { case 238: return visitImportDeclaration(node); @@ -43922,7 +44285,7 @@ var ts; case 244: return visitExportDeclaration(node); default: - return visitorWorker(node); + ts.Debug.fail("Unhandled ellided statement"); } } function namespaceElementVisitor(node) { @@ -44072,7 +44435,7 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && - !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { @@ -44136,8 +44499,10 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, context.endLexicalEnvironment()); + var iife = ts.createImmediatelyInvokedArrowFunction(statements); + ts.setEmitFlags(iife, 33554432); var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, ts.createImmediatelyInvokedFunctionExpression(statements)) + ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, iife) ])); ts.setOriginalNode(varStatement, node); ts.setCommentRange(varStatement, node); @@ -44743,7 +45108,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; - name.parent = currentScope; + name.parent = ts.getParseTreeNode(currentScope); if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -44873,7 +45238,7 @@ var ts; return updated; } function visitArrowFunction(node) { - var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.visitFunctionBody(node.body, visitor, context)); return updated; } function visitParameter(node) { @@ -45009,6 +45374,7 @@ var ts; return isExportOfNamespace(node) || (isExternalModuleExport(node) && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { @@ -45468,7 +45834,6 @@ var ts; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var currentSourceFile; var enabledSubstitutions; var enclosingSuperContainerFlags = 0; var previousOnEmitNode = context.onEmitNode; @@ -45480,10 +45845,8 @@ var ts; if (node.isDeclarationFile) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -45526,7 +45889,7 @@ var ts; : ts.visitFunctionBody(node.body, visitor, context)); } function visitArrowFunction(node) { - return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -45816,8 +46179,8 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { - var e = elements_4[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; if (e.kind === 263) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); @@ -45835,7 +46198,7 @@ var ts; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } else { - chunkObject.push(e); + chunkObject.push(ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } } } @@ -46025,7 +46388,7 @@ var ts; function visitArrowFunction(node) { var savedEnclosingFunctionFlags = enclosingFunctionFlags; enclosingFunctionFlags = ts.getFunctionFlags(node); - var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; return updated; } @@ -46850,58 +47213,12 @@ var ts; && node.kind === 219 && !node.expression; } - function isClassLikeVariableStatement(node) { - if (!ts.isVariableStatement(node)) - return false; - var variable = ts.singleOrUndefined(node.declarationList.declarations); - return variable - && variable.initializer - && ts.isIdentifier(variable.name) - && (ts.isClassLike(variable.initializer) - || (ts.isAssignmentExpression(variable.initializer) - && ts.isIdentifier(variable.initializer.left) - && ts.isClassLike(variable.initializer.right))); - } - function isTypeScriptClassWrapper(node) { - var call = ts.tryCast(node, ts.isCallExpression); - if (!call || ts.isParseTreeNode(call) || - ts.some(call.typeArguments) || - ts.some(call.arguments)) { - return false; - } - var func = ts.tryCast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression); - if (!func || ts.isParseTreeNode(func) || - ts.some(func.typeParameters) || - ts.some(func.parameters) || - func.type || - !func.body) { - return false; - } - var statements = func.body.statements; - if (statements.length < 2) { - return false; - } - var firstStatement = statements[0]; - if (ts.isParseTreeNode(firstStatement) || - !ts.isClassLike(firstStatement) && - !isClassLikeVariableStatement(firstStatement)) { - return false; - } - var lastStatement = ts.elementAt(statements, -1); - var returnStatement = ts.tryCast(ts.isVariableStatement(lastStatement) ? ts.elementAt(statements, -2) : lastStatement, ts.isReturnStatement); - if (!returnStatement || - !returnStatement.expression || - !ts.isIdentifier(ts.skipOuterExpressions(returnStatement.expression))) { - return false; - } - return true; - } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 207))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) - || isTypeScriptClassWrapper(node); + || (ts.getEmitFlags(node) & 33554432) !== 0; } function visitor(node) { if (shouldVisitNode(node)) { @@ -48381,7 +48698,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - if (isTypeScriptClassWrapper(node)) { + if (ts.getEmitFlags(node) & 33554432) { return visitTypeScriptClassWrapper(node); } if (node.transformFlags & 64) { @@ -48390,7 +48707,7 @@ var ts; return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitTypeScriptClassWrapper(node) { - var body = ts.cast(ts.skipOuterExpressions(node.expression), ts.isFunctionExpression).body; + var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); var classStatements = ts.visitNodes(body.statements, visitor, ts.isStatement, 0, 1); var remainingStatements = ts.visitNodes(body.statements, visitor, ts.isStatement, 1, body.statements.length - 1); var varStatement = ts.cast(ts.firstOrUndefined(classStatements), ts.isVariableStatement); @@ -48810,7 +49127,6 @@ var ts; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - var currentSourceFile; var renamedCatchVariables; var renamedCatchVariableDeclarations; var inGeneratorFunctionBody; @@ -48841,10 +49157,8 @@ var ts; if (node.isDeclarationFile || (node.transformFlags & 512) === 0) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -50588,6 +50902,7 @@ var ts; } function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ ts.createVariableStatement(undefined, [ @@ -50598,13 +50913,13 @@ var ts; ]), ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") - ])) + ]))) ]))) ], true), undefined)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ @@ -50669,17 +50984,20 @@ var ts; } function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 | 1536); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536); - statements.push(statement); + var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, importCallExpressionVisitor); + if (expressionResult) { + if (emitAsReturn) { + var statement = ts.createReturn(expressionResult); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 | 1536); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536); + statements.push(statement); + } } } } @@ -51013,7 +51331,7 @@ var ts; return statements; } if (ts.hasModifier(decl, 1)) { - var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; + var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : ts.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); } if (decl.name) { @@ -51722,7 +52040,8 @@ var ts; } function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; - return ts.createCall(exportFunction, undefined, [exportName, value]); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536); + return ts.setCommentRange(ts.createCall(exportFunction, undefined, [exportName, value]), value); } function nestedElementVisitor(node) { switch (node.kind) { @@ -54853,8 +55172,13 @@ var ts; comments.reset(); setWriter(undefined); } + function emitIfPresent(node) { + if (node) { + emit(node); + } + } function emit(node) { - pipelineEmitWithNotification(3, node); + pipelineEmitWithNotification(4, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -54892,7 +55216,8 @@ var ts; case 0: return pipelineEmitSourceFile(node); case 2: return pipelineEmitIdentifierName(node); case 1: return pipelineEmitExpression(node); - case 3: return pipelineEmitUnspecified(node); + case 3: return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + case 4: return pipelineEmitUnspecified(node); } } function pipelineEmitSourceFile(node) { @@ -54903,6 +55228,11 @@ var ts; ts.Debug.assertNode(node, ts.isIdentifier); emitIdentifier(node); } + function emitMappedTypeParameter(node) { + emit(node.name); + write(" in "); + emit(node.constraint); + } function pipelineEmitUnspecified(node) { var kind = node.kind; if (ts.isKeyword(kind)) { @@ -55246,9 +55576,9 @@ var ts; function emitParameter(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } @@ -55260,7 +55590,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); write(";"); } @@ -55268,7 +55598,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); write(";"); @@ -55277,7 +55607,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); @@ -55286,9 +55616,9 @@ var ts; function emitMethodDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.asteriskToken, "*"); + emitIfPresent(node.asteriskToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } function emitConstructor(node) { @@ -55358,9 +55688,8 @@ var ts; } function emitTypeLiteral(node) { write("{"); - if (node.members.length > 0) { - emitList(node, node.members, ts.getEmitFlags(node) & 1 ? 448 : 65); - } + var flags = ts.getEmitFlags(node) & 1 ? 448 : 65; + emitList(node, node.members, flags | 262144); write("}"); } function emitArrayType(node) { @@ -55407,13 +55736,14 @@ var ts; writeLine(); increaseIndent(); } - writeIfPresent(node.readonlyToken, "readonly "); + if (node.readonlyToken) { + emit(node.readonlyToken); + write(" "); + } write("["); - emit(node.typeParameter.name); - write(" in "); - emit(node.typeParameter.constraint); + pipelineEmitWithNotification(3, node.typeParameter); write("]"); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); write(": "); emit(node.type); write(";"); @@ -55453,36 +55783,25 @@ var ts; } function emitBindingElement(node) { emitWithSuffix(node.propertyName, ": "); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); } function emitArrayLiteralExpression(node) { var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else { - var preferNewLine = node.multiLine ? 32768 : 0; - emitExpressionList(node, elements, 4466 | preferNewLine); - } + var preferNewLine = node.multiLine ? 32768 : 0; + emitExpressionList(node, elements, 4466 | preferNewLine); } function emitObjectLiteralExpression(node) { - var properties = node.properties; - if (properties.length === 0) { - write("{}"); + var indentedFlag = ts.getEmitFlags(node) & 65536; + if (indentedFlag) { + increaseIndent(); } - else { - var indentedFlag = ts.getEmitFlags(node) & 65536; - if (indentedFlag) { - increaseIndent(); - } - var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; - emitList(node, properties, 978 | allowTrailingComma | preferNewLine); - if (indentedFlag) { - decreaseIndent(); - } + var preferNewLine = node.multiLine ? 32768 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; + emitList(node, node.properties, 263122 | allowTrailingComma | preferNewLine); + if (indentedFlag) { + decreaseIndent(); } } function emitPropertyAccessExpression(node) { @@ -55564,7 +55883,8 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParametersForArrow(node, node.parameters); emitWithPrefix(": ", node.type); - write(" =>"); + write(" "); + emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { write("delete "); @@ -55619,12 +55939,12 @@ var ts; var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); increaseIndentIf(indentBeforeQuestion, " "); - write("?"); + emit(node.questionToken); increaseIndentIf(indentAfterQuestion, " "); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); increaseIndentIf(indentBeforeColon, " "); - write(":"); + emit(node.colonToken); increaseIndentIf(indentAfterColon, " "); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); @@ -55634,7 +55954,8 @@ var ts; emitList(node, node.templateSpans, 131072); } function emitYieldExpression(node) { - write(node.asteriskToken ? "yield*" : "yield"); + write("yield"); + emit(node.asteriskToken); emitExpressionWithPrefix(" ", node.expression); } function emitSpreadExpression(node) { @@ -55669,27 +55990,16 @@ var ts; emit(node.literal); } function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - writeToken(17, node.pos, node); - write(" "); - writeToken(18, node.statements.end, node); - } - else { - writeToken(17, node.pos, node); - emitBlockStatements(node); - increaseIndent(); - emitLeadingCommentsOfPosition(node.statements.end); - decreaseIndent(); - writeToken(18, node.statements.end, node); - } + writeToken(17, node.pos, node); + emitBlockStatements(node, !node.multiLine && isEmptyBlock(node)); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); + writeToken(18, node.statements.end, node); } - function emitBlockStatements(node) { - if (ts.getEmitFlags(node) & 1) { - emitList(node, node.statements, 384); - } - else { - emitList(node, node.statements, 65); - } + function emitBlockStatements(node, forceSingleLine) { + var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 384 : 65; + emitList(node, node.statements, format); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -55867,7 +56177,9 @@ var ts; function emitFunctionDeclarationOrExpression(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.asteriskToken ? "function* " : "function "); + write("function"); + emitIfPresent(node.asteriskToken); + write(" "); emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -55885,7 +56197,7 @@ var ts; if (ts.getEmitFlags(node) & 524288) { emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3, body, emitBlockCallback); + onEmitNode(4, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -55895,7 +56207,7 @@ var ts; pushNameGenerationScope(); emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3, body, emitBlockCallback); + onEmitNode(4, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -56033,7 +56345,9 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - write(node.flags & 16 ? "namespace " : "module "); + if (~node.flags & 512) { + write(node.flags & 16 ? "namespace " : "module "); + } emit(node.name); var body = node.body; while (body.kind === 233) { @@ -56045,16 +56359,11 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isEmptyBlock(node)) { - write("{ }"); - } - else { - pushNameGenerationScope(); - write("{"); - emitBlockStatements(node); - write("}"); - popNameGenerationScope(); - } + pushNameGenerationScope(); + write("{"); + emitBlockStatements(node, isEmptyBlock(node)); + write("}"); + popNameGenerationScope(); } function emitCaseBlock(node) { writeToken(17, node.pos); @@ -56197,9 +56506,7 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); - if (node.dotDotDotToken) { - write("..."); - } + emitIfPresent(node.dotDotDotToken); emitExpression(node.expression); write("}"); } @@ -56230,13 +56537,12 @@ var ts; if (statements.length > 0) { emitTrailingCommentsOfPosition(statements.pos); } + var format = 81985; if (emitAsSingleStatement) { write(" "); - emit(statements[0]); - } - else { - emitList(parentNode, statements, 81985); + format &= ~(1 | 64); } + emitList(parentNode, statements, format); } function emitHeritageClause(node) { write(" "); @@ -56429,7 +56735,7 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emit(parameters[0]); + emitList(parentNode, parameters, 1360 & ~1024); } else { emitParameters(parentNode, parameters); @@ -56451,8 +56757,14 @@ var ts; if (isUndefined && format & 8192) { return; } - var isEmpty = isUndefined || children.length === 0 || start >= children.length || count === 0; + var isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & 16384) { + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } return; } if (format & 7680) { @@ -56465,7 +56777,7 @@ var ts; if (format & 1) { writeLine(); } - else if (format & 128) { + else if (format & 128 && !(format & 262144)) { write(" "); } } @@ -56524,7 +56836,7 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } - if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + if (previousSibling && delimiter && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) { emitLeadingCommentsOfPosition(previousSibling.end); } if (format & 64) { @@ -56561,11 +56873,6 @@ var ts; write(text); } } - function writeIfPresent(node, text) { - if (node) { - write(text); - } - } function writeToken(token, pos, contextNode) { return onEmitSourceMapOfToken ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) @@ -56575,7 +56882,7 @@ var ts; if (onBeforeEmitToken) { onBeforeEmitToken(node); } - writeTokenText(node.kind); + write(ts.tokenToString(node.kind)); if (onAfterEmitToken) { onAfterEmitToken(node); } @@ -56724,10 +57031,6 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); - } function isEmptyBlock(block) { return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); @@ -56971,6 +57274,8 @@ var ts; ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 448] = "SingleLineTypeLiteralMembers"; @@ -56980,7 +57285,7 @@ var ts; ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; @@ -57174,7 +57479,7 @@ var ts; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -57198,7 +57503,7 @@ var ts; var redForegroundEscapeSequence = "\u001b[91m"; var yellowForegroundEscapeSequence = "\u001b[93m"; var blueForegroundEscapeSequence = "\u001b[93m"; - var gutterStyleSequence = "\u001b[100;30m"; + var gutterStyleSequence = "\u001b[30;47m"; var gutterSeparator = " "; var resetEscapeSequence = "\u001b[0m"; var ellipsis = "..."; @@ -57223,9 +57528,9 @@ var ts; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; if (diagnostic.file) { - var start = diagnostic.start, length_6 = diagnostic.length, file = diagnostic.file; + var start = diagnostic.start, length_5 = diagnostic.length, file = diagnostic.file; var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; - var _b = ts.getLineAndCharacterOfPosition(file, start + length_6), lastLine = _b.line, lastLineChar = _b.character; + var _b = ts.getLineAndCharacterOfPosition(file, start + length_5), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; @@ -57233,10 +57538,10 @@ var ts; if (hasMoreThanFiveLines) { gutterWidth = Math.max(ellipsis.length, gutterWidth); } - output += ts.sys.newLine; + output += host.getNewLine(); for (var i = firstLine; i <= lastLine; i++) { if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); @@ -57245,7 +57550,7 @@ var ts; lineContent = lineContent.replace(/\s+$/g, ""); lineContent = lineContent.replace("\t", " "); output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + ts.sys.newLine; + output += lineContent + host.getNewLine(); output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; output += redForegroundEscapeSequence; if (i === firstLine) { @@ -57260,15 +57565,15 @@ var ts; output += lineContent.replace(/./g, "~"); } output += resetEscapeSequence; - output += ts.sys.newLine; + output += host.getNewLine(); } - output += ts.sys.newLine; + output += host.getNewLine(); output += relativeFileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } var categoryColor = getCategoryFormat(diagnostic.category); var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine); - output += ts.sys.newLine; + output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); + output += host.getNewLine(); } return output; } @@ -57334,6 +57639,8 @@ var ts; ts.performance.mark("beforeProgram"); host = host || createCompilerHost(options); var skipDefaultLib = options.noLib; + var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); + var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName()); var programDiagnostics = ts.createDiagnosticCollection(); var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); @@ -57383,12 +57690,11 @@ var ts; } if (!skipDefaultLib) { if (!options.lib) { - processRootFile(host.getDefaultLibFileName(options), true); + processRootFile(getDefaultLibraryFileName(), true); } else { - var libDirectory_1 = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(host.getDefaultLibFileName(options)); ts.forEach(options.lib, function (libFileName) { - processRootFile(ts.combinePaths(libDirectory_1, libFileName), true); + processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true); }); } } @@ -57421,6 +57727,7 @@ var ts; getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + isSourceFileDefaultLibrary: isSourceFileDefaultLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, sourceFileToPackageName: sourceFileToPackageName, @@ -57644,7 +57951,7 @@ var ts; var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var moduleNames = getModuleNames(newSourceFile); var oldProgramState = { program: oldProgram, file: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); @@ -57711,6 +58018,15 @@ var ts; function isSourceFileFromExternalLibrary(file) { return sourceFilesFoundSearchingNodeModules.get(file.path); } + function isSourceFileDefaultLibrary(file) { + if (file.hasNoDefaultLib) { + return true; + } + if (defaultLibraryPath && defaultLibraryPath.length !== 0) { + return ts.containsPath(defaultLibraryPath, file.path, currentDirectory, !host.useCaseSensitiveFileNames()); + } + return ts.compareStrings(file.fileName, getDefaultLibraryFileName(), !host.useCaseSensitiveFileNames()) === 0; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } @@ -57825,9 +58141,7 @@ var ts; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - return ts.isSourceFileJavaScript(sourceFile) - ? ts.filter(diagnostics, shouldReportDiagnostic) - : diagnostics; + return ts.filter(diagnostics, shouldReportDiagnostic); }); } function shouldReportDiagnostic(diagnostic) { @@ -58043,16 +58357,15 @@ var ts; return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); + processSourceFile(ts.normalizePath(fileName), isDefaultLib, undefined); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function getTextOfLiteral(literal) { - return literal.text; + return a.kind === 9 + ? b.kind === 9 && a.text === b.text + : b.kind === 71 && a.escapedText === b.escapedText; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -58168,8 +58481,8 @@ var ts; return sourceFileWithAddedExtension; } } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, undefined); }, function (diagnostic) { + function processSourceFile(fileName, isDefaultLib, packageId, refFile, refPos, refEnd) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -58235,7 +58548,7 @@ var ts; } }); if (packageId) { - var packageIdKey = packageId.name + "@" + packageId.version; + var packageIdKey = packageId.name + "/" + packageId.subModuleName + "@" + packageId.version; var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); @@ -58282,7 +58595,7 @@ var ts; function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, undefined, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -58304,7 +58617,7 @@ var ts; var saveResolution = true; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } else { if (previousResolution) { @@ -58317,7 +58630,7 @@ var ts; saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } } @@ -58346,8 +58659,7 @@ var ts; function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { - var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9; }); - var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var moduleNames = getModuleNames(file); var oldProgramState = { program: oldProgram, file: file, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState); ts.Debug.assert(resolutions.length === moduleNames.length); @@ -58358,13 +58670,19 @@ var ts; continue; } var isFromNodeModulesSearch = resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var isJsFile = !ts.extensionIsTypeScript(resolution.extension); + var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; var resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { currentNodeModulesDepth++; } var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; - var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; + var shouldAddFile = resolvedFileName + && !getResolutionDiagnostic(options, resolution) + && !options.noResolve + && i < file.imports.length + && !elideImport + && !(isJsFile && !options.allowJs); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -58679,7 +58997,7 @@ var ts; return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + return options.allowJs || !options.noImplicitAny ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } } ts.getResolutionDiagnostic = getResolutionDiagnostic; @@ -58687,6 +59005,17 @@ var ts; ts.Debug.assert(names.every(function (name) { return name !== undefined; }), "A name is undefined.", function () { return JSON.stringify(names); }); return names; } + function getModuleNames(_a) { + var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations; + var res = imports.map(function (i) { return i.text; }); + for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { + var aug = moduleAugmentations_1[_i]; + if (aug.kind === 9) { + res.push(aug.text); + } + } + return res; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -59622,7 +59951,7 @@ var ts; errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } var value = convertPropertyValueToJson(element.initializer, option); - if (typeof keyText !== "undefined" && typeof value !== "undefined") { + if (typeof keyText !== "undefined") { result[keyText] = value; if (jsonConversionNotifier && (parentOption || knownOptions === knownRootOptions)) { @@ -59657,7 +59986,7 @@ var ts; reportInvalidOptionValue(option && option.type !== "boolean"); return false; case 95: - reportInvalidOptionValue(!!option); + reportInvalidOptionValue(option && option.name === "extends"); return null; case 9: if (!isDoubleQuotedString(valueExpression)) { @@ -59713,6 +60042,8 @@ var ts; } function isCompilerOptionsValue(option, value) { if (option) { + if (isNullOrUndefined(value)) + return true; if (option.type === "list") { return ts.isArray(value); } @@ -59865,6 +60196,12 @@ var ts; } } ts.setConfigFileInOptions = setConfigFileInOptions; + function isNullOrUndefined(x) { + return x === undefined || x === null; + } + function directoryOfCombinedPath(fileName, basePath) { + return ts.getDirectoryPath(ts.toPath(fileName, basePath, ts.identity)); + } function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { if (existingOptions === void 0) { existingOptions = {}; } if (resolutionStack === void 0) { resolutionStack = []; } @@ -59888,7 +60225,7 @@ var ts; }; function getFileNames() { var fileNames; - if (ts.hasProperty(raw, "files")) { + if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw["files"])) { if (ts.isArray(raw["files"])) { fileNames = raw["files"]; if (fileNames.length === 0) { @@ -59900,7 +60237,7 @@ var ts; } } var includeSpecs; - if (ts.hasProperty(raw, "include")) { + if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw["include"])) { if (ts.isArray(raw["include"])) { includeSpecs = raw["include"]; } @@ -59909,7 +60246,7 @@ var ts; } } var excludeSpecs; - if (ts.hasProperty(raw, "exclude")) { + if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw["exclude"])) { if (ts.isArray(raw["exclude"])) { excludeSpecs = raw["exclude"]; } @@ -59926,7 +60263,7 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !ts.hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); } @@ -59988,7 +60325,8 @@ var ts; errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, ts.createCompilerDiagnostic); + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, ts.createCompilerDiagnostic); } } return { raw: json, options: options, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath }; @@ -60010,7 +60348,8 @@ var ts; onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) { switch (key) { case "extends": - extendedConfigPath = getExtendsConfigPath(value, host, basePath, getCanonicalFileName, errors, function (message, arg0) { + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(value, host, newBase, getCanonicalFileName, errors, function (message, arg0) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0); }); return; @@ -60164,6 +60503,8 @@ var ts; } } function normalizeOptionValue(option, basePath, value) { + if (isNullOrUndefined(value)) + return undefined; if (option.type === "list") { var listOption_1 = option; if (listOption_1.element.isFilePath || typeof listOption_1.element.type !== "string") { @@ -60186,6 +60527,8 @@ var ts; return value; } function convertJsonOptionOfCustomType(opt, value, errors) { + if (isNullOrUndefined(value)) + return undefined; var key = value.toLowerCase(); var val = opt.type.get(key); if (val !== undefined) { @@ -60222,7 +60565,7 @@ var ts; if (fileNames) { for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); + var file = ts.getNormalizedAbsolutePath(fileName, basePath); literalFileMap.set(keyMapper(file), file); } } @@ -60809,25 +61152,24 @@ var ts; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 9 || node.kind === 8) { - switch (node.parent.kind) { - case 149: - case 148: - case 261: - case 264: - case 151: - case 150: - case 153: - case 154: - case 233: - return ts.getNameOfDeclaration(node.parent) === node; - case 180: - return node.parent.argumentExpression === node; - case 144: - return true; - } + switch (node.parent.kind) { + case 149: + case 148: + case 261: + case 264: + case 151: + case 150: + case 153: + case 154: + case 233: + return ts.getNameOfDeclaration(node.parent) === node; + case 180: + return node.parent.argumentExpression === node; + case 144: + return true; + case 173: + return node.parent.parent.kind === 171; } - return false; } ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; function isExpressionOfExternalModuleImportEqualsDeclaration(node) { @@ -60904,6 +61246,27 @@ var ts; return "alias"; case 283: return "type"; + case 194: + var kind = ts.getSpecialPropertyAssignmentKind(node); + var right = node.right; + switch (kind) { + case 0: + return ""; + case 1: + case 2: + var rightKind = getNodeKind(right); + return rightKind === "" ? "const" : rightKind; + case 3: + return "method"; + case 4: + return "property"; + case 5: + return ts.isFunctionExpression(right) ? "method" : "property"; + default: { + ts.assertTypeIsNever(kind); + return ""; + } + } default: return ""; } @@ -61091,7 +61454,7 @@ var ts; return undefined; } var children = list.getChildren(); - var listItemIndex = ts.indexOf(children, node); + var listItemIndex = ts.indexOfNode(children, node); return { listItemIndex: listItemIndex, list: list @@ -62224,7 +62587,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_7 = dense[i + 1]; + var length_6 = dense[i + 1]; var type = dense[i + 2]; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; @@ -62232,8 +62595,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_7, classification: convertClassification(type) }); - lastEnd = start + length_7; + entries.push({ length: length_6, classification: convertClassification(type) }); + lastEnd = start + length_6; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -63087,8 +63450,8 @@ var ts; continue; } var start = completePrefix.length; - var length_8 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_8))); + var length_7 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_7))); } return result; } @@ -63348,7 +63711,7 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, request = completionData.request, keywordFilters = completionData.keywordFilters; + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, allowStringLiteral = completionData.allowStringLiteral, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, request = completionData.request, keywordFilters = completionData.keywordFilters; if (sourceFile.languageVariant === 1 && location && location.parent && location.parent.kind === 252) { var tagName = location.parent.parent.openingElement.tagName; @@ -63370,14 +63733,14 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log, allowStringLiteral); getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); } else { if ((!symbols || symbols.length === 0) && keywordFilters === 0) { return undefined; } - getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); + getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log, allowStringLiteral); } if (keywordFilters !== 0 || !isMemberCompletion) { ts.addRange(entries, getKeywordCompletions(keywordFilters)); @@ -63395,7 +63758,7 @@ var ts; return; } uniqueNames.set(realName, true); - var displayName = getCompletionEntryDisplayName(realName, target, true); + var displayName = getCompletionEntryDisplayName(realName, target, true, false); if (displayName) { entries.push({ name: displayName, @@ -63406,8 +63769,8 @@ var ts; } }); } - function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks); + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral) { + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral); if (!displayName) { return undefined; } @@ -63418,13 +63781,13 @@ var ts; sortText: "0", }; } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log, allowStringLiteral) { var start = ts.timestamp(); var uniqueNames = ts.createMap(); if (symbols) { for (var _i = 0, symbols_5 = symbols; _i < symbols_5.length; _i++) { var symbol = symbols_5[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral); if (entry) { var id = entry.name; if (!uniqueNames.has(id)) { @@ -63471,7 +63834,7 @@ var ts; var type = typeChecker.getContextualType(element.parent); var entries = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false, typeChecker, target, log, true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } @@ -63495,7 +63858,7 @@ var ts; var type = typeChecker.getTypeAtLocation(node.expression); var entries = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false, typeChecker, target, log, true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } @@ -63526,7 +63889,7 @@ var ts; addStringLiteralCompletionsFromType(t, result, typeChecker, uniques); } } - else if (type.flags & 32) { + else if (type.flags & 32 && !(type.flags & 256)) { var name = type.value; if (!uniques.has(name)) { uniques.set(name, true); @@ -63542,8 +63905,8 @@ var ts; function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location = completionData.location; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location = completionData.location, allowStringLiteral_1 = completionData.allowStringLiteral; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false, allowStringLiteral_1) === entryName ? s : undefined; }); if (symbol) { var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { @@ -63572,7 +63935,11 @@ var ts; Completions.getCompletionEntryDetails = getCompletionEntryDetails; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); - return completionData && ts.forEach(completionData.symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false) === entryName ? s : undefined; }); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, allowStringLiteral = completionData.allowStringLiteral; + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false, allowStringLiteral) === entryName ? s : undefined; }); } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; function getCompletionData(typeChecker, log, sourceFile, position) { @@ -63616,7 +63983,7 @@ var ts; } } if (request) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request: request, keywordFilters: 0 }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, allowStringLiteral: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request: request, keywordFilters: 0 }; } if (!insideJsDocTagTypeExpression) { log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); @@ -63686,6 +64053,7 @@ var ts; var semanticStart = ts.timestamp(); var isGlobalCompletion = false; var isMemberCompletion; + var allowStringLiteral = false; var isNewIdentifierLocation; var keywordFilters = 0; var symbols = []; @@ -63718,7 +64086,7 @@ var ts; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request: request, keywordFilters: keywordFilters }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, allowStringLiteral: allowStringLiteral, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request: request, keywordFilters: keywordFilters }; function isTagWithTypeExpression(tag) { switch (tag.kind) { case 277: @@ -63983,6 +64351,7 @@ var ts; } function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { isMemberCompletion = true; + allowStringLiteral = true; var typeMembers; var existingMembers; if (objectLikeContainer.kind === 178) { @@ -63990,7 +64359,7 @@ var ts; var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return false; - typeMembers = typeChecker.getAllPossiblePropertiesOfType(typeForObject); + typeMembers = getPropertiesForCompletion(typeForObject, typeChecker); existingMembers = objectLikeContainer.properties; } else { @@ -64419,7 +64788,7 @@ var ts; return node.getStart() <= position && position <= node.getEnd(); } } - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral) { var name = symbol.name; if (!name) return undefined; @@ -64429,11 +64798,11 @@ var ts; return undefined; } } - return getCompletionEntryDisplayName(name, target, performCharacterChecks); + return getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral); } - function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + function getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral) { if (performCharacterChecks && !ts.isIdentifierText(name, target)) { - return undefined; + return allowStringLiteral ? JSON.stringify(name) : undefined; } return name; } @@ -64537,6 +64906,14 @@ var ts; return node.parent; } } + function getPropertiesForCompletion(type, checker) { + if (!(type.flags & 65536)) { + return checker.getPropertiesOfType(type); + } + var types = type.types; + var filteredTypes = types.filter(function (memberType) { return !(memberType.flags & 8190 || checker.isArrayLikeType(memberType)); }); + return checker.getAllPossiblePropertiesOfTypes(filteredTypes); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -65085,11 +65462,10 @@ var ts; var bucket = getBucketForCompilationSettings(key, true); var entry = bucket.get(path); if (!entry) { - ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false, scriptKind); entry = { sourceFile: sourceFile, - languageServiceRefCount: 0, + languageServiceRefCount: 1, owners: [] }; bucket.set(path, entry); @@ -65098,9 +65474,9 @@ var ts; if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); } - } - if (acquiring) { - entry.languageServiceRefCount++; + if (acquiring) { + entry.languageServiceRefCount++; + } } return entry.sourceFile; } @@ -65265,7 +65641,6 @@ var ts; } } function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, checker, isForRename) { - var exportName = exportSymbol.escapedName; var importSearches = []; var singleReferences = []; function addSearch(location, symbol) { @@ -65296,10 +65671,10 @@ var ts; searchForNamedImport(decl.exportClause); return; } - if (!decl.importClause) { + var importClause = decl.importClause; + if (!importClause) { return; } - var importClause = decl.importClause; var namedBindings = importClause.namedBindings; if (namedBindings && namedBindings.kind === 240) { handleNamespaceImportLike(namedBindings.name); @@ -65315,39 +65690,42 @@ var ts; addSearch(name, defaultImportAlias); } if (!isForRename && exportKind === 1) { - ts.Debug.assert(exportName === "default"); searchForNamedImport(namedBindings); } } } function handleNamespaceImportLike(importName) { - if (exportKind === 2 && (!isForRename || importName.escapedText === exportName)) { + if (exportKind === 2 && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } function searchForNamedImport(namedBindings) { - if (namedBindings) { - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name = element.name, propertyName = element.propertyName; - if ((propertyName || name).escapedText !== exportName) { - continue; - } - if (propertyName) { - singleReferences.push(propertyName); - if (!isForRename) { - addSearch(name, checker.getSymbolAtLocation(name)); - } - } - else { - var localSymbol = element.kind === 246 && element.propertyName - ? checker.getExportSpecifierLocalTargetSymbol(element) - : checker.getSymbolAtLocation(name); - addSearch(name, localSymbol); + if (!namedBindings) { + return; + } + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name = element.name, propertyName = element.propertyName; + if (!isNameMatch((propertyName || name).escapedText)) { + continue; + } + if (propertyName) { + singleReferences.push(propertyName); + if (!isForRename) { + addSearch(name, checker.getSymbolAtLocation(name)); } } + else { + var localSymbol = element.kind === 246 && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } } } + function isNameMatch(name) { + return name === exportSymbol.escapedName || exportKind !== 0 && name === "default"; + } } function findNamespaceReExports(sourceFileLike, name, checker) { var namespaceImportSymbol = checker.getSymbolAtLocation(name); @@ -65508,7 +65886,8 @@ var ts; function getExportAssignmentExport(ex) { var exportingModuleSymbol = ex.symbol.parent; ts.Debug.assert(!!exportingModuleSymbol); - return { kind: 1, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: 2 } }; + var exportKind = ex.isExportEquals ? 2 : 1; + return { kind: 1, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -65537,7 +65916,8 @@ var ts; if (importedSymbol.escapedName === "export=") { importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker); } - if (symbolName(importedSymbol) === symbol.escapedName) { + var importedName = symbolName(importedSymbol); + if (importedName === undefined || importedName === "default" || importedName === symbol.escapedName) { return __assign({ kind: 0, symbol: importedSymbol }, isImport); } } @@ -65713,8 +66093,8 @@ var ts; case "symbol": { var symbol = def.symbol, node_2 = def.node; var _a = getDefinitionKindAndDisplayParts(symbol, node_2, checker), displayParts_1 = _a.displayParts, kind_1 = _a.kind; - var name_3 = displayParts_1.map(function (p) { return p.text; }).join(""); - return { node: node_2, name: name_3, kind: kind_1, displayParts: displayParts_1 }; + var name_4 = displayParts_1.map(function (p) { return p.text; }).join(""); + return { node: node_2, name: name_4, kind: kind_1, displayParts: displayParts_1 }; } case "label": { var node_3 = def.node; @@ -65722,8 +66102,8 @@ var ts; } case "keyword": { var node_4 = def.node; - var name_4 = ts.tokenToString(node_4.kind); - return { node: node_4, name: name_4, kind: "keyword", displayParts: [{ text: name_4, kind: "keyword" }] }; + var name_5 = ts.tokenToString(node_4.kind); + return { node: node_4, name: name_5, kind: "keyword", displayParts: [{ text: name_5, kind: "keyword" }] }; } case "this": { var node_5 = def.node; @@ -65764,8 +66144,10 @@ var ts; return { fileName: node.getSourceFile().fileName, textSpan: getTextSpan(node), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isAnyDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node), + isWriteAccess: isWriteAccessForReference(node), + isDefinition: node.kind === 79 + || ts.isAnyDeclarationName(node) + || ts.isLiteralComputedPropertyDeclarationName(node), isInString: isInString }; } @@ -65807,7 +66189,7 @@ var ts; } var node = entry.node, isInString = entry.isInString; var fileName = entry.node.getSourceFile().fileName; - var writeAccess = isWriteAccess(node); + var writeAccess = isWriteAccessForReference(node); var span = { textSpan: getTextSpan(node), kind: writeAccess ? "writtenReference" : "reference", @@ -65825,20 +66207,8 @@ var ts; } return ts.createTextSpanFromBounds(start, end); } - function isWriteAccess(node) { - if (ts.isAnyDeclarationName(node)) { - return true; - } - var parent = node.parent; - switch (parent && parent.kind) { - case 193: - case 192: - return true; - case 194: - return parent.left === node && ts.isAssignmentOperator(parent.operatorToken.kind); - default: - return false; - } + function isWriteAccessForReference(node) { + return node.kind === 79 || ts.isAnyDeclarationName(node) || ts.isWriteAccess(node); } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -66163,7 +66533,7 @@ var ts; return [{ definition: { type: "label", node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { - switch (node && node.kind) { + switch (node.kind) { case 71: return node.text.length === searchSymbolName.length; case 9: @@ -66171,6 +66541,8 @@ var ts; node.text.length === searchSymbolName.length; case 8: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; + case 79: + return "default".length === searchSymbolName.length; default: return false; } @@ -66683,17 +67055,21 @@ var ts; var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); if (bindingElementPropertySymbol) { result.push(bindingElementPropertySymbol); + addRootSymbols(bindingElementPropertySymbol); } - for (var _i = 0, _a = checker.getRootSymbols(symbol); _i < _a.length; _i++) { - var rootSymbol = _a[_i]; - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, ts.createSymbolTable(), checker); - } - } + addRootSymbols(symbol); return result; + function addRootSymbols(sym) { + for (var _i = 0, _a = checker.getRootSymbols(sym); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== sym) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, ts.createSymbolTable(), checker); + } + } + } } function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, checker) { if (!symbol) { @@ -66746,23 +67122,28 @@ var ts; } } var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); - if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; + if (bindingElementPropertySymbol) { + var fromBindingElement = findRootSymbol(bindingElementPropertySymbol); + if (fromBindingElement) + return fromBindingElement; } - return ts.forEach(state.checker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (search.includes(rootSymbol)) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { - return undefined; + return findRootSymbol(referenceSymbol); + function findRootSymbol(sym) { + return ts.forEach(state.checker.getRootSymbols(sym), function (rootSymbol) { + if (search.includes(rootSymbol)) { + return rootSymbol; } - var result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, ts.createSymbolTable(), state.checker); - return ts.find(result, search.includes); - } - return undefined; - }); + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { + return undefined; + } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, ts.createSymbolTable(), state.checker); + return ts.find(result, search.includes); + } + return undefined; + }); + } } function getNameFromObjectLiteralElement(node) { if (node.name.kind === 144) { @@ -67279,43 +67660,31 @@ var ts; if (!tokenAtPos || tokenStart < position) { return undefined; } - var commentOwner; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case 228: - case 151: - case 152: - case 229: - case 208: - break findOwner; - case 265: - return undefined; - case 233: - if (commentOwner.parent.kind === 233) { - return undefined; - } - break findOwner; - } + var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + if (!commentOwnerInfo) { + return undefined; } - if (!commentOwner || commentOwner.getStart() < position) { + var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters; + if (commentOwner.getStart() < position) { return undefined; } - var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0; i < parameters.length; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 71 ? - currentName.escapedText : - "param" + i; - if (isJavaScriptFile) { - docParams += indentationStr + " * @param {any} " + paramName + newLine; - } - else { - docParams += indentationStr + " * @param " + paramName + newLine; + if (parameters) { + for (var i = 0; i < parameters.length; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 71 ? + currentName.escapedText : + "param" + i; + if (isJavaScriptFile) { + docParams += indentationStr + " * @param {any} " + paramName + newLine; + } + else { + docParams += indentationStr + " * @param " + paramName + newLine; + } } } var preamble = "/**" + newLine + @@ -67327,18 +67696,38 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; - function getParametersForJsDocOwningNode(commentOwner) { - if (ts.isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } - if (commentOwner.kind === 208) { - var varStatement = commentOwner; - var varDeclarations = varStatement.declarationList.declarations; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + function getCommentOwnerInfo(tokenAtPos) { + for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 228: + case 151: + case 152: + var parameters = commentOwner.parameters; + return { commentOwner: commentOwner, parameters: parameters }; + case 229: + return { commentOwner: commentOwner }; + case 208: { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer + ? getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer) + : undefined; + return { commentOwner: commentOwner, parameters: parameters_1 }; + } + case 265: + return undefined; + case 233: + return commentOwner.parent.kind === 233 ? undefined : { commentOwner: commentOwner }; + case 194: { + var be = commentOwner; + if (ts.getSpecialPropertyAssignmentKind(be) === 0) { + return undefined; + } + var parameters_2 = ts.isFunctionLike(be.right) ? be.right.parameters : ts.emptyArray; + return { commentOwner: commentOwner, parameters: parameters_2 }; + } } } - return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { while (rightHandSide.kind === 185) { @@ -67536,148 +67925,149 @@ var ts; return "continue"; } ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { - if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); - if (!matches) { - return; - } - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (patternMatcher.patternContainsDots) { - var containers = getContainers(declaration); - if (!containers) { - return true; - } - matches = patternMatcher.getMatches(containers, name); - if (!matches) { - return; - } - } - var fileName = sourceFile.fileName; - var matchKind = bestMatchKind(matches); - rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); - } - } + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, rawItems); }); }; for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; _loop_6(sourceFile); } - rawItems = ts.filter(rawItems, function (item) { - var decl = item.declaration; - if (decl.kind === 239 || decl.kind === 242 || decl.kind === 237) { - var importer = checker.getSymbolAtLocation(decl.name); - var imported = checker.getAliasedSymbol(importer); - return importer.escapedName !== imported.escapedName; - } - else { - return true; - } - }); rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { rawItems = rawItems.slice(0, maxResultCount); } - var items = ts.map(rawItems, createNavigateToItem); - return items; - function allMatchesAreCaseSensitive(matches) { - ts.Debug.assert(matches.length > 0); - for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { - var match = matches_2[_i]; - if (!match.isCaseSensitive) { + return rawItems.map(createNavigateToItem); + } + NavigateTo.getNavigateToItems = getNavigateToItems; + function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); + if (!matches) { + return; + } + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + if (!shouldKeepItem(declaration, checker)) { + continue; + } + var containerMatches = matches; + if (patternMatcher.patternContainsDots) { + containerMatches = patternMatcher.getMatches(getContainers(declaration), name); + if (!containerMatches) { + continue; + } + } + var matchKind = bestMatchKind(containerMatches); + var isCaseSensitive = allMatchesAreCaseSensitive(containerMatches); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: isCaseSensitive, declaration: declaration }); + } + } + function shouldKeepItem(declaration, checker) { + switch (declaration.kind) { + case 239: + case 242: + case 237: + var importer = checker.getSymbolAtLocation(declaration.name); + var imported = checker.getAliasedSymbol(importer); + return importer.escapedName !== imported.escapedName; + default: + return true; + } + } + function allMatchesAreCaseSensitive(matches) { + ts.Debug.assert(matches.length > 0); + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; + if (!match.isCaseSensitive) { + return false; + } + } + return true; + } + function tryAddSingleDeclarationName(declaration, containers) { + if (declaration) { + var name = ts.getNameOfDeclaration(declaration); + if (name) { + var text = ts.getTextOfIdentifierOrLiteral(name); + if (text !== undefined) { + containers.unshift(text); + } + else if (name.kind === 144) { + return tryAddComputedPropertyName(name.expression, containers, true); + } + else { return false; } } - return true; } - function tryAddSingleDeclarationName(declaration, containers) { - if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - var text = ts.getTextOfIdentifierOrLiteral(name); - if (text !== undefined) { - containers.unshift(text); - } - else if (name.kind === 144) { - return tryAddComputedPropertyName(name.expression, containers, true); - } - else { - return false; - } - } + return true; + } + function tryAddComputedPropertyName(expression, containers, includeLastPortion) { + var text = ts.getTextOfIdentifierOrLiteral(expression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); } return true; } - function tryAddComputedPropertyName(expression, containers, includeLastPortion) { - var text = ts.getTextOfIdentifierOrLiteral(expression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; + if (expression.kind === 179) { + var propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); } - if (expression.kind === 179) { - var propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); - } - return false; + return tryAddComputedPropertyName(propertyAccess.expression, containers, true); } - function getContainers(declaration) { - var containers = []; - var name = ts.getNameOfDeclaration(declaration); - if (name.kind === 144) { - if (!tryAddComputedPropertyName(name.expression, containers, false)) { - return undefined; - } + return false; + } + function getContainers(declaration) { + var containers = []; + var name = ts.getNameOfDeclaration(declaration); + if (name.kind === 144) { + if (!tryAddComputedPropertyName(name.expression, containers, false)) { + return undefined; + } + } + declaration = ts.getContainerNode(declaration); + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; } declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } - declaration = ts.getContainerNode(declaration); - } - return containers; - } - function bestMatchKind(matches) { - ts.Debug.assert(matches.length > 0); - var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { - var match = matches_3[_i]; - var kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } - return bestMatchKind; - } - function compareNavigateToItems(i1, i2) { - return i1.matchKind - i2.matchKind || - ts.compareStringsCaseInsensitive(i1.name, i2.name) || - ts.compareStrings(i1.name, i2.name); - } - function createNavigateToItem(rawItem) { - var declaration = rawItem.declaration; - var container = ts.getContainerNode(declaration); - var containerName = container && ts.getNameOfDeclaration(container); - return { - name: rawItem.name, - kind: ts.getNodeKind(declaration), - kindModifiers: ts.getNodeModifiers(declaration), - matchKind: ts.PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromNode(declaration), - containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" - }; } + return containers; + } + function bestMatchKind(matches) { + ts.Debug.assert(matches.length > 0); + var bestMatchKind = ts.PatternMatchKind.camelCase; + for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { + var match = matches_3[_i]; + var kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; + } + } + return bestMatchKind; + } + function compareNavigateToItems(i1, i2) { + return i1.matchKind - i2.matchKind || + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); + } + function createNavigateToItem(rawItem) { + var declaration = rawItem.declaration; + var container = ts.getContainerNode(declaration); + var containerName = container && ts.getNameOfDeclaration(container); + return { + name: rawItem.name, + kind: ts.getNodeKind(declaration), + kindModifiers: ts.getNodeModifiers(declaration), + matchKind: ts.PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: ts.createTextSpanFromNode(declaration), + containerName: containerName ? containerName.text : "", + containerKind: containerName ? ts.getNodeKind(container) : "" + }; } - NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); var ts; @@ -67825,16 +68215,22 @@ var ts; break; case 176: case 226: - var decl = node; - var name = decl.name; + var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - addChildrenRecursively(decl.initializer); + else if (initializer && isFunctionOrClassExpression(initializer)) { + if (initializer.name) { + addChildrenRecursively(initializer); + } + else { + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); + } } else { - addNodeWithRecursiveChild(decl, decl.initializer); + addNodeWithRecursiveChild(node, initializer); } break; case 187: @@ -67844,8 +68240,8 @@ var ts; break; case 232: startNode(node); - for (var _d = 0, _e = node.members; _d < _e.length; _d++) { - var member = _e[_d]; + for (var _e = 0, _f = node.members; _e < _f.length; _e++) { + var member = _f[_e]; if (!isComputedProperty(member)) { addLeafNode(member); } @@ -67856,8 +68252,8 @@ var ts; case 199: case 230: startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; + for (var _g = 0, _h = node.members; _g < _h.length; _g++) { + var member = _h[_g]; addChildrenRecursively(member); } endNode(); @@ -67874,13 +68270,15 @@ var ts; addLeafNode(node); break; default: - ts.forEach(node.jsDoc, function (jsDoc) { - ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 283) { - addLeafNode(tag); - } + if (ts.hasJSDocNodes(node)) { + ts.forEach(node.jsDoc, function (jsDoc) { + ts.forEach(jsDoc.tags, function (tag) { + if (tag.kind === 283) { + addLeafNode(tag); + } + }); }); - }); + } ts.forEachChild(node, addChildrenRecursively); } } @@ -68193,7 +68591,14 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 186 || node.kind === 187 || node.kind === 199; + switch (node.kind) { + case 187: + case 186: + case 199: + return true; + default: + return false; + } } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -68203,11 +68608,15 @@ var ts; (function (OutliningElementsCollector) { var collapseText = "..."; var maxDepth = 20; + var defaultLabel = "#region"; + var regionMatch = new RegExp("^\\s*//\\s*#(end)?region(?:\\s+(.*))?$"); function collectElements(sourceFile, cancellationToken) { var elements = []; var depth = 0; + var regions = []; walk(sourceFile); - return elements; + gatherRegions(); + return elements.sort(function (span1, span2) { return span1.textSpan.start - span2.textSpan.start; }); function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse, useFullStart) { if (hintSpanNode && startElement && endElement) { var span_13 = { @@ -68272,6 +68681,36 @@ var ts; function autoCollapse(node) { return ts.isFunctionBlock(node) && node.parent.kind !== 187; } + function gatherRegions() { + var lineStarts = sourceFile.getLineStarts(); + for (var i = 0; i < lineStarts.length; i++) { + var currentLineStart = lineStarts[i]; + var lineEnd = lineStarts[i + 1] - 1 || sourceFile.getEnd(); + var comment = sourceFile.text.substring(currentLineStart, lineEnd); + var result = comment.match(regionMatch); + if (result && !ts.isInComment(sourceFile, currentLineStart)) { + if (!result[1]) { + var start = sourceFile.getFullText().indexOf("//", currentLineStart); + var textSpan = ts.createTextSpanFromBounds(start, lineEnd); + var region = { + textSpan: textSpan, + hintSpan: textSpan, + bannerText: result[2] || defaultLabel, + autoCollapse: false + }; + regions.push(region); + } + else { + var region = regions.pop(); + if (region) { + region.textSpan.length = lineEnd - region.textSpan.start; + region.hintSpan.length = lineEnd - region.textSpan.start; + elements.push(region); + } + } + } + } + } function walk(n) { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -68988,11 +69427,9 @@ var ts; return true; } token = nextToken(); - var i = 0; while (token !== 22 && token !== 1) { if (token === 9) { recordModuleName(); - i++; } token = nextToken(); } @@ -69132,10 +69569,16 @@ var ts; return ts.createTextSpan(start, width); } function nodeIsEligibleForRename(node) { - return node.kind === 71 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node); + switch (node.kind) { + case 71: + case 9: + case 99: + return true; + case 8: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); + default: + return false; + } } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); @@ -69374,7 +69817,7 @@ var ts; if (isTypeParameterList) { isVariadic = false; prefixDisplayParts.push(ts.punctuationPart(27)); - var typeParameters = candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; + var typeParameters = (candidateSignature.target || candidateSignature).typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : ts.emptyArray; suffixDisplayParts.push(ts.punctuationPart(29)); var parameterParts = ts.mapToDisplayParts(function (writer) { @@ -69509,7 +69952,7 @@ var ts; if (rootSymbolFlags & (98308 | 3)) { return "property"; } - ts.Debug.assert(!!(rootSymbolFlags & 8192)); + ts.Debug.assert(!!(rootSymbolFlags & (8192 | 16))); }); if (!unionPropertyKind) { var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); @@ -70035,7 +70478,6 @@ var ts; (function (formatting) { var standardScanner = ts.createScanner(5, false, 0); var jsxScanner = ts.createScanner(5, false, 1); - var scanner; var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -70045,9 +70487,8 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); - function getFormattingScanner(text, languageVariant, startPos, endPos) { - ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = languageVariant === 1 ? jsxScanner : standardScanner; + function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { + var scanner = languageVariant === 1 ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -70056,38 +70497,28 @@ var ts; var savedPos; var lastScanAction; var lastTokenInfo; - return { + var res = cb({ advance: advance, readTokenInfo: readTokenInfo, isOnToken: isOnToken, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, - close: function () { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; + }); + lastTokenInfo = undefined; + scanner.setText(undefined); + return res; function advance() { - ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - if (trailingTrivia) { - ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4; - } - else { - wasNewLine = false; - } + wasNewLine = trailingTrivia && ts.lastOrUndefined(trailingTrivia).kind === 4; + } + else { + scanner.scan(); } leadingTrivia = undefined; trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } var pos = scanner.getStartPos(); while (pos < endPos) { var t = scanner.getToken(); @@ -70101,23 +70532,18 @@ var ts; kind: t }; pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; - } - leadingTrivia.push(item); + leadingTrivia = ts.append(leadingTrivia, item); } savedPos = scanner.getStartPos(); } function shouldRescanGreaterThanToken(node) { - if (node) { - switch (node.kind) { - case 31: - case 66: - case 67: - case 47: - case 46: - return true; - } + switch (node.kind) { + case 31: + case 66: + case 67: + case 47: + case 46: + return true; } return false; } @@ -70128,13 +70554,13 @@ var ts; case 251: case 252: case 250: - return node.kind === 71; + return ts.isKeyword(node.kind) || node.kind === 71; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 10; + return node.kind === 10; } function shouldRescanSlashToken(container) { return container.kind === 12; @@ -70147,14 +70573,7 @@ var ts; return t === 41 || t === 63; } function readTokenInfo(n) { - ts.Debug.assert(scanner !== undefined); - if (!isOnToken()) { - return { - leadingTrivia: leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } + ts.Debug.assert(isOnToken()); var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 : shouldRescanSlashToken(n) @@ -70174,32 +70593,7 @@ var ts; scanner.setTextPos(savedPos); scanner.scan(); } - var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 29) { - currentToken = scanner.reScanGreaterToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 1; - } - else if (expectedScanAction === 2 && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 2; - } - else if (expectedScanAction === 3 && currentToken === 18) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = 3; - } - else if (expectedScanAction === 4 && currentToken === 71) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = 4; - } - else if (expectedScanAction === 5) { - currentToken = scanner.reScanJsxToken(); - lastScanAction = 5; - } - else { - lastScanAction = 0; - } + var currentToken = getNextToken(n, expectedScanAction); var token = { pos: scanner.getStartPos(), end: scanner.getTextPos(), @@ -70230,8 +70624,46 @@ var ts; lastTokenInfo = { leadingTrivia: leadingTrivia, trailingTrivia: trailingTrivia, token: token }; return fixTokenKind(lastTokenInfo, n); } + function getNextToken(n, expectedScanAction) { + var token = scanner.getToken(); + lastScanAction = 0; + switch (expectedScanAction) { + case 1: + if (token === 29) { + lastScanAction = 1; + var newToken = scanner.reScanGreaterToken(); + ts.Debug.assert(n.kind === newToken); + return newToken; + } + break; + case 2: + if (startsWithSlashToken(token)) { + lastScanAction = 2; + var newToken = scanner.reScanSlashToken(); + ts.Debug.assert(n.kind === newToken); + return newToken; + } + break; + case 3: + if (token === 18) { + lastScanAction = 3; + return scanner.reScanTemplateToken(); + } + break; + case 4: + lastScanAction = 4; + return scanner.scanJsxIdentifier(); + case 5: + lastScanAction = 5; + return scanner.reScanJsxToken(); + case 0: + break; + default: + ts.Debug.assertNever(expectedScanAction); + } + return token; + } function isOnToken() { - ts.Debug.assert(scanner !== undefined); var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 && !ts.isTrivia(current); @@ -70360,11 +70792,6 @@ var ts; this.Operation = Operation; this.Flag = Flag; } - Rule.prototype.toString = function () { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; - }; return Rule; }()); formatting.Rule = Rule; @@ -70683,16 +71110,16 @@ var ts; this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - } - Rules.prototype.getRuleName = function (rule) { - var o = this; - for (var name in o) { - if (o[name] === rule) { - return name; + if (ts.Debug.isDebugging) { + var o = this; + for (var name in o) { + var rule = o[name]; + if (rule instanceof formatting.Rule) { + rule.debugName = name; + } } } - throw new Error("Unknown rule"); - }; + } Rules.IsOptionEnabled = function (optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; }; @@ -70831,8 +71258,7 @@ var ts; return true; case 207: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 187 && - blockParent.kind !== 186) { + if (!blockParent || blockParent.kind !== 187 && blockParent.kind !== 186) { return true; } } @@ -71242,15 +71668,9 @@ var ts; var RulesProvider = (function () { function RulesProvider() { this.globalRules = new formatting.Rules(); - var activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); + var activeRules = this.globalRules.HighPriorityCommonRules.concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); this.rulesMap = formatting.RulesMap.create(activeRules); } - RulesProvider.prototype.getRuleName = function (rule) { - return this.globalRules.getRuleName(rule); - }; - RulesProvider.prototype.getRuleByName = function (name) { - return this.globalRules[name]; - }; RulesProvider.prototype.getRulesMap = function () { return this.rulesMap; }; @@ -71443,7 +71863,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, rulesProvider) { var range = { pos: 0, end: sourceFileLike.text.length }; - return formatSpanWorker(range, node, initialIndentation, delta, formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), rulesProvider.getFormatOptions(), rulesProvider, 1, function (_) { return false; }, sourceFileLike); + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, rulesProvider.getFormatOptions(), rulesProvider, 1, function (_) { return false; }, sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; function formatNodeLines(node, sourceFile, options, rulesProvider, requestKind) { @@ -71458,7 +71878,7 @@ var ts; } function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { var enclosingNode = findEnclosingNode(originalRange, sourceFile); - return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); + return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), scanner, options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); @@ -71484,7 +71904,6 @@ var ts; trimTrailingWhitespacesForRemainingRange(); } } - formattingScanner.close(); return edits; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || @@ -71681,6 +72100,7 @@ var ts; return inheritedIndentation; } function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { + ts.Debug.assert(ts.isNodeArray(nodes)); var listStartToken = getOpenTokenForList(parent, nodes); var listEndToken = getCloseTokenForOpenToken(listStartToken); var listDynamicIndentation = parentDynamicIndentation; @@ -72474,6 +72894,8 @@ var ts; case 241: case 246: case 242: + case 261: + case 149: return true; } return false; @@ -72518,15 +72940,21 @@ var ts; var textChanges; (function (textChanges) { function getPos(n) { - return n["__pos"]; + var result = n["__pos"]; + ts.Debug.assert(typeof result === "number"); + return result; } function setPos(n, pos) { + ts.Debug.assert(typeof pos === "number"); n["__pos"] = pos; } function getEnd(n) { - return n["__end"]; + var result = n["__end"]; + ts.Debug.assert(typeof result === "number"); + return result; } function setEnd(n, end) { + ts.Debug.assert(typeof end === "number"); n["__end"] = end; } var Position; @@ -72573,7 +73001,8 @@ var ts; if (startLine === fullStartLine) { return position === Position.Start ? start : fullStart; } - var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + var nextLineStart = fullStart > 0 ? 1 : 0; + var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + nextLineStart, sourceFile); adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } @@ -72599,9 +73028,6 @@ var ts; } return s; } - function getNewlineKind(context) { - return context.newLineCharacter === "\n" ? 1 : 0; - } var ChangeTracker = (function () { function ChangeTracker(newLine, rulesProvider, validator) { this.newLine = newLine; @@ -72610,8 +73036,8 @@ var ts; this.changes = []; this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); } - ChangeTracker.fromCodeFixContext = function (context) { - return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + ChangeTracker.fromContext = function (context) { + return new ChangeTracker(context.newLineCharacter === "\n" ? 1 : 0, context.rulesProvider); }; ChangeTracker.prototype.deleteRange = function (sourceFile, range) { this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); @@ -72637,7 +73063,7 @@ var ts; ts.Debug.fail("node is not a list element"); return this; } - var index = containingList.indexOf(node); + var index = ts.indexOfNode(containingList, node); if (index < 0) { return this; } @@ -72752,7 +73178,7 @@ var ts; ts.Debug.fail("node is not a list element"); return this; } - var index = containingList.indexOf(after); + var index = ts.indexOfNode(containingList, after); if (index < 0) { return this; } @@ -72915,10 +73341,9 @@ var ts; var options = { newLine: newLine, target: sourceFile && sourceFile.languageVersion }; var writer = new Writer(ts.getNewLineCharacter(options)); var printer = ts.createPrinter(options, writer); - printer.writeNode(3, node, sourceFile, writer); + printer.writeNode(4, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } - textChanges.getNonformattedText = getNonformattedText; function applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, rulesProvider) { var lineMap = ts.computeLineStarts(nonFormattedText.text); var file = { @@ -72929,7 +73354,6 @@ var ts; var changes = ts.formatting.formatNodeGivenIndentation(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); return applyChanges(nonFormattedText.text, changes); } - textChanges.applyFormatting = applyFormatting; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var change = changes[i]; @@ -72943,13 +73367,10 @@ var ts; } function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); - var newNode = ts.nodeIsSynthesized(visited) - ? visited - : (Proxy.prototype = visited, new Proxy()); + var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited); newNode.pos = getPos(node); newNode.end = getEnd(node); return newNode; - function Proxy() { } } function assignPositionsToNodeArray(nodes, visitor, test, start, count) { var visited = ts.visitNodes(nodes, visitor, test, start, count); @@ -73082,7 +73503,15 @@ var ts; ts.forEach(fixes, function (f) { var actions = f.getCodeActions(context); if (actions && actions.length > 0) { - allActions = allActions.concat(actions); + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + if (action === undefined) { + context.host.log("Action for error code " + context.errorCode + " added an invalid action entry; please log a bug"); + } + else { + allActions.push(action); + } + } } }); return allActions; @@ -73111,6 +73540,10 @@ var ts; } refactor_1.getEditsForRefactor = getEditsForRefactor; })(refactor = ts.refactor || (ts.refactor = {})); + function getRefactorContextLength(context) { + return context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + } + ts.getRefactorContextLength = getRefactorContextLength; })(ts || (ts = {})); var ts; (function (ts) { @@ -73129,7 +73562,7 @@ var ts; var leftText = qualifiedName.left.getText(sourceFile); var rightText = qualifiedName.right.getText(sourceFile); var replacement = ts.createIndexedAccessTypeNode(ts.createTypeReferenceNode(qualifiedName.left, undefined), ts.createLiteralTypeNode(ts.createLiteral(rightText))); - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, qualifiedName, replacement); return [{ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Rewrite_as_the_indexed_access_type_0), [leftText + "[\"" + rightText + "\"]"]), @@ -73258,7 +73691,7 @@ var ts; } var className = classDeclaration.name.getText(); var staticInitialization = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier(className), tokenName), ts.createIdentifier("undefined"))); - var staticInitializationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var staticInitializationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); staticInitializationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classDeclaration, staticInitialization, { suffix: context.newLineCharacter }); var initializeStaticAction = { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_static_property_0), [tokenName]), @@ -73273,7 +73706,7 @@ var ts; return actions; } var propertyInitialization = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), tokenName), ts.createIdentifier("undefined"))); - var propertyInitializationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var propertyInitializationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); propertyInitializationChangeTracker.insertNodeAt(classDeclarationSourceFile, classConstructor.body.getEnd() - 1, propertyInitialization, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); var initializeAction = { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]), @@ -73299,7 +73732,7 @@ var ts; } typeNode = typeNode || ts.createKeywordTypeNode(119); var property = ts.createProperty(undefined, makeStatic ? [ts.createToken(115)] : undefined, tokenName, undefined, typeNode, undefined); - var propertyChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var propertyChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter }); (actions || (actions = [])).push({ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Declare_property_0), [tokenName]), @@ -73309,7 +73742,7 @@ var ts; var stringTypeNode = ts.createKeywordTypeNode(136); var indexingParameter = ts.createParameter(undefined, undefined, undefined, "x", undefined, stringTypeNode, undefined); var indexSignature = ts.createIndexSignature(undefined, undefined, [indexingParameter], typeNode); - var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); indexSignatureChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, indexSignature, { suffix: context.newLineCharacter }); actions.push({ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_property_0), [tokenName]), @@ -73322,7 +73755,7 @@ var ts; if (token.parent.parent.kind === 181) { var callExpression = token.parent.parent; var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic); - var methodDeclarationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var methodDeclarationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); return { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(makeStatic ? @@ -73453,7 +73886,7 @@ var ts; } } } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); changeTracker.deleteNode(sourceFile, superCall); return [{ @@ -73485,7 +73918,7 @@ var ts; if (token.kind !== 123) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var superCall = ts.createStatement(ts.createCall(ts.createSuper(), undefined, ts.emptyArray)); changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ @@ -73518,7 +73951,7 @@ var ts; if (!(extendsToken && extendsToken.kind === 85)) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, extendsToken, ts.createToken(108)); for (var i = 1; i < heritageClauses.length; i++) { var keywordToken = heritageClauses[i].getFirstToken(); @@ -73547,7 +73980,7 @@ var ts; if (token.kind !== 71) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createThis(), token)); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), @@ -73563,8 +73996,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code + ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code, + ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code ], getCodeActions: function (context) { var sourceFile = context.sourceFile; @@ -73700,19 +74133,19 @@ var ts; } } function deleteNode(n) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNode(sourceFile, n)); } function deleteRange(range) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteRange(sourceFile, range)); } function deleteNodeInList(n) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNodeInList(sourceFile, n)); } function deleteNodeRange(start, end) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNodeRange(sourceFile, start, end)); } function replaceNode(n, newNode) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).replaceNode(sourceFile, n, newNode)); } function makeChange(changeTracker) { return { @@ -73735,11 +74168,30 @@ var ts; function getActionsForJSDocTypes(context) { var sourceFile = context.sourceFile; var node = ts.getTokenAtPosition(sourceFile, context.span.start, false); - var decl = ts.findAncestor(node, function (n) { return n.kind === 226; }); + var decl = ts.findAncestor(node, function (n) { + return n.kind === 202 || + n.kind === 155 || + n.kind === 156 || + n.kind === 228 || + n.kind === 153 || + n.kind === 157 || + n.kind === 172 || + n.kind === 151 || + n.kind === 150 || + n.kind === 146 || + n.kind === 149 || + n.kind === 148 || + n.kind === 154 || + n.kind === 231 || + n.kind === 184 || + n.kind === 226; + }); if (!decl) return; var checker = context.program.getTypeChecker(); var jsdocType = decl.type; + if (!jsdocType) + return; var original = ts.getTextOfNode(jsdocType); var type = checker.getTypeFromTypeNode(jsdocType); var actions = [createAction(jsdocType, sourceFile.fileName, original, checker.typeToString(type, undefined, 8))]; @@ -73918,28 +74370,21 @@ var ts; if (cached) { return cached; } - var existingDeclarations = []; - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importModuleSpecifier = _a[_i]; - var importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); - if (importSymbol === moduleSymbol) { - existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); - } - } + var existingDeclarations = ts.mapDefined(sourceFile.imports, function (importModuleSpecifier) { + return checker.getSymbolAtLocation(importModuleSpecifier) === moduleSymbol ? getImportDeclaration(importModuleSpecifier) : undefined; + }); cachedImportDeclarations[moduleSymbolId] = existingDeclarations; return existingDeclarations; - function getImportDeclaration(moduleSpecifier) { - var node = moduleSpecifier; - while (node) { - if (node.kind === 238) { - return node; - } - if (node.kind === 237) { - return node; - } - node = node.parent; + function getImportDeclaration(_a) { + var parent = _a.parent; + switch (parent.kind) { + case 238: + return parent; + case 248: + return parent.parent; + default: + return undefined; } - return undefined; } } function getUniqueSymbolId(symbol) { @@ -74281,7 +74726,7 @@ var ts; } } function createChangeTracker() { - return ts.textChanges.ChangeTracker.fromCodeFixContext(context); + return ts.textChanges.ChangeTracker.fromContext(context); } function createCodeAction(description, diagnosticArgs, changes, kind, moduleSpecifier) { return { @@ -74361,7 +74806,7 @@ var ts; (function (codefix) { function newNodesToChanges(newNodes, insertAfter, context) { var sourceFile = context.sourceFile; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) { var newNode = newNodes_1[_i]; changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); @@ -74587,7 +75032,7 @@ var ts; return undefined; } var ctorDeclaration = ctorSymbol.valueDeclaration; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { @@ -74616,7 +75061,9 @@ var ts; deleteCallback(); } return { - edits: changeTracker.getChanges() + edits: changeTracker.getChanges(), + renameFilename: undefined, + renameLocation: undefined, }; function deleteNode(node, inList) { if (inList === void 0) { inList = false; } @@ -74754,7 +75201,7 @@ var ts; }; refactor.registerRefactor(extractMethod); function getAvailableActions(context) { - var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: ts.getRefactorContextLength(context) }); var targetRange = rangeToExtract.targetRange; if (targetRange === undefined) { return undefined; @@ -74767,11 +75214,11 @@ var ts; var usedNames = ts.createMap(); var i = 0; for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) { - var extr = extractions_1[_i]; - if (extr.errors && extr.errors.length) { + var _a = extractions_1[_i], scopeDescription = _a.scopeDescription, errors = _a.errors; + if (errors.length) { continue; } - var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_to_0.message, [scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -74792,16 +75239,13 @@ var ts; }]; } function getEditsForAction(context, actionName) { - var length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; - var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: length }); + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: ts.getRefactorContextLength(context) }); var targetRange = rangeToExtract.targetRange; var parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); ts.Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); var index = +parsedIndexMatch[1]; ts.Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); - var extractions = getPossibleExtractions(targetRange, context, index); - ts.Debug.assert(extractions !== undefined, "The extraction went missing? How?"); - return ({ edits: extractions[0].changes }); + return getExtractionAtIndex(targetRange, context, index); } var Messages; (function (Messages) { @@ -74830,9 +75274,12 @@ var ts; RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; - })(RangeFacts = extractMethod_1.RangeFacts || (extractMethod_1.RangeFacts = {})); + })(RangeFacts || (RangeFacts = {})); function getRangeToExtract(sourceFile, span) { - var length = span.length || 0; + var length = span.length; + if (length === 0) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.StatementOrExpressionExpected)] }; + } var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, false), sourceFile, span); var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; @@ -74875,18 +75322,13 @@ var ts; if (errors) { return { errors: errors }; } - var range = ts.isStatement(start) - ? [start] - : start.parent && start.parent.kind === 210 - ? [start.parent] - : start; - return { targetRange: { range: range, facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations: declarations } }; } function createErrorResult(sourceFile, start, length, message) { return { errors: [ts.createFileDiagnostic(sourceFile, start, length, message)] }; } function checkRootNode(node) { - if (ts.isIdentifier(node)) { + if (ts.isIdentifier(ts.isExpressionStatement(node) ? node.expression : node)) { return [ts.createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; @@ -74923,7 +75365,7 @@ var ts; PermittedJumps[PermittedJumps["Continue"] = 2] = "Continue"; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); - if (!ts.isStatement(nodeToCheck) && !(ts.isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + if (!ts.isStatement(nodeToCheck) && !(ts.isPartOfExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; } if (ts.isInAmbientContext(nodeToCheck)) { @@ -74979,39 +75421,26 @@ var ts; return false; } var savedPermittedJumps = permittedJumps; - if (node.parent) { - switch (node.parent.kind) { - case 211: - if (node.parent.thenStatement === node || node.parent.elseStatement === node) { - permittedJumps = 0; - } - break; - case 224: - if (node.parent.tryBlock === node) { - permittedJumps = 0; - } - else if (node.parent.finallyBlock === node) { - permittedJumps = 4; - } - break; - case 260: - if (node.parent.block === node) { - permittedJumps = 0; - } - break; - case 257: - if (node.expression !== node) { - permittedJumps |= 1; - } - break; - default: - if (ts.isIterationStatement(node.parent, false)) { - if (node.parent.statement === node) { - permittedJumps |= 1 | 2; - } - } - break; - } + switch (node.kind) { + case 211: + permittedJumps = 0; + break; + case 224: + permittedJumps = 0; + break; + case 207: + if (node.parent && node.parent.kind === 224 && node.finallyBlock === node) { + permittedJumps = 4; + } + break; + case 257: + permittedJumps |= 1; + break; + default: + if (ts.isIterationStatement(node, false)) { + permittedJumps |= 1 | 2; + } + break; } switch (node.kind) { case 169: @@ -75036,7 +75465,7 @@ var ts; } } else { - if (!(permittedJumps & (218 ? 1 : 2))) { + if (!(permittedJumps & (node.kind === 218 ? 1 : 2))) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } @@ -75065,6 +75494,15 @@ var ts; } } extractMethod_1.getRangeToExtract = getRangeToExtract; + function getStatementOrExpressionRange(node) { + if (ts.isStatement(node)) { + return [node]; + } + else if (ts.isPartOfExpression(node)) { + return ts.isExpressionStatement(node.parent) ? [node.parent] : node; + } + return undefined; + } function isValidExtractionTarget(node) { return (node.kind === 228) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node); } @@ -75091,9 +75529,21 @@ var ts; } return scopes; } - extractMethod_1.collectEnclosingScopes = collectEnclosingScopes; - function getPossibleExtractions(targetRange, context, requestedChangesIndex) { - if (requestedChangesIndex === void 0) { requestedChangesIndex = undefined; } + function getExtractionAtIndex(targetRange, context, requestedChangesIndex) { + var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, _b = _a.readsAndWrites, target = _b.target, usagesPerScope = _b.usagesPerScope, errorsPerScope = _b.errorsPerScope; + ts.Debug.assert(!errorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); + context.cancellationToken.throwIfCancellationRequested(); + return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context); + } + extractMethod_1.getExtractionAtIndex = getExtractionAtIndex; + function getPossibleExtractions(targetRange, context) { + var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, errorsPerScope = _a.readsAndWrites.errorsPerScope; + return scopes.map(function (scope, i) { + return ({ scopeDescription: getDescriptionForScope(scope), errors: errorsPerScope[i] }); + }); + } + extractMethod_1.getPossibleExtractions = getPossibleExtractions; + function getPossibleExtractionsWorker(targetRange, context) { var sourceFile = context.file; if (targetRange === undefined) { return undefined; @@ -75103,86 +75553,62 @@ var ts; return undefined; } var enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); - var _a = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker()), target = _a.target, usagesPerScope = _a.usagesPerScope, errorsPerScope = _a.errorsPerScope; - context.cancellationToken.throwIfCancellationRequested(); - if (requestedChangesIndex !== undefined) { - if (errorsPerScope[requestedChangesIndex].length) { - return undefined; - } - return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; - } - else { - return scopes.map(function (scope, i) { - var errors = errorsPerScope[i]; - if (errors.length) { - return { - scope: scope, - scopeDescription: getDescriptionForScope(scope), - errors: errors - }; - } - return { scope: scope, scopeDescription: getDescriptionForScope(scope) }; - }); - } + var readsAndWrites = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker(), context.cancellationToken); + return { scopes: scopes, readsAndWrites: readsAndWrites }; } - extractMethod_1.getPossibleExtractions = getPossibleExtractions; function getDescriptionForScope(scope) { - if (ts.isFunctionLike(scope)) { - switch (scope.kind) { - case 152: - return "constructor"; - case 186: - return scope.name - ? "function expression " + scope.name.getText() - : "anonymous function expression"; - case 228: - return "function " + scope.name.getText(); - case 187: - return "arrow function"; - case 151: - return "method " + scope.name.getText(); - case 153: - return "get " + scope.name.getText(); - case 154: - return "set " + scope.name.getText(); - } - } - else if (ts.isModuleBlock(scope)) { - return "namespace " + scope.parent.name.getText(); - } - else if (ts.isClassLike(scope)) { - return scope.kind === 229 - ? "class " + scope.name.text - : scope.name.text - ? "class expression " + scope.name.text - : "anonymous class expression"; - } - else if (ts.isSourceFile(scope)) { - return "file '" + scope.fileName + "'"; - } - else { - return "unknown"; + return ts.isFunctionLikeDeclaration(scope) + ? "inner function in " + getDescriptionForFunctionLikeDeclaration(scope) + : ts.isClassLike(scope) + ? "method in " + getDescriptionForClassLikeDeclaration(scope) + : "function in " + getDescriptionForModuleLikeDeclaration(scope); + } + function getDescriptionForFunctionLikeDeclaration(scope) { + switch (scope.kind) { + case 152: + return "constructor"; + case 186: + return scope.name + ? "function expression '" + scope.name.text + "'" + : "anonymous function expression"; + case 228: + return "function '" + scope.name.text + "'"; + case 187: + return "arrow function"; + case 151: + return "method '" + scope.name.getText(); + case 153: + return "'get " + scope.name.getText() + "'"; + case 154: + return "'set " + scope.name.getText() + "'"; + default: + ts.Debug.assertNever(scope); } } - function getUniqueName(isNameOkay) { + function getDescriptionForClassLikeDeclaration(scope) { + return scope.kind === 229 + ? "class '" + scope.name.text + "'" + : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + } + function getDescriptionForModuleLikeDeclaration(scope) { + return scope.kind === 234 + ? "namespace '" + scope.parent.name.getText() + "'" + : scope.externalModuleIndicator ? "module scope" : "global scope"; + } + function getUniqueName(fileText) { var functionNameText = "newFunction"; - if (isNameOkay(functionNameText)) { - return functionNameText; - } - var i = 1; - while (!isNameOkay(functionNameText = "newFunction_" + i)) { - i++; + for (var i = 1; fileText.indexOf(functionNameText) !== -1; i++) { + functionNameText = "newFunction_" + i; } return functionNameText; } function extractFunctionInScope(node, scope, _a, range, context) { - var usagesInScope = _a.usages, substitutions = _a.substitutions; + var usagesInScope = _a.usages, typeParameterUsages = _a.typeParameterUsages, substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); var file = scope.getSourceFile(); - var functionNameText = getUniqueName(function (n) { return !file.identifiers.has(n); }); + var functionNameText = getUniqueName(file.text); var isJS = ts.isInJavaScriptFile(scope); var functionName = ts.createIdentifier(functionNameText); - var functionReference = ts.createIdentifier(functionNameText); var returnType = undefined; var parameters = []; var callArguments = []; @@ -75201,11 +75627,19 @@ var ts; } callArguments.push(ts.createIdentifier(name)); }); + var typeParametersAndDeclarations = ts.arrayFrom(typeParameterUsages.values()).map(function (type) { return ({ type: type, declaration: getFirstDeclaration(type) }); }); + var sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder); + var typeParameters = sortedTypeParametersAndDeclarations.length === 0 + ? undefined + : sortedTypeParametersAndDeclarations.map(function (t) { return t.declaration; }); + var callTypeArguments = typeParameters !== undefined + ? typeParameters.map(function (decl) { return ts.createTypeReferenceNode(decl.name, undefined); }) + : undefined; if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); returnType = checker.typeToTypeNode(contextualType); } - var _b = transformFunctionBody(node), body = _b.body, returnValueProperty = _b.returnValueProperty; + var _b = transformFunctionBody(node, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; var newFunction; if (ts.isClassLike(scope)) { var modifiers = isJS ? [] : [ts.createToken(112)]; @@ -75215,15 +75649,23 @@ var ts; if (range.facts & RangeFacts.IsAsyncFunction) { modifiers.push(ts.createToken(120)); } - newFunction = ts.createMethod(undefined, modifiers, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, undefined, [], parameters, returnType, body); + newFunction = ts.createMethod(undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, undefined, typeParameters, parameters, returnType, body); } else { - newFunction = ts.createFunctionDeclaration(undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, [], parameters, returnType, body); + newFunction = ts.createFunctionDeclaration(undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, typeParameters, parameters, returnType, body); + } + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); + var minInsertionPos = (isReadonlyArray(range.range) ? ts.lastOrUndefined(range.range) : range.range).end; + var nodeToInsertBefore = getNodeToInsertBefore(minInsertionPos, scope); + if (nodeToInsertBefore) { + changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); - changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); var newNodes = []; - var call = ts.createCall(ts.isClassLike(scope) ? ts.createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.getText()) : ts.createThis(), functionReference) : functionReference, undefined, callArguments); + var called = getCalledExpression(scope, range, functionNameText); + var call = ts.createCall(called, callTypeArguments, callArguments); if (range.facts & RangeFacts.IsGenerator) { call = ts.createYield(ts.createToken(39), call); } @@ -75244,6 +75686,9 @@ var ts; } else { newNodes.push(ts.createStatement(ts.createBinary(assignments[0].name, 58, call))); + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(ts.createReturn()); + } } } else { @@ -75273,63 +75718,152 @@ var ts; else { changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); } - return { - scope: scope, - scopeDescription: getDescriptionForScope(scope), - changes: changeTracker.getChanges() - }; - function getPropertyAssignmentsForWrites(writes) { - return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + var edits = changeTracker.getChanges(); + var renameRange = isReadonlyArray(range.range) ? range.range[0] : range.range; + var renameFilename = renameRange.getSourceFile().fileName; + var renameLocation = getRenameLocation(edits, renameFilename, functionNameText); + return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + } + function getRenameLocation(edits, renameFilename, functionNameText) { + var delta = 0; + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; + ts.Debug.assert(fileName === renameFilename); + for (var _b = 0, textChanges_2 = textChanges_1; _b < textChanges_2.length; _b++) { + var change = textChanges_2[_b]; + var span_17 = change.span, newText = change.newText; + var index = newText.indexOf(functionNameText); + if (index !== -1) { + return span_17.start + delta + index; + } + delta += newText.length - span_17.length; + } } - function generateReturnValueProperty() { - return "__return"; + throw new Error(); + } + function getFirstDeclaration(type) { + var firstDeclaration = undefined; + var symbol = type.symbol; + if (symbol && symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { + firstDeclaration = declaration; + } + } } - function transformFunctionBody(body) { - if (ts.isBlock(body) && !writes && substitutions.size === 0) { - return { body: ts.createBlock(body.statements, true), returnValueProperty: undefined }; - } - var returnValueProperty; - var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); - if (writes || substitutions.size) { - var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); - if (writes && !(range.facts & RangeFacts.HasReturn) && ts.isStatement(body)) { - var assignments = getPropertyAssignmentsForWrites(writes); - if (assignments.length === 1) { - rewrittenStatements.push(ts.createReturn(assignments[0].name)); - } - else { - rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); - } + return firstDeclaration; + } + function compareTypesByDeclarationOrder(_a, _b) { + var type1 = _a.type, declaration1 = _a.declaration; + var type2 = _b.type, declaration2 = _b.declaration; + if (declaration1) { + if (declaration2) { + var positionDiff = declaration1.pos - declaration2.pos; + if (positionDiff !== 0) { + return positionDiff; } - return { body: ts.createBlock(rewrittenStatements, true), returnValueProperty: returnValueProperty }; } else { - return { body: ts.createBlock(statements, true), returnValueProperty: undefined }; + return 1; } - function visitor(node) { - if (node.kind === 219 && writes) { - var assignments = getPropertyAssignmentsForWrites(writes); - if (node.expression) { - if (!returnValueProperty) { - returnValueProperty = generateReturnValueProperty(); - } - assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); - } - if (assignments.length === 1) { - return ts.createReturn(assignments[0].name); - } - else { - return ts.createReturn(ts.createObjectLiteral(assignments)); - } + } + else if (declaration2) { + return -1; + } + var name1 = type1.symbol ? type1.symbol.getName() : ""; + var name2 = type2.symbol ? type2.symbol.getName() : ""; + var nameDiff = ts.compareStrings(name1, name2); + if (nameDiff !== 0) { + return nameDiff; + } + return type1.id - type2.id; + } + function getCalledExpression(scope, range, functionNameText) { + var functionReference = ts.createIdentifier(functionNameText); + if (ts.isClassLike(scope)) { + var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); + return ts.createPropertyAccess(lhs, functionReference); + } + else { + return functionReference; + } + } + function transformFunctionBody(body, writes, substitutions, hasReturn) { + if (ts.isBlock(body) && !writes && substitutions.size === 0) { + return { body: ts.createBlock(body.statements, true), returnValueProperty: undefined }; + } + var returnValueProperty; + var ignoreReturns = false; + var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); + if (writes || substitutions.size) { + var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); + if (writes && !hasReturn && ts.isStatement(body)) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(ts.createReturn(assignments[0].name)); } else { - var substitution = substitutions.get(ts.getNodeId(node).toString()); - return substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); } } + return { body: ts.createBlock(rewrittenStatements, true), returnValueProperty: returnValueProperty }; + } + else { + return { body: ts.createBlock(statements, true), returnValueProperty: undefined }; + } + function visitor(node) { + if (!ignoreReturns && node.kind === 219 && writes) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (node.expression) { + if (!returnValueProperty) { + returnValueProperty = "__return"; + } + assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); + } + if (assignments.length === 1) { + return ts.createReturn(assignments[0].name); + } + else { + return ts.createReturn(ts.createObjectLiteral(assignments)); + } + } + else { + var oldIgnoreReturns = ignoreReturns; + ignoreReturns = ignoreReturns || ts.isFunctionLike(node) || ts.isClassLike(node); + var substitution = substitutions.get(ts.getNodeId(node).toString()); + var result = substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + ignoreReturns = oldIgnoreReturns; + return result; + } } } - extractMethod_1.extractFunctionInScope = extractFunctionInScope; + function getStatementsOrClassElements(scope) { + if (ts.isFunctionLike(scope)) { + var body = scope.body; + if (ts.isBlock(body)) { + return body.statements; + } + } + else if (ts.isModuleBlock(scope) || ts.isSourceFile(scope)) { + return scope.statements; + } + else if (ts.isClassLike(scope)) { + return scope.members; + } + else { + ts.assertTypeIsNever(scope); + } + return ts.emptyArray; + } + function getNodeToInsertBefore(minPos, scope) { + return ts.find(getStatementsOrClassElements(scope), function (child) { + return child.pos >= minPos && ts.isFunctionLike(child) && !ts.isConstructorDeclaration(child); + }); + } + function getPropertyAssignmentsForWrites(writes) { + return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + } function isReadonlyArray(v) { return ts.isArray(v); } @@ -75343,21 +75877,50 @@ var ts; Usage[Usage["Read"] = 1] = "Read"; Usage[Usage["Write"] = 2] = "Write"; })(Usage || (Usage = {})); - function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker) { + function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker, cancellationToken) { + var allTypeParameterUsages = ts.createMap(); var usagesPerScope = []; var substitutionsPerScope = []; var errorsPerScope = []; var visibleDeclarationsInExtractedRange = []; for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { var _ = scopes_1[_i]; - usagesPerScope.push({ usages: ts.createMap(), substitutions: ts.createMap() }); + usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); errorsPerScope.push([]); } var seenUsages = ts.createMap(); var target = isReadonlyArray(targetRange.range) ? ts.createBlock(targetRange.range) : targetRange.range; var containingLexicalScopeOfExtraction = ts.isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : ts.getEnclosingBlockScopeContainer(scopes[0]); + var unmodifiedNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; + var inGenericContext = isInGenericContext(unmodifiedNode); collectUsages(target); + if (inGenericContext && !isReadonlyArray(targetRange.range)) { + var contextualType = checker.getContextualType(targetRange.range); + recordTypeParameterUsages(contextualType); + } + if (allTypeParameterUsages.size > 0) { + var seenTypeParameterUsages = ts.createMap(); + var i_1 = 0; + for (var curr = unmodifiedNode; curr !== undefined && i_1 < scopes.length; curr = curr.parent) { + if (curr === scopes[i_1]) { + seenTypeParameterUsages.forEach(function (typeParameter, id) { + usagesPerScope[i_1].typeParameterUsages.set(id, typeParameter); + }); + i_1++; + } + if (ts.isDeclarationWithTypeParameters(curr) && curr.typeParameters) { + for (var _a = 0, _b = curr.typeParameters; _a < _b.length; _a++) { + var typeParameterDecl = _b[_a]; + var typeParameter = checker.getTypeAtLocation(typeParameterDecl); + if (allTypeParameterUsages.has(typeParameter.id.toString())) { + seenTypeParameterUsages.set(typeParameter.id.toString(), typeParameter); + } + } + } + } + ts.Debug.assert(i_1 === scopes.length); + } var _loop_8 = function (i) { var hasWrite = false; var readonlyClassPropertyWrite = undefined; @@ -75375,7 +75938,7 @@ var ts; errorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); } else if (readonlyClassPropertyWrite && i > 0) { - errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor)); } }; for (var i = 0; i < scopes.length; i++) { @@ -75385,8 +75948,35 @@ var ts; ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } return { target: target, usagesPerScope: usagesPerScope, errorsPerScope: errorsPerScope }; + function hasTypeParameters(node) { + return ts.isDeclarationWithTypeParameters(node) && + node.typeParameters !== undefined && + node.typeParameters.length > 0; + } + function isInGenericContext(node) { + for (; node; node = node.parent) { + if (hasTypeParameters(node)) { + return true; + } + } + return false; + } + function recordTypeParameterUsages(type) { + var symbolWalker = checker.getSymbolWalker(function () { return (cancellationToken.throwIfCancellationRequested(), true); }); + var visitedTypes = symbolWalker.walkType(type).visitedTypes; + for (var _i = 0, visitedTypes_1 = visitedTypes; _i < visitedTypes_1.length; _i++) { + var visitedType = visitedTypes_1[_i]; + if (visitedType.flags & 16384) { + allTypeParameterUsages.set(visitedType.id.toString(), visitedType); + } + } + } function collectUsages(node, valueUsage) { if (valueUsage === void 0) { valueUsage = 1; } + if (inGenericContext) { + var type = checker.getTypeAtLocation(node); + recordTypeParameterUsages(type); + } if (ts.isDeclaration(node) && node.symbol) { visibleDeclarationsInExtractedRange.push(node.symbol); } @@ -75428,7 +76018,9 @@ var ts; } } function recordUsagebySymbol(identifier, usage, isTypeName) { - var symbol = checker.getSymbolAtLocation(identifier); + var symbol = identifier.parent && ts.isShorthandPropertyAssignment(identifier.parent) && identifier.parent.name === identifier + ? checker.getShorthandAssignmentValueSymbol(identifier.parent) + : checker.getSymbolAtLocation(identifier); if (!symbol) { return undefined; } @@ -75452,7 +76044,7 @@ var ts; if (!declInFile) { return undefined; } - if (ts.rangeContainsRange(enclosingTextRange, declInFile)) { + if (ts.rangeContainsStartEnd(enclosingTextRange, declInFile.getStart(), declInFile.end)) { return undefined; } if (targetRange.facts & RangeFacts.IsGenerator && usage === 2) { @@ -75473,7 +76065,9 @@ var ts; substitutionsPerScope[i].set(symbolId, substitution); } else if (isTypeName) { - errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + if (!(symbol.flags & 262144)) { + errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } } else { usagesPerScope[i].usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); @@ -76059,6 +76653,10 @@ var ts; } } break; + case 194: + if (ts.getSpecialPropertyAssignmentKind(node) !== 0) { + addDeclaration(node); + } default: ts.forEachChild(node, visit); } @@ -76366,7 +76964,7 @@ var ts; oldSettings.noResolve !== newSettings.noResolve || oldSettings.jsx !== newSettings.jsx || oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.disableSizeLimit !== newSettings.disableSizeLimit || oldSettings.baseUrl !== newSettings.baseUrl || !ts.equalOwnProperties(oldSettings.paths, newSettings.paths)); var compilerHost = { @@ -76495,17 +77093,17 @@ var ts; } function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } function getSemanticDiagnostics(fileName) { synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; + return semanticDiagnostics.slice(); } var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return ts.concatenate(semanticDiagnostics, declarationDiagnostics); + return semanticDiagnostics.concat(declarationDiagnostics); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); @@ -76534,7 +77132,7 @@ var ts; return undefined; } var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); + var symbol = getSymbolAtLocationForQuickInfo(node, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 71: @@ -76567,6 +77165,20 @@ var ts; tags: displayPartsDocumentationsAndKind.tags }; } + function getSymbolAtLocationForQuickInfo(node, checker) { + if ((ts.isIdentifier(node) || ts.isStringLiteral(node)) + && ts.isPropertyAssignment(node.parent) + && node.parent.name === node) { + var type = checker.getContextualType(node.parent.parent); + if (type) { + var property = checker.getPropertyOfType(type, ts.getTextOfIdentifierOrLiteral(node)); + if (property) { + return property; + } + } + } + return checker.getSymbolAtLocation(node); + } function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); @@ -76624,7 +77236,19 @@ var ts; } function getReferences(fileName, position, options) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); + var sourceFiles = []; + if (options && options.isForRename) { + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + if (!program.isSourceFileDefaultLibrary(sourceFile)) { + sourceFiles.push(sourceFile); + } + } + } + else { + sourceFiles = program.getSourceFiles().slice(); + } + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -76929,7 +77553,7 @@ var ts; startPosition: startPosition, endPosition: endPosition, program: getProgram(), - newLineCharacter: host.getNewLine(), + newLineCharacter: formatOptions ? formatOptions.newLineCharacter : host.getNewLine(), rulesProvider: getRuleProvider(formatOptions), cancellationToken: cancellationToken }; @@ -77008,7 +77632,7 @@ var ts; nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); } ts.forEachChild(node, walk); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; ts.forEachChild(jsDoc, walk); @@ -78278,16 +78902,18 @@ var ts; }()); server.TextStorage = TextStorage; var ScriptInfo = (function () { - function ScriptInfo(host, fileName, scriptKind, hasMixedContent) { + function ScriptInfo(host, fileName, scriptKind, hasMixedContent, isDynamic) { if (hasMixedContent === void 0) { hasMixedContent = false; } + if (isDynamic === void 0) { isDynamic = false; } this.host = host; this.fileName = fileName; this.scriptKind = scriptKind; this.hasMixedContent = hasMixedContent; + this.isDynamic = isDynamic; this.containingProjects = []; this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); this.textStorage = new TextStorage(host, fileName); - if (hasMixedContent) { + if (hasMixedContent || isDynamic) { this.textStorage.reload(""); } this.scriptKind = scriptKind @@ -78304,7 +78930,7 @@ var ts; }; ScriptInfo.prototype.close = function () { this.isOpen = false; - this.textStorage.useText(this.hasMixedContent ? "" : undefined); + this.textStorage.useText(this.hasMixedContent || this.isDynamic ? "" : undefined); this.markContainingProjectsAsDirty(); }; ScriptInfo.prototype.getSnapshot = function () { @@ -78413,7 +79039,7 @@ var ts; this.host.writeFile(fileName, snap.getText(0, snap.getLength())); }; ScriptInfo.prototype.reloadFromFile = function (tempFileName) { - if (this.hasMixedContent) { + if (this.hasMixedContent || this.isDynamic) { this.reload(""); } else { @@ -78749,7 +79375,7 @@ var ts; var server; (function (server) { function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; + return !scriptInfo.hasMixedContent && !scriptInfo.isDynamic; } server.shouldEmitFile = shouldEmitFile; var BuilderFileInfo = (function () { @@ -78877,7 +79503,7 @@ var ts; }; NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { var info = this.getOrCreateFileInfo(scriptInfo.path); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var singleFileResult = scriptInfo.hasMixedContent || scriptInfo.isDynamic ? [] : [scriptInfo.fileName]; if (info.updateShapeSignature()) { var options = this.project.getCompilerOptions(); if (options && (options.out || options.outFile)) { @@ -78974,7 +79600,7 @@ var ts; }; ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { this.ensureProjectDependencyGraphUpToDate(); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var singleFileResult = scriptInfo.hasMixedContent || scriptInfo.isDynamic ? [] : [scriptInfo.fileName]; var fileInfo = this.getFileInfo(scriptInfo.path); if (!fileInfo || !fileInfo.updateShapeSignature()) { return singleFileResult; @@ -79437,24 +80063,23 @@ var ts; var file = changedFiles_1[_i]; this.cachedUnresolvedImportsPerFile.remove(file); } - var unresolvedImports; - if (hasChanges || changedFiles.length) { - var result = []; - for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { - var sourceFile = _b[_a]; - this.extractUnresolvedImportsFromSourceFile(sourceFile, result); - } - this.lastCachedUnresolvedImportsList = server.toDeduplicatedSortedArray(result); - } - unresolvedImports = this.lastCachedUnresolvedImportsList; - var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; - } if (this.languageServiceEnabled) { + if (hasChanges || changedFiles.length) { + var result = []; + for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { + var sourceFile = _b[_a]; + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = server.toDeduplicatedSortedArray(result); + } + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } this.builder.onProjectUpdateGraph(); } else { + this.lastCachedUnresolvedImportsList = undefined; this.builder.clear(); } if (hasChanges) { @@ -79597,7 +80222,8 @@ var ts; return { info: info, projectErrors: this.getGlobalProjectErrors() }; } var lastReportedFileNames_1 = this.lastReportedFileNames; - var currentFiles_1 = ts.arrayToSet(this.getFileNames()); + var externalFiles = this.getExternalFiles().map(function (f) { return server.toNormalizedPath(f); }); + var currentFiles_1 = ts.arrayToSet(this.getFileNames().concat(externalFiles)); var added_1 = []; var removed_1 = []; var updated = updatedFileNames ? ts.arrayFrom(updatedFileNames.keys()) : []; @@ -79617,7 +80243,8 @@ var ts; } else { var projectFileNames = this.getFileNames(); - this.lastReportedFileNames = ts.arrayToSet(projectFileNames); + var externalFiles = this.getExternalFiles().map(function (f) { return server.toNormalizedPath(f); }); + this.lastReportedFileNames = ts.arrayToSet(projectFileNames.concat(externalFiles)); this.lastReportedVersion = this.projectStructureVersion; return { info: info, files: projectFileNames, projectErrors: this.getGlobalProjectErrors() }; } @@ -79785,8 +80412,11 @@ var ts; } if (this.projectService.globalPlugins) { var _loop_10 = function (globalPluginName) { + if (!globalPluginName) + return "continue"; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; + this_2.projectService.logger.info("Loading global plugin " + globalPluginName); this_2.enablePlugin({ name: globalPluginName, global: true }, searchPaths); }; var this_2 = this; @@ -79798,6 +80428,7 @@ var ts; }; ConfiguredProject.prototype.enablePlugin = function (pluginConfigEntry, searchPaths) { var _this = this; + this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); var log = function (message) { _this.projectService.logger.info(message); }; @@ -79809,7 +80440,7 @@ var ts; return; } } - this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name + " anywhere in paths: " + searchPaths.join(",")); + this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); }; ConfiguredProject.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { @@ -79825,7 +80456,16 @@ var ts; serverHost: this.projectService.host }; var pluginModule = pluginModuleFactory({ typescript: ts }); - this.languageService = pluginModule.create(info); + var newLS = pluginModule.create(info); + for (var _i = 0, _a = Object.keys(this.languageService); _i < _a.length; _i++) { + var k = _a[_i]; + if (!(k in newLS)) { + this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); + newLS[k] = this.languageService[k]; + } + } + this.projectService.logger.info("Plugin validation succeded"); + this.languageService = newLS; this.plugins.push(pluginModule); } catch (e) { @@ -79854,6 +80494,9 @@ var ts; } catch (e) { _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + if (e.stack) { + _this.projectService.logger.info(e.stack); + } } })); }; @@ -80089,11 +80732,13 @@ var ts; getFileName: function (x) { return x; }, getScriptKind: function (_) { return undefined; }, hasMixedContent: function (fileName, extraFileExtensions) { return ts.some(extraFileExtensions, function (ext) { return ext.isMixedContent && ts.fileExtensionIs(fileName, ext.extension); }); }, + isDynamicFile: function (x) { return x[0] === "^"; }, }; var externalFilePropertyReader = { getFileName: function (x) { return x.fileName; }, getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, - hasMixedContent: function (x) { return x.hasMixedContent; } + hasMixedContent: function (x) { return x.hasMixedContent; }, + isDynamicFile: function (x) { return x.fileName[0] === "^"; }, }; function findProjectByName(projectName, projects) { for (var _i = 0, projects_1 = projects; _i < projects_1.length; _i++) { @@ -80747,7 +81392,8 @@ var ts; var _this = this; var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + var filesToAdd = projectOptions.files.concat(project.getExternalFiles()); + this.addFilesToProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); if (!sizeLimitExceeded) { this.watchConfigDirectoryForProject(project, projectOptions); @@ -80768,15 +81414,16 @@ var ts; var errors; for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { var f = files_4[_i]; - var rootFilename = propertyReader.getFileName(f); + var rootFileName = propertyReader.getFileName(f); var scriptKind = propertyReader.getScriptKind(f); var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - if (this.host.fileExists(rootFilename)) { - var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName === rootFilename, undefined, scriptKind, hasMixedContent); + var isDynamicFile = propertyReader.isDynamicFile(f); + if (isDynamicFile || this.host.fileExists(rootFileName)) { + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFileName), clientFileName === rootFileName, undefined, scriptKind, hasMixedContent, isDynamicFile); project.addRoot(info); } else { - (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFileName)); } } project.setProjectErrors(ts.concatenate(configFileErrors, errors)); @@ -80804,7 +81451,8 @@ var ts; for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { var f = newUncheckedFiles_1[_i]; var newRootFile = propertyReader.getFileName(f); - if (!this.host.fileExists(newRootFile)) { + var isDynamic = propertyReader.isDynamicFile(f); + if (!isDynamic && !this.host.fileExists(newRootFile)) { (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); continue; } @@ -80815,7 +81463,7 @@ var ts; if (!scriptInfo) { var scriptKind = propertyReader.getScriptKind(f); var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent, isDynamic); } } newRootScriptInfos.push(scriptInfo); @@ -80954,16 +81602,16 @@ var ts; }; ProjectService.prototype.watchClosedScriptInfo = function (info) { var _this = this; - if (!info.hasMixedContent) { + if (!info.hasMixedContent && !info.isDynamic) { var fileName_2 = info.fileName; info.setWatcher(this.host.watchFile(fileName_2, function (_) { return _this.onSourceFileChanged(fileName_2); })); } }; - ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { + ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent, isDynamic) { var info = this.getScriptInfoForNormalizedPath(fileName); if (!info) { - if (openedByClient || this.host.fileExists(fileName)) { - info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent); + if (openedByClient || isDynamic || this.host.fileExists(fileName)) { + info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent, isDynamic); this.filenameToScriptInfo.set(info.path, info); if (openedByClient) { if (fileContent === undefined) { @@ -81112,7 +81760,7 @@ var ts; for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { var file = openFiles_1[_i]; var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen()); + ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already"); var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); } @@ -81150,7 +81798,9 @@ var ts; var configuredProject = this.findConfiguredProjectByProjectName(configFile); if (configuredProject && configuredProject.deleteOpenRef() === 0) { this.removeProject(configuredProject); + return true; } + return false; }; ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { if (suppressRefresh === void 0) { suppressRefresh = false; } @@ -81447,8 +82097,8 @@ var ts; { start: start, end: end, text: text, code: code, category: category, source: source }; } function allEditsBeforePos(edits, pos) { - for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var edit = edits_1[_i]; + for (var _i = 0, edits_2 = edits; _i < edits_2.length; _i++) { + var edit = edits_2[_i]; if (ts.textSpanEnd(edit.span) >= pos) { return false; } @@ -81929,7 +82579,7 @@ var ts; }; Session.prototype.semanticCheck = function (file, project) { try { - var diags = []; + var diags = server.emptyArray; if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } @@ -82617,12 +83267,12 @@ var ts; return undefined; } if (simplifiedResult) { - var span_17 = helpItems.applicableSpan; + var span_18 = helpItems.applicableSpan; return { items: helpItems.items, applicableSpan: { - start: scriptInfo.positionToLineOffset(span_17.start), - end: scriptInfo.positionToLineOffset(span_17.start + span_17.length) + start: scriptInfo.positionToLineOffset(span_18.start), + end: scriptInfo.positionToLineOffset(span_18.start + span_18.length) }, selectedItemIndex: helpItems.selectedItemIndex, argumentIndex: helpItems.argumentIndex, @@ -82824,7 +83474,7 @@ var ts; var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var _b = this.extractPositionAndRange(args, scriptInfo), position = _b.position, textRange = _b.textRange; - var result = project.getLanguageService().getEditsForRefactor(file, this.projectService.getFormatCodeOptions(), position || textRange, args.refactor, args.action); + var result = project.getLanguageService().getEditsForRefactor(file, args.formatOptions ? server.convertFormatOptions(args.formatOptions) : this.projectService.getFormatCodeOptions(), position || textRange, args.refactor, args.action); if (result === undefined) { return { edits: [] @@ -82928,6 +83578,9 @@ var ts; return; } var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); + if (fileNamesInProject.length === 0) { + return; + } var highPriorityFiles = []; var mediumPriorityFiles = []; var lowPriorityFiles = []; @@ -82942,7 +83595,7 @@ var ts; else { var info = this.projectService.getScriptInfo(fileNameInProject); if (!info.isScriptOpen()) { - if (fileNameInProject.indexOf(".d.ts") > 0) { + if (ts.fileExtensionIs(fileNameInProject, ".d.ts")) { veryLowPriorityFiles.push(fileNameInProject); } else { @@ -82954,11 +83607,9 @@ var ts; } } } - fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); - if (fileNamesInProject.length > 0) { - var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(next, checkList, delay, false); - } + var sortedFiles = highPriorityFiles.concat(mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); + var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); + this.updateErrorCheck(next, checkList, delay, false); }; Session.prototype.getCanonicalFileName = function (fileName) { var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); @@ -83927,13 +84578,16 @@ var ts; var _this = this; this.telemetryEnabled = telemetryEnabled; this.logger = logger; + this.host = host; this.globalTypingsCacheLocation = globalTypingsCacheLocation; this.typingSafeListLocation = typingSafeListLocation; this.typesMapLocation = typesMapLocation; this.npmLocation = npmLocation; this.newLine = newLine; this.installerPidReported = false; - this.throttledOperations = new server.ThrottledOperations(host); + this.activeRequestCount = 0; + this.requestQueue = []; + this.requestMap = ts.createMap(); if (eventPort) { var s_1 = net.connect({ port: eventPort }, function () { _this.socket = s_1; @@ -84008,70 +84662,124 @@ var ts; this.logger.info("Scheduling throttled operation: " + JSON.stringify(request)); } } - this.throttledOperations.schedule(project.getProjectName(), 250, function () { + var operationId = project.getProjectName(); + var operation = function () { if (_this.logger.hasLevel(server.LogLevel.verbose)) { _this.logger.info("Sending request: " + JSON.stringify(request)); } _this.installer.send(request); - }); + }; + var queuedRequest = { operationId: operationId, operation: operation }; + if (this.activeRequestCount < NodeTypingsInstaller.maxActiveRequestCount) { + this.scheduleRequest(queuedRequest); + } + else { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Deferring request for: " + operationId); + } + this.requestQueue.push(queuedRequest); + this.requestMap.set(operationId, queuedRequest); + } }; NodeTypingsInstaller.prototype.handleMessage = function (response) { if (this.logger.hasLevel(server.LogLevel.verbose)) { this.logger.info("Received response: " + JSON.stringify(response)); } - if (response.kind === server.EventInitializationFailed) { - if (!this.eventSender) { - return; - } - var body = { - message: response.message - }; - var eventName = "typesInstallerInitializationFailed"; - this.eventSender.event(body, eventName); - return; - } - if (response.kind === server.EventBeginInstallTypes) { - if (!this.eventSender) { - return; - } - var body = { - eventId: response.eventId, - packages: response.packagesToInstall, - }; - var eventName = "beginInstallTypes"; - this.eventSender.event(body, eventName); - return; - } - if (response.kind === server.EventEndInstallTypes) { - if (!this.eventSender) { - return; - } - if (this.telemetryEnabled) { - var body_1 = { - telemetryEventName: "typingsInstalled", - payload: { - installedPackages: response.packagesToInstall.join(","), - installSuccess: response.installSuccess, - typingsInstallerVersion: response.typingsInstallerVersion + switch (response.kind) { + case server.EventInitializationFailed: + { + if (!this.eventSender) { + break; } - }; - var eventName_1 = "telemetry"; - this.eventSender.event(body_1, eventName_1); - } - var body = { - eventId: response.eventId, - packages: response.packagesToInstall, - success: response.installSuccess, - }; - var eventName = "endInstallTypes"; - this.eventSender.event(body, eventName); - return; - } - this.projectService.updateTypingsForProject(response); - if (response.kind === server.ActionSet && this.socket) { - this.sendEvent(0, "setTypings", response); + var body = { + message: response.message + }; + var eventName = "typesInstallerInitializationFailed"; + this.eventSender.event(body, eventName); + break; + } + case server.EventBeginInstallTypes: + { + if (!this.eventSender) { + break; + } + var body = { + eventId: response.eventId, + packages: response.packagesToInstall, + }; + var eventName = "beginInstallTypes"; + this.eventSender.event(body, eventName); + break; + } + case server.EventEndInstallTypes: + { + if (!this.eventSender) { + break; + } + if (this.telemetryEnabled) { + var body_1 = { + telemetryEventName: "typingsInstalled", + payload: { + installedPackages: response.packagesToInstall.join(","), + installSuccess: response.installSuccess, + typingsInstallerVersion: response.typingsInstallerVersion + } + }; + var eventName_1 = "telemetry"; + this.eventSender.event(body_1, eventName_1); + } + var body = { + eventId: response.eventId, + packages: response.packagesToInstall, + success: response.installSuccess, + }; + var eventName = "endInstallTypes"; + this.eventSender.event(body, eventName); + break; + } + case server.ActionInvalidate: + { + this.projectService.updateTypingsForProject(response); + break; + } + case server.ActionSet: + { + if (this.activeRequestCount > 0) { + this.activeRequestCount--; + } + else { + ts.Debug.fail("Received too many responses"); + } + while (this.requestQueue.length > 0) { + var queuedRequest = this.requestQueue.shift(); + if (this.requestMap.get(queuedRequest.operationId) === queuedRequest) { + this.requestMap.delete(queuedRequest.operationId); + this.scheduleRequest(queuedRequest); + break; + } + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Skipping defunct request for: " + queuedRequest.operationId); + } + } + this.projectService.updateTypingsForProject(response); + if (this.socket) { + this.sendEvent(0, "setTypings", response); + } + break; + } + default: + ts.assertTypeIsNever(response); } }; + NodeTypingsInstaller.prototype.scheduleRequest = function (request) { + if (this.logger.hasLevel(server.LogLevel.verbose)) { + this.logger.info("Scheduling request for: " + request.operationId); + } + this.activeRequestCount++; + this.host.setTimeout(request.operation, NodeTypingsInstaller.requestDelayMillis); + }; + NodeTypingsInstaller.maxActiveRequestCount = 10; + NodeTypingsInstaller.requestDelayMillis = 100; return NodeTypingsInstaller; }()); var IOSession = (function (_super) { @@ -84176,7 +84884,6 @@ var ts; if (chunkSize === void 0) { chunkSize = 30; } var watchedFiles = []; var nextFileToCheck = 0; - var watchTimer; return { getModifiedTime: getModifiedTime, poll: poll, startWatchTimer: startWatchTimer, addFile: addFile, removeFile: removeFile }; function getModifiedTime(fileName) { return fs.statSync(fileName).mtime; @@ -84206,7 +84913,7 @@ var ts; }); } function startWatchTimer() { - watchTimer = setInterval(function () { + setInterval(function () { var count = 0; var nextToCheck = nextFileToCheck; var firstCheck = -1; diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 513d8079a40..01827a24d0a 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -435,6 +435,9 @@ declare namespace ts { modifiers?: ModifiersArray; parent?: Node; } + interface JSDocContainer { + } + type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken; interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } @@ -447,7 +450,7 @@ declare namespace ts { type EqualsToken = Token; type AsteriskToken = Token; type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token; + type EndOfFileToken = Token & JSDocContainer; type AtToken = Token; type ReadonlyToken = Token; type AwaitKeywordToken = Token; @@ -485,6 +488,7 @@ declare namespace ts { } interface Decorator extends Node { kind: SyntaxKind.Decorator; + parent?: NamedDeclaration; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends NamedDeclaration { @@ -495,16 +499,18 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclaration extends NamedDeclaration { + interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; - type?: TypeNode; + type: TypeNode | undefined; } - interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } type BindingName = Identifier | BindingPattern; @@ -520,7 +526,7 @@ declare namespace ts { parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration { + interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -537,14 +543,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement { + interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement { + interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; questionToken?: QuestionToken; name: PropertyName; @@ -556,27 +562,30 @@ declare namespace ts { name?: PropertyName; } type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement { + interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement { + interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement { + interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } interface VariableLikeDeclaration extends NamedDeclaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; - name?: DeclarationName; + name: DeclarationName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; @@ -596,7 +605,7 @@ declare namespace ts { } type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; type ArrayBindingElement = BindingElement | OmittedExpression; - interface FunctionLikeDeclarationBase extends SignatureDeclaration { + interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; @@ -609,16 +618,16 @@ declare namespace ts { name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclaration, TypeElement { + interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement { + interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; @@ -627,20 +636,20 @@ declare namespace ts { kind: SyntaxKind.SemicolonClassElement; parent?: ClassDeclaration | ClassExpression; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { + interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } @@ -654,10 +663,10 @@ declare namespace ts { kind: SyntaxKind.ThisType; } type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionTypeNode extends TypeNode, SignatureDeclaration { + interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { + interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; @@ -668,6 +677,7 @@ declare namespace ts { } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; + parent?: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } @@ -712,7 +722,6 @@ declare namespace ts { } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; - parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -720,7 +729,7 @@ declare namespace ts { } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; - literal: Expression; + literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; @@ -854,12 +863,12 @@ declare namespace ts { } type FunctionBody = Block; type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase { + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase { + interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; @@ -905,7 +914,7 @@ declare namespace ts { expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression { + interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } @@ -915,6 +924,7 @@ declare namespace ts { } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; + parent?: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { @@ -1072,11 +1082,11 @@ declare namespace ts { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement { + interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement { + interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } @@ -1157,7 +1167,7 @@ declare namespace ts { statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement { + interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; @@ -1179,19 +1189,21 @@ declare namespace ts { block: Block; } type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclaration extends NamedDeclaration { + interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; name?: Identifier; } - interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } + type ClassLikeDeclaration = ClassDeclaration | ClassExpression; interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; @@ -1201,7 +1213,7 @@ declare namespace ts { name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement { + interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; @@ -1214,26 +1226,26 @@ declare namespace ts { token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement { + interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration { + interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent?: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement { + interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } type ModuleName = Identifier | StringLiteral; type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement { + interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent?: ModuleBody | SourceFile; name: ModuleName; @@ -1255,7 +1267,7 @@ declare namespace ts { statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; - interface ImportEqualsDeclaration extends DeclarationStatement { + interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent?: SourceFile | ModuleBlock; name: Identifier; @@ -1365,7 +1377,7 @@ declare namespace ts { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } interface JSDocVariadicType extends JSDocType { @@ -1375,6 +1387,7 @@ declare namespace ts { type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; + parent?: HasJSDoc; tags: NodeArray | undefined; comment: string | undefined; } @@ -1429,7 +1442,6 @@ declare namespace ts { interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; jsDocPropertyTags?: ReadonlyArray; - jsDocTypeTag?: JSDocTypeTag; isArrayType?: boolean; } const enum FlowFlags { @@ -1503,10 +1515,10 @@ declare namespace ts { endOfFileToken: Token; fileName: string; text: string; - amdDependencies: AmdDependency[]; + amdDependencies: ReadonlyArray; moduleName: string; - referencedFiles: FileReference[]; - typeReferenceDirectives: FileReference[]; + referencedFiles: ReadonlyArray; + typeReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; isDeclarationFile: boolean; hasNoDefaultLib: boolean; @@ -1514,7 +1526,7 @@ declare namespace ts { } interface Bundle extends Node { kind: SyntaxKind.Bundle; - sourceFiles: SourceFile[]; + sourceFiles: ReadonlyArray; } interface JsonSourceFile extends SourceFile { jsonObject?: ObjectLiteralExpression; @@ -1533,7 +1545,7 @@ declare namespace ts { readFile(path: string): string | undefined; } interface WriteFileCallback { - (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray): void; + (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray): void; } class OperationCanceledException { } @@ -1542,15 +1554,16 @@ declare namespace ts { throwIfCancellationRequested(): void; } interface Program extends ScriptReferenceHost { - getRootFileNames(): string[]; - getSourceFiles(): SourceFile[]; + getRootFileNames(): ReadonlyArray; + getSourceFiles(): ReadonlyArray; emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; getTypeChecker(): TypeChecker; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; } interface CustomTransformers { before?: TransformerFactory[]; @@ -1583,7 +1596,7 @@ declare namespace ts { } interface EmitResult { emitSkipped: boolean; - diagnostics: Diagnostic[]; + diagnostics: ReadonlyArray; emittedFiles: string[]; } interface TypeChecker { @@ -1857,6 +1870,7 @@ declare namespace ts { IndexedAccess = 524288, NonPrimitive = 16777216, Literal = 224, + Unit = 6368, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, StringLike = 262178, @@ -2032,7 +2046,7 @@ declare namespace ts { interface PluginImport { name: string; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | null | undefined; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; @@ -2199,6 +2213,7 @@ declare namespace ts { } interface PackageId { name: string; + subModuleName: string; version: string; } const enum Extension { @@ -2214,14 +2229,15 @@ declare namespace ts { interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName?: string; + packageId?: PackageId; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective; failedLookupLocations: string[]; } interface CompilerHost extends ModuleResolutionHost { - getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined; + getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined; getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; getDefaultLibLocation?(): string; @@ -2283,7 +2299,8 @@ declare namespace ts { SourceFile = 0, Expression = 1, IdentifierName = 2, - Unspecified = 3, + MappedTypeParameter = 3, + Unspecified = 4, } interface TransformationContext { getCompilerOptions(): CompilerOptions; @@ -2343,6 +2360,9 @@ declare namespace ts { const versionMajorMinor = "2.6"; const version: string; } +declare namespace ts { + function isExternalModuleNameRelative(moduleName: string): boolean; +} declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { @@ -2433,7 +2453,18 @@ declare namespace ts { function getParseTreeNode(node: Node, nodeTest?: (node: Node) => node is T): T; function unescapeLeadingUnderscores(identifier: __String): string; function unescapeIdentifier(id: string): string; - function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined; + function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray | undefined; + function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean; + function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined; + function getJSDocClassTag(node: Node): JSDocClassTag | undefined; + function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined; + function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined; + function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined; + function getJSDocType(node: Node): TypeNode | undefined; + function getJSDocReturnType(node: Node): TypeNode | undefined; + function getJSDocTags(node: Node): ReadonlyArray | undefined; } declare namespace ts { function isNumericLiteral(node: Node): node is NumericLiteral; @@ -2805,8 +2836,8 @@ declare namespace ts { function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; - function createLiteralTypeNode(literal: Expression): LiteralTypeNode; - function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode; + function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; + function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; @@ -2835,6 +2866,7 @@ declare namespace ts { function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -2852,8 +2884,13 @@ declare namespace ts { function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; + function createTemplateHead(text: string): TemplateHead; + function createTemplateMiddle(text: string): TemplateMiddle; + function createTemplateTail(text: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; @@ -2992,10 +3029,12 @@ declare namespace ts { function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; function createCommaList(elements: ReadonlyArray): CommaListExpression; function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: SourceFile[]): Bundle; - function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; + function createBundle(sourceFiles: ReadonlyArray): Bundle; + function updateBundle(node: Bundle, sourceFiles: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression; function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -3062,10 +3101,10 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; + function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; + function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { interface Node { @@ -3121,7 +3160,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): number[]; + getLineStarts(): ReadonlyArray; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -3273,15 +3312,15 @@ declare namespace ts { inlineable?: boolean; actions: RefactorActionInfo[]; } - type RefactorActionInfo = { + interface RefactorActionInfo { name: string; description: string; - }; - type RefactorEditInfo = { + } + interface RefactorEditInfo { edits: FileTextChanges[]; - renameFilename?: string; - renameLocation?: number; - }; + renameFilename: string | undefined; + renameLocation: number | undefined; + } interface TextInsertion { newText: string; caretOffset: number; @@ -4041,10 +4080,10 @@ declare namespace ts.server.protocol { inlineable?: boolean; actions: RefactorActionInfo[]; } - type RefactorActionInfo = { + interface RefactorActionInfo { name: string; description: string; - }; + } interface GetEditsForRefactorRequest extends Request { command: CommandTypes.GetEditsForRefactor; arguments: GetEditsForRefactorRequestArgs; @@ -4052,15 +4091,16 @@ declare namespace ts.server.protocol { type GetEditsForRefactorRequestArgs = FileLocationOrRangeRequestArgs & { refactor: string; action: string; + formatOptions?: FormatCodeSettings; }; interface GetEditsForRefactorResponse extends Response { body?: RefactorEditInfo; } - type RefactorEditInfo = { + interface RefactorEditInfo { edits: FileCodeEdits[]; renameLocation?: Location; renameFilename?: string; - }; + } interface CodeFixRequest extends Request { command: CommandTypes.GetCodeFixes; arguments: CodeFixRequestArgs; @@ -4943,13 +4983,14 @@ declare namespace ts.server { readonly fileName: NormalizedPath; readonly scriptKind: ScriptKind; hasMixedContent: boolean; + isDynamic: boolean; readonly containingProjects: Project[]; private formatCodeSettings; readonly path: Path; private fileWatcher; private textStorage; private isOpen; - constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean); + constructor(host: ServerHost, fileName: NormalizedPath, scriptKind: ScriptKind, hasMixedContent?: boolean, isDynamic?: boolean); isScriptOpen(): boolean; open(newText: string): void; close(): void; @@ -5295,7 +5336,7 @@ declare namespace ts.server { interface SafeList { [name: string]: { match: RegExp; - exclude?: Array>; + exclude?: (string | number)[][]; types?: string[]; }; } @@ -5412,7 +5453,7 @@ declare namespace ts.server { getOrCreateScriptInfo(uncheckedFileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind): ScriptInfo; getScriptInfo(uncheckedFileName: string): ScriptInfo; watchClosedScriptInfo(info: ScriptInfo): void; - getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): ScriptInfo; + getOrCreateScriptInfoForNormalizedPath(fileName: NormalizedPath, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, isDynamic?: boolean): ScriptInfo; getScriptInfoForNormalizedPath(fileName: NormalizedPath): ScriptInfo; getScriptInfoForPath(fileName: Path): ScriptInfo; setHostConfiguration(args: protocol.ConfigureRequestArguments): void; diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 263796daa7a..cbc35cf1876 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -705,6 +705,7 @@ var ts; TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 6368] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; @@ -1065,6 +1066,7 @@ var ts; EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; + EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); var ExternalEmitHelpers; (function (ExternalEmitHelpers) { @@ -1097,7 +1099,8 @@ var ts; EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; EmitHint[EmitHint["Expression"] = 1] = "Expression"; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; - EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; + EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; @@ -1164,6 +1167,12 @@ var ts; ts.versionMajorMinor = "2.6"; ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); +(function (ts) { + function isExternalModuleNameRelative(moduleName) { + return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; +})(ts || (ts = {})); (function (ts) { ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; @@ -1795,6 +1804,26 @@ var ts; return to; } ts.addRange = addRange; + function pushIfUnique(array, toAdd) { + if (contains(array, toAdd)) { + return false; + } + else { + array.push(toAdd); + return true; + } + } + ts.pushIfUnique = pushIfUnique; + function appendIfUnique(array, toAdd) { + if (array) { + pushIfUnique(array, toAdd); + return array; + } + else { + return [toAdd]; + } + } + ts.appendIfUnique = appendIfUnique; function stableSort(array, comparer) { if (comparer === void 0) { comparer = compareValues; } return array @@ -1941,6 +1970,16 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getOwnValues(sparseArray) { + var values = []; + for (var key in sparseArray) { + if (hasOwnProperty.call(sparseArray, key)) { + values.push(sparseArray[key]); + } + } + return values; + } + ts.getOwnValues = getOwnValues; function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { @@ -2105,6 +2144,8 @@ var ts; ts.cast = cast; function noop() { } ts.noop = noop; + function identity(x) { return x; } + ts.identity = identity; function notImplemented() { throw new Error("Not implemented"); } @@ -2181,12 +2222,11 @@ var ts; } ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { - var end = start + length; Debug.assertGreaterThanOrEqual(start, 0); Debug.assertGreaterThanOrEqual(length, 0); if (file) { Debug.assertLessThanOrEqual(start, file.text.length); - Debug.assertLessThanOrEqual(end, file.text.length); + Debug.assertLessThanOrEqual(start + length, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2428,12 +2468,8 @@ var ts; return /^\.\.?($|[\\/])/.test(path); } ts.pathIsRelative = pathIsRelative; - function isExternalModuleNameRelative(moduleName) { - return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function moduleHasNonRelativeName(moduleName) { - return !isExternalModuleNameRelative(moduleName); + return !ts.isExternalModuleNameRelative(moduleName); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; function getEmitScriptTarget(compilerOptions) { @@ -2470,7 +2506,7 @@ var ts; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { @@ -3096,6 +3132,10 @@ var ts; throw e; } Debug.fail = fail; + function assertNever(member, message, stackCrawlMark) { + return fail(message || "Illegal value: " + member, stackCrawlMark || assertNever); + } + Debug.assertNever = assertNever; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -3233,6 +3273,12 @@ var ts; return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; + function and(f, g) { + return function (arg) { return f(arg) && g(arg); }; + } + ts.and = and; + function assertTypeIsNever(_) { } + ts.assertTypeIsNever = assertTypeIsNever; })(ts || (ts = {})); var ts; (function (ts) { @@ -3797,8 +3843,8 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asteri_1202", "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_defaul_1203", "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), @@ -4118,7 +4164,9 @@ var ts; Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), - Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), + Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."), + The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, ts.DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4191,6 +4239,7 @@ var ts; A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"), + The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -4308,7 +4357,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), - Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), + Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."), @@ -4413,17 +4462,16 @@ var ts; Resolving_real_path_for_0_result_1: diag(6130, ts.DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."), Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, ts.DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."), File_name_0_has_a_1_extension_stripping_it: diag(6132, ts.DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."), - _0_is_declared_but_never_used: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6133", "'{0}' is declared but never used."), + _0_is_declared_but_its_value_is_never_read: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read."), Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."), Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."), The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, ts.DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."), Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, ts.DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."), - Property_0_is_declared_but_never_used: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_never_used_6138", "Property '{0}' is declared but never used."), + Property_0_is_declared_but_its_value_is_never_read: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read."), Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."), Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, ts.DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."), Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, ts.DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."), Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."), - Module_0_was_resolved_to_1_but_allowJs_is_not_set: diag(6143, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", "Module '{0}' was resolved to '{1}', but '--allowJs' is not set."), Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."), Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."), Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."), @@ -4514,6 +4562,7 @@ var ts; Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."), Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."), JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, ts.DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."), + JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, ts.DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."), Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), @@ -4561,7 +4610,7 @@ var ts; Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), - Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), + Extract_to_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_95004", "Extract to {0}"), }; })(ts || (ts = {})); var ts; @@ -4583,7 +4632,6 @@ var ts; } ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriter = createSingleLineStringWriter(); - var stringWriterAcquired = false; function createSingleLineStringWriter() { var str = ""; var writeText = function (text) { return str += text; }; @@ -4607,15 +4655,14 @@ var ts; }; } function usingSingleLineStringWriter(action) { + var oldString = stringWriter.string(); try { - ts.Debug.assert(!stringWriterAcquired); - stringWriterAcquired = true; action(stringWriter); return stringWriter.string(); } finally { stringWriter.clear(); - stringWriterAcquired = false; + stringWriter.writeKeyword(oldString); } } ts.usingSingleLineStringWriter = usingSingleLineStringWriter; @@ -4649,7 +4696,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.version === b.version; + return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; @@ -4771,7 +4818,7 @@ var ts; if (ts.isJSDocNode(node)) { return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } if (node.kind === 286 && node._children.length > 0) { @@ -4808,6 +4855,15 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; + function indexOfNode(nodeArray, node) { + return ts.binarySearch(nodeArray, node, compareNodePos); + } + ts.indexOfNode = indexOfNode; + function compareNodePos(_a, _b) { + var aPos = _a.pos; + var bPos = _b.pos; + return aPos < bPos ? -1 : bPos < aPos ? 1 : 0; + } function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -4835,6 +4891,7 @@ var ts; case 16: return "}" + escapeText(node.text, 96) + "`"; case 8: + case 12: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -4932,6 +4989,34 @@ var ts; return false; } ts.isBlockScope = isBlockScope; + function isDeclarationWithTypeParameters(node) { + switch (node.kind) { + case 155: + case 156: + case 150: + case 157: + case 160: + case 161: + case 273: + case 229: + case 199: + case 230: + case 231: + case 282: + case 228: + case 151: + case 152: + case 153: + case 154: + case 186: + case 187: + return true; + default: + ts.assertTypeIsNever(node); + return false; + } + } + ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function getEnclosingBlockScopeContainer(node) { var current = node.parent; while (current) { @@ -5579,59 +5664,62 @@ var ts; case 8: case 9: case 99: - var parent_3 = node.parent; - switch (parent_3.kind) { - case 226: - case 146: - case 149: - case 148: - case 264: - case 261: - case 176: - return parent_3.initializer === node; - case 210: - case 211: - case 212: - case 213: - case 219: - case 220: - case 221: - case 257: - case 223: - return parent_3.expression === node; - case 214: - var forStatement = parent_3; - return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || - forStatement.condition === node || - forStatement.incrementor === node; - case 215: - case 216: - var forInStatement = parent_3; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || - forInStatement.expression === node; - case 184: - case 202: - return node === parent_3.expression; - case 205: - return node === parent_3.expression; - case 144: - return node === parent_3.expression; - case 147: - case 256: - case 255: - case 263: - return true; - case 201: - return parent_3.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent_3); - default: - if (isPartOfExpression(parent_3)) { - return true; - } - } + return isInExpressionContext(node); + default: + return false; } - return false; } ts.isPartOfExpression = isPartOfExpression; + function isInExpressionContext(node) { + var parent = node.parent; + switch (parent.kind) { + case 226: + case 146: + case 149: + case 148: + case 264: + case 261: + case 176: + return parent.initializer === node; + case 210: + case 211: + case 212: + case 213: + case 219: + case 220: + case 221: + case 257: + case 223: + return parent.expression === node; + case 214: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || + forStatement.condition === node || + forStatement.incrementor === node; + case 215: + case 216: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || + forInStatement.expression === node; + case 184: + case 202: + return node === parent.expression; + case 205: + return node === parent.expression; + case 144: + return node === parent.expression; + case 147: + case 256: + case 255: + case 263: + return true; + case 201: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + return isPartOfExpression(parent); + } + } + ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { return node.kind === 237 && node.moduleReference.kind === 248; } @@ -5795,14 +5883,6 @@ var ts; node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function hasJSDocParameterTags(node) { - return !!getFirstJSDocTag(node, 279); - } - ts.hasJSDocParameterTags = hasJSDocParameterTags; - function getFirstJSDocTag(node, kind) { - var tags = getJSDocTags(node); - return ts.find(tags, function (doc) { return doc.kind === kind; }); - } function getAllJSDocs(node) { if (ts.isJSDocTypedefTag(node)) { return [node.parent]; @@ -5810,14 +5890,6 @@ var ts; return getJSDocCommentsAndTags(node); } ts.getAllJSDocs = getAllJSDocs; - function getJSDocTags(node) { - var tags = node.jsDocCache; - if (tags === undefined) { - node.jsDocCache = tags = ts.flatMap(getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); - } - return tags; - } - ts.getJSDocTags = getJSDocTags; function getJSDocCommentsAndTags(node) { var result; getJSDocCommentsAndTagsWorker(node); @@ -5849,22 +5921,17 @@ var ts; getJSDocCommentsAndTagsWorker(parent); } if (node.kind === 146) { - result = ts.addRange(result, getJSDocParameterTags(node)); + result = ts.addRange(result, ts.getJSDocParameterTags(node)); } - if (isVariableLike(node) && node.initializer) { + if (isVariableLike(node) && node.initializer && ts.hasJSDocNodes(node.initializer)) { result = ts.addRange(result, node.initializer.jsDoc); } - result = ts.addRange(result, node.jsDoc); + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); + } } } - function getJSDocParameterTags(param) { - if (param.name && ts.isIdentifier(param.name)) { - var name_5 = param.name.escapedText; - return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_5; }); - } - return undefined; - } - ts.getJSDocParameterTags = getJSDocParameterTags; + ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getParameterSymbolFromJSDoc(node) { if (node.symbol) { return node.symbol; @@ -5890,38 +5957,6 @@ var ts; return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; - function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 281); - if (!tag && node.kind === 146) { - var paramTags = getJSDocParameterTags(node); - if (paramTags) { - tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); - } - } - return tag && tag.typeExpression && tag.typeExpression.type; - } - ts.getJSDocType = getJSDocType; - function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 277); - } - ts.getJSDocAugmentsTag = getJSDocAugmentsTag; - function getJSDocClassTag(node) { - return getFirstJSDocTag(node, 278); - } - ts.getJSDocClassTag = getJSDocClassTag; - function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 280); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocReturnType(node) { - var returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - ts.getJSDocReturnType = getJSDocReturnType; - function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 282); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { return isRestParameter(ts.lastOrUndefined(s.parameters)); } @@ -5933,7 +5968,7 @@ var ts; function isRestParameter(node) { if (isInJavaScriptFile(node)) { if (node.type && node.type.kind === 274 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274; })) { + ts.forEach(ts.getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274; })) { return true; } } @@ -6334,9 +6369,9 @@ var ts; || kind === 265; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); + function nodeIsSynthesized(range) { + return ts.positionIsSynthesized(range.pos) + || ts.positionIsSynthesized(range.end); } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFile(sourceFile) { @@ -6600,13 +6635,17 @@ var ts; "\u2029": "\\u2029", "\u0085": "\\u0085" }); + var escapedNullRegExp = /\\0[0-9]/g; function escapeString(s, quoteChar) { var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp : quoteChar === 39 ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; - return s.replace(escapedCharsRegExp, getReplacement); + return s.replace(escapedCharsRegExp, getReplacement).replace(escapedNullRegExp, nullReplacement); } ts.escapeString = escapeString; + function nullReplacement(c) { + return "\\x00" + c.charAt(c.length - 1); + } function getReplacement(c) { return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } @@ -6886,7 +6925,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocType(node); + return ts.getJSDocType(node); } } ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode; @@ -6895,7 +6934,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocReturnType(node); + return ts.getJSDocReturnType(node); } } ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode; @@ -6904,7 +6943,7 @@ var ts; return node.typeParameters; } if (isInJavaScriptFile(node)) { - var templateTag = getJSDocTemplateTag(node); + var templateTag = ts.getJSDocTemplateTag(node); return templateTag && templateTag.typeParameters; } } @@ -7293,10 +7332,10 @@ var ts; } function getEnumMembers(enumObject) { var result = []; - for (var name_6 in enumObject) { - var value = enumObject[name_6]; + for (var name_5 in enumObject) { + var value = enumObject[name_5]; if (typeof value === "number") { - result.push([value, name_6]); + result.push([value, name_5]); } } return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); }); @@ -7463,6 +7502,41 @@ var ts; return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; + function isWriteOnlyAccess(node) { + return accessKind(node) === 1; + } + ts.isWriteOnlyAccess = isWriteOnlyAccess; + function isWriteAccess(node) { + return accessKind(node) !== 0; + } + ts.isWriteAccess = isWriteAccess; + var AccessKind; + (function (AccessKind) { + AccessKind[AccessKind["Read"] = 0] = "Read"; + AccessKind[AccessKind["Write"] = 1] = "Write"; + AccessKind[AccessKind["ReadWrite"] = 2] = "ReadWrite"; + })(AccessKind || (AccessKind = {})); + function accessKind(node) { + var parent = node.parent; + if (!parent) + return 0; + switch (parent.kind) { + case 193: + case 192: + var operator = parent.operator; + return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; + case 194: + var _a = parent, left = _a.left, operatorToken = _a.operatorToken; + return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; + case 179: + return parent.name !== node ? 0 : accessKind(parent); + default: + return 0; + } + function writeOrReadWrite() { + return parent.parent && parent.parent.kind === 210 ? 1 : 2; + } + } })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -7741,6 +7815,56 @@ var ts; return id; } ts.unescapeIdentifier = unescapeIdentifier; + function nameForNamelessJSDocTypedef(declaration) { + var hostNode = declaration.parent.parent; + if (!hostNode) { + return undefined; + } + if (ts.isDeclaration(hostNode)) { + return getDeclarationIdentifier(hostNode); + } + switch (hostNode.kind) { + case 208: + if (hostNode.declarationList && + hostNode.declarationList.declarations[0]) { + return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); + } + return undefined; + case 210: + var expr = hostNode.expression; + switch (expr.kind) { + case 179: + return expr.name; + case 180: + var arg = expr.argumentExpression; + if (ts.isIdentifier(arg)) { + return arg; + } + } + return undefined; + case 1: + return undefined; + case 185: { + return getDeclarationIdentifier(hostNode.expression); + } + case 222: { + if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { + return getDeclarationIdentifier(hostNode.statement); + } + return undefined; + } + default: + ts.Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!"); + } + } + function getDeclarationIdentifier(node) { + var name = getNameOfDeclaration(node); + return ts.isIdentifier(name) ? name : undefined; + } + function getNameOfJSDocTypedef(declaration) { + return declaration.name || nameForNamelessJSDocTypedef(declaration); + } + ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef; function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; @@ -7760,11 +7884,78 @@ var ts; return undefined; } } + else if (declaration.kind === 283) { + return getNameOfJSDocTypedef(declaration); + } else { return declaration.name; } } ts.getNameOfDeclaration = getNameOfDeclaration; + function getJSDocParameterTags(param) { + if (param.name && ts.isIdentifier(param.name)) { + var name_6 = param.name.escapedText; + return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_6; }); + } + return undefined; + } + ts.getJSDocParameterTags = getJSDocParameterTags; + function hasJSDocParameterTags(node) { + return !!getFirstJSDocTag(node, 279); + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 277); + } + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + function getJSDocClassTag(node) { + return getFirstJSDocTag(node, 278); + } + ts.getJSDocClassTag = getJSDocClassTag; + function getJSDocReturnTag(node) { + return getFirstJSDocTag(node, 280); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getFirstJSDocTag(node, 282); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getJSDocTypeTag(node) { + var tag = getFirstJSDocTag(node, 281); + if (tag && tag.typeExpression && tag.typeExpression.type) { + return tag; + } + return undefined; + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 281); + if (!tag && node.kind === 146) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + function getJSDocReturnType(node) { + var returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + ts.getJSDocReturnType = getJSDocReturnType; + function getJSDocTags(node) { + var tags = node.jsDocCache; + if (tags === undefined) { + node.jsDocCache = tags = ts.flatMap(ts.getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); + } + return tags; + } + ts.getJSDocTags = getJSDocTags; + function getFirstJSDocTag(node, kind) { + var tags = getJSDocTags(node); + return ts.find(tags, function (doc) { return doc.kind === kind; }); + } })(ts || (ts = {})); (function (ts) { function isNumericLiteral(node) { @@ -8397,8 +8588,7 @@ var ts; } ts.isToken = isToken; function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + return array.hasOwnProperty("pos") && array.hasOwnProperty("end"); } ts.isNodeArray = isNodeArray; function isLiteralKind(kind) { @@ -8483,16 +8673,27 @@ var ts; return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { + function isFunctionLikeDeclaration(node) { + return node && isFunctionLikeDeclarationKind(node.kind); + } + ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; + function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 152: - case 186: case 228: - case 187: case 151: - case 150: + case 152: case 153: case 154: + case 186: + case 187: + return true; + default: + return false; + } + } + function isFunctionLikeKind(kind) { + switch (kind) { + case 150: case 155: case 156: case 157: @@ -8500,10 +8701,15 @@ var ts; case 273: case 161: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - return false; } ts.isFunctionLikeKind = isFunctionLikeKind; + function isFunctionOrModuleBlock(node) { + return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent); + } + ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; return kind === 152 @@ -8657,52 +8863,61 @@ var ts; || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; - function isLeftHandSideExpressionKind(kind) { - return kind === 179 - || kind === 180 - || kind === 182 - || kind === 181 - || kind === 249 - || kind === 250 - || kind === 183 - || kind === 177 - || kind === 185 - || kind === 178 - || kind === 199 - || kind === 186 - || kind === 71 - || kind === 12 - || kind === 8 - || kind === 9 - || kind === 13 - || kind === 196 - || kind === 86 - || kind === 95 - || kind === 99 - || kind === 101 - || kind === 97 - || kind === 91 - || kind === 203 - || kind === 204; - } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 192 - || kind === 193 - || kind === 188 - || kind === 189 - || kind === 190 - || kind === 191 - || kind === 184 - || isLeftHandSideExpressionKind(kind); + function isLeftHandSideExpressionKind(kind) { + switch (kind) { + case 179: + case 180: + case 182: + case 181: + case 249: + case 250: + case 183: + case 177: + case 185: + case 178: + case 199: + case 186: + case 71: + case 12: + case 8: + case 9: + case 13: + case 196: + case 86: + case 95: + case 99: + case 101: + case 97: + case 203: + case 204: + case 91: + return true; + default: + return false; + } } function isUnaryExpression(node) { return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionKind(kind) { + switch (kind) { + case 192: + case 193: + case 188: + case 189: + case 190: + case 191: + case 184: + return true; + default: + return isLeftHandSideExpressionKind(kind); + } + } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { case 193: @@ -8715,21 +8930,26 @@ var ts; } } ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; - function isExpressionKind(kind) { - return kind === 195 - || kind === 197 - || kind === 187 - || kind === 194 - || kind === 198 - || kind === 202 - || kind === 200 - || kind === 289 - || isUnaryExpressionKind(kind); - } function isExpression(node) { return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isExpression = isExpression; + function isExpressionKind(kind) { + switch (kind) { + case 195: + case 197: + case 187: + case 194: + case 198: + case 202: + case 200: + case 289: + case 288: + return true; + default: + return isUnaryExpressionKind(kind); + } + } function isAssertionExpression(node) { var kind = node.kind; return kind === 184 @@ -8970,6 +9190,10 @@ var ts; return node.kind >= 276 && node.kind <= 285; } ts.isJSDocTag = isJSDocTag; + function hasJSDocNodes(node) { + return !!node.jsDoc && node.jsDoc.length > 0; + } + ts.hasJSDocNodes = hasJSDocNodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -9196,7 +9420,7 @@ var ts; ts.Debug.assert(res < lineStarts[line + 1]); } else if (debugText !== undefined) { - ts.Debug.assert(res < debugText.length); + ts.Debug.assert(res <= debugText.length); } return res; } @@ -10987,9 +11211,11 @@ var ts; visitNode(cbNode, node.typeExpression); } case 285: - for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { - var tag = _a[_i]; - visitNode(cbNode, tag); + if (node.jsDocPropertyTags) { + for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { + var tag = _a[_i]; + visitNode(cbNode, tag); + } } return; case 288: @@ -11169,7 +11395,7 @@ var ts; var saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDoc) { + if (ts.hasJSDocNodes(n)) { for (var _i = 0, _a = n.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; jsDoc.parent = n; @@ -11289,9 +11515,6 @@ var ts; function getNodePos() { return scanner.getStartPos(); } - function getNodeEnd() { - return scanner.getStartPos(); - } function token() { return currentToken; } @@ -11414,13 +11637,11 @@ var ts; kind === 71 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } - function createNodeArray(elements, pos) { - var array = (elements || []); - if (!(pos >= 0)) { - pos = getNodePos(); - } + function createNodeArray(elements, pos, end) { + var length = elements.length; + var array = (length >= 1 && length <= 4 ? elements.slice() : elements); array.pos = pos; - array.end = pos; + array.end = end === undefined ? scanner.getStartPos() : end; return array; } function finishNode(node, end) { @@ -11468,7 +11689,8 @@ var ts; nextToken(); return finishNode(node); } - return createMissingNode(71, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var reportAtCurrentPosition = token() === 1; + return createMissingNode(71, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -11701,20 +11923,20 @@ var ts; function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); - result.push(element); + list.push(element); continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - result.end = getNodeEnd(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); @@ -11920,12 +12142,13 @@ var ts; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var commaStart = -1; while (true) { if (isListElement(kind, false)) { var startPos = scanner.getStartPos(); - result.push(parseListElement(kind, parseElement)); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(26)) { continue; @@ -11950,15 +12173,15 @@ var ts; break; } } + parsingContext = saveParsingContext; + var result = createNodeArray(list, listPos); if (commaStart >= 0) { result.hasTrailingComma = true; } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; return result; } function createMissingList() { - return createNodeArray(); + return createNodeArray([], getNodePos()); } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -12000,12 +12223,12 @@ var ts; var template = createNode(196); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); - var templateSpans = createNodeArray(); + var list = []; + var listPos = getNodePos(); do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 15); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; + list.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(list).literal.kind === 15); + template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { @@ -12100,7 +12323,7 @@ var ts; var result = createNode(273); nextToken(); fillSignature(56, 4 | 32, result); - return finishNode(result); + return addJSDocComment(finishNode(result)); } var node = createNode(159); node.typeName = parseIdentifierName(); @@ -12158,9 +12381,10 @@ var ts; return token() === 24 || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 || isStartOfType(); + token() === 57 || + isStartOfType(true); } - function parseParameter() { + function parseParameter(requireEqualsToken) { var node = createNode(146); if (token() === 99) { node.name = createIdentifier(true); @@ -12176,37 +12400,33 @@ var ts; } node.questionToken = parseOptionalToken(55); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseInitializer(true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(true); - } function fillSignature(returnToken, flags, signature) { if (!(flags & 32)) { signature.typeParameters = parseTypeParameters(); } signature.parameters = parseParameterList(flags); - var returnTokenRequired = returnToken === 36; - if (returnTokenRequired) { + signature.type = parseReturnType(returnToken, !!(flags & 4)); + } + function parseReturnType(returnToken, isType) { + return shouldParseReturnType(returnToken, isType) ? parseTypeOrTypePredicate() : undefined; + } + function shouldParseReturnType(returnToken, isType) { + if (returnToken === 36) { parseExpected(returnToken); - signature.type = parseTypeOrTypePredicate(); + return true; } - else if (parseOptional(returnToken)) { - signature.type = parseTypeOrTypePredicate(); + else if (parseOptional(56)) { + return true; } - else if (flags & 4) { - var start = scanner.getTokenPos(); - var length_1 = scanner.getTextPos() - start; - var backwardToken = parseOptional(returnToken === 56 ? 36 : 56); - if (backwardToken) { - signature.type = parseTypeOrTypePredicate(); - parseErrorAtPosition(start, length_1, ts.Diagnostics._0_expected, ts.tokenToString(returnToken)); - } + else if (isType && token() === 36) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56)); + nextToken(); + return true; } + return false; } function parseParameterList(flags) { if (parseExpected(19)) { @@ -12214,7 +12434,7 @@ var ts; var savedAwaitContext = inAwaitContext(); setYieldContext(!!(flags & 1)); setAwaitContext(!!(flags & 2)); - var result = parseDelimitedList(16, flags & 32 ? parseJSDocParameter : parseParameter); + var result = parseDelimitedList(16, flags & 32 ? parseJSDocParameter : function () { return parseParameter(!!(flags & 8)); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); if (!parseExpected(20) && (flags & 8)) { @@ -12278,7 +12498,7 @@ var ts; node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); @@ -12410,7 +12630,7 @@ var ts; parseExpected(94); } fillSignature(36, 4, node); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseKeywordAndNoDot() { var node = parseTokenNode(); @@ -12424,16 +12644,9 @@ var ts; unaryMinusExpression.operator = 38; nextToken(); } - var expression; - switch (token()) { - case 9: - case 8: - expression = parseLiteralLikeNode(token()); - break; - case 101: - case 86: - expression = parseTokenNode(); - } + var expression = token() === 101 || token() === 86 + ? parseTokenNode() + : parseLiteralLikeNode(token()); if (negative) { unaryMinusExpression.operand = expression; finishNode(unaryMinusExpression); @@ -12466,6 +12679,7 @@ var ts; return parseJSDocNodeWithType(274); case 51: return parseJSDocNodeWithType(271); + case 13: case 9: case 8: case 101: @@ -12497,7 +12711,7 @@ var ts; return parseTypeReference(); } } - function isStartOfType() { + function isStartOfType(inStartOfParameter) { switch (token()) { case 119: case 136: @@ -12522,11 +12736,14 @@ var ts; case 86: case 134: case 39: + case 55: + case 51: + case 24: return true; case 38: - return lookAhead(nextTokenIsNumericLiteral); + return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case 19: - return lookAhead(isStartOfParenthesizedOrFunctionType); + return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } @@ -12592,13 +12809,12 @@ var ts; parseOptional(operator); var type = parseConstituentType(); if (token() === operator) { - var types = createNodeArray([type], type.pos); + var types = [type]; while (parseOptional(operator)) { types.push(parseConstituentType()); } - types.end = getNodeEnd(); var node = createNode(kind, type.pos); - node.types = types; + node.types = createNodeArray(types, type.pos); type = finishNode(node); } return type; @@ -12758,11 +12974,16 @@ var ts; } return expr; } - function parseInitializer(inParameter) { + function parseInitializer(inParameter, requireEqualsToken) { if (token() !== 58) { if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17) || !isStartOfExpression()) { return undefined; } + if (inParameter && requireEqualsToken) { + var result = createMissingNode(71, true, ts.Diagnostics._0_expected, "="); + result.escapedText = "= not found"; + return result; + } } parseExpected(58); return parseAssignmentExpressionOrHigher(); @@ -12823,8 +13044,7 @@ var ts; var parameter = createNode(146, identifier.pos); parameter.name = identifier; finishNode(parameter); - node.parameters = createNodeArray([parameter], parameter.pos); - node.parameters.end = parameter.end; + node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); node.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); @@ -12931,8 +13151,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { if (token() === 120) { - var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === 1) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); return parseSimpleArrowFunctionExpression(expr, asyncModifier); @@ -12961,7 +13180,8 @@ var ts; if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 36 && token() !== 17) { + if (!allowAmbiguity && ((token() !== 36 && token() !== 17) || + ts.find(node.parameters, function (p) { return p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"; }))) { return undefined; } return node; @@ -13303,7 +13523,8 @@ var ts; ts.Debug.fail("Unknown JSX child kind " + token()); } function parseJsxChildren(openingTagName) { - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var saveParsingContext = parsingContext; parsingContext |= 1 << 14; while (true) { @@ -13320,12 +13541,11 @@ var ts; } var child = parseJsxChild(); if (child) { - result.push(child); + list.push(child); } } - result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseJsxAttributes() { var jsxAttributes = createNode(254); @@ -14204,7 +14424,7 @@ var ts; var node = createNode(176); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { @@ -14220,7 +14440,7 @@ var ts; node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingPattern() { @@ -14254,7 +14474,7 @@ var ts; node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseInitializer(false); + node.initializer = parseNonParameterInitializer(); } return finishNode(node); } @@ -14418,7 +14638,8 @@ var ts; return false; } function parseDecorators() { - var decorators; + var list; + var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); if (!parseOptional(57)) { @@ -14427,20 +14648,13 @@ var ts; var decorator = createNode(147, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); - if (!decorators) { - decorators = createNodeArray([decorator], decoratorStart); - } - else { - decorators.push(decorator); - } + (list || (list = [])).push(decorator); } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; + return list && createNodeArray(list, listPos); } function parseModifiers(permitInvalidConstAsModifier) { - var modifiers; + var list; + var listPos = getNodePos(); while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); @@ -14455,17 +14669,9 @@ var ts; } } var modifier = finishNode(createNode(modifierKind, modifierStart)); - if (!modifiers) { - modifiers = createNodeArray([modifier], modifierStart); - } - else { - modifiers.push(modifier); - } + (list || (list = [])).push(modifier); } - if (modifiers) { - modifiers.end = scanner.getStartPos(); - } - return modifiers; + return list && createNodeArray(list, listPos); } function parseModifiersForArrowFunction() { var modifiers; @@ -14475,7 +14681,6 @@ var ts; nextToken(); var modifier = finishNode(createNode(modifierKind, modifierStart)); modifiers = createNodeArray([modifier], modifierStart); - modifiers.end = scanner.getStartPos(); } return modifiers; } @@ -14970,9 +15175,11 @@ var ts; return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - function parseJSDocTypeExpression() { + function parseJSDocTypeExpression(requireBraces) { var result = createNode(267, scanner.getTokenPos()); - parseExpected(17); + if (!parseExpected(17) && requireBraces) { + return undefined; + } result.type = doInsideOfContext(1048576, parseType); parseExpected(18); fixupParentReferences(result); @@ -15029,6 +15236,8 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; + var tagsPos; + var tagsEnd; var comments = []; var result; if (!isJsDocStart(content, start)) { @@ -15137,7 +15346,7 @@ var ts; } function createJSDocComment() { var result = createNode(275, start); - result.tags = tags; + result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -15260,21 +15469,17 @@ var ts; function addTag(tag, comments) { tag.comment = comments.join(""); if (!tags) { - tags = createNodeArray([tag], tag.pos); + tags = [tag]; + tagsPos = tag.pos; } else { tags.push(tag); } - tags.end = tag.end; + tagsEnd = tag.end; } function tryParseTypeExpression() { - return tryParse(function () { - skipWhitespace(); - if (token() !== 17) { - return undefined; - } - return parseJSDocTypeExpression(); - }); + skipWhitespace(); + return token() === 17 ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { var isBracketed = parseOptional(21); @@ -15364,11 +15569,11 @@ var ts; var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); + result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); + var typeExpression = parseJSDocTypeExpression(true); var result = createNode(277, atToken.pos); result.atToken = atToken; result.tagName = tagName; @@ -15403,19 +15608,18 @@ var ts; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { var child = void 0; var jsdocTypeLiteral = void 0; - var alreadyHasTypeTag = false; + var childTypeTag = void 0; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildParameterOrPropertyTag(0); })) { if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(285, start_3); } if (child.kind === 281) { - if (alreadyHasTypeTag) { + if (childTypeTag) { break; } else { - jsdocTypeLiteral.jsDocTypeTag = child; - alreadyHasTypeTag = true; + childTypeTag = child; } } else { @@ -15429,7 +15633,9 @@ var ts; if (typeExpression && typeExpression.type.kind === 164) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = finishNode(jsdocTypeLiteral); + typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + childTypeTag.typeExpression : + finishNode(jsdocTypeLiteral); } } return finishNode(typedefTag); @@ -15523,7 +15729,8 @@ var ts; if (ts.forEach(tags, function (t) { return t.kind === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var typeParameters = createNodeArray(); + var typeParameters = []; + var typeParametersPos = getNodePos(); while (true) { var name_8 = parseJSDocIdentifierName(); skipWhitespace(); @@ -15546,9 +15753,8 @@ var ts; var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; + result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); - typeParameters.end = result.end; return result; } function nextJSDocToken() { @@ -15640,7 +15846,7 @@ var ts; ts.Debug.assert(text === newText.substring(node.pos, node.end)); } forEachChild(node, visitNode, visitArray); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDocComment = _a[_i]; forEachChild(jsDocComment, visitNode, visitArray); @@ -16814,7 +17020,7 @@ var ts; errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } var value = convertPropertyValueToJson(element.initializer, option); - if (typeof keyText !== "undefined" && typeof value !== "undefined") { + if (typeof keyText !== "undefined") { result[keyText] = value; if (jsonConversionNotifier && (parentOption || knownOptions === knownRootOptions)) { @@ -16849,7 +17055,7 @@ var ts; reportInvalidOptionValue(option && option.type !== "boolean"); return false; case 95: - reportInvalidOptionValue(!!option); + reportInvalidOptionValue(option && option.name === "extends"); return null; case 9: if (!isDoubleQuotedString(valueExpression)) { @@ -16905,6 +17111,8 @@ var ts; } function isCompilerOptionsValue(option, value) { if (option) { + if (isNullOrUndefined(value)) + return true; if (option.type === "list") { return ts.isArray(value); } @@ -17057,6 +17265,12 @@ var ts; } } ts.setConfigFileInOptions = setConfigFileInOptions; + function isNullOrUndefined(x) { + return x === undefined || x === null; + } + function directoryOfCombinedPath(fileName, basePath) { + return ts.getDirectoryPath(ts.toPath(fileName, basePath, ts.identity)); + } function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { if (existingOptions === void 0) { existingOptions = {}; } if (resolutionStack === void 0) { resolutionStack = []; } @@ -17080,7 +17294,7 @@ var ts; }; function getFileNames() { var fileNames; - if (ts.hasProperty(raw, "files")) { + if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw["files"])) { if (ts.isArray(raw["files"])) { fileNames = raw["files"]; if (fileNames.length === 0) { @@ -17092,7 +17306,7 @@ var ts; } } var includeSpecs; - if (ts.hasProperty(raw, "include")) { + if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw["include"])) { if (ts.isArray(raw["include"])) { includeSpecs = raw["include"]; } @@ -17101,7 +17315,7 @@ var ts; } } var excludeSpecs; - if (ts.hasProperty(raw, "exclude")) { + if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw["exclude"])) { if (ts.isArray(raw["exclude"])) { excludeSpecs = raw["exclude"]; } @@ -17118,7 +17332,7 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !ts.hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); } @@ -17180,7 +17394,8 @@ var ts; errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, ts.createCompilerDiagnostic); + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, ts.createCompilerDiagnostic); } } return { raw: json, options: options, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath }; @@ -17202,7 +17417,8 @@ var ts; onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) { switch (key) { case "extends": - extendedConfigPath = getExtendsConfigPath(value, host, basePath, getCanonicalFileName, errors, function (message, arg0) { + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(value, host, newBase, getCanonicalFileName, errors, function (message, arg0) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0); }); return; @@ -17356,6 +17572,8 @@ var ts; } } function normalizeOptionValue(option, basePath, value) { + if (isNullOrUndefined(value)) + return undefined; if (option.type === "list") { var listOption_1 = option; if (listOption_1.element.isFilePath || typeof listOption_1.element.type !== "string") { @@ -17378,6 +17596,8 @@ var ts; return value; } function convertJsonOptionOfCustomType(opt, value, errors) { + if (isNullOrUndefined(value)) + return undefined; var key = value.toLowerCase(); var val = opt.type.get(key); if (val !== undefined) { @@ -17414,7 +17634,7 @@ var ts; if (fileNames) { for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); + var file = ts.getNormalizedAbsolutePath(fileName, basePath); literalFileMap.set(keyMapper(file), file); } } @@ -17613,7 +17833,7 @@ var ts; return undefined; } ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); - return resolved.path; + return { fileName: resolved.path, packageId: resolved.packageId }; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { @@ -17716,12 +17936,12 @@ var ts; var resolvedTypeReferenceDirective; if (resolved) { if (!options.preserveSymlinks) { - resolved = realPath(resolved, host, traceEnabled); + resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); } if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -17834,12 +18054,12 @@ var ts; var commonPrefix = getCommonPrefix(path, resolvedFileName); var current = path; while (true) { - var parent_4 = ts.getDirectoryPath(current); - if (parent_4 === current || directoryPathMap.has(parent_4)) { + var parent_3 = ts.getDirectoryPath(current); + if (parent_3 === current || directoryPathMap.has(parent_3)) { break; } - directoryPathMap.set(parent_4, result); - current = parent_4; + directoryPathMap.set(parent_3, result); + current = parent_3; if (current === commonPrefix) { break; } @@ -18018,7 +18238,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension, packageId: undefined }; + return noPackageId({ path: path_1, ext: extension }); } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -18180,31 +18400,40 @@ var ts; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } + var _a = considerPackageJson + ? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state) + : { packageJsonContent: undefined, packageId: undefined }, packageJsonContent = _a.packageJsonContent, packageId = _a.packageId; + return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent)); + } + function loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent) { + var fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - var packageId; - if (considerPackageJson) { - var packageJsonPath = pathToPackageJson(candidate); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var jsonContent = readJson(packageJsonPath, state.host); - if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { - packageId = { name: jsonContent.name, version: jsonContent.version }; - } - var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); - if (fromPackageJson) { - return withPackageId(packageId, fromPackageJson); - } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, _a) { + var host = _a.host, traceEnabled = _a.traceEnabled; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); + var packageJsonPath = pathToPackageJson(nodeModuleDirectory); + if (directoryExists && host.fileExists(packageJsonPath)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); + var packageJsonContent = readJson(packageJsonPath, host); + var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" + ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version } + : undefined; + return { packageJsonContent: packageJsonContent, packageId: packageId }; + } + else { + if (directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + failedLookupLocations.push(packageJsonPath); + return { packageJsonContent: undefined, packageId: undefined }; } - return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); @@ -18247,9 +18476,20 @@ var ts; return ts.combinePaths(directory, "package.json"); } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { + var _a = getPackageName(moduleName), packageName = _a.packageName, rest = _a.rest; + var packageRootPath = ts.combinePaths(nodeModulesFolder, packageName); + var _b = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state), packageJsonContent = _b.packageJsonContent, packageId = _b.packageId; var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + var pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent); + return withPackageId(packageId, pathAndExtension); + } + function getPackageName(moduleName) { + var idx = moduleName.indexOf(ts.directorySeparator); + if (moduleName[0] === "@") { + idx = moduleName.indexOf(ts.directorySeparator, idx + 1); + } + return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); @@ -18532,9 +18772,11 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; if (!symbol.declarations) { - symbol.declarations = []; + symbol.declarations = [node]; + } + else { + symbol.declarations.push(node); } - symbol.declarations.push(node); if (symbolFlags & 1952 && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -18598,17 +18840,8 @@ var ts; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; case 283: - var parentNode = node.parent && node.parent.parent; - var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 208) { - if (parentNode.declarationList.declarations.length > 0) { - var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (ts.isIdentifier(nameIdentifier)) { - nameFromParentNode = nameIdentifier.escapedText; - } - } - } - return nameFromParentNode; + var name_11 = ts.getNameOfJSDocTypedef(node); + return typeof name_11 !== "undefined" ? name_11.escapedText : undefined; } } function getDisplayName(node) { @@ -18809,7 +19042,7 @@ var ts; ts.forEachChild(node, bind, bindEach); } function bindChildrenWorker(node) { - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { if (ts.isInJavaScriptFile(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var j = _a[_i]; @@ -19549,9 +19782,6 @@ var ts; lastContainer = next; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - return declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { case 233: return declareModuleMember(node, symbolFlags, symbolExcludes); @@ -19713,6 +19943,9 @@ var ts; } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); + if (symbolFlags & 8) { + symbol.parent = container.symbol; + } addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { @@ -19870,7 +20103,7 @@ var ts; inStrictMode = saveInStrictMode; } function bindJSDocTypedefTagIfAny(node) { - if (!node.jsDoc) { + if (!ts.hasJSDocNodes(node)) { return; } for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -20121,12 +20354,12 @@ var ts; return; } else { - var parent_5 = node.parent; - if (!ts.isExternalModule(parent_5)) { + var parent_4 = node.parent; + if (!ts.isExternalModule(parent_4)) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files)); return; } - if (!parent_5.isDeclarationFile) { + if (!parent_4.isDeclarationFile) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files)); return; } @@ -21047,31 +21280,38 @@ var ts; return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } - var visitedTypes = ts.createMap(); - var visitedSymbols = ts.createMap(); + var visitedTypes = []; + var visitedSymbols = []; return { walkType: function (type) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitType(type); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitType(type); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, walkSymbol: function (symbol) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitSymbol(symbol); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitSymbol(symbol); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, }; function visitType(type) { if (!type) { return; } - var typeIdString = type.id.toString(); - if (visitedTypes.has(typeIdString)) { + if (visitedTypes[type.id]) { return; } - visitedTypes.set(typeIdString, type); + visitedTypes[type.id] = type; var shouldBail = visitSymbol(type.symbol); if (shouldBail) return; @@ -21104,23 +21344,15 @@ var ts; visitIndexedAccessType(type); } } - function visitTypeList(types) { - if (!types) { - return; - } - for (var i = 0; i < types.length; i++) { - visitType(types[i]); - } - } function visitTypeReference(type) { visitType(type.target); - visitTypeList(type.typeArguments); + ts.forEach(type.typeArguments, visitType); } function visitTypeParameter(type) { visitType(getConstraintFromTypeParameter(type)); } function visitUnionOrIntersectionType(type) { - visitTypeList(type.types); + ts.forEach(type.types, visitType); } function visitIndexType(type) { visitType(type.type); @@ -21140,7 +21372,7 @@ var ts; if (signature.typePredicate) { visitType(signature.typePredicate.type); } - visitTypeList(signature.typeParameters); + ts.forEach(signature.typeParameters, visitType); for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; visitSymbol(parameter); @@ -21150,8 +21382,8 @@ var ts; } function visitInterfaceType(interfaceT) { visitObjectType(interfaceT); - visitTypeList(interfaceT.typeParameters); - visitTypeList(getBaseTypes(interfaceT)); + ts.forEach(interfaceT.typeParameters, visitType); + ts.forEach(getBaseTypes(interfaceT), visitType); visitType(interfaceT.thisType); } function visitObjectType(type) { @@ -21177,11 +21409,11 @@ var ts; if (!symbol) { return; } - var symbolIdString = ts.getSymbolId(symbol).toString(); - if (visitedSymbols.has(symbolIdString)) { + var symbolId = ts.getSymbolId(symbol); + if (visitedSymbols[symbolId]) { return; } - visitedSymbols.set(symbolIdString, symbol); + visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { return true; } @@ -21243,6 +21475,7 @@ var ts; var enumCount = 0; var symbolInstantiationDepth = 0; var emptySymbols = ts.createSymbolTable(); + var identityMapper = ts.identity; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -21395,12 +21628,13 @@ var ts; return tryFindAmbientModule(moduleName, false); }, getApparentType: getApparentType, - getAllPossiblePropertiesOfType: getAllPossiblePropertiesOfType, + isArrayLikeType: isArrayLikeType, + getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, resolveName: function (name, location, meaning) { - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined); + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false); }, getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; @@ -21479,7 +21713,8 @@ var ts; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; var flowLoopCount = 0; - var visitedFlowCount = 0; + var sharedFlowCount = 0; + var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var resolutionTargets = []; @@ -21494,8 +21729,8 @@ var ts; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; - var visitedFlowNodes = []; - var visitedFlowTypes = []; + var sharedFlowNodes = []; + var sharedFlowTypes = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -21624,6 +21859,7 @@ var ts; })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -21705,7 +21941,7 @@ var ts; } function cloneSymbol(symbol) { var result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations.slice(0); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; @@ -21933,10 +22169,10 @@ var ts; }); } } - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, suggestedNameNotFoundMessage) { - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, suggestedNameNotFoundMessage) { + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, getSymbol, suggestedNameNotFoundMessage); } - function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, lookup, suggestedNameNotFoundMessage) { + function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, lookup, suggestedNameNotFoundMessage) { var originalLocation = location; var result; var lastLocation; @@ -22092,10 +22328,16 @@ var ts; lastLocation = location; location = location.parent; } - if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { + if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { + if (lastLocation) { + ts.Debug.assert(lastLocation.kind === 265); + if (lastLocation.commonJsModuleIndicator && name === "exports") { + return lastLocation.symbol; + } + } result = lookup(globals, name, meaning); } if (!result) { @@ -22207,15 +22449,15 @@ var ts; } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { if (meaning === 1920) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); - var parent_6 = errorLocation.parent; + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined, false)); + var parent_5 = errorLocation.parent; if (symbol) { - if (ts.isQualifiedName(parent_6)) { - ts.Debug.assert(parent_6.left === errorLocation, "Should only be resolving left side of qualified name as a namespace"); - var propName = parent_6.right.escapedText; + if (ts.isQualifiedName(parent_5)) { + ts.Debug.assert(parent_5.left === errorLocation, "Should only be resolving left side of qualified name as a namespace"); + var propName = parent_5.right.escapedText; var propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName); if (propType) { - error(parent_6, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, ts.unescapeLeadingUnderscores(name), ts.unescapeLeadingUnderscores(propName)); + error(parent_5, ts.Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1, ts.unescapeLeadingUnderscores(name), ts.unescapeLeadingUnderscores(propName)); return true; } } @@ -22231,7 +22473,7 @@ var ts; error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 & ~107455, undefined, undefined, false)); if (symbol && !(symbol.flags & 1024)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -22241,14 +22483,14 @@ var ts; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { if (meaning & (107455 & ~1024 & ~793064)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } else if (meaning & (793064 & ~1024 & ~107455)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined, false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -22276,11 +22518,17 @@ var ts; return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 237) { + switch (node.kind) { + case 237: return node; - } - return ts.findAncestor(node, ts.isImportDeclaration); + case 239: + return node.parent; + case 240: + return node.parent.parent; + case 242: + return node.parent.parent.parent; + default: + return undefined; } } function getDeclarationOfAliasSymbol(symbol) { @@ -22353,28 +22601,28 @@ var ts; var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { - var name_11 = specifier.propertyName || specifier.name; - if (name_11.escapedText) { + var name_12 = specifier.propertyName || specifier.name; + if (name_12.escapedText) { if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) { return moduleSymbol; } var symbolFromVariable = void 0; if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) { - symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_11.escapedText); + symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name_12.escapedText); } else { - symbolFromVariable = getPropertyOfVariable(targetSymbol, name_11.escapedText); + symbolFromVariable = getPropertyOfVariable(targetSymbol, name_12.escapedText); } symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); - var symbolFromModule = getExportOfModule(targetSymbol, name_11.escapedText, dontResolveAlias); - if (!symbolFromModule && allowSyntheticDefaultImports && name_11.escapedText === "default") { + var symbolFromModule = getExportOfModule(targetSymbol, name_12.escapedText, dontResolveAlias); + if (!symbolFromModule && allowSyntheticDefaultImports && name_12.escapedText === "default") { symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; if (!symbol) { - error(name_11, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_11)); + error(name_12, ts.Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(moduleSymbol), ts.declarationNameToString(name_12)); } return symbol; } @@ -22490,7 +22738,7 @@ var ts; var symbol; if (name.kind === 71) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name); + symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name, true); if (!symbol) { return undefined; } @@ -22529,7 +22777,7 @@ var ts; undefined; } else { - ts.Debug.fail("Unknown entity name kind."); + ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -22577,13 +22825,13 @@ var ts; return getMergedSymbol(pattern.symbol); } } - if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } else if (noImplicitAny && moduleNotFoundError) { - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + var errorInfo = !resolvedModule.isExternalLibraryImport ? undefined : ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } @@ -22682,10 +22930,9 @@ var ts; moduleSymbol = resolveExternalModuleSymbol(moduleSymbol); return visit(moduleSymbol) || emptySymbols; function visit(symbol) { - if (!(symbol && symbol.flags & 1952 && !ts.contains(visitedSymbols, symbol))) { + if (!(symbol && symbol.flags & 1952 && ts.pushIfUnique(visitedSymbols, symbol))) { return; } - visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); var exportStars = symbol.exports.get("__export"); if (exportStars) { @@ -22824,55 +23071,51 @@ var ts; return rightMeaning === 107455 ? 107455 : 1920; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - return getAccessibleSymbolChainFromSymbolTableWorker(symbols, []); + if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { + return undefined; } - function getAccessibleSymbolChainFromSymbolTableWorker(symbols, visitedSymbolTables) { - if (ts.contains(visitedSymbolTables, symbols)) { + var visitedSymbolTables = []; + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function getAccessibleSymbolChainFromSymbolTable(symbols) { + if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - visitedSymbolTables.push(symbols); var result = trySymbolTable(symbols); visitedSymbolTables.pop(); return result; - function canQualifySymbol(symbolFromSymbolTable, meaning) { - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - function trySymbolTable(symbols) { - if (isAccessible(symbols.get(symbol.escapedName))) { - return [symbol]; - } - return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 - && symbolFromSymbolTable.escapedName !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) { - if (!useOnlyExternalAliasing || - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { - return [symbolFromSymbolTable]; - } - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTableWorker(resolvedImportedSymbol.exports, visitedSymbolTables) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } } - if (symbol && !isPropertyOrMethodDeclarationSymbol(symbol)) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function canQualifySymbol(symbolFromSymbolTable, meaning) { + return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) || + !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + function isUMDExportSymbol(symbol) { + return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + } + function trySymbolTable(symbols) { + if (isAccessible(symbols.get(symbol.escapedName))) { + return [symbol]; + } + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 2097152 + && symbolFromSymbolTable.escapedName !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246) + && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) + && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { + return [symbolFromSymbolTable]; + } + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + }); } } function needsQualification(symbol, enclosingDeclaration, meaning) { @@ -22975,14 +23218,7 @@ var ts; isDeclarationVisible(anyImportSyntax.parent)) { if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } + aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, anyImportSyntax); } return true; } @@ -23004,7 +23240,7 @@ var ts; meaning = 793064; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false); return (symbol && hasVisibleDeclarations(symbol, true)) || { accessibility: 1, errorSymbolName: ts.getTextOfNode(firstIdentifier), @@ -23037,7 +23273,7 @@ var ts; var writer = ts.createTextWriter(""); var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(3, typeNode, sourceFile, writer); + printer.writeNode(4, typeNode, sourceFile, writer); var result = writer.getText(); var maxLength = compilerOptions.noErrorTruncation || flags & 8 ? undefined : 100; if (maxLength && result.length >= maxLength) { @@ -23122,8 +23358,8 @@ var ts; return ts.createTypeReferenceNode(enumLiteralName, undefined); } if (type.flags & 272) { - var name_12 = symbolToName(type.symbol, context, 793064, false); - return ts.createTypeReferenceNode(name_12, undefined); + var name_13 = symbolToName(type.symbol, context, 793064, false); + return ts.createTypeReferenceNode(name_13, undefined); } if (type.flags & (32)) { return ts.createLiteralTypeNode(ts.setEmitFlags(ts.createLiteral(type.value), 16777216)); @@ -23166,13 +23402,13 @@ var ts; return typeReferenceToTypeNode(type); } if (type.flags & 16384 || objectFlags & 3) { - var name_13 = symbolToName(type.symbol, context, 793064, false); - return ts.createTypeReferenceNode(name_13, undefined); + var name_14 = symbolToName(type.symbol, context, 793064, false); + return ts.createTypeReferenceNode(name_14, undefined); } if (!inTypeAlias && type.aliasSymbol && isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration)) { - var name_14 = symbolToTypeReferenceName(type.aliasSymbol); + var name_15 = symbolToTypeReferenceName(type.aliasSymbol); var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); - return ts.createTypeReferenceNode(name_14, typeArgumentNodes); + return ts.createTypeReferenceNode(name_15, typeArgumentNodes); } if (type.flags & (65536 | 131072)) { var types = type.flags & 65536 ? formatUnionTypes(type.types) : type.types; @@ -23319,17 +23555,17 @@ var ts; var i = 0; var qualifiedName = void 0; if (outerTypeParameters) { - var length_2 = outerTypeParameters.length; - while (i < length_2) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { var start = i; - var parent_7 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_6 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_7); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_6); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); var typeArgumentNodes_1 = typeArgumentSlice && ts.createNodeArray(typeArgumentSlice); - var namePart = symbolToTypeReferenceName(parent_7); + var namePart = symbolToTypeReferenceName(parent_6); (namePart.kind === 71 ? namePart : namePart.right).typeArguments = typeArgumentNodes_1; if (qualifiedName) { ts.Debug.assert(!qualifiedName.right); @@ -23559,11 +23795,11 @@ var ts; var parentSymbol; if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_8) { - var parentChain = getSymbolChain(parent_8, getQualifiedLeftMeaning(meaning), false); + var parent_7 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_7) { + var parentChain = getSymbolChain(parent_7, getQualifiedLeftMeaning(meaning), false); if (parentChain) { - parentSymbol = parent_8; + parentSymbol = parent_7; accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); } } @@ -23578,29 +23814,6 @@ var ts; } } } - function getNameOfSymbol(symbol, context) { - var declaration = ts.firstOrUndefined(symbol.declarations); - if (declaration) { - var name_15 = ts.getNameOfDeclaration(declaration); - if (name_15) { - return ts.declarationNameToString(name_15); - } - if (declaration.parent && declaration.parent.kind === 226) { - return ts.declarationNameToString(declaration.parent.name); - } - if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { - context.encounteredError = true; - } - switch (declaration.kind) { - case 199: - return "(Anonymous class)"; - case 186: - case 187: - return "(Anonymous function)"; - } - } - return ts.unescapeLeadingUnderscores(symbol.escapedName); - } } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { return ts.usingSingleLineStringWriter(function (writer) { @@ -23658,9 +23871,9 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { - return type.flags & 32 ? "\"" + ts.escapeString(type.value) + "\"" : "" + type.value; + return type.flags & 32 ? '"' + ts.escapeString(type.value) + '"' : "" + type.value; } - function getNameOfSymbol(symbol) { + function getNameOfSymbol(symbol, context) { if (symbol.declarations && symbol.declarations.length) { var declaration = symbol.declarations[0]; var name_16 = ts.getNameOfDeclaration(declaration); @@ -23670,6 +23883,9 @@ var ts; if (declaration.parent && declaration.parent.kind === 226) { return ts.declarationNameToString(declaration.parent.name); } + if (context && !context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { + context.encounteredError = true; + } switch (declaration.kind) { case 199: return "(Anonymous class)"; @@ -23678,6 +23894,12 @@ var ts; return "(Anonymous function)"; } } + if (symbol.syntheticLiteralTypeOrigin) { + var stringValue = symbol.syntheticLiteralTypeOrigin.value; + if (!ts.isIdentifierText(stringValue, compilerOptions.target)) { + return "\"" + ts.escapeString(stringValue, 34) + "\""; + } + } return ts.unescapeLeadingUnderscores(symbol.escapedName); } function getSymbolDisplayBuilder() { @@ -23728,9 +23950,9 @@ var ts; var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & 2)); if (!accessibleSymbolChain || needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - var parent_9 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); - if (parent_9) { - walkSymbol(parent_9, getQualifiedLeftMeaning(meaning), false); + var parent_8 = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent_8) { + walkSymbol(parent_8, getQualifiedLeftMeaning(meaning), false); } } if (accessibleSymbolChain) { @@ -23775,9 +23997,9 @@ var ts; writeTypeReference(type, nextFlags); } else if (type.flags & 256 && !(type.flags & 65536)) { - var parent_10 = getParentOfSymbol(type.symbol); - buildSymbolDisplay(parent_10, writer, enclosingDeclaration, 793064, 0, nextFlags); - if (getDeclaredTypeOfSymbol(parent_10) !== type) { + var parent_9 = getParentOfSymbol(type.symbol); + buildSymbolDisplay(parent_9, writer, enclosingDeclaration, 793064, 0, nextFlags); + if (getDeclaredTypeOfSymbol(parent_9) !== type) { writePunctuation(writer, 23); appendSymbolNameOnly(type.symbol, writer); } @@ -23874,15 +24096,15 @@ var ts; var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_3 = outerTypeParameters.length; - while (i < length_3) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { var start = i; - var parent_11 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + var parent_10 = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_3 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_11); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent_10); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { - writeSymbolTypeReference(parent_11, typeArguments, start, i, flags); + writeSymbolTypeReference(parent_10, typeArguments, start, i, flags); writePunctuation(writer, 23); } } @@ -24349,12 +24571,12 @@ var ts; if (ts.isExternalModuleAugmentation(node)) { return true; } - var parent_12 = getDeclarationContainer(node); + var parent_11 = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 237 && parent_12.kind !== 265 && ts.isInAmbientContext(parent_12))) { - return isGlobalSourceFile(parent_12); + !(node.kind !== 237 && parent_11.kind !== 265 && ts.isInAmbientContext(parent_11))) { + return isGlobalSourceFile(parent_11); } - return isDeclarationVisible(parent_12); + return isDeclarationVisible(parent_11); case 149: case 148: case 153: @@ -24398,7 +24620,7 @@ var ts; function collectLinkedAliases(node) { var exportSymbol; if (node.parent && node.parent.kind === 243) { - exportSymbol = resolveName(node.parent, node.escapedText, 107455 | 793064 | 1920 | 2097152, ts.Diagnostics.Cannot_find_name_0, node); + exportSymbol = resolveName(node.parent, node.escapedText, 107455 | 793064 | 1920 | 2097152, ts.Diagnostics.Cannot_find_name_0, node, false); } else if (node.parent.kind === 246) { exportSymbol = getTargetOfExportSpecifier(node.parent, 107455 | 793064 | 1920 | 2097152); @@ -24412,13 +24634,11 @@ var ts; ts.forEach(declarations, function (declaration) { getNodeLinks(declaration).isVisible = true; var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } + ts.pushIfUnique(result, resultNode); if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 | 793064 | 1920, undefined, undefined); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 | 793064 | 1920, undefined, undefined, false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -24429,8 +24649,8 @@ var ts; function pushTypeResolution(target, propertyName) { var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { - var length_4 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_4; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -25041,34 +25261,48 @@ var ts; for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } + typeParameters = ts.appendIfUnique(typeParameters, tp); } return typeParameters; } - function appendOuterTypeParameters(typeParameters, node) { + function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; if (!node) { - return typeParameters; + return undefined; } - if (node.kind === 229 || node.kind === 199 || - node.kind === 228 || node.kind === 186 || - node.kind === 151 || node.kind === 187) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } + switch (node.kind) { + case 229: + case 199: + case 230: + case 155: + case 156: + case 150: + case 160: + case 161: + case 273: + case 228: + case 151: + case 186: + case 187: + case 231: + case 282: + case 172: + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + if (node.kind === 172) { + return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); + } + var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray); + var thisType = includeThisTypes && + (node.kind === 229 || node.kind === 199 || node.kind === 230) && + getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; + return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } function getOuterTypeParametersOfClassOrInterface(symbol) { var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230); - return appendOuterTypeParameters(undefined, declaration); + return getOuterTypeParameters(declaration); } function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) { var result; @@ -25116,7 +25350,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig; }); + return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJavaScriptFile(location)) : sig; }); } function getBaseConstructorTypeOfClass(type) { if (!type.resolvedBaseConstructorType) { @@ -25190,7 +25424,7 @@ var ts; var valueDecl = type.symbol.valueDeclaration; if (valueDecl && ts.isInJavaScriptFile(valueDecl)) { var augTag = ts.getJSDocAugmentsTag(type.symbol.valueDeclaration); - if (augTag) { + if (augTag && augTag.typeExpression && augTag.typeExpression.type) { baseType = getTypeFromTypeNode(augTag.typeExpression.type); } } @@ -25306,7 +25540,8 @@ var ts; var declaration = ts.find(symbol.declarations, function (d) { return d.kind === 283 || d.kind === 231; }); - var type = getTypeFromTypeNode(declaration.kind === 283 ? declaration.typeExpression : declaration.type); + var typeNode = declaration.kind === 283 ? declaration.typeExpression : declaration.type; + var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -25640,7 +25875,7 @@ var ts; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -25674,9 +25909,7 @@ var ts; if (!match) { return undefined; } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } + result = ts.appendIfUnique(result, match); } return result; } @@ -25852,7 +26085,11 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t, propertySymbol) { + function addMemberForKeyType(t, propertySymbolOrIndex) { + var propertySymbol; + if (typeof propertySymbolOrIndex === "object") { + propertySymbol = propertySymbolOrIndex; + } var iterationMapper = createTypeMapper([typeParameter], [t]); var templateMapper = type.mapper ? combineTypeMappers(type.mapper, iterationMapper) : iterationMapper; var propType = instantiateType(templateType, templateMapper); @@ -25867,6 +26104,7 @@ var ts; prop.syntheticOrigin = propertySymbol; prop.declarations = propertySymbol.declarations; } + prop.syntheticLiteralTypeOrigin = t; members.set(propName, prop); } else if (t.flags & 2) { @@ -25977,26 +26215,22 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getAllPossiblePropertiesOfType(type) { - if (type.flags & 65536) { - var props = ts.createSymbolTable(); - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var memberType = _a[_i]; - if (memberType.flags & 8190) { - continue; - } - for (var _b = 0, _c = getPropertiesOfType(memberType); _b < _c.length; _b++) { - var escapedName = _c[_b].escapedName; - if (!props.has(escapedName)) { - props.set(escapedName, createUnionOrIntersectionProperty(type, escapedName)); - } + function getAllPossiblePropertiesOfTypes(types) { + var unionType = getUnionType(types); + if (!(unionType.flags & 65536)) { + return getPropertiesOfType(unionType); + } + var props = ts.createSymbolTable(); + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var memberType = types_2[_i]; + for (var _a = 0, _b = getPropertiesOfType(memberType); _a < _b.length; _a++) { + var escapedName = _b[_a].escapedName; + if (!props.has(escapedName)) { + props.set(escapedName, createUnionOrIntersectionProperty(unionType, escapedName)); } } - return ts.arrayFrom(props.values()); - } - else { - return getPropertiesOfType(type); } + return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { return type.flags & 16384 ? getConstraintOfTypeParameter(type) : @@ -26058,8 +26292,8 @@ var ts; if (t.flags & 196608) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_2 = types_2[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); @@ -26122,20 +26356,15 @@ var ts; var commonFlags = isUnion ? 0 : 16777216; var syntheticFlag = 4; var checkFlags = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } + props = ts.appendIfUnique(props, prop); checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) | (!(modifiers & 24) ? 64 : 0) | (modifiers & 16 ? 128 : 0) | @@ -26261,12 +26490,7 @@ var ts; var result; ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) { var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - if (!result) { - result = []; - } - result.push(tp); - } + result = ts.appendIfUnique(result, tp); }); return result; } @@ -26302,7 +26526,7 @@ var ts; if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512); return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } function isOptionalParameter(node) { @@ -26352,11 +26576,10 @@ var ts; } return minTypeArgumentCount; } - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScript) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - var isJavaScript = ts.isInJavaScriptFile(location); if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; @@ -26388,7 +26611,7 @@ var ts; var param = declaration.parameters[i]; var paramSymbol = param.symbol; if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455, undefined, undefined); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455, undefined, undefined, false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -26576,8 +26799,8 @@ var ts; } return anyType; } - function getSignatureInstantiation(signature, typeArguments) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); + function getSignatureInstantiation(signature, typeArguments, isJavascript) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -26590,12 +26813,20 @@ var ts; return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), true); } function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); - } - return signature.erasedSignatureCache; + return signature.typeParameters ? + signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : + signature; + } + function createErasedSignature(signature) { + return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true); + } + function getCanonicalSignature(signature) { + return signature.typeParameters ? + signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) : + signature; + } + function createCanonicalSignature(signature) { + return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJavaScriptFile(signature.declaration)); } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { @@ -26661,12 +26892,12 @@ var ts; function getTypeListId(types) { var result = ""; if (types) { - var length_5 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_5) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_5 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -26683,8 +26914,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -26720,13 +26951,14 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { + var isJavascript = ts.isInJavaScriptFile(node); + if (!isJavascript && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJavascript)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -26742,7 +26974,7 @@ var ts; var id = getTypeListId(typeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJavaScriptFile(symbol.valueDeclaration))))); } return instantiation; } @@ -26934,7 +27166,7 @@ var ts; return getGlobalSymbol(name, 793064, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); + return resolveName(undefined, name, meaning, diagnostic, name, false); } function getGlobalType(name, arity, reportErrors) { var symbol = getGlobalTypeSymbol(name, reportErrors); @@ -27080,6 +27312,20 @@ var ts; function containsType(types, type) { return binarySearchTypes(types, type) >= 0; } + function isEmptyIntersectionType(type) { + var combined = 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (t.flags & 6368 && combined & 6368) { + return true; + } + combined |= t.flags; + if (combined & 6144 && combined & (32768 | 16777216)) { + return true; + } + } + return false; + } function addTypeToUnion(typeSet, type) { var flags = type.flags; if (flags & 65536) { @@ -27096,7 +27342,7 @@ var ts; if (!(flags & 2097152)) typeSet.containsNonWideningType = true; } - else if (!(flags & 8192)) { + else if (!(flags & 8192 || flags & 131072 && isEmptyIntersectionType(type))) { if (flags & 2) typeSet.containsString = true; if (flags & 4) @@ -27114,14 +27360,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -27129,8 +27375,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -27254,8 +27500,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -27401,20 +27647,6 @@ var ts; } return anyType; } - function getIndexedAccessForMappedType(type, indexType, accessNode) { - if (accessNode) { - if (!isTypeAssignableTo(indexType, getIndexType(type))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); - return unknownType; - } - if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { - error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - } - } - var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); - var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); - } function isGenericObjectType(type) { return type.flags & 540672 ? true : getObjectFlags(type) & 32 ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : @@ -27454,12 +27686,15 @@ var ts; getIntersectionType(stringIndexTypes) ]); } + if (isGenericMappedType(objectType)) { + var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [type.indexType]); + var objectTypeMapper = objectType.mapper; + var templateMapper = objectTypeMapper ? combineTypeMappers(objectTypeMapper, mapper) : mapper; + return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); + } return undefined; } function getIndexedAccessType(objectType, indexType, accessNode) { - if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); - } if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180) && isGenericObjectType(objectType)) { if (objectType.flags & 1) { return objectType; @@ -27472,7 +27707,7 @@ var ts; return type; } var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 65536 && !(indexType.flags & 8190)) { + if (indexType.flags & 65536 && !(indexType.flags & 8)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -27548,7 +27783,10 @@ var ts; return mapType(right, function (t) { return getSpreadType(left, t); }); } if (right.flags & 16777216) { - return emptyObjectType; + return nonPrimitiveType; + } + if (right.flags & (136 | 84 | 262178 | 272)) { + return left; } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); @@ -27768,10 +28006,6 @@ var ts; function instantiateSignatures(signatures, mapper) { return instantiateList(signatures, mapper, instantiateSignature); } - function instantiateCached(type, mapper, instantiator) { - var instantiations = mapper.instantiations || (mapper.instantiations = []); - return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); - } function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -27790,19 +28024,15 @@ var ts; } function createTypeMapper(sources, targets) { ts.Debug.assert(targets === undefined || sources.length === targets.length); - var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : makeArrayTypeMapper(sources, targets); - mapper.mappedTypes = sources; - return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, undefined); } function createBackreferenceMapper(typeParameters, index) { - var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; - mapper.mappedTypes = typeParameters; - return mapper; + return function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; } function isInferenceContext(mapper) { return !!mapper.signature; @@ -27812,18 +28042,11 @@ var ts; createInferenceContext(mapper.signature, mapper.flags | 2, mapper.compareTypes, mapper.inferences) : mapper; } - function identityMapper(type) { - return type; - } function combineTypeMappers(mapper1, mapper2) { - var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); - return mapper; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function createReplacementMapper(source, target, baseMapper) { - var mapper = function (t) { return t === source ? target : baseMapper(t); }; - mapper.mappedTypes = baseMapper.mappedTypes; - return mapper; + return function (t) { return t === source ? target : baseMapper(t); }; } function cloneTypeParameter(typeParameter) { var result = createType(16384); @@ -27881,15 +28104,50 @@ var ts; if (symbol.valueDeclaration) { result.valueDeclaration = symbol.valueDeclaration; } + if (symbol.isRestParameter) { + result.isRestParameter = symbol.isRestParameter; + } return result; } - function instantiateAnonymousType(type, mapper) { - var result = createObjectType(16 | 64, type.symbol); - result.target = type.objectFlags & 64 ? type.target : type; - result.mapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); - return result; + function getAnonymousTypeInstantiation(type, mapper) { + var target = type.objectFlags & 64 ? type.target : type; + var symbol = target.symbol; + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (!typeParameters) { + var declaration_1 = symbol.declarations[0]; + var outerTypeParameters = getOuterTypeParameters(declaration_1, true) || ts.emptyArray; + typeParameters = symbol.flags & 2048 && !target.aliasTypeArguments ? + ts.filter(outerTypeParameters, function (tp) { return isTypeParameterReferencedWithin(tp, declaration_1); }) : + outerTypeParameters; + links.typeParameters = typeParameters; + if (typeParameters.length) { + links.instantiations = ts.createMap(); + links.instantiations.set(getTypeListId(typeParameters), target); + } + } + if (typeParameters.length) { + var combinedMapper = type.objectFlags & 64 ? combineTypeMappers(type.mapper, mapper) : mapper; + var typeArguments = ts.map(typeParameters, combinedMapper); + var id = getTypeListId(typeArguments); + var result = links.instantiations.get(id); + if (!result) { + var newMapper = createTypeMapper(typeParameters, typeArguments); + result = target.objectFlags & 32 ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + links.instantiations.set(id, result); + } + return result; + } + return type; + } + function isTypeParameterReferencedWithin(tp, node) { + return tp.isThisType ? ts.forEachChild(node, checkThis) : ts.forEachChild(node, checkIdentifier); + function checkThis(node) { + return node.kind === 169 || ts.forEachChild(node, checkThis); + } + function checkIdentifier(node) { + return node.kind === 71 && ts.isPartOfTypeNode(node) && getTypeFromTypeNode(node) === tp || ts.forEachChild(node, checkIdentifier); + } } function instantiateMappedType(type, mapper) { var constraintType = getConstraintTypeFromMappedType(type); @@ -27900,134 +28158,58 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + return instantiateAnonymousType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); } } } - return instantiateMappedObjectType(type, mapper); + return instantiateAnonymousType(type, mapper); } function isMappableType(type) { return type.flags & (16384 | 32768 | 131072 | 524288); } - function instantiateMappedObjectType(type, mapper) { - var result = createObjectType(32 | 64, type.symbol); - result.declaration = type.declaration; - result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + function instantiateAnonymousType(type, mapper) { + var result = createObjectType(type.objectFlags | 64, type.symbol); + if (type.objectFlags & 32) { + result.declaration = type.declaration; + } + result.target = type; + result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { - if (!(symbol.declarations && symbol.declarations.length)) { - return false; - } - var mappedTypes = mapper.mappedTypes; - return !!ts.findAncestor(symbol.declarations[0], function (node) { - if (node.kind === 233 || node.kind === 265) { - return "quit"; - } - switch (node.kind) { - case 160: - case 161: - case 228: - case 151: - case 150: - case 152: - case 155: - case 156: - case 157: - case 153: - case 154: - case 186: - case 187: - case 229: - case 199: - case 230: - case 231: - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (typeParameters) { - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var d = typeParameters_1[_i]; - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) { - return true; - } - } - } - if (ts.isClassLike(node) || node.kind === 230) { - var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; - if (thisType && ts.contains(mappedTypes, thisType)) { - return true; - } - } - break; - case 172: - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { - return true; - } - break; - case 273: - var func = node; - for (var _a = 0, _b = func.parameters; _a < _b.length; _a++) { - var p = _b[_a]; - if (ts.contains(mappedTypes, getTypeOfNode(p))) { - return true; - } - } - break; - } - }); - } - function isTopLevelTypeAlias(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 265 || parentKind === 234; - } - return false; - } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { - if (type.aliasTypeArguments) { - return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + if (type.flags & 16384) { + return mapper(type); + } + if (type.flags & 32768) { + if (type.objectFlags & 16) { + return type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ? + getAnonymousTypeInstantiation(type, mapper) : type; + } + if (type.objectFlags & 32) { + return getAnonymousTypeInstantiation(type, mapper); + } + if (type.objectFlags & 4) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } - return type; } - return instantiateTypeNoAlias(type, mapper); - } - return type; - } - function instantiateTypeNoAlias(type, mapper) { - if (type.flags & 16384) { - return mapper(type); - } - if (type.flags & 32768) { - if (type.objectFlags & 16) { - return type.symbol && - type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && - (type.objectFlags & 64 || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateCached(type, mapper, instantiateAnonymousType) : type; + if (type.flags & 65536 && !(type.flags & 8190)) { + return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 32) { - return instantiateCached(type, mapper, instantiateMappedType); + if (type.flags & 131072) { + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 4) { - return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); + if (type.flags & 262144) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - } - if (type.flags & 65536 && !(type.flags & 8190)) { - return getUnionType(instantiateTypes(type.types, mapper), false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 131072) { - return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 262144) { - return getIndexType(instantiateType(type.type, mapper)); - } - if (type.flags & 524288) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } return type; } @@ -28039,6 +28221,7 @@ var ts; switch (node.kind) { case 186: case 187: + case 151: return isContextSensitiveFunctionLikeDeclaration(node); case 178: return ts.forEach(node.properties, isContextSensitive); @@ -28052,9 +28235,6 @@ var ts; (isContextSensitive(node.left) || isContextSensitive(node.right)); case 261: return isContextSensitive(node.initializer); - case 151: - case 150: - return isContextSensitiveFunctionLikeDeclaration(node); case 185: return isContextSensitive(node.expression); case 254: @@ -28141,7 +28321,8 @@ var ts; if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { return 0; } - if (source.typeParameters) { + if (source.typeParameters && source.typeParameters !== target.typeParameters) { + target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, undefined, compareTypes); } var result = -1; @@ -28384,6 +28565,13 @@ var ts; var targetStack; var maybeCount = 0; var depth = 0; + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); var expandingFlags = 0; var overflow = false; var isIntersectionConstituent = false; @@ -28567,10 +28755,21 @@ var ts; } else { var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; })) { - errorNode = prop.valueDeclaration; + var propDeclaration = prop.valueDeclaration; + ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); + errorNode = propDeclaration; + if (ts.isIdentifier(propDeclaration.name)) { + suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + } + } + if (suggestion !== undefined) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2, symbolToString(prop), typeToString(target), ts.unescapeLeadingUnderscores(suggestion)); + } + else { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } } return { value: true }; @@ -28777,7 +28976,7 @@ var ts; } } else if (target.flags & 524288) { - var constraint = getConstraintOfType(target); + var constraint = getConstraintOfIndexedAccess(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -28810,7 +29009,7 @@ var ts; } } else if (source.flags & 524288) { - var constraint = getConstraintOfType(source); + var constraint = getConstraintOfIndexedAccess(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -28885,22 +29084,21 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); + var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); + if (unmatchedProperty) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + } + return 0; + } var result = -1; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var targetProp = properties_3[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 16777216) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0; - } - } - else if (!(targetProp.flags & 4194304)) { + if (!(targetProp.flags & 4194304)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp && sourceProp !== targetProp) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { @@ -29172,9 +29370,10 @@ var ts; return type.flags & 16384 && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return getObjectFlags(type) & 4 && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + return getObjectFlags(type) & 4 && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } - function getTypeReferenceId(type, typeParameters) { + function getTypeReferenceId(type, typeParameters, depth) { + if (depth === void 0) { depth = 0; } var result = "" + type.target.id; for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { var t = _a[_i]; @@ -29186,6 +29385,9 @@ var ts; } result += "=" + index; } + else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; + } else { result += "-" + t.id; } @@ -29351,8 +29553,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -29388,7 +29590,7 @@ var ts; return !!getPropertyOfType(type, "0"); } function isUnitType(type) { - return (type.flags & (224 | 2048 | 4096)) !== 0; + return !!(type.flags & 6368); } function isLiteralType(type) { return type.flags & 8 ? true : @@ -29416,8 +29618,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -29629,7 +29831,6 @@ var ts; function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; - context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; @@ -29667,7 +29868,7 @@ var ts; } function couldContainTypeVariables(type) { var objectFlags = getObjectFlags(type); - return !!(type.flags & 540672 || + return !!(type.flags & (540672 | 262144) || objectFlags & 4 && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 2048 | 32) || objectFlags & 32 || @@ -29721,18 +29922,18 @@ var ts; return inference.candidates && getUnionType(inference.candidates, true); } } - function isPossiblyAssignableTo(source, target) { + function getUnmatchedProperty(source, target, requireOptionalProperties) { var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; - if (!(targetProp.flags & (16777216 | 4194304))) { - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (requireOptionalProperties || !(targetProp.flags & 16777216)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!sourceProp) { - return false; + return targetProp; } } } - return true; + return undefined; } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } @@ -29808,6 +30009,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 262144 && target.flags & 262144) { + inferFromTypes(source.type, target.type); + } + else if (source.flags & 524288 && target.flags & 524288) { + inferFromTypes(source.objectType, target.objectType); + inferFromTypes(source.indexType, target.indexType); + } else if (target.flags & 196608) { var targetTypes = target.types; var typeVariableCount = 0; @@ -29829,7 +30037,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 196608) { + else if (source.flags & 65536) { var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { var sourceType = sourceTypes_3[_e]; @@ -29838,7 +30046,7 @@ var ts; } else { source = getApparentType(source); - if (source.flags & 32768) { + if (source.flags & (32768 | 131072)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -29873,6 +30081,10 @@ var ts; return undefined; } function inferFromObjectTypes(source, target) { + if (isGenericMappedType(source) && isGenericMappedType(target)) { + inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + } if (getObjectFlags(target) & 32) { var constraintType = getConstraintTypeFromMappedType(target); if (constraintType.flags & 262144) { @@ -29894,7 +30106,7 @@ var ts; return; } } - if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + if (!getUnmatchedProperty(source, target, false) || !getUnmatchedProperty(target, source, false)) { inferFromProperties(source, target); inferFromSignatures(source, target, 0); inferFromSignatures(source, target, 1); @@ -29905,7 +30117,7 @@ var ts; var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -29951,8 +30163,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -30023,7 +30235,8 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = !ts.nodeIsMissing(node) && resolveName(node, node.escapedText, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + links.resolvedSymbol = !ts.nodeIsMissing(node) && + resolveName(node, node.escapedText, 107455 | 1048576, ts.Diagnostics.Cannot_find_name_0, node, !ts.isWriteOnlyAccess(node), ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } @@ -30187,8 +30400,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -30445,8 +30658,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -30515,8 +30728,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -30565,69 +30778,87 @@ var ts; } return false; } + function reportFlowControlError(node) { + var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); + var sourceFile = ts.getSourceFileOfNode(node); + var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; + var flowDepth = 0; + if (flowAnalysisDisabled) { + return unknownType; + } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810175)) { return declaredType; } - var visitedFlowStart = visitedFlowCount; + var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); - visitedFlowCount = visitedFlowStart; + sharedFlowCount = sharedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); if (reference.parent.kind === 203 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; function getTypeAtFlowNode(flow) { + if (flowDepth === 2500) { + flowAnalysisDisabled = true; + reportFlowControlError(reference); + return unknownType; + } + flowDepth++; while (true) { - if (flow.flags & 1024) { - for (var i = visitedFlowStart; i < visitedFlowCount; i++) { - if (visitedFlowNodes[i] === flow) { - return visitedFlowTypes[i]; + var flags = flow.flags; + if (flags & 1024) { + for (var i = sharedFlowStart; i < sharedFlowCount; i++) { + if (sharedFlowNodes[i] === flow) { + flowDepth--; + return sharedFlowTypes[i]; } } } var type = void 0; - if (flow.flags & 4096) { + if (flags & 4096) { flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flow.flags & 2048) { + else if (flags & 2048) { flow = flow.antecedent; continue; } - else if (flow.flags & 16) { + else if (flags & 16) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 96) { + else if (flags & 96) { type = getTypeAtFlowCondition(flow); } - else if (flow.flags & 128) { + else if (flags & 128) { type = getTypeAtSwitchClause(flow); } - else if (flow.flags & 12) { + else if (flags & 12) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flow.flags & 4 ? + type = flags & 4 ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flow.flags & 256) { + else if (flags & 256) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 2) { + else if (flags & 2) { var container = flow.container; if (container && container !== flowContainer && reference.kind !== 179 && reference.kind !== 99) { flow = container.flowNode; @@ -30638,11 +30869,12 @@ var ts; else { type = convertAutoToAny(declaredType); } - if (flow.flags & 1024) { - visitedFlowNodes[visitedFlowCount] = flow; - visitedFlowTypes[visitedFlowCount] = type; - visitedFlowCount++; + if (flags & 1024) { + sharedFlowNodes[sharedFlowCount] = flow; + sharedFlowTypes[sharedFlowCount] = type; + sharedFlowCount++; } + flowDepth--; return type; } } @@ -30671,30 +30903,32 @@ var ts; return undefined; } function getTypeAtFlowArrayMutation(flow) { - var node = flow.node; - var expr = node.kind === 181 ? - node.expression.expression : - node.left.expression; - if (isMatchingReference(reference, getReferenceCandidate(expr))) { - var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); - if (getObjectFlags(type) & 256) { - var evolvedType_1 = type; - if (node.kind === 181) { - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var arg = _a[_i]; - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + if (declaredType === autoType || declaredType === autoArrayType) { + var node = flow.node; + var expr = node.kind === 181 ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (getObjectFlags(type) & 256) { + var evolvedType_1 = type; + if (node.kind === 181) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } } - } - else { - var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84)) { - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + else { + var indexType = getTypeOfExpression(node.left.argumentExpression); + if (isTypeAssignableToKind(indexType, 84)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); } - return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + return flowType; } - return flowType; } return undefined; } @@ -30740,9 +30974,7 @@ var ts; if (type === declaredType && declaredType === initialType) { return type; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); if (!isTypeSubsetOf(type, declaredType)) { subtypeReduction = true; } @@ -30789,9 +31021,7 @@ var ts; if (cached_1) { return cached_1; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); if (!isTypeSubsetOf(type, declaredType)) { subtypeReduction = true; } @@ -31565,7 +31795,8 @@ var ts; } } } - if (noImplicitThis || ts.isInJavaScriptFile(func)) { + var inJs = ts.isInJavaScriptFile(func); + if (noImplicitThis || inJs) { var containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { var contextualType = getApparentTypeOfContextualType(containingLiteral); @@ -31584,10 +31815,18 @@ var ts; } return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); } - if (func.parent.kind === 194 && func.parent.operatorToken.kind === 58) { - var target = func.parent.left; + var parent_12 = func.parent; + if (parent_12.kind === 194 && parent_12.operatorToken.kind === 58) { + var target = parent_12.left; if (target.kind === 179 || target.kind === 180) { - return checkExpressionCached(target.expression); + var expression = target.expression; + if (inJs && ts.isIdentifier(expression)) { + var sourceFile = ts.getSourceFileOfNode(parent_12); + if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) { + return undefined; + } + } + return checkExpressionCached(expression); } } } @@ -31741,7 +31980,7 @@ var ts; else if (operator === 54) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { - type = getTypeOfExpression(binaryExpression.left); + type = getTypeOfExpression(binaryExpression.left, true); } return type; } @@ -31787,16 +32026,10 @@ var ts; } return undefined; } - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getApparentTypeOfContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1) - || getIteratedTypeOrElementType(type, undefined, false, false, false); - } - return undefined; + function getContextualTypeForElementExpression(arrayContextualType, index) { + return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) + || getIndexTypeOfContextualType(arrayContextualType, 1) + || getIteratedTypeOrElementType(arrayContextualType, undefined, false, false, false)); } function getContextualTypeForConditionalOperand(node) { var conditional = node.parent; @@ -31870,15 +32103,20 @@ var ts; return getContextualTypeForObjectLiteralElement(parent); case 263: return getApparentTypeOfContextualType(parent.parent); - case 177: - return getContextualTypeForElementExpression(node); + case 177: { + var arrayLiteral = parent; + var type = getApparentTypeOfContextualType(arrayLiteral); + return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); + } case 195: return getContextualTypeForConditionalOperand(node); case 205: ts.Debug.assert(parent.parent.kind === 196); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 185: - return getContextualType(parent); + case 185: { + var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); + } case 256: return getContextualTypeForJsxExpression(parent); case 253: @@ -31941,8 +32179,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -31980,8 +32218,9 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); - for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { - var e = elements_1[_i]; + var contextualType = getApparentTypeOfContextualType(node); + for (var index = 0; index < elements.length; index++) { + var e = elements[index]; if (inDestructuringPattern && e.kind === 198) { var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || @@ -31991,7 +32230,8 @@ var ts; } } else { - var type = checkExpressionForMutableLocation(e, checkMode); + var elementContextualType = getContextualTypeForElementExpression(contextualType, index); + var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === 198; @@ -32002,15 +32242,15 @@ var ts; type.pattern = node; return type; } - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - var pattern = contextualType.pattern; + var contextualType_1 = getApparentTypeOfContextualType(node); + if (contextualType_1 && contextualTypeIsTupleLikeType(contextualType_1)) { + var pattern = contextualType_1.pattern; if (pattern && (pattern.kind === 175 || pattern.kind === 177)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.typeArguments[i]); + elementTypes.push(contextualType_1.typeArguments[i]); } else { if (patternElement.kind !== 200) { @@ -32096,6 +32336,7 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; + var literalName = void 0; if (memberDecl.kind === 261 || memberDecl.kind === 262 || ts.isObjectLiteralMethod(memberDecl)) { @@ -32105,6 +32346,12 @@ var ts; } var type = void 0; if (memberDecl.kind === 261) { + if (memberDecl.name.kind === 144) { + var t = checkComputedPropertyName(memberDecl.name); + if (t.flags & 224) { + literalName = ts.escapeLeadingUnderscores("" + t.value); + } + } type = checkPropertyAssignment(memberDecl, checkMode); } else if (memberDecl.kind === 151) { @@ -32119,14 +32366,14 @@ var ts; type = jsdocType; } typeFlags |= type.flags; - var prop = createSymbol(4 | member.flags, member.escapedName); + var prop = createSymbol(4 | member.flags, literalName || member.escapedName); if (inDestructuringPattern) { var isOptional = (memberDecl.kind === 261 && hasDefaultValue(memberDecl.initializer)) || (memberDecl.kind === 262 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 16777216; } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; } } @@ -32173,7 +32420,7 @@ var ts; ts.Debug.assert(memberDecl.kind === 153 || memberDecl.kind === 154); checkNodeDeferred(memberDecl); } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -32231,7 +32478,8 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 | 4096 | 2048 | 16777216) || + return !!(type.flags & (1 | 16777216) || + getFalsyFlags(type) & 7392 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 32768 && !isGenericMappedType(type) || type.flags & 196608 && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -32421,8 +32669,9 @@ var ts; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { var signature = signatures_3[_i]; if (signature.typeParameters) { - var typeArguments = fillMissingTypeArguments(undefined, signature.typeParameters, 0); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + var isJavascript = ts.isInJavaScriptFile(node); + var typeArguments = fillMissingTypeArguments(undefined, signature.typeParameters, 0, isJavascript); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); } else { instantiatedSignatures.push(signature); @@ -32705,7 +32954,7 @@ var ts; checkJsxPreconditions(node); var reactRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(); - var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace); + var reactSym = resolveName(node.tagName, reactNamespace, 107455, reactRefErr, reactNamespace, true); if (reactSym) { reactSym.isReferenced = true; if (reactSym.flags & 2097152 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(reactSym))) { @@ -32881,19 +33130,8 @@ var ts; } return unknownType; } - if (prop.valueDeclaration) { - if (isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - if (prop.valueDeclaration.kind === 229 && - node.parent && node.parent.kind !== 159 && - !ts.isInAmbientContext(prop.valueDeclaration) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - } - markPropertyAsReferenced(prop); + checkPropertyNotUsedBeforeDeclaration(prop, node, right); + markPropertyAsReferenced(prop, node); getNodeLinks(node).resolvedSymbol = prop; checkPropertyAccessibility(node, left, apparentType, prop); var propType = getDeclaredOrApparentType(prop, node); @@ -32912,6 +33150,56 @@ var ts; var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { + var valueDeclaration = prop.valueDeclaration; + if (!valueDeclaration) { + return; + } + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) + && !isPropertyDeclaredInAncestorClass(prop)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + else if (valueDeclaration.kind === 229 && + node.parent.kind !== 159 && + !ts.isInAmbientContext(valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + } + function isInPropertyInitializer(node) { + return !!ts.findAncestor(node, function (node) { + switch (node.kind) { + case 149: + return true; + case 261: + return false; + default: + return ts.isPartOfExpression(node) ? false : "quit"; + } + }); + } + function isPropertyDeclaredInAncestorClass(prop) { + var classType = getTypeOfSymbol(prop.parent); + while (true) { + classType = getSuperClass(classType); + if (!classType) { + return false; + } + var superProperty = getPropertyOfObjectType(classType, prop.escapedName); + if (superProperty && superProperty.valueDeclaration) { + return true; + } + } + } + function getSuperClass(classType) { + var x = getBaseTypes(classType); + if (x.length === 0) { + return undefined; + } + ts.Debug.assert(x.length === 1); + return x[0]; + } function reportNonexistentProperty(propNode, containingType) { var errorInfo; if (containingType.flags & 65536 && !(containingType.flags & 8190)) { @@ -32924,8 +33212,8 @@ var ts; } } var suggestion = getSuggestionForNonexistentProperty(propNode, containingType); - if (suggestion) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); + if (suggestion !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), ts.unescapeLeadingUnderscores(suggestion)); } else { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); @@ -32937,7 +33225,7 @@ var ts; return suggestion && suggestion.escapedName; } function getSuggestionForNonexistentSymbol(location, name, meaning) { - var result = resolveNameHelper(location, name, meaning, undefined, name, function (symbols, name, meaning) { + var result = resolveNameHelper(location, name, meaning, undefined, name, false, function (symbols, name, meaning) { var symbol = getSymbol(symbols, name, meaning); if (symbol) { return symbol; @@ -32997,11 +33285,12 @@ var ts; } return bestCandidate; } - function markPropertyAsReferenced(prop) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly) { if (prop && noUnusedIdentifiers && (prop.flags & 106500) && - prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8) + && !(nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly))) { if (ts.getCheckFlags(prop) & 1) { getSymbolLinks(prop).target.isReferenced = true; } @@ -33010,15 +33299,6 @@ var ts; } } } - function isInPropertyInitializer(node) { - while (node) { - if (node.parent && node.parent.kind === 149 && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } function isValidPropertyAccess(node, propertyName) { var left = node.kind === 179 ? node.expression @@ -33209,7 +33489,6 @@ var ts; var argCount; var typeArguments; var callIsIncomplete; - var isDecorator; var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { return true; @@ -33231,7 +33510,6 @@ var ts; } } else if (node.kind === 147) { - isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); } @@ -33280,7 +33558,7 @@ var ts; if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 4); } - return getSignatureInstantiation(signature, getInferredTypes(context)); + return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJavaScriptFile(contextualSignature.declaration)); } function inferTypeArguments(node, signature, args, excludeArgument, context) { for (var _i = 0, _a = context.inferences; _i < _a.length; _i++) { @@ -33289,13 +33567,13 @@ var ts; inference.inferredType = undefined; } } - if (ts.isExpression(node)) { + if (node.kind !== 147) { var contextualType = getContextualType(node); if (contextualType) { var instantiatedType = instantiateType(contextualType, cloneTypeMapper(getContextualMapper(node))); var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 4); @@ -33715,8 +33993,9 @@ var ts; candidate = originalCandidate; if (candidate.typeParameters) { var typeArgumentTypes = void 0; + var isJavascript = ts.isInJavaScriptFile(candidate.declaration); if (typeArguments) { - typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript); if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, false)) { candidateForTypeArgumentError = originalCandidate; break; @@ -33725,7 +34004,7 @@ var ts; else { typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); } if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, false)) { candidateForArgumentError = candidate; @@ -33831,11 +34110,6 @@ var ts; if (expressionType === unknownType) { return resolveErrorCall(node); } - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasModifier(valueDecl, 128)) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); - return resolveErrorCall(node); - } if (isTypeAny(expressionType)) { if (node.typeArguments) { error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments); @@ -33847,6 +34121,11 @@ var ts; if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); } + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && ts.hasModifier(valueDecl, 128)) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } var callSignatures = getSignaturesOfType(expressionType, 0); @@ -33960,8 +34239,8 @@ var ts; if (elementType.flags & 65536) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var type = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -33986,7 +34265,7 @@ var ts; case 250: return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } - ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); + ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } function getResolvedSignature(node, candidatesOutArray) { var links = getNodeLinks(node); @@ -34000,16 +34279,30 @@ var ts; return result; } function isJavaScriptConstructor(node) { - if (ts.isInJavaScriptFile(node)) { + if (node && ts.isInJavaScriptFile(node)) { if (ts.getJSDocClassTag(node)) return true; var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : - ts.isVariableDeclaration(node) && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : + ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; return symbol && symbol.members !== undefined; } return false; } + function getJavaScriptClassType(symbol) { + if (ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = getSymbolOfNode(symbol.valueDeclaration.initializer); + } + if (isJavaScriptConstructor(symbol.valueDeclaration)) { + return getInferredClassType(symbol); + } + if (symbol.flags & 3) { + var valueType = getTypeOfSymbol(symbol); + if (valueType.symbol && !isInferredClassType(valueType) && isJavaScriptConstructor(valueType.symbol.valueDeclaration)) { + return getInferredClassType(valueType.symbol); + } + } + } function getInferredClassType(symbol) { var links = getSymbolLinks(symbol); if (!links.inferredClassType) { @@ -34038,13 +34331,11 @@ var ts; var funcSymbol = node.expression.kind === 71 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { - funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + var type = funcSymbol && getJavaScriptClassType(funcSymbol); + if (type) { + return type; } - if (funcSymbol && funcSymbol.flags & 16 && (funcSymbol.members || ts.getJSDocClassTag(funcSymbol.valueDeclaration))) { - return getInferredClassType(funcSymbol); - } - else if (noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -34105,7 +34396,7 @@ var ts; } if (!ts.isIdentifier(node.expression)) throw ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455, undefined, undefined); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455, undefined, undefined, true); if (!resolvedRequire) { return true; } @@ -34211,7 +34502,7 @@ var ts; } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); - if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { + if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } @@ -34341,9 +34632,7 @@ var ts; ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } }); return aggregatedTypes; @@ -34387,9 +34676,7 @@ var ts; if (type.flags & 8192) { hasReturnOfTypeNever = true; } - else if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } else { hasReturnWithNoExpression = true; @@ -34400,9 +34687,7 @@ var ts; return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { - if (!ts.contains(aggregatedTypes, undefinedType)) { - aggregatedTypes.push(undefinedType); - } + ts.pushIfUnique(aggregatedTypes, undefinedType); } return aggregatedTypes; } @@ -34655,8 +34940,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -35154,20 +35439,6 @@ var ts; var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } - function checkLiteralExpression(node) { - switch (node.kind) { - case 13: - case 9: - return getFreshTypeOfLiteralType(getLiteralType(node.text)); - case 8: - checkGrammarNumericLiteral(node); - return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101: - return trueType; - case 86: - return falseType; - } - } function checkTemplateExpression(node) { ts.forEach(node.templateSpans, function (templateSpan) { checkExpression(templateSpan.expression); @@ -35219,9 +35490,13 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, checkMode) { + function checkExpressionForMutableLocation(node, checkMode, contextualType) { + if (arguments.length === 2) { + contextualType = getContextualType(node); + } var type = checkExpression(node, checkMode); - return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); + var shouldWiden = isTypeAssertion(node) || isLiteralContextualType(contextualType); + return shouldWiden ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, checkMode) { if (node.name.kind === 144) { @@ -35289,12 +35564,9 @@ var ts; return type; } function checkParenthesizedExpression(node, checkMode) { - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - var typecasts = ts.flatMap(node.jsDoc, function (doc) { return ts.filter(doc.tags, function (tag) { return tag.kind === 281; }); }); - if (typecasts && typecasts.length) { - var cast_1 = typecasts[0]; - return checkAssertionWorker(cast_1, cast_1.typeExpression.type, node.expression, checkMode); - } + var tag = ts.isInJavaScriptFile(node) ? ts.getJSDocTypeTag(node) : undefined; + if (tag) { + return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -35310,10 +35582,14 @@ var ts; return nullWideningType; case 13: case 9: + return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8: + checkGrammarNumericLiteral(node); + return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101: + return trueType; case 86: - return checkLiteralExpression(node); + return falseType; case 196: return checkTemplateExpression(node); case 12: @@ -35862,7 +36138,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, ts.isInJavaScriptFile(typeArgumentNodes[i])); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -35930,6 +36206,10 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + if (accessNode.kind === 180 && ts.isAssignmentTarget(accessNode) && + getObjectFlags(objectType) & 32 && objectType.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + } return type; } if (getIndexInfoOfType(getApparentType(objectType), 1) && isTypeAssignableToKind(indexType, 84)) { @@ -36195,6 +36475,7 @@ var ts; switch (d.kind) { case 230: case 231: + case 283: return 2; case 233: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 @@ -36204,6 +36485,8 @@ var ts; case 232: return 2 | 1; case 237: + case 240: + case 239: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -36393,8 +36676,11 @@ var ts; markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node)); } function markEntityNameOrEntityExpressionAsReference(typeName) { - var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.escapedText, (typeName.kind === 71 ? 793064 : 1920) | 2097152, undefined, undefined); + if (!typeName) + return; + var rootName = getFirstIdentifier(typeName); + var meaning = (typeName.kind === 71 ? 793064 : 1920) | 2097152; + var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true); if (rootSymbol && rootSymbol.flags & 2097152 && symbolIsValue(rootSymbol) @@ -36500,22 +36786,12 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } - function checkJSDoc(node) { - if (!ts.isInJavaScriptFile(node)) { - return; - } - ts.forEach(node.jsDoc, checkSourceElement); - } - function checkJSDocComment(node) { - if (node.tags) { - for (var _i = 0, _a = node.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - checkSourceElement(tag); - } + function checkJSDocTypedefTag(node) { + if (!node.typeExpression) { + error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags); } } function checkFunctionOrMethodDeclaration(node) { - checkJSDoc(node); checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); @@ -36620,11 +36896,11 @@ var ts; !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name_27)) { - error(name_27, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(local.escapedName)); + error(name_27, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(local.escapedName)); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return errorUnusedLocal(ts.getNameOfDeclaration(d) || d, ts.unescapeLeadingUnderscores(local.escapedName)); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d, ts.unescapeLeadingUnderscores(local.escapedName)); }); } } }); @@ -36637,15 +36913,17 @@ var ts; } return false; } - function errorUnusedLocal(node, name) { + function errorUnusedLocal(declaration, name) { + var node = ts.getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 226 && ts.isForInOrOfStatement(declaration.parent.parent)) { + var declaration_2 = ts.getRootDeclaration(node.parent); + if ((declaration_2.kind === 226 && ts.isForInOrOfStatement(declaration_2.parent.parent)) || + declaration_2.kind === 145) { return; } } if (!isRemovedPropertyFromObjectSpread(node.kind === 71 ? node.parent : node)) { - error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + error(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name); } } function parameterNameStartsWithUnderscore(parameterName) { @@ -36661,14 +36939,14 @@ var ts; var member = _a[_i]; if (member.kind === 151 || member.kind === 149) { if (!member.symbol.isReferenced && ts.hasModifier(member, 8)) { - error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); + error(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8)) { - error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); + error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } } @@ -36686,8 +36964,8 @@ var ts; } for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { var typeParameter = _a[_i]; - if (!getMergedSymbol(typeParameter.symbol).isReferenced) { - error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); + if (!getMergedSymbol(typeParameter.symbol).isReferenced && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } } @@ -36700,7 +36978,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - errorUnusedLocal(ts.getNameOfDeclaration(declaration), ts.unescapeLeadingUnderscores(local.escapedName)); + errorUnusedLocal(declaration, ts.unescapeLeadingUnderscores(local.escapedName)); } } } @@ -36711,7 +36989,14 @@ var ts; if (node.kind === 207) { checkGrammarStatementInAmbientContext(node); } - ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionOrModuleBlock(node)) { + var saveFlowAnalysisDisabled = flowAnalysisDisabled; + ts.forEach(node.statements, checkSourceElement); + flowAnalysisDisabled = saveFlowAnalysisDisabled; + } + else { + ts.forEach(node.statements, checkSourceElement); + } if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -36841,7 +37126,7 @@ var ts; if (symbol.flags & 1) { if (!ts.isIdentifier(node.name)) throw ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { @@ -36877,7 +37162,7 @@ var ts; return visit(n.expression); } else if (n.kind === 71) { - var symbol = resolveName(n, n.escapedText, 107455 | 2097152, undefined, undefined); + var symbol = resolveName(n, n.escapedText, 107455 | 2097152, undefined, undefined, false); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; } @@ -36938,7 +37223,7 @@ var ts; var parentType = getTypeForBindingElementParent(parent_15); var name_29 = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name_29)); - markPropertyAsReferenced(property); + markPropertyAsReferenced(property, undefined); if (parent_15.initializer && property) { checkPropertyAccessibility(parent_15, parent_15.initializer, parentType, property); } @@ -38343,8 +38628,8 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + if (modulekind >= ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -38371,7 +38656,7 @@ var ts; if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } - if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015) { + if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015 && modulekind !== ts.ModuleKind.ESNext) { checkExternalEmitHelpers(node, 32768); } } @@ -38388,7 +38673,7 @@ var ts; checkAliasSymbol(node); if (!node.parent.parent.moduleSpecifier) { var exportedName = node.propertyName || node.name; - var symbol = resolveName(exportedName, exportedName.escapedText, 107455 | 793064 | 1920 | 2097152, undefined, undefined); + var symbol = resolveName(exportedName, exportedName.escapedText, 107455 | 793064 | 1920 | 2097152, undefined, undefined, true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.unescapeLeadingUnderscores(exportedName.escapedText)); } @@ -38421,9 +38706,12 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); + if (ts.isInAmbientContext(node) && !ts.isEntityNameExpression(node.expression)) { + grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); + } if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES2015) { - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); + if (modulekind >= ts.ModuleKind.ES2015) { + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system); @@ -38453,7 +38741,7 @@ var ts; if (flags & (1920 | 64 | 384)) { return; } - var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor); if (flags & 524288 && exportedDeclarationsCount <= 2) { return; } @@ -38468,15 +38756,24 @@ var ts; }); links.exportsChecked = true; } - function isNotOverload(declaration) { - return (declaration.kind !== 228 && declaration.kind !== 151) || - !!declaration.body; - } + } + function isNotAccessor(declaration) { + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 228 && declaration.kind !== 151) || + !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } + if (ts.isInJavaScriptFile(node) && node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var tags = _a[_i].tags; + ts.forEach(tags, checkSourceElement); + } + } var kind = node.kind; if (cancellationToken) { switch (kind) { @@ -38528,8 +38825,8 @@ var ts; case 168: case 170: return checkSourceElement(node.type); - case 275: - return checkJSDocComment(node); + case 283: + return checkJSDocTypedefTag(node); case 279: return checkSourceElement(node.typeExpression); case 273: @@ -38659,6 +38956,7 @@ var ts; ts.clear(potentialNewTargetCollisions); deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; + flowAnalysisDisabled = false; ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalModule(node)) { @@ -38988,11 +39286,13 @@ var ts; return sig.thisParameter; } } - case 97: - var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); - return type.symbol; + if (ts.isInExpressionContext(node)) { + return checkExpression(node).symbol; + } case 169: - return getTypeFromTypeNode(node).symbol; + return getTypeFromThisTypeNode(node).symbol; + case 97: + return checkExpression(node).symbol; case 123: var constructorDeclaration = node.parent; if (constructorDeclaration && constructorDeclaration.kind === 152) { @@ -39006,13 +39306,17 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 180 && node.parent.argumentExpression === node) { - var objectType = getTypeOfExpression(node.parent.expression); - return getPropertyOfType(objectType, node.text); - } - break; + var objectType = ts.isElementAccessExpression(node.parent) + ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined + : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) + ? getTypeFromTypeNode(node.parent.parent.objectType) + : undefined; + return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); + case 79: + return getSymbolOfNode(node.parent); + default: + return undefined; } - return undefined; } function getShorthandAssignmentValueSymbol(location) { if (location && location.kind === 262) { @@ -39226,7 +39530,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (!!resolveName(container.parent, symbol.escapedName, 107455, undefined, undefined)) { + if (resolveName(container.parent, symbol.escapedName, 107455, undefined, undefined, false)) { links.isDeclarationWithCollidingName = true; } else if (nodeLinks_1.flags & 131072) { @@ -39369,6 +39673,14 @@ var ts; return type.flags & 32768 && getSignaturesOfType(type, 0).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { + typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + if (!typeName) + return ts.TypeReferenceSerializationKind.Unknown; + if (location) { + location = ts.getParseTreeNode(location); + if (!location) + return ts.TypeReferenceSerializationKind.Unknown; + } var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); if (valueSymbol && valueSymbol === typeSymbol) { @@ -39452,7 +39764,7 @@ var ts; location = getDeclarationContainer(parent_16); } } - return resolveName(location, reference.escapedText, 107455 | 1048576 | 2097152, undefined, undefined); + return resolveName(location, reference.escapedText, 107455 | 1048576 | 2097152, undefined, undefined, true); } function getReferencedValueDeclaration(reference) { if (!ts.isGeneratedIdentifier(reference)) { @@ -39728,7 +40040,7 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -39750,12 +40062,6 @@ var ts; case 113: case 112: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 113) { - lastProtected = modifier; - } - else if (modifier.kind === 112) { - lastPrivate = modifier; - } if (flags & 28) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } @@ -40247,7 +40553,7 @@ var ts; currentKind = SetAccessor; } else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name_35); if (effectiveName === undefined) { @@ -40507,7 +40813,7 @@ var ts; } } } - if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1)) { checkESModuleMarker(node.name); } @@ -40522,8 +40828,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var element = elements_1[_i]; if (!ts.isOmittedExpression(element)) { return checkESModuleMarker(element.name); } @@ -40538,8 +40844,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var element = elements_3[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -40988,7 +41294,7 @@ var ts; || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer - ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node; } ts.updateParameter = updateParameter; @@ -41604,13 +41910,26 @@ var ts; return node; } ts.createArrowFunction = createArrowFunction; - function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { + function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody, bodyOrUndefined) { + var equalsGreaterThanToken; + var body; + if (bodyOrUndefined === undefined) { + equalsGreaterThanToken = node.equalsGreaterThanToken; + body = ts.cast(equalsGreaterThanTokenOrBody, ts.isConciseBody); + } + else { + equalsGreaterThanToken = ts.cast(equalsGreaterThanTokenOrBody, function (n) { + return n.kind === 36; + }); + body = bodyOrUndefined; + } return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type + || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } ts.updateArrowFunction = updateArrowFunction; @@ -41715,11 +42034,23 @@ var ts; return node; } ts.createConditional = createConditional; - function updateConditional(node, condition, whenTrue, whenFalse) { + function updateConditional(node, condition) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + if (args.length === 2) { + var whenTrue_1 = args[0], whenFalse_1 = args[1]; + return updateConditional(node, condition, node.questionToken, whenTrue_1, node.colonToken, whenFalse_1); + } + ts.Debug.assert(args.length === 4); + var questionToken = args[0], whenTrue = args[1], colonToken = args[2], whenFalse = args[3]; return node.condition !== condition + || node.questionToken !== questionToken || node.whenTrue !== whenTrue + || node.colonToken !== colonToken || node.whenFalse !== whenFalse - ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node) : node; } ts.updateConditional = updateConditional; @@ -41737,6 +42068,30 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; + function createTemplateHead(text) { + var node = createSynthesizedNode(14); + node.text = text; + return node; + } + ts.createTemplateHead = createTemplateHead; + function createTemplateMiddle(text) { + var node = createSynthesizedNode(15); + node.text = text; + return node; + } + ts.createTemplateMiddle = createTemplateMiddle; + function createTemplateTail(text) { + var node = createSynthesizedNode(16); + node.text = text; + return node; + } + ts.createTemplateTail = createTemplateTail; + function createNoSubstitutionTemplateLiteral(text) { + var node = createSynthesizedNode(13); + node.text = text; + return node; + } + ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { var node = createSynthesizedNode(197); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; @@ -42824,6 +43179,10 @@ var ts; return createCall(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []); } ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression; + function createImmediatelyInvokedArrowFunction(statements, param, paramValue) { + return createCall(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []); + } + ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { return createBinary(left, 26, right); } @@ -43019,9 +43378,7 @@ var ts; var emitNode = getOrCreateEmitNode(node); for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { var helper = helpers_1[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } + emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper); } } return node; @@ -43054,9 +43411,7 @@ var ts; var helper = sourceEmitHelpers[i]; if (predicate(helper)) { helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } + targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper); } else if (helpersRemoved > 0) { sourceEmitHelpers[i - helpersRemoved] = helper; @@ -43774,11 +44129,9 @@ var ts; return recreateOuterExpressions(expression, mutableCall, 4); } } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { - return ts.setTextRange(ts.createParen(expression), expression); - } + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { + return ts.setTextRange(ts.createParen(expression), expression); } return expression; } @@ -43914,9 +44267,17 @@ var ts; case 288: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } + function isIgnorableParen(node) { + return node.kind === 185 + && ts.nodeIsSynthesized(node) + && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) + && ts.nodeIsSynthesized(ts.getCommentRange(node)) + && !ts.some(ts.getSyntheticLeadingComments(node)) + && !ts.some(ts.getSyntheticTrailingComments(node)); + } function recreateOuterExpressions(outerExpression, innerExpression, kinds) { if (kinds === void 0) { kinds = 7; } - if (outerExpression && isOuterExpression(outerExpression, kinds)) { + if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression)); } return innerExpression; @@ -43942,7 +44303,8 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var create = hasExportStarsToExportValues && moduleKind !== ts.ModuleKind.System - && moduleKind !== ts.ModuleKind.ES2015; + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { @@ -44372,7 +44734,7 @@ var ts; case 186: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 187: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 188: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 189: @@ -44388,7 +44750,7 @@ var ts; case 194: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 195: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 196: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 197: @@ -45142,7 +45504,7 @@ var ts; } else { var name_41 = node.name; - if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name_41.escapedText))) { + if (name_41 && !uniqueExports.get(ts.unescapeLeadingUnderscores(name_41.escapedText))) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name_41); uniqueExports.set(ts.unescapeLeadingUnderscores(name_41.escapedText), true); exportedNames = ts.append(exportedNames, name_41); @@ -45435,7 +45797,7 @@ var ts; } function createDestructuringPropertyAccess(flattenContext, value, propertyName) { if (ts.isComputedPropertyName(propertyName)) { - var argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, false, propertyName); + var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName); return ts.createElementAccess(value, argumentExpression); } else if (ts.isStringOrNumericLiteral(propertyName)) { @@ -45618,6 +45980,21 @@ var ts; return saveStateAndInvoke(node, sourceElementVisitorWorker); } function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 238: + case 237: + case 243: + case 244: + return visitEllidableStatement(node); + default: + return visitorWorker(node); + } + } + function visitEllidableStatement(node) { + var parsed = ts.getParseTreeNode(node); + if (parsed !== node) { + return node; + } switch (node.kind) { case 238: return visitImportDeclaration(node); @@ -45628,7 +46005,7 @@ var ts; case 244: return visitExportDeclaration(node); default: - return visitorWorker(node); + ts.Debug.fail("Unhandled ellided statement"); } } function namespaceElementVisitor(node) { @@ -45778,7 +46155,7 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && - !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { @@ -45842,8 +46219,10 @@ var ts; ts.setEmitFlags(statement, 1536 | 384); statements.push(statement); ts.addRange(statements, context.endLexicalEnvironment()); + var iife = ts.createImmediatelyInvokedArrowFunction(statements); + ts.setEmitFlags(iife, 33554432); var varStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ - ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, ts.createImmediatelyInvokedFunctionExpression(statements)) + ts.createVariableDeclaration(ts.getLocalName(node, false, false), undefined, iife) ])); ts.setOriginalNode(varStatement, node); ts.setCommentRange(varStatement, node); @@ -46449,7 +46828,7 @@ var ts; var name_44 = ts.getMutableClone(node); name_44.flags &= ~8; name_44.original = undefined; - name_44.parent = currentScope; + name_44.parent = ts.getParseTreeNode(currentScope); if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name_44), ts.createLiteral("undefined")), name_44); } @@ -46579,7 +46958,7 @@ var ts; return updated; } function visitArrowFunction(node) { - var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.visitFunctionBody(node.body, visitor, context)); return updated; } function visitParameter(node) { @@ -46715,6 +47094,7 @@ var ts; return isExportOfNamespace(node) || (isExternalModuleExport(node) && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System); } function recordEmittedDeclarationInScope(node) { @@ -47174,7 +47554,6 @@ var ts; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var currentSourceFile; var enabledSubstitutions; var enclosingSuperContainerFlags = 0; var previousOnEmitNode = context.onEmitNode; @@ -47186,10 +47565,8 @@ var ts; if (node.isDeclarationFile) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -47232,7 +47609,7 @@ var ts; : ts.visitFunctionBody(node.body, visitor, context)); } function visitArrowFunction(node) { - return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -47522,8 +47899,8 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { - var e = elements_4[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; if (e.kind === 263) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); @@ -47541,7 +47918,7 @@ var ts; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } else { - chunkObject.push(e); + chunkObject.push(ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } } } @@ -47731,7 +48108,7 @@ var ts; function visitArrowFunction(node) { var savedEnclosingFunctionFlags = enclosingFunctionFlags; enclosingFunctionFlags = ts.getFunctionFlags(node); - var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; return updated; } @@ -48556,58 +48933,12 @@ var ts; && node.kind === 219 && !node.expression; } - function isClassLikeVariableStatement(node) { - if (!ts.isVariableStatement(node)) - return false; - var variable = ts.singleOrUndefined(node.declarationList.declarations); - return variable - && variable.initializer - && ts.isIdentifier(variable.name) - && (ts.isClassLike(variable.initializer) - || (ts.isAssignmentExpression(variable.initializer) - && ts.isIdentifier(variable.initializer.left) - && ts.isClassLike(variable.initializer.right))); - } - function isTypeScriptClassWrapper(node) { - var call = ts.tryCast(node, ts.isCallExpression); - if (!call || ts.isParseTreeNode(call) || - ts.some(call.typeArguments) || - ts.some(call.arguments)) { - return false; - } - var func = ts.tryCast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression); - if (!func || ts.isParseTreeNode(func) || - ts.some(func.typeParameters) || - ts.some(func.parameters) || - func.type || - !func.body) { - return false; - } - var statements = func.body.statements; - if (statements.length < 2) { - return false; - } - var firstStatement = statements[0]; - if (ts.isParseTreeNode(firstStatement) || - !ts.isClassLike(firstStatement) && - !isClassLikeVariableStatement(firstStatement)) { - return false; - } - var lastStatement = ts.elementAt(statements, -1); - var returnStatement = ts.tryCast(ts.isVariableStatement(lastStatement) ? ts.elementAt(statements, -2) : lastStatement, ts.isReturnStatement); - if (!returnStatement || - !returnStatement.expression || - !ts.isIdentifier(ts.skipOuterExpressions(returnStatement.expression))) { - return false; - } - return true; - } function shouldVisitNode(node) { return (node.transformFlags & 128) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 4096 && (ts.isStatement(node) || (node.kind === 207))) || (ts.isIterationStatement(node, false) && shouldConvertIterationStatementBody(node)) - || isTypeScriptClassWrapper(node); + || (ts.getEmitFlags(node) & 33554432) !== 0; } function visitor(node) { if (shouldVisitNode(node)) { @@ -50087,7 +50418,7 @@ var ts; return ts.visitEachChild(node, visitor, context); } function visitCallExpression(node) { - if (isTypeScriptClassWrapper(node)) { + if (ts.getEmitFlags(node) & 33554432) { return visitTypeScriptClassWrapper(node); } if (node.transformFlags & 64) { @@ -50096,7 +50427,7 @@ var ts; return ts.updateCall(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression)); } function visitTypeScriptClassWrapper(node) { - var body = ts.cast(ts.skipOuterExpressions(node.expression), ts.isFunctionExpression).body; + var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); var classStatements = ts.visitNodes(body.statements, visitor, ts.isStatement, 0, 1); var remainingStatements = ts.visitNodes(body.statements, visitor, ts.isStatement, 1, body.statements.length - 1); var varStatement = ts.cast(ts.firstOrUndefined(classStatements), ts.isVariableStatement); @@ -50516,7 +50847,6 @@ var ts; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - var currentSourceFile; var renamedCatchVariables; var renamedCatchVariableDeclarations; var inGeneratorFunctionBody; @@ -50547,10 +50877,8 @@ var ts; if (node.isDeclarationFile || (node.transformFlags & 512) === 0) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -52294,6 +52622,7 @@ var ts; } function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var umdHeader = ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(ts.createBlock([ ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("module"), "object"), ts.createTypeCheck(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), "object")), ts.createBlock([ ts.createVariableStatement(undefined, [ @@ -52304,13 +52633,13 @@ var ts; ]), ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ - ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, [ + ts.createStatement(ts.createCall(ts.createIdentifier("define"), undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") - ])) + ]))) ]))) ], true), undefined)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray([ @@ -52375,17 +52704,20 @@ var ts; } function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 | 1536); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536); - statements.push(statement); + var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, importCallExpressionVisitor); + if (expressionResult) { + if (emitAsReturn) { + var statement = ts.createReturn(expressionResult); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 | 1536); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536); + statements.push(statement); + } } } } @@ -52719,7 +53051,7 @@ var ts; return statements; } if (ts.hasModifier(decl, 1)) { - var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : decl.name; + var exportName = ts.hasModifier(decl, 512) ? ts.createIdentifier("default") : ts.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), decl); } if (decl.name) { @@ -53428,7 +53760,8 @@ var ts; } function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; - return ts.createCall(exportFunction, undefined, [exportName, value]); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536); + return ts.setCommentRange(ts.createCall(exportFunction, undefined, [exportName, value]), value); } function nestedElementVisitor(node) { switch (node.kind) { @@ -56559,8 +56892,13 @@ var ts; comments.reset(); setWriter(undefined); } + function emitIfPresent(node) { + if (node) { + emit(node); + } + } function emit(node) { - pipelineEmitWithNotification(3, node); + pipelineEmitWithNotification(4, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -56598,7 +56936,8 @@ var ts; case 0: return pipelineEmitSourceFile(node); case 2: return pipelineEmitIdentifierName(node); case 1: return pipelineEmitExpression(node); - case 3: return pipelineEmitUnspecified(node); + case 3: return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + case 4: return pipelineEmitUnspecified(node); } } function pipelineEmitSourceFile(node) { @@ -56609,6 +56948,11 @@ var ts; ts.Debug.assertNode(node, ts.isIdentifier); emitIdentifier(node); } + function emitMappedTypeParameter(node) { + emit(node.name); + write(" in "); + emit(node.constraint); + } function pipelineEmitUnspecified(node) { var kind = node.kind; if (ts.isKeyword(kind)) { @@ -56952,9 +57296,9 @@ var ts; function emitParameter(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } @@ -56966,7 +57310,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); write(";"); } @@ -56974,7 +57318,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); write(";"); @@ -56983,7 +57327,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); @@ -56992,9 +57336,9 @@ var ts; function emitMethodDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.asteriskToken, "*"); + emitIfPresent(node.asteriskToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } function emitConstructor(node) { @@ -57064,9 +57408,8 @@ var ts; } function emitTypeLiteral(node) { write("{"); - if (node.members.length > 0) { - emitList(node, node.members, ts.getEmitFlags(node) & 1 ? 448 : 65); - } + var flags = ts.getEmitFlags(node) & 1 ? 448 : 65; + emitList(node, node.members, flags | 262144); write("}"); } function emitArrayType(node) { @@ -57113,13 +57456,14 @@ var ts; writeLine(); increaseIndent(); } - writeIfPresent(node.readonlyToken, "readonly "); + if (node.readonlyToken) { + emit(node.readonlyToken); + write(" "); + } write("["); - emit(node.typeParameter.name); - write(" in "); - emit(node.typeParameter.constraint); + pipelineEmitWithNotification(3, node.typeParameter); write("]"); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); write(": "); emit(node.type); write(";"); @@ -57159,36 +57503,25 @@ var ts; } function emitBindingElement(node) { emitWithSuffix(node.propertyName, ": "); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); } function emitArrayLiteralExpression(node) { var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else { - var preferNewLine = node.multiLine ? 32768 : 0; - emitExpressionList(node, elements, 4466 | preferNewLine); - } + var preferNewLine = node.multiLine ? 32768 : 0; + emitExpressionList(node, elements, 4466 | preferNewLine); } function emitObjectLiteralExpression(node) { - var properties = node.properties; - if (properties.length === 0) { - write("{}"); + var indentedFlag = ts.getEmitFlags(node) & 65536; + if (indentedFlag) { + increaseIndent(); } - else { - var indentedFlag = ts.getEmitFlags(node) & 65536; - if (indentedFlag) { - increaseIndent(); - } - var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; - emitList(node, properties, 978 | allowTrailingComma | preferNewLine); - if (indentedFlag) { - decreaseIndent(); - } + var preferNewLine = node.multiLine ? 32768 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; + emitList(node, node.properties, 263122 | allowTrailingComma | preferNewLine); + if (indentedFlag) { + decreaseIndent(); } } function emitPropertyAccessExpression(node) { @@ -57270,7 +57603,8 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParametersForArrow(node, node.parameters); emitWithPrefix(": ", node.type); - write(" =>"); + write(" "); + emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { write("delete "); @@ -57325,12 +57659,12 @@ var ts; var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); increaseIndentIf(indentBeforeQuestion, " "); - write("?"); + emit(node.questionToken); increaseIndentIf(indentAfterQuestion, " "); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); increaseIndentIf(indentBeforeColon, " "); - write(":"); + emit(node.colonToken); increaseIndentIf(indentAfterColon, " "); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); @@ -57340,7 +57674,8 @@ var ts; emitList(node, node.templateSpans, 131072); } function emitYieldExpression(node) { - write(node.asteriskToken ? "yield*" : "yield"); + write("yield"); + emit(node.asteriskToken); emitExpressionWithPrefix(" ", node.expression); } function emitSpreadExpression(node) { @@ -57375,27 +57710,16 @@ var ts; emit(node.literal); } function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - writeToken(17, node.pos, node); - write(" "); - writeToken(18, node.statements.end, node); - } - else { - writeToken(17, node.pos, node); - emitBlockStatements(node); - increaseIndent(); - emitLeadingCommentsOfPosition(node.statements.end); - decreaseIndent(); - writeToken(18, node.statements.end, node); - } + writeToken(17, node.pos, node); + emitBlockStatements(node, !node.multiLine && isEmptyBlock(node)); + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); + writeToken(18, node.statements.end, node); } - function emitBlockStatements(node) { - if (ts.getEmitFlags(node) & 1) { - emitList(node, node.statements, 384); - } - else { - emitList(node, node.statements, 65); - } + function emitBlockStatements(node, forceSingleLine) { + var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 384 : 65; + emitList(node, node.statements, format); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -57573,7 +57897,9 @@ var ts; function emitFunctionDeclarationOrExpression(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.asteriskToken ? "function* " : "function "); + write("function"); + emitIfPresent(node.asteriskToken); + write(" "); emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -57591,7 +57917,7 @@ var ts; if (ts.getEmitFlags(node) & 524288) { emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3, body, emitBlockCallback); + onEmitNode(4, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -57601,7 +57927,7 @@ var ts; pushNameGenerationScope(); emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3, body, emitBlockCallback); + onEmitNode(4, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -57739,7 +58065,9 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - write(node.flags & 16 ? "namespace " : "module "); + if (~node.flags & 512) { + write(node.flags & 16 ? "namespace " : "module "); + } emit(node.name); var body = node.body; while (body.kind === 233) { @@ -57751,16 +58079,11 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isEmptyBlock(node)) { - write("{ }"); - } - else { - pushNameGenerationScope(); - write("{"); - emitBlockStatements(node); - write("}"); - popNameGenerationScope(); - } + pushNameGenerationScope(); + write("{"); + emitBlockStatements(node, isEmptyBlock(node)); + write("}"); + popNameGenerationScope(); } function emitCaseBlock(node) { writeToken(17, node.pos); @@ -57903,9 +58226,7 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); - if (node.dotDotDotToken) { - write("..."); - } + emitIfPresent(node.dotDotDotToken); emitExpression(node.expression); write("}"); } @@ -57936,13 +58257,12 @@ var ts; if (statements.length > 0) { emitTrailingCommentsOfPosition(statements.pos); } + var format = 81985; if (emitAsSingleStatement) { write(" "); - emit(statements[0]); - } - else { - emitList(parentNode, statements, 81985); + format &= ~(1 | 64); } + emitList(parentNode, statements, format); } function emitHeritageClause(node) { write(" "); @@ -58135,7 +58455,7 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emit(parameters[0]); + emitList(parentNode, parameters, 1360 & ~1024); } else { emitParameters(parentNode, parameters); @@ -58157,8 +58477,14 @@ var ts; if (isUndefined && format & 8192) { return; } - var isEmpty = isUndefined || children.length === 0 || start >= children.length || count === 0; + var isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & 16384) { + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } return; } if (format & 7680) { @@ -58171,7 +58497,7 @@ var ts; if (format & 1) { writeLine(); } - else if (format & 128) { + else if (format & 128 && !(format & 262144)) { write(" "); } } @@ -58230,7 +58556,7 @@ var ts; if (format & 16 && hasTrailingComma) { write(","); } - if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + if (previousSibling && delimiter && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024)) { emitLeadingCommentsOfPosition(previousSibling.end); } if (format & 64) { @@ -58267,11 +58593,6 @@ var ts; write(text); } } - function writeIfPresent(node, text) { - if (node) { - write(text); - } - } function writeToken(token, pos, contextNode) { return onEmitSourceMapOfToken ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) @@ -58281,7 +58602,7 @@ var ts; if (onBeforeEmitToken) { onBeforeEmitToken(node); } - writeTokenText(node.kind); + write(ts.tokenToString(node.kind)); if (onAfterEmitToken) { onAfterEmitToken(node); } @@ -58430,10 +58751,6 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); - } function isEmptyBlock(block) { return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); @@ -58677,6 +58994,8 @@ var ts; ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; ListFormat[ListFormat["SingleLineTypeLiteralMembers"] = 448] = "SingleLineTypeLiteralMembers"; @@ -58686,7 +59005,7 @@ var ts; ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; @@ -58880,7 +59199,7 @@ var ts; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -58904,7 +59223,7 @@ var ts; var redForegroundEscapeSequence = "\u001b[91m"; var yellowForegroundEscapeSequence = "\u001b[93m"; var blueForegroundEscapeSequence = "\u001b[93m"; - var gutterStyleSequence = "\u001b[100;30m"; + var gutterStyleSequence = "\u001b[30;47m"; var gutterSeparator = " "; var resetEscapeSequence = "\u001b[0m"; var ellipsis = "..."; @@ -58929,9 +59248,9 @@ var ts; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; if (diagnostic.file) { - var start = diagnostic.start, length_6 = diagnostic.length, file = diagnostic.file; + var start = diagnostic.start, length_5 = diagnostic.length, file = diagnostic.file; var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; - var _b = ts.getLineAndCharacterOfPosition(file, start + length_6), lastLine = _b.line, lastLineChar = _b.character; + var _b = ts.getLineAndCharacterOfPosition(file, start + length_5), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; @@ -58939,10 +59258,10 @@ var ts; if (hasMoreThanFiveLines) { gutterWidth = Math.max(ellipsis.length, gutterWidth); } - output += ts.sys.newLine; + output += host.getNewLine(); for (var i = firstLine; i <= lastLine; i++) { if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); @@ -58951,7 +59270,7 @@ var ts; lineContent = lineContent.replace(/\s+$/g, ""); lineContent = lineContent.replace("\t", " "); output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + ts.sys.newLine; + output += lineContent + host.getNewLine(); output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; output += redForegroundEscapeSequence; if (i === firstLine) { @@ -58966,15 +59285,15 @@ var ts; output += lineContent.replace(/./g, "~"); } output += resetEscapeSequence; - output += ts.sys.newLine; + output += host.getNewLine(); } - output += ts.sys.newLine; + output += host.getNewLine(); output += relativeFileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } var categoryColor = getCategoryFormat(diagnostic.category); var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine); - output += ts.sys.newLine; + output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); + output += host.getNewLine(); } return output; } @@ -59040,6 +59359,8 @@ var ts; ts.performance.mark("beforeProgram"); host = host || createCompilerHost(options); var skipDefaultLib = options.noLib; + var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); + var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName()); var programDiagnostics = ts.createDiagnosticCollection(); var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); @@ -59089,12 +59410,11 @@ var ts; } if (!skipDefaultLib) { if (!options.lib) { - processRootFile(host.getDefaultLibFileName(options), true); + processRootFile(getDefaultLibraryFileName(), true); } else { - var libDirectory_1 = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(host.getDefaultLibFileName(options)); ts.forEach(options.lib, function (libFileName) { - processRootFile(ts.combinePaths(libDirectory_1, libFileName), true); + processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true); }); } } @@ -59127,6 +59447,7 @@ var ts; getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + isSourceFileDefaultLibrary: isSourceFileDefaultLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, sourceFileToPackageName: sourceFileToPackageName, @@ -59350,7 +59671,7 @@ var ts; var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var moduleNames = getModuleNames(newSourceFile); var oldProgramState = { program: oldProgram, file: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo); @@ -59417,6 +59738,15 @@ var ts; function isSourceFileFromExternalLibrary(file) { return sourceFilesFoundSearchingNodeModules.get(file.path); } + function isSourceFileDefaultLibrary(file) { + if (file.hasNoDefaultLib) { + return true; + } + if (defaultLibraryPath && defaultLibraryPath.length !== 0) { + return ts.containsPath(defaultLibraryPath, file.path, currentDirectory, !host.useCaseSensitiveFileNames()); + } + return ts.compareStrings(file.fileName, getDefaultLibraryFileName(), !host.useCaseSensitiveFileNames()) === 0; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true)); } @@ -59531,9 +59861,7 @@ var ts; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - return ts.isSourceFileJavaScript(sourceFile) - ? ts.filter(diagnostics, shouldReportDiagnostic) - : diagnostics; + return ts.filter(diagnostics, shouldReportDiagnostic); }); } function shouldReportDiagnostic(diagnostic) { @@ -59749,16 +60077,15 @@ var ts; return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); + processSourceFile(ts.normalizePath(fileName), isDefaultLib, undefined); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function getTextOfLiteral(literal) { - return literal.text; + return a.kind === 9 + ? b.kind === 9 && a.text === b.text + : b.kind === 71 && a.escapedText === b.escapedText; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -59874,8 +60201,8 @@ var ts; return sourceFileWithAddedExtension; } } - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, undefined); }, function (diagnostic) { + function processSourceFile(fileName, isDefaultLib, packageId, refFile, refPos, refEnd) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -59941,7 +60268,7 @@ var ts; } }); if (packageId) { - var packageIdKey = packageId.name + "@" + packageId.version; + var packageIdKey = packageId.name + "/" + packageId.subModuleName + "@" + packageId.version; var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path); @@ -59988,7 +60315,7 @@ var ts; function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, undefined, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -60010,7 +60337,7 @@ var ts; var saveResolution = true; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } else { if (previousResolution) { @@ -60023,7 +60350,7 @@ var ts; saveResolution = false; } else { - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } } @@ -60052,8 +60379,7 @@ var ts; function processImportedModules(file) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { - var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9; }); - var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var moduleNames = getModuleNames(file); var oldProgramState = { program: oldProgram, file: file, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState); ts.Debug.assert(resolutions.length === moduleNames.length); @@ -60064,13 +60390,19 @@ var ts; continue; } var isFromNodeModulesSearch = resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var isJsFile = !ts.extensionIsTypeScript(resolution.extension); + var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; var resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { currentNodeModulesDepth++; } var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; - var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; + var shouldAddFile = resolvedFileName + && !getResolutionDiagnostic(options, resolution) + && !options.noResolve + && i < file.imports.length + && !elideImport + && !(isJsFile && !options.allowJs); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -60385,7 +60717,7 @@ var ts; return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + return options.allowJs || !options.noImplicitAny ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } } ts.getResolutionDiagnostic = getResolutionDiagnostic; @@ -60393,6 +60725,17 @@ var ts; ts.Debug.assert(names.every(function (name) { return name !== undefined; }), "A name is undefined.", function () { return JSON.stringify(names); }); return names; } + function getModuleNames(_a) { + var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations; + var res = imports.map(function (i) { return i.text; }); + for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { + var aug = moduleAugmentations_1[_i]; + if (aug.kind === 9) { + res.push(aug.text); + } + } + return res; + } })(ts || (ts = {})); var ts; (function (ts) { @@ -60809,25 +61152,24 @@ var ts; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 9 || node.kind === 8) { - switch (node.parent.kind) { - case 149: - case 148: - case 261: - case 264: - case 151: - case 150: - case 153: - case 154: - case 233: - return ts.getNameOfDeclaration(node.parent) === node; - case 180: - return node.parent.argumentExpression === node; - case 144: - return true; - } + switch (node.parent.kind) { + case 149: + case 148: + case 261: + case 264: + case 151: + case 150: + case 153: + case 154: + case 233: + return ts.getNameOfDeclaration(node.parent) === node; + case 180: + return node.parent.argumentExpression === node; + case 144: + return true; + case 173: + return node.parent.parent.kind === 171; } - return false; } ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; function isExpressionOfExternalModuleImportEqualsDeclaration(node) { @@ -60904,6 +61246,27 @@ var ts; return "alias"; case 283: return "type"; + case 194: + var kind = ts.getSpecialPropertyAssignmentKind(node); + var right = node.right; + switch (kind) { + case 0: + return ""; + case 1: + case 2: + var rightKind = getNodeKind(right); + return rightKind === "" ? "const" : rightKind; + case 3: + return "method"; + case 4: + return "property"; + case 5: + return ts.isFunctionExpression(right) ? "method" : "property"; + default: { + ts.assertTypeIsNever(kind); + return ""; + } + } default: return ""; } @@ -61091,7 +61454,7 @@ var ts; return undefined; } var children = list.getChildren(); - var listItemIndex = ts.indexOf(children, node); + var listItemIndex = ts.indexOfNode(children, node); return { listItemIndex: listItemIndex, list: list @@ -62224,7 +62587,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_7 = dense[i + 1]; + var length_6 = dense[i + 1]; var type = dense[i + 2]; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; @@ -62232,8 +62595,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_7, classification: convertClassification(type) }); - lastEnd = start + length_7; + entries.push({ length: length_6, classification: convertClassification(type) }); + lastEnd = start + length_6; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -63087,8 +63450,8 @@ var ts; continue; } var start = completePrefix.length; - var length_8 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_8))); + var length_7 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_7))); } return result; } @@ -63348,7 +63711,7 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, request = completionData.request, keywordFilters = completionData.keywordFilters; + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, allowStringLiteral = completionData.allowStringLiteral, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, request = completionData.request, keywordFilters = completionData.keywordFilters; if (sourceFile.languageVariant === 1 && location && location.parent && location.parent.kind === 252) { var tagName = location.parent.parent.openingElement.tagName; @@ -63370,14 +63733,14 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log, allowStringLiteral); getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); } else { if ((!symbols || symbols.length === 0) && keywordFilters === 0) { return undefined; } - getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log); + getCompletionEntriesFromSymbols(symbols, entries, location, true, typeChecker, compilerOptions.target, log, allowStringLiteral); } if (keywordFilters !== 0 || !isMemberCompletion) { ts.addRange(entries, getKeywordCompletions(keywordFilters)); @@ -63395,7 +63758,7 @@ var ts; return; } uniqueNames.set(realName, true); - var displayName = getCompletionEntryDisplayName(realName, target, true); + var displayName = getCompletionEntryDisplayName(realName, target, true, false); if (displayName) { entries.push({ name: displayName, @@ -63406,8 +63769,8 @@ var ts; } }); } - function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks); + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral) { + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral); if (!displayName) { return undefined; } @@ -63418,13 +63781,13 @@ var ts; sortText: "0", }; } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log, allowStringLiteral) { var start = ts.timestamp(); var uniqueNames = ts.createMap(); if (symbols) { for (var _i = 0, symbols_5 = symbols; _i < symbols_5.length; _i++) { var symbol = symbols_5[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral); if (entry) { var id = entry.name; if (!uniqueNames.has(id)) { @@ -63471,7 +63834,7 @@ var ts; var type = typeChecker.getContextualType(element.parent); var entries = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, false, typeChecker, target, log, true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } @@ -63495,7 +63858,7 @@ var ts; var type = typeChecker.getTypeAtLocation(node.expression); var entries = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, false, typeChecker, target, log, true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } @@ -63526,7 +63889,7 @@ var ts; addStringLiteralCompletionsFromType(t, result, typeChecker, uniques); } } - else if (type.flags & 32) { + else if (type.flags & 32 && !(type.flags & 256)) { var name_56 = type.value; if (!uniques.has(name_56)) { uniques.set(name_56, true); @@ -63542,8 +63905,8 @@ var ts; function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location_3 = completionData.location; - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false) === entryName ? s : undefined; }); + var symbols = completionData.symbols, location_3 = completionData.location, allowStringLiteral_1 = completionData.allowStringLiteral; + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false, allowStringLiteral_1) === entryName ? s : undefined; }); if (symbol) { var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_3, location_3, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { @@ -63572,7 +63935,11 @@ var ts; Completions.getCompletionEntryDetails = getCompletionEntryDetails; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); - return completionData && ts.forEach(completionData.symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false) === entryName ? s : undefined; }); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, allowStringLiteral = completionData.allowStringLiteral; + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, false, allowStringLiteral) === entryName ? s : undefined; }); } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; function getCompletionData(typeChecker, log, sourceFile, position) { @@ -63616,7 +63983,7 @@ var ts; } } if (request) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request: request, keywordFilters: 0 }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, allowStringLiteral: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request: request, keywordFilters: 0 }; } if (!insideJsDocTagTypeExpression) { log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); @@ -63686,6 +64053,7 @@ var ts; var semanticStart = ts.timestamp(); var isGlobalCompletion = false; var isMemberCompletion; + var allowStringLiteral = false; var isNewIdentifierLocation; var keywordFilters = 0; var symbols = []; @@ -63718,7 +64086,7 @@ var ts; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request: request, keywordFilters: keywordFilters }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, allowStringLiteral: allowStringLiteral, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request: request, keywordFilters: keywordFilters }; function isTagWithTypeExpression(tag) { switch (tag.kind) { case 277: @@ -63983,6 +64351,7 @@ var ts; } function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { isMemberCompletion = true; + allowStringLiteral = true; var typeMembers; var existingMembers; if (objectLikeContainer.kind === 178) { @@ -63990,7 +64359,7 @@ var ts; var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return false; - typeMembers = typeChecker.getAllPossiblePropertiesOfType(typeForObject); + typeMembers = getPropertiesForCompletion(typeForObject, typeChecker); existingMembers = objectLikeContainer.properties; } else { @@ -64419,7 +64788,7 @@ var ts; return node.getStart() <= position && position <= node.getEnd(); } } - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral) { var name = symbol.name; if (!name) return undefined; @@ -64429,11 +64798,11 @@ var ts; return undefined; } } - return getCompletionEntryDisplayName(name, target, performCharacterChecks); + return getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral); } - function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + function getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral) { if (performCharacterChecks && !ts.isIdentifierText(name, target)) { - return undefined; + return allowStringLiteral ? JSON.stringify(name) : undefined; } return name; } @@ -64537,6 +64906,14 @@ var ts; return node.parent; } } + function getPropertiesForCompletion(type, checker) { + if (!(type.flags & 65536)) { + return checker.getPropertiesOfType(type); + } + var types = type.types; + var filteredTypes = types.filter(function (memberType) { return !(memberType.flags & 8190 || checker.isArrayLikeType(memberType)); }); + return checker.getAllPossiblePropertiesOfTypes(filteredTypes); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); var ts; @@ -65085,11 +65462,10 @@ var ts; var bucket = getBucketForCompilationSettings(key, true); var entry = bucket.get(path); if (!entry) { - ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, false, scriptKind); entry = { sourceFile: sourceFile, - languageServiceRefCount: 0, + languageServiceRefCount: 1, owners: [] }; bucket.set(path, entry); @@ -65098,9 +65474,9 @@ var ts; if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); } - } - if (acquiring) { - entry.languageServiceRefCount++; + if (acquiring) { + entry.languageServiceRefCount++; + } } return entry.sourceFile; } @@ -65265,7 +65641,6 @@ var ts; } } function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, checker, isForRename) { - var exportName = exportSymbol.escapedName; var importSearches = []; var singleReferences = []; function addSearch(location, symbol) { @@ -65296,10 +65671,10 @@ var ts; searchForNamedImport(decl.exportClause); return; } - if (!decl.importClause) { + var importClause = decl.importClause; + if (!importClause) { return; } - var importClause = decl.importClause; var namedBindings = importClause.namedBindings; if (namedBindings && namedBindings.kind === 240) { handleNamespaceImportLike(namedBindings.name); @@ -65315,39 +65690,42 @@ var ts; addSearch(name_60, defaultImportAlias); } if (!isForRename && exportKind === 1) { - ts.Debug.assert(exportName === "default"); searchForNamedImport(namedBindings); } } } function handleNamespaceImportLike(importName) { - if (exportKind === 2 && (!isForRename || importName.escapedText === exportName)) { + if (exportKind === 2 && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } function searchForNamedImport(namedBindings) { - if (namedBindings) { - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name_61 = element.name, propertyName = element.propertyName; - if ((propertyName || name_61).escapedText !== exportName) { - continue; - } - if (propertyName) { - singleReferences.push(propertyName); - if (!isForRename) { - addSearch(name_61, checker.getSymbolAtLocation(name_61)); - } - } - else { - var localSymbol = element.kind === 246 && element.propertyName - ? checker.getExportSpecifierLocalTargetSymbol(element) - : checker.getSymbolAtLocation(name_61); - addSearch(name_61, localSymbol); + if (!namedBindings) { + return; + } + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name_61 = element.name, propertyName = element.propertyName; + if (!isNameMatch((propertyName || name_61).escapedText)) { + continue; + } + if (propertyName) { + singleReferences.push(propertyName); + if (!isForRename) { + addSearch(name_61, checker.getSymbolAtLocation(name_61)); } } + else { + var localSymbol = element.kind === 246 && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) + : checker.getSymbolAtLocation(name_61); + addSearch(name_61, localSymbol); + } } } + function isNameMatch(name) { + return name === exportSymbol.escapedName || exportKind !== 0 && name === "default"; + } } function findNamespaceReExports(sourceFileLike, name, checker) { var namespaceImportSymbol = checker.getSymbolAtLocation(name); @@ -65508,7 +65886,8 @@ var ts; function getExportAssignmentExport(ex) { var exportingModuleSymbol = ex.symbol.parent; ts.Debug.assert(!!exportingModuleSymbol); - return { kind: 1, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: 2 } }; + var exportKind = ex.isExportEquals ? 2 : 1; + return { kind: 1, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -65537,7 +65916,8 @@ var ts; if (importedSymbol.escapedName === "export=") { importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker); } - if (symbolName(importedSymbol) === symbol.escapedName) { + var importedName = symbolName(importedSymbol); + if (importedName === undefined || importedName === "default" || importedName === symbol.escapedName) { return __assign({ kind: 0, symbol: importedSymbol }, isImport); } } @@ -65764,8 +66144,10 @@ var ts; return { fileName: node.getSourceFile().fileName, textSpan: getTextSpan(node), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isAnyDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node), + isWriteAccess: isWriteAccessForReference(node), + isDefinition: node.kind === 79 + || ts.isAnyDeclarationName(node) + || ts.isLiteralComputedPropertyDeclarationName(node), isInString: isInString }; } @@ -65807,7 +66189,7 @@ var ts; } var node = entry.node, isInString = entry.isInString; var fileName = entry.node.getSourceFile().fileName; - var writeAccess = isWriteAccess(node); + var writeAccess = isWriteAccessForReference(node); var span = { textSpan: getTextSpan(node), kind: writeAccess ? "writtenReference" : "reference", @@ -65825,20 +66207,8 @@ var ts; } return ts.createTextSpanFromBounds(start, end); } - function isWriteAccess(node) { - if (ts.isAnyDeclarationName(node)) { - return true; - } - var parent = node.parent; - switch (parent && parent.kind) { - case 193: - case 192: - return true; - case 194: - return parent.left === node && ts.isAssignmentOperator(parent.operatorToken.kind); - default: - return false; - } + function isWriteAccessForReference(node) { + return node.kind === 79 || ts.isAnyDeclarationName(node) || ts.isWriteAccess(node); } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -66163,7 +66533,7 @@ var ts; return [{ definition: { type: "label", node: targetLabel }, references: references }]; } function isValidReferencePosition(node, searchSymbolName) { - switch (node && node.kind) { + switch (node.kind) { case 71: return node.text.length === searchSymbolName.length; case 9: @@ -66171,6 +66541,8 @@ var ts; node.text.length === searchSymbolName.length; case 8: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; + case 79: + return "default".length === searchSymbolName.length; default: return false; } @@ -66683,17 +67055,21 @@ var ts; var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); if (bindingElementPropertySymbol) { result.push(bindingElementPropertySymbol); + addRootSymbols(bindingElementPropertySymbol); } - for (var _i = 0, _a = checker.getRootSymbols(symbol); _i < _a.length; _i++) { - var rootSymbol = _a[_i]; - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, ts.createSymbolTable(), checker); - } - } + addRootSymbols(symbol); return result; + function addRootSymbols(sym) { + for (var _i = 0, _a = checker.getRootSymbols(sym); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== sym) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, ts.createSymbolTable(), checker); + } + } + } } function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, checker) { if (!symbol) { @@ -66746,23 +67122,28 @@ var ts; } } var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); - if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; + if (bindingElementPropertySymbol) { + var fromBindingElement = findRootSymbol(bindingElementPropertySymbol); + if (fromBindingElement) + return fromBindingElement; } - return ts.forEach(state.checker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (search.includes(rootSymbol)) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { - return undefined; + return findRootSymbol(referenceSymbol); + function findRootSymbol(sym) { + return ts.forEach(state.checker.getRootSymbols(sym), function (rootSymbol) { + if (search.includes(rootSymbol)) { + return rootSymbol; } - var result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, ts.createSymbolTable(), state.checker); - return ts.find(result, search.includes); - } - return undefined; - }); + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { + return undefined; + } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, ts.createSymbolTable(), state.checker); + return ts.find(result, search.includes); + } + return undefined; + }); + } } function getNameFromObjectLiteralElement(node) { if (node.name.kind === 144) { @@ -67279,43 +67660,31 @@ var ts; if (!tokenAtPos || tokenStart < position) { return undefined; } - var commentOwner; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case 228: - case 151: - case 152: - case 229: - case 208: - break findOwner; - case 265: - return undefined; - case 233: - if (commentOwner.parent.kind === 233) { - return undefined; - } - break findOwner; - } + var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + if (!commentOwnerInfo) { + return undefined; } - if (!commentOwner || commentOwner.getStart() < position) { + var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters; + if (commentOwner.getStart() < position) { return undefined; } - var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0; i < parameters.length; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 71 ? - currentName.escapedText : - "param" + i; - if (isJavaScriptFile) { - docParams += indentationStr + " * @param {any} " + paramName + newLine; - } - else { - docParams += indentationStr + " * @param " + paramName + newLine; + if (parameters) { + for (var i = 0; i < parameters.length; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 71 ? + currentName.escapedText : + "param" + i; + if (isJavaScriptFile) { + docParams += indentationStr + " * @param {any} " + paramName + newLine; + } + else { + docParams += indentationStr + " * @param " + paramName + newLine; + } } } var preamble = "/**" + newLine + @@ -67327,18 +67696,38 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; - function getParametersForJsDocOwningNode(commentOwner) { - if (ts.isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } - if (commentOwner.kind === 208) { - var varStatement = commentOwner; - var varDeclarations = varStatement.declarationList.declarations; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + function getCommentOwnerInfo(tokenAtPos) { + for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 228: + case 151: + case 152: + var parameters = commentOwner.parameters; + return { commentOwner: commentOwner, parameters: parameters }; + case 229: + return { commentOwner: commentOwner }; + case 208: { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer + ? getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer) + : undefined; + return { commentOwner: commentOwner, parameters: parameters_1 }; + } + case 265: + return undefined; + case 233: + return commentOwner.parent.kind === 233 ? undefined : { commentOwner: commentOwner }; + case 194: { + var be = commentOwner; + if (ts.getSpecialPropertyAssignmentKind(be) === 0) { + return undefined; + } + var parameters_2 = ts.isFunctionLike(be.right) ? be.right.parameters : ts.emptyArray; + return { commentOwner: commentOwner, parameters: parameters_2 }; + } } } - return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { while (rightHandSide.kind === 185) { @@ -67536,148 +67925,149 @@ var ts; return "continue"; } ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { - if (declarations) { - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); - if (!matches) { - return; - } - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - if (patternMatcher.patternContainsDots) { - var containers = getContainers(declaration); - if (!containers) { - return true; - } - matches = patternMatcher.getMatches(containers, name); - if (!matches) { - return; - } - } - var fileName = sourceFile.fileName; - var matchKind = bestMatchKind(matches); - rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); - } - } + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, rawItems); }); }; for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { var sourceFile = sourceFiles_8[_i]; _loop_6(sourceFile); } - rawItems = ts.filter(rawItems, function (item) { - var decl = item.declaration; - if (decl.kind === 239 || decl.kind === 242 || decl.kind === 237) { - var importer = checker.getSymbolAtLocation(decl.name); - var imported = checker.getAliasedSymbol(importer); - return importer.escapedName !== imported.escapedName; - } - else { - return true; - } - }); rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { rawItems = rawItems.slice(0, maxResultCount); } - var items = ts.map(rawItems, createNavigateToItem); - return items; - function allMatchesAreCaseSensitive(matches) { - ts.Debug.assert(matches.length > 0); - for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { - var match = matches_2[_i]; - if (!match.isCaseSensitive) { + return rawItems.map(createNavigateToItem); + } + NavigateTo.getNavigateToItems = getNavigateToItems; + function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); + if (!matches) { + return; + } + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + if (!shouldKeepItem(declaration, checker)) { + continue; + } + var containerMatches = matches; + if (patternMatcher.patternContainsDots) { + containerMatches = patternMatcher.getMatches(getContainers(declaration), name); + if (!containerMatches) { + continue; + } + } + var matchKind = bestMatchKind(containerMatches); + var isCaseSensitive = allMatchesAreCaseSensitive(containerMatches); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: isCaseSensitive, declaration: declaration }); + } + } + function shouldKeepItem(declaration, checker) { + switch (declaration.kind) { + case 239: + case 242: + case 237: + var importer = checker.getSymbolAtLocation(declaration.name); + var imported = checker.getAliasedSymbol(importer); + return importer.escapedName !== imported.escapedName; + default: + return true; + } + } + function allMatchesAreCaseSensitive(matches) { + ts.Debug.assert(matches.length > 0); + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; + if (!match.isCaseSensitive) { + return false; + } + } + return true; + } + function tryAddSingleDeclarationName(declaration, containers) { + if (declaration) { + var name_64 = ts.getNameOfDeclaration(declaration); + if (name_64) { + var text = ts.getTextOfIdentifierOrLiteral(name_64); + if (text !== undefined) { + containers.unshift(text); + } + else if (name_64.kind === 144) { + return tryAddComputedPropertyName(name_64.expression, containers, true); + } + else { return false; } } - return true; } - function tryAddSingleDeclarationName(declaration, containers) { - if (declaration) { - var name_64 = ts.getNameOfDeclaration(declaration); - if (name_64) { - var text = ts.getTextOfIdentifierOrLiteral(name_64); - if (text !== undefined) { - containers.unshift(text); - } - else if (name_64.kind === 144) { - return tryAddComputedPropertyName(name_64.expression, containers, true); - } - else { - return false; - } - } + return true; + } + function tryAddComputedPropertyName(expression, containers, includeLastPortion) { + var text = ts.getTextOfIdentifierOrLiteral(expression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); } return true; } - function tryAddComputedPropertyName(expression, containers, includeLastPortion) { - var text = ts.getTextOfIdentifierOrLiteral(expression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; + if (expression.kind === 179) { + var propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); } - if (expression.kind === 179) { - var propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - return tryAddComputedPropertyName(propertyAccess.expression, containers, true); - } - return false; + return tryAddComputedPropertyName(propertyAccess.expression, containers, true); } - function getContainers(declaration) { - var containers = []; - var name = ts.getNameOfDeclaration(declaration); - if (name.kind === 144) { - if (!tryAddComputedPropertyName(name.expression, containers, false)) { - return undefined; - } + return false; + } + function getContainers(declaration) { + var containers = []; + var name = ts.getNameOfDeclaration(declaration); + if (name.kind === 144) { + if (!tryAddComputedPropertyName(name.expression, containers, false)) { + return undefined; + } + } + declaration = ts.getContainerNode(declaration); + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; } declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } - declaration = ts.getContainerNode(declaration); - } - return containers; - } - function bestMatchKind(matches) { - ts.Debug.assert(matches.length > 0); - var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { - var match = matches_3[_i]; - var kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } - return bestMatchKind; - } - function compareNavigateToItems(i1, i2) { - return i1.matchKind - i2.matchKind || - ts.compareStringsCaseInsensitive(i1.name, i2.name) || - ts.compareStrings(i1.name, i2.name); - } - function createNavigateToItem(rawItem) { - var declaration = rawItem.declaration; - var container = ts.getContainerNode(declaration); - var containerName = container && ts.getNameOfDeclaration(container); - return { - name: rawItem.name, - kind: ts.getNodeKind(declaration), - kindModifiers: ts.getNodeModifiers(declaration), - matchKind: ts.PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromNode(declaration), - containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" - }; } + return containers; + } + function bestMatchKind(matches) { + ts.Debug.assert(matches.length > 0); + var bestMatchKind = ts.PatternMatchKind.camelCase; + for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { + var match = matches_3[_i]; + var kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; + } + } + return bestMatchKind; + } + function compareNavigateToItems(i1, i2) { + return i1.matchKind - i2.matchKind || + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); + } + function createNavigateToItem(rawItem) { + var declaration = rawItem.declaration; + var container = ts.getContainerNode(declaration); + var containerName = container && ts.getNameOfDeclaration(container); + return { + name: rawItem.name, + kind: ts.getNodeKind(declaration), + kindModifiers: ts.getNodeModifiers(declaration), + matchKind: ts.PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: ts.createTextSpanFromNode(declaration), + containerName: containerName ? containerName.text : "", + containerKind: containerName ? ts.getNodeKind(container) : "" + }; } - NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); var ts; @@ -67825,16 +68215,22 @@ var ts; break; case 176: case 226: - var decl = node; - var name_65 = decl.name; + var _d = node, name_65 = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name_65)) { addChildrenRecursively(name_65); } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - addChildrenRecursively(decl.initializer); + else if (initializer && isFunctionOrClassExpression(initializer)) { + if (initializer.name) { + addChildrenRecursively(initializer); + } + else { + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); + } } else { - addNodeWithRecursiveChild(decl, decl.initializer); + addNodeWithRecursiveChild(node, initializer); } break; case 187: @@ -67844,8 +68240,8 @@ var ts; break; case 232: startNode(node); - for (var _d = 0, _e = node.members; _d < _e.length; _d++) { - var member = _e[_d]; + for (var _e = 0, _f = node.members; _e < _f.length; _e++) { + var member = _f[_e]; if (!isComputedProperty(member)) { addLeafNode(member); } @@ -67856,8 +68252,8 @@ var ts; case 199: case 230: startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; + for (var _g = 0, _h = node.members; _g < _h.length; _g++) { + var member = _h[_g]; addChildrenRecursively(member); } endNode(); @@ -67874,13 +68270,15 @@ var ts; addLeafNode(node); break; default: - ts.forEach(node.jsDoc, function (jsDoc) { - ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 283) { - addLeafNode(tag); - } + if (ts.hasJSDocNodes(node)) { + ts.forEach(node.jsDoc, function (jsDoc) { + ts.forEach(jsDoc.tags, function (tag) { + if (tag.kind === 283) { + addLeafNode(tag); + } + }); }); - }); + } ts.forEachChild(node, addChildrenRecursively); } } @@ -68193,7 +68591,14 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 186 || node.kind === 187 || node.kind === 199; + switch (node.kind) { + case 187: + case 186: + case 199: + return true; + default: + return false; + } } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -68203,11 +68608,15 @@ var ts; (function (OutliningElementsCollector) { var collapseText = "..."; var maxDepth = 20; + var defaultLabel = "#region"; + var regionMatch = new RegExp("^\\s*//\\s*#(end)?region(?:\\s+(.*))?$"); function collectElements(sourceFile, cancellationToken) { var elements = []; var depth = 0; + var regions = []; walk(sourceFile); - return elements; + gatherRegions(); + return elements.sort(function (span1, span2) { return span1.textSpan.start - span2.textSpan.start; }); function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse, useFullStart) { if (hintSpanNode && startElement && endElement) { var span_13 = { @@ -68272,6 +68681,36 @@ var ts; function autoCollapse(node) { return ts.isFunctionBlock(node) && node.parent.kind !== 187; } + function gatherRegions() { + var lineStarts = sourceFile.getLineStarts(); + for (var i = 0; i < lineStarts.length; i++) { + var currentLineStart = lineStarts[i]; + var lineEnd = lineStarts[i + 1] - 1 || sourceFile.getEnd(); + var comment = sourceFile.text.substring(currentLineStart, lineEnd); + var result = comment.match(regionMatch); + if (result && !ts.isInComment(sourceFile, currentLineStart)) { + if (!result[1]) { + var start = sourceFile.getFullText().indexOf("//", currentLineStart); + var textSpan = ts.createTextSpanFromBounds(start, lineEnd); + var region = { + textSpan: textSpan, + hintSpan: textSpan, + bannerText: result[2] || defaultLabel, + autoCollapse: false + }; + regions.push(region); + } + else { + var region = regions.pop(); + if (region) { + region.textSpan.length = lineEnd - region.textSpan.start; + region.hintSpan.length = lineEnd - region.textSpan.start; + elements.push(region); + } + } + } + } + } function walk(n) { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -68988,11 +69427,9 @@ var ts; return true; } token = nextToken(); - var i = 0; while (token !== 22 && token !== 1) { if (token === 9) { recordModuleName(); - i++; } token = nextToken(); } @@ -69132,10 +69569,16 @@ var ts; return ts.createTextSpan(start, width); } function nodeIsEligibleForRename(node) { - return node.kind === 71 || - node.kind === 9 || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node); + switch (node.kind) { + case 71: + case 9: + case 99: + return true; + case 8: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); + default: + return false; + } } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); @@ -69374,7 +69817,7 @@ var ts; if (isTypeParameterList) { isVariadic = false; prefixDisplayParts.push(ts.punctuationPart(27)); - var typeParameters = candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; + var typeParameters = (candidateSignature.target || candidateSignature).typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : ts.emptyArray; suffixDisplayParts.push(ts.punctuationPart(29)); var parameterParts = ts.mapToDisplayParts(function (writer) { @@ -69509,7 +69952,7 @@ var ts; if (rootSymbolFlags & (98308 | 3)) { return "property"; } - ts.Debug.assert(!!(rootSymbolFlags & 8192)); + ts.Debug.assert(!!(rootSymbolFlags & (8192 | 16))); }); if (!unionPropertyKind) { var typeOfUnionProperty = typeChecker.getTypeOfSymbolAtLocation(symbol, location); @@ -70035,7 +70478,6 @@ var ts; (function (formatting) { var standardScanner = ts.createScanner(5, false, 0); var jsxScanner = ts.createScanner(5, false, 1); - var scanner; var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -70045,9 +70487,8 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); - function getFormattingScanner(text, languageVariant, startPos, endPos) { - ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = languageVariant === 1 ? jsxScanner : standardScanner; + function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { + var scanner = languageVariant === 1 ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -70056,38 +70497,28 @@ var ts; var savedPos; var lastScanAction; var lastTokenInfo; - return { + var res = cb({ advance: advance, readTokenInfo: readTokenInfo, isOnToken: isOnToken, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, - close: function () { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; + }); + lastTokenInfo = undefined; + scanner.setText(undefined); + return res; function advance() { - ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - if (trailingTrivia) { - ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4; - } - else { - wasNewLine = false; - } + wasNewLine = trailingTrivia && ts.lastOrUndefined(trailingTrivia).kind === 4; + } + else { + scanner.scan(); } leadingTrivia = undefined; trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } var pos = scanner.getStartPos(); while (pos < endPos) { var t = scanner.getToken(); @@ -70101,23 +70532,18 @@ var ts; kind: t }; pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; - } - leadingTrivia.push(item); + leadingTrivia = ts.append(leadingTrivia, item); } savedPos = scanner.getStartPos(); } function shouldRescanGreaterThanToken(node) { - if (node) { - switch (node.kind) { - case 31: - case 66: - case 67: - case 47: - case 46: - return true; - } + switch (node.kind) { + case 31: + case 66: + case 67: + case 47: + case 46: + return true; } return false; } @@ -70128,13 +70554,13 @@ var ts; case 251: case 252: case 250: - return node.kind === 71; + return ts.isKeyword(node.kind) || node.kind === 71; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 10; + return node.kind === 10; } function shouldRescanSlashToken(container) { return container.kind === 12; @@ -70147,14 +70573,7 @@ var ts; return t === 41 || t === 63; } function readTokenInfo(n) { - ts.Debug.assert(scanner !== undefined); - if (!isOnToken()) { - return { - leadingTrivia: leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } + ts.Debug.assert(isOnToken()); var expectedScanAction = shouldRescanGreaterThanToken(n) ? 1 : shouldRescanSlashToken(n) @@ -70174,32 +70593,7 @@ var ts; scanner.setTextPos(savedPos); scanner.scan(); } - var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 29) { - currentToken = scanner.reScanGreaterToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 1; - } - else if (expectedScanAction === 2 && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 2; - } - else if (expectedScanAction === 3 && currentToken === 18) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = 3; - } - else if (expectedScanAction === 4 && currentToken === 71) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = 4; - } - else if (expectedScanAction === 5) { - currentToken = scanner.reScanJsxToken(); - lastScanAction = 5; - } - else { - lastScanAction = 0; - } + var currentToken = getNextToken(n, expectedScanAction); var token = { pos: scanner.getStartPos(), end: scanner.getTextPos(), @@ -70230,8 +70624,46 @@ var ts; lastTokenInfo = { leadingTrivia: leadingTrivia, trailingTrivia: trailingTrivia, token: token }; return fixTokenKind(lastTokenInfo, n); } + function getNextToken(n, expectedScanAction) { + var token = scanner.getToken(); + lastScanAction = 0; + switch (expectedScanAction) { + case 1: + if (token === 29) { + lastScanAction = 1; + var newToken = scanner.reScanGreaterToken(); + ts.Debug.assert(n.kind === newToken); + return newToken; + } + break; + case 2: + if (startsWithSlashToken(token)) { + lastScanAction = 2; + var newToken = scanner.reScanSlashToken(); + ts.Debug.assert(n.kind === newToken); + return newToken; + } + break; + case 3: + if (token === 18) { + lastScanAction = 3; + return scanner.reScanTemplateToken(); + } + break; + case 4: + lastScanAction = 4; + return scanner.scanJsxIdentifier(); + case 5: + lastScanAction = 5; + return scanner.reScanJsxToken(); + case 0: + break; + default: + ts.Debug.assertNever(expectedScanAction); + } + return token; + } function isOnToken() { - ts.Debug.assert(scanner !== undefined); var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 && !ts.isTrivia(current); @@ -70360,11 +70792,6 @@ var ts; this.Operation = Operation; this.Flag = Flag; } - Rule.prototype.toString = function () { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; - }; return Rule; }()); formatting.Rule = Rule; @@ -70683,16 +71110,16 @@ var ts; this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - } - Rules.prototype.getRuleName = function (rule) { - var o = this; - for (var name_66 in o) { - if (o[name_66] === rule) { - return name_66; + if (ts.Debug.isDebugging) { + var o = this; + for (var name_66 in o) { + var rule = o[name_66]; + if (rule instanceof formatting.Rule) { + rule.debugName = name_66; + } } } - throw new Error("Unknown rule"); - }; + } Rules.IsOptionEnabled = function (optionName) { return function (context) { return context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; }; }; @@ -70831,8 +71258,7 @@ var ts; return true; case 207: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 187 && - blockParent.kind !== 186) { + if (!blockParent || blockParent.kind !== 187 && blockParent.kind !== 186) { return true; } } @@ -71242,15 +71668,9 @@ var ts; var RulesProvider = (function () { function RulesProvider() { this.globalRules = new formatting.Rules(); - var activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); + var activeRules = this.globalRules.HighPriorityCommonRules.concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); this.rulesMap = formatting.RulesMap.create(activeRules); } - RulesProvider.prototype.getRuleName = function (rule) { - return this.globalRules.getRuleName(rule); - }; - RulesProvider.prototype.getRuleByName = function (name) { - return this.globalRules[name]; - }; RulesProvider.prototype.getRulesMap = function () { return this.rulesMap; }; @@ -71443,7 +71863,7 @@ var ts; } function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, rulesProvider) { var range = { pos: 0, end: sourceFileLike.text.length }; - return formatSpanWorker(range, node, initialIndentation, delta, formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), rulesProvider.getFormatOptions(), rulesProvider, 1, function (_) { return false; }, sourceFileLike); + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, rulesProvider.getFormatOptions(), rulesProvider, 1, function (_) { return false; }, sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; function formatNodeLines(node, sourceFile, options, rulesProvider, requestKind) { @@ -71458,7 +71878,7 @@ var ts; } function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { var enclosingNode = findEnclosingNode(originalRange, sourceFile); - return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); + return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), scanner, options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { var formattingContext = new formatting.FormattingContext(sourceFile, requestKind, options); @@ -71484,7 +71904,6 @@ var ts; trimTrailingWhitespacesForRemainingRange(); } } - formattingScanner.close(); return edits; function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || @@ -71681,6 +72100,7 @@ var ts; return inheritedIndentation; } function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { + ts.Debug.assert(ts.isNodeArray(nodes)); var listStartToken = getOpenTokenForList(parent, nodes); var listEndToken = getCloseTokenForOpenToken(listStartToken); var listDynamicIndentation = parentDynamicIndentation; @@ -72474,6 +72894,8 @@ var ts; case 241: case 246: case 242: + case 261: + case 149: return true; } return false; @@ -72518,15 +72940,21 @@ var ts; var textChanges; (function (textChanges) { function getPos(n) { - return n["__pos"]; + var result = n["__pos"]; + ts.Debug.assert(typeof result === "number"); + return result; } function setPos(n, pos) { + ts.Debug.assert(typeof pos === "number"); n["__pos"] = pos; } function getEnd(n) { - return n["__end"]; + var result = n["__end"]; + ts.Debug.assert(typeof result === "number"); + return result; } function setEnd(n, end) { + ts.Debug.assert(typeof end === "number"); n["__end"] = end; } var Position; @@ -72573,7 +73001,8 @@ var ts; if (startLine === fullStartLine) { return position === Position.Start ? start : fullStart; } - var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + var nextLineStart = fullStart > 0 ? 1 : 0; + var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + nextLineStart, sourceFile); adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); } @@ -72599,9 +73028,6 @@ var ts; } return s; } - function getNewlineKind(context) { - return context.newLineCharacter === "\n" ? 1 : 0; - } var ChangeTracker = (function () { function ChangeTracker(newLine, rulesProvider, validator) { this.newLine = newLine; @@ -72610,8 +73036,8 @@ var ts; this.changes = []; this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); } - ChangeTracker.fromCodeFixContext = function (context) { - return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + ChangeTracker.fromContext = function (context) { + return new ChangeTracker(context.newLineCharacter === "\n" ? 1 : 0, context.rulesProvider); }; ChangeTracker.prototype.deleteRange = function (sourceFile, range) { this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); @@ -72637,7 +73063,7 @@ var ts; ts.Debug.fail("node is not a list element"); return this; } - var index = containingList.indexOf(node); + var index = ts.indexOfNode(containingList, node); if (index < 0) { return this; } @@ -72752,7 +73178,7 @@ var ts; ts.Debug.fail("node is not a list element"); return this; } - var index = containingList.indexOf(after); + var index = ts.indexOfNode(containingList, after); if (index < 0) { return this; } @@ -72915,10 +73341,9 @@ var ts; var options = { newLine: newLine, target: sourceFile && sourceFile.languageVersion }; var writer = new Writer(ts.getNewLineCharacter(options)); var printer = ts.createPrinter(options, writer); - printer.writeNode(3, node, sourceFile, writer); + printer.writeNode(4, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } - textChanges.getNonformattedText = getNonformattedText; function applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, rulesProvider) { var lineMap = ts.computeLineStarts(nonFormattedText.text); var file = { @@ -72929,7 +73354,6 @@ var ts; var changes = ts.formatting.formatNodeGivenIndentation(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); return applyChanges(nonFormattedText.text, changes); } - textChanges.applyFormatting = applyFormatting; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var change = changes[i]; @@ -72943,13 +73367,10 @@ var ts; } function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); - var newNode = ts.nodeIsSynthesized(visited) - ? visited - : (Proxy.prototype = visited, new Proxy()); + var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited); newNode.pos = getPos(node); newNode.end = getEnd(node); return newNode; - function Proxy() { } } function assignPositionsToNodeArray(nodes, visitor, test, start, count) { var visited = ts.visitNodes(nodes, visitor, test, start, count); @@ -73082,7 +73503,15 @@ var ts; ts.forEach(fixes, function (f) { var actions = f.getCodeActions(context); if (actions && actions.length > 0) { - allActions = allActions.concat(actions); + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + if (action === undefined) { + context.host.log("Action for error code " + context.errorCode + " added an invalid action entry; please log a bug"); + } + else { + allActions.push(action); + } + } } }); return allActions; @@ -73111,6 +73540,10 @@ var ts; } refactor_1.getEditsForRefactor = getEditsForRefactor; })(refactor = ts.refactor || (ts.refactor = {})); + function getRefactorContextLength(context) { + return context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + } + ts.getRefactorContextLength = getRefactorContextLength; })(ts || (ts = {})); var ts; (function (ts) { @@ -73129,7 +73562,7 @@ var ts; var leftText = qualifiedName.left.getText(sourceFile); var rightText = qualifiedName.right.getText(sourceFile); var replacement = ts.createIndexedAccessTypeNode(ts.createTypeReferenceNode(qualifiedName.left, undefined), ts.createLiteralTypeNode(ts.createLiteral(rightText))); - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, qualifiedName, replacement); return [{ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Rewrite_as_the_indexed_access_type_0), [leftText + "[\"" + rightText + "\"]"]), @@ -73258,7 +73691,7 @@ var ts; } var className = classDeclaration.name.getText(); var staticInitialization = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier(className), tokenName), ts.createIdentifier("undefined"))); - var staticInitializationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var staticInitializationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); staticInitializationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classDeclaration, staticInitialization, { suffix: context.newLineCharacter }); var initializeStaticAction = { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_static_property_0), [tokenName]), @@ -73273,7 +73706,7 @@ var ts; return actions; } var propertyInitialization = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), tokenName), ts.createIdentifier("undefined"))); - var propertyInitializationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var propertyInitializationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); propertyInitializationChangeTracker.insertNodeAt(classDeclarationSourceFile, classConstructor.body.getEnd() - 1, propertyInitialization, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); var initializeAction = { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]), @@ -73299,7 +73732,7 @@ var ts; } typeNode = typeNode || ts.createKeywordTypeNode(119); var property = ts.createProperty(undefined, makeStatic ? [ts.createToken(115)] : undefined, tokenName, undefined, typeNode, undefined); - var propertyChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var propertyChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter }); (actions || (actions = [])).push({ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Declare_property_0), [tokenName]), @@ -73309,7 +73742,7 @@ var ts; var stringTypeNode = ts.createKeywordTypeNode(136); var indexingParameter = ts.createParameter(undefined, undefined, undefined, "x", undefined, stringTypeNode, undefined); var indexSignature = ts.createIndexSignature(undefined, undefined, [indexingParameter], typeNode); - var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); indexSignatureChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, indexSignature, { suffix: context.newLineCharacter }); actions.push({ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_property_0), [tokenName]), @@ -73322,7 +73755,7 @@ var ts; if (token.parent.parent.kind === 181) { var callExpression = token.parent.parent; var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic); - var methodDeclarationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var methodDeclarationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); return { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(makeStatic ? @@ -73453,7 +73886,7 @@ var ts; } } } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); changeTracker.deleteNode(sourceFile, superCall); return [{ @@ -73485,7 +73918,7 @@ var ts; if (token.kind !== 123) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var superCall = ts.createStatement(ts.createCall(ts.createSuper(), undefined, ts.emptyArray)); changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ @@ -73518,7 +73951,7 @@ var ts; if (!(extendsToken && extendsToken.kind === 85)) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, extendsToken, ts.createToken(108)); for (var i = 1; i < heritageClauses.length; i++) { var keywordToken = heritageClauses[i].getFirstToken(); @@ -73547,7 +73980,7 @@ var ts; if (token.kind !== 71) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createThis(), token)); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), @@ -73563,8 +73996,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code + ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code, + ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code ], getCodeActions: function (context) { var sourceFile = context.sourceFile; @@ -73700,19 +74133,19 @@ var ts; } } function deleteNode(n) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNode(sourceFile, n)); } function deleteRange(range) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteRange(sourceFile, range)); } function deleteNodeInList(n) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNodeInList(sourceFile, n)); } function deleteNodeRange(start, end) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNodeRange(sourceFile, start, end)); } function replaceNode(n, newNode) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).replaceNode(sourceFile, n, newNode)); } function makeChange(changeTracker) { return { @@ -73735,11 +74168,30 @@ var ts; function getActionsForJSDocTypes(context) { var sourceFile = context.sourceFile; var node = ts.getTokenAtPosition(sourceFile, context.span.start, false); - var decl = ts.findAncestor(node, function (n) { return n.kind === 226; }); + var decl = ts.findAncestor(node, function (n) { + return n.kind === 202 || + n.kind === 155 || + n.kind === 156 || + n.kind === 228 || + n.kind === 153 || + n.kind === 157 || + n.kind === 172 || + n.kind === 151 || + n.kind === 150 || + n.kind === 146 || + n.kind === 149 || + n.kind === 148 || + n.kind === 154 || + n.kind === 231 || + n.kind === 184 || + n.kind === 226; + }); if (!decl) return; var checker = context.program.getTypeChecker(); var jsdocType = decl.type; + if (!jsdocType) + return; var original = ts.getTextOfNode(jsdocType); var type = checker.getTypeFromTypeNode(jsdocType); var actions = [createAction(jsdocType, sourceFile.fileName, original, checker.typeToString(type, undefined, 8))]; @@ -73918,28 +74370,21 @@ var ts; if (cached) { return cached; } - var existingDeclarations = []; - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importModuleSpecifier = _a[_i]; - var importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); - if (importSymbol === moduleSymbol) { - existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); - } - } + var existingDeclarations = ts.mapDefined(sourceFile.imports, function (importModuleSpecifier) { + return checker.getSymbolAtLocation(importModuleSpecifier) === moduleSymbol ? getImportDeclaration(importModuleSpecifier) : undefined; + }); cachedImportDeclarations[moduleSymbolId] = existingDeclarations; return existingDeclarations; - function getImportDeclaration(moduleSpecifier) { - var node = moduleSpecifier; - while (node) { - if (node.kind === 238) { - return node; - } - if (node.kind === 237) { - return node; - } - node = node.parent; + function getImportDeclaration(_a) { + var parent = _a.parent; + switch (parent.kind) { + case 238: + return parent; + case 248: + return parent.parent; + default: + return undefined; } - return undefined; } } function getUniqueSymbolId(symbol) { @@ -74281,7 +74726,7 @@ var ts; } } function createChangeTracker() { - return ts.textChanges.ChangeTracker.fromCodeFixContext(context); + return ts.textChanges.ChangeTracker.fromContext(context); } function createCodeAction(description, diagnosticArgs, changes, kind, moduleSpecifier) { return { @@ -74361,7 +74806,7 @@ var ts; (function (codefix) { function newNodesToChanges(newNodes, insertAfter, context) { var sourceFile = context.sourceFile; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) { var newNode = newNodes_1[_i]; changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); @@ -74587,7 +75032,7 @@ var ts; return undefined; } var ctorDeclaration = ctorSymbol.valueDeclaration; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { @@ -74616,7 +75061,9 @@ var ts; deleteCallback(); } return { - edits: changeTracker.getChanges() + edits: changeTracker.getChanges(), + renameFilename: undefined, + renameLocation: undefined, }; function deleteNode(node, inList) { if (inList === void 0) { inList = false; } @@ -74754,7 +75201,7 @@ var ts; }; refactor.registerRefactor(extractMethod); function getAvailableActions(context) { - var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: ts.getRefactorContextLength(context) }); var targetRange = rangeToExtract.targetRange; if (targetRange === undefined) { return undefined; @@ -74767,11 +75214,11 @@ var ts; var usedNames = ts.createMap(); var i = 0; for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) { - var extr = extractions_1[_i]; - if (extr.errors && extr.errors.length) { + var _a = extractions_1[_i], scopeDescription = _a.scopeDescription, errors = _a.errors; + if (errors.length) { continue; } - var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_to_0.message, [scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -74792,16 +75239,13 @@ var ts; }]; } function getEditsForAction(context, actionName) { - var length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; - var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: length }); + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: ts.getRefactorContextLength(context) }); var targetRange = rangeToExtract.targetRange; var parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); ts.Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); var index = +parsedIndexMatch[1]; ts.Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); - var extractions = getPossibleExtractions(targetRange, context, index); - ts.Debug.assert(extractions !== undefined, "The extraction went missing? How?"); - return ({ edits: extractions[0].changes }); + return getExtractionAtIndex(targetRange, context, index); } var Messages; (function (Messages) { @@ -74830,9 +75274,12 @@ var ts; RangeFacts[RangeFacts["IsAsyncFunction"] = 4] = "IsAsyncFunction"; RangeFacts[RangeFacts["UsesThis"] = 8] = "UsesThis"; RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; - })(RangeFacts = extractMethod_1.RangeFacts || (extractMethod_1.RangeFacts = {})); + })(RangeFacts || (RangeFacts = {})); function getRangeToExtract(sourceFile, span) { - var length = span.length || 0; + var length = span.length; + if (length === 0) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.StatementOrExpressionExpected)] }; + } var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, false), sourceFile, span); var end = getParentNodeInSpan(ts.findTokenOnLeftOfPosition(sourceFile, ts.textSpanEnd(span)), sourceFile, span); var declarations = []; @@ -74875,18 +75322,13 @@ var ts; if (errors) { return { errors: errors }; } - var range = ts.isStatement(start) - ? [start] - : start.parent && start.parent.kind === 210 - ? [start.parent] - : start; - return { targetRange: { range: range, facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations: declarations } }; } function createErrorResult(sourceFile, start, length, message) { return { errors: [ts.createFileDiagnostic(sourceFile, start, length, message)] }; } function checkRootNode(node) { - if (ts.isIdentifier(node)) { + if (ts.isIdentifier(ts.isExpressionStatement(node) ? node.expression : node)) { return [ts.createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; @@ -74923,7 +75365,7 @@ var ts; PermittedJumps[PermittedJumps["Continue"] = 2] = "Continue"; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); - if (!ts.isStatement(nodeToCheck) && !(ts.isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + if (!ts.isStatement(nodeToCheck) && !(ts.isPartOfExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; } if (ts.isInAmbientContext(nodeToCheck)) { @@ -74979,39 +75421,26 @@ var ts; return false; } var savedPermittedJumps = permittedJumps; - if (node.parent) { - switch (node.parent.kind) { - case 211: - if (node.parent.thenStatement === node || node.parent.elseStatement === node) { - permittedJumps = 0; - } - break; - case 224: - if (node.parent.tryBlock === node) { - permittedJumps = 0; - } - else if (node.parent.finallyBlock === node) { - permittedJumps = 4; - } - break; - case 260: - if (node.parent.block === node) { - permittedJumps = 0; - } - break; - case 257: - if (node.expression !== node) { - permittedJumps |= 1; - } - break; - default: - if (ts.isIterationStatement(node.parent, false)) { - if (node.parent.statement === node) { - permittedJumps |= 1 | 2; - } - } - break; - } + switch (node.kind) { + case 211: + permittedJumps = 0; + break; + case 224: + permittedJumps = 0; + break; + case 207: + if (node.parent && node.parent.kind === 224 && node.finallyBlock === node) { + permittedJumps = 4; + } + break; + case 257: + permittedJumps |= 1; + break; + default: + if (ts.isIterationStatement(node, false)) { + permittedJumps |= 1 | 2; + } + break; } switch (node.kind) { case 169: @@ -75036,7 +75465,7 @@ var ts; } } else { - if (!(permittedJumps & (218 ? 1 : 2))) { + if (!(permittedJumps & (node.kind === 218 ? 1 : 2))) { (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); } } @@ -75065,6 +75494,15 @@ var ts; } } extractMethod_1.getRangeToExtract = getRangeToExtract; + function getStatementOrExpressionRange(node) { + if (ts.isStatement(node)) { + return [node]; + } + else if (ts.isPartOfExpression(node)) { + return ts.isExpressionStatement(node.parent) ? [node.parent] : node; + } + return undefined; + } function isValidExtractionTarget(node) { return (node.kind === 228) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node); } @@ -75091,9 +75529,21 @@ var ts; } return scopes; } - extractMethod_1.collectEnclosingScopes = collectEnclosingScopes; - function getPossibleExtractions(targetRange, context, requestedChangesIndex) { - if (requestedChangesIndex === void 0) { requestedChangesIndex = undefined; } + function getExtractionAtIndex(targetRange, context, requestedChangesIndex) { + var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, _b = _a.readsAndWrites, target = _b.target, usagesPerScope = _b.usagesPerScope, errorsPerScope = _b.errorsPerScope; + ts.Debug.assert(!errorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); + context.cancellationToken.throwIfCancellationRequested(); + return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context); + } + extractMethod_1.getExtractionAtIndex = getExtractionAtIndex; + function getPossibleExtractions(targetRange, context) { + var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, errorsPerScope = _a.readsAndWrites.errorsPerScope; + return scopes.map(function (scope, i) { + return ({ scopeDescription: getDescriptionForScope(scope), errors: errorsPerScope[i] }); + }); + } + extractMethod_1.getPossibleExtractions = getPossibleExtractions; + function getPossibleExtractionsWorker(targetRange, context) { var sourceFile = context.file; if (targetRange === undefined) { return undefined; @@ -75103,86 +75553,62 @@ var ts; return undefined; } var enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); - var _a = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker()), target = _a.target, usagesPerScope = _a.usagesPerScope, errorsPerScope = _a.errorsPerScope; - context.cancellationToken.throwIfCancellationRequested(); - if (requestedChangesIndex !== undefined) { - if (errorsPerScope[requestedChangesIndex].length) { - return undefined; - } - return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; - } - else { - return scopes.map(function (scope, i) { - var errors = errorsPerScope[i]; - if (errors.length) { - return { - scope: scope, - scopeDescription: getDescriptionForScope(scope), - errors: errors - }; - } - return { scope: scope, scopeDescription: getDescriptionForScope(scope) }; - }); - } + var readsAndWrites = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker(), context.cancellationToken); + return { scopes: scopes, readsAndWrites: readsAndWrites }; } - extractMethod_1.getPossibleExtractions = getPossibleExtractions; function getDescriptionForScope(scope) { - if (ts.isFunctionLike(scope)) { - switch (scope.kind) { - case 152: - return "constructor"; - case 186: - return scope.name - ? "function expression " + scope.name.getText() - : "anonymous function expression"; - case 228: - return "function " + scope.name.getText(); - case 187: - return "arrow function"; - case 151: - return "method " + scope.name.getText(); - case 153: - return "get " + scope.name.getText(); - case 154: - return "set " + scope.name.getText(); - } - } - else if (ts.isModuleBlock(scope)) { - return "namespace " + scope.parent.name.getText(); - } - else if (ts.isClassLike(scope)) { - return scope.kind === 229 - ? "class " + scope.name.text - : scope.name.text - ? "class expression " + scope.name.text - : "anonymous class expression"; - } - else if (ts.isSourceFile(scope)) { - return "file '" + scope.fileName + "'"; - } - else { - return "unknown"; + return ts.isFunctionLikeDeclaration(scope) + ? "inner function in " + getDescriptionForFunctionLikeDeclaration(scope) + : ts.isClassLike(scope) + ? "method in " + getDescriptionForClassLikeDeclaration(scope) + : "function in " + getDescriptionForModuleLikeDeclaration(scope); + } + function getDescriptionForFunctionLikeDeclaration(scope) { + switch (scope.kind) { + case 152: + return "constructor"; + case 186: + return scope.name + ? "function expression '" + scope.name.text + "'" + : "anonymous function expression"; + case 228: + return "function '" + scope.name.text + "'"; + case 187: + return "arrow function"; + case 151: + return "method '" + scope.name.getText(); + case 153: + return "'get " + scope.name.getText() + "'"; + case 154: + return "'set " + scope.name.getText() + "'"; + default: + ts.Debug.assertNever(scope); } } - function getUniqueName(isNameOkay) { + function getDescriptionForClassLikeDeclaration(scope) { + return scope.kind === 229 + ? "class '" + scope.name.text + "'" + : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + } + function getDescriptionForModuleLikeDeclaration(scope) { + return scope.kind === 234 + ? "namespace '" + scope.parent.name.getText() + "'" + : scope.externalModuleIndicator ? "module scope" : "global scope"; + } + function getUniqueName(fileText) { var functionNameText = "newFunction"; - if (isNameOkay(functionNameText)) { - return functionNameText; - } - var i = 1; - while (!isNameOkay(functionNameText = "newFunction_" + i)) { - i++; + for (var i = 1; fileText.indexOf(functionNameText) !== -1; i++) { + functionNameText = "newFunction_" + i; } return functionNameText; } function extractFunctionInScope(node, scope, _a, range, context) { - var usagesInScope = _a.usages, substitutions = _a.substitutions; + var usagesInScope = _a.usages, typeParameterUsages = _a.typeParameterUsages, substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); var file = scope.getSourceFile(); - var functionNameText = getUniqueName(function (n) { return !file.identifiers.has(n); }); + var functionNameText = getUniqueName(file.text); var isJS = ts.isInJavaScriptFile(scope); var functionName = ts.createIdentifier(functionNameText); - var functionReference = ts.createIdentifier(functionNameText); var returnType = undefined; var parameters = []; var callArguments = []; @@ -75201,11 +75627,19 @@ var ts; } callArguments.push(ts.createIdentifier(name)); }); + var typeParametersAndDeclarations = ts.arrayFrom(typeParameterUsages.values()).map(function (type) { return ({ type: type, declaration: getFirstDeclaration(type) }); }); + var sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder); + var typeParameters = sortedTypeParametersAndDeclarations.length === 0 + ? undefined + : sortedTypeParametersAndDeclarations.map(function (t) { return t.declaration; }); + var callTypeArguments = typeParameters !== undefined + ? typeParameters.map(function (decl) { return ts.createTypeReferenceNode(decl.name, undefined); }) + : undefined; if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); returnType = checker.typeToTypeNode(contextualType); } - var _b = transformFunctionBody(node), body = _b.body, returnValueProperty = _b.returnValueProperty; + var _b = transformFunctionBody(node, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; var newFunction; if (ts.isClassLike(scope)) { var modifiers = isJS ? [] : [ts.createToken(112)]; @@ -75215,15 +75649,23 @@ var ts; if (range.facts & RangeFacts.IsAsyncFunction) { modifiers.push(ts.createToken(120)); } - newFunction = ts.createMethod(undefined, modifiers, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, undefined, [], parameters, returnType, body); + newFunction = ts.createMethod(undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, undefined, typeParameters, parameters, returnType, body); } else { - newFunction = ts.createFunctionDeclaration(undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, [], parameters, returnType, body); + newFunction = ts.createFunctionDeclaration(undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39) : undefined, functionName, typeParameters, parameters, returnType, body); + } + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); + var minInsertionPos = (isReadonlyArray(range.range) ? ts.lastOrUndefined(range.range) : range.range).end; + var nodeToInsertBefore = getNodeToInsertBefore(minInsertionPos, scope); + if (nodeToInsertBefore) { + changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); - changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); var newNodes = []; - var call = ts.createCall(ts.isClassLike(scope) ? ts.createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.getText()) : ts.createThis(), functionReference) : functionReference, undefined, callArguments); + var called = getCalledExpression(scope, range, functionNameText); + var call = ts.createCall(called, callTypeArguments, callArguments); if (range.facts & RangeFacts.IsGenerator) { call = ts.createYield(ts.createToken(39), call); } @@ -75244,6 +75686,9 @@ var ts; } else { newNodes.push(ts.createStatement(ts.createBinary(assignments[0].name, 58, call))); + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(ts.createReturn()); + } } } else { @@ -75273,63 +75718,152 @@ var ts; else { changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); } - return { - scope: scope, - scopeDescription: getDescriptionForScope(scope), - changes: changeTracker.getChanges() - }; - function getPropertyAssignmentsForWrites(writes) { - return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + var edits = changeTracker.getChanges(); + var renameRange = isReadonlyArray(range.range) ? range.range[0] : range.range; + var renameFilename = renameRange.getSourceFile().fileName; + var renameLocation = getRenameLocation(edits, renameFilename, functionNameText); + return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + } + function getRenameLocation(edits, renameFilename, functionNameText) { + var delta = 0; + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; + ts.Debug.assert(fileName === renameFilename); + for (var _b = 0, textChanges_2 = textChanges_1; _b < textChanges_2.length; _b++) { + var change = textChanges_2[_b]; + var span_17 = change.span, newText = change.newText; + var index = newText.indexOf(functionNameText); + if (index !== -1) { + return span_17.start + delta + index; + } + delta += newText.length - span_17.length; + } } - function generateReturnValueProperty() { - return "__return"; + throw new Error(); + } + function getFirstDeclaration(type) { + var firstDeclaration = undefined; + var symbol = type.symbol; + if (symbol && symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { + firstDeclaration = declaration; + } + } } - function transformFunctionBody(body) { - if (ts.isBlock(body) && !writes && substitutions.size === 0) { - return { body: ts.createBlock(body.statements, true), returnValueProperty: undefined }; - } - var returnValueProperty; - var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); - if (writes || substitutions.size) { - var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); - if (writes && !(range.facts & RangeFacts.HasReturn) && ts.isStatement(body)) { - var assignments = getPropertyAssignmentsForWrites(writes); - if (assignments.length === 1) { - rewrittenStatements.push(ts.createReturn(assignments[0].name)); - } - else { - rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); - } + return firstDeclaration; + } + function compareTypesByDeclarationOrder(_a, _b) { + var type1 = _a.type, declaration1 = _a.declaration; + var type2 = _b.type, declaration2 = _b.declaration; + if (declaration1) { + if (declaration2) { + var positionDiff = declaration1.pos - declaration2.pos; + if (positionDiff !== 0) { + return positionDiff; } - return { body: ts.createBlock(rewrittenStatements, true), returnValueProperty: returnValueProperty }; } else { - return { body: ts.createBlock(statements, true), returnValueProperty: undefined }; + return 1; } - function visitor(node) { - if (node.kind === 219 && writes) { - var assignments = getPropertyAssignmentsForWrites(writes); - if (node.expression) { - if (!returnValueProperty) { - returnValueProperty = generateReturnValueProperty(); - } - assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); - } - if (assignments.length === 1) { - return ts.createReturn(assignments[0].name); - } - else { - return ts.createReturn(ts.createObjectLiteral(assignments)); - } + } + else if (declaration2) { + return -1; + } + var name1 = type1.symbol ? type1.symbol.getName() : ""; + var name2 = type2.symbol ? type2.symbol.getName() : ""; + var nameDiff = ts.compareStrings(name1, name2); + if (nameDiff !== 0) { + return nameDiff; + } + return type1.id - type2.id; + } + function getCalledExpression(scope, range, functionNameText) { + var functionReference = ts.createIdentifier(functionNameText); + if (ts.isClassLike(scope)) { + var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); + return ts.createPropertyAccess(lhs, functionReference); + } + else { + return functionReference; + } + } + function transformFunctionBody(body, writes, substitutions, hasReturn) { + if (ts.isBlock(body) && !writes && substitutions.size === 0) { + return { body: ts.createBlock(body.statements, true), returnValueProperty: undefined }; + } + var returnValueProperty; + var ignoreReturns = false; + var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); + if (writes || substitutions.size) { + var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); + if (writes && !hasReturn && ts.isStatement(body)) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(ts.createReturn(assignments[0].name)); } else { - var substitution = substitutions.get(ts.getNodeId(node).toString()); - return substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); } } + return { body: ts.createBlock(rewrittenStatements, true), returnValueProperty: returnValueProperty }; + } + else { + return { body: ts.createBlock(statements, true), returnValueProperty: undefined }; + } + function visitor(node) { + if (!ignoreReturns && node.kind === 219 && writes) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (node.expression) { + if (!returnValueProperty) { + returnValueProperty = "__return"; + } + assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); + } + if (assignments.length === 1) { + return ts.createReturn(assignments[0].name); + } + else { + return ts.createReturn(ts.createObjectLiteral(assignments)); + } + } + else { + var oldIgnoreReturns = ignoreReturns; + ignoreReturns = ignoreReturns || ts.isFunctionLike(node) || ts.isClassLike(node); + var substitution = substitutions.get(ts.getNodeId(node).toString()); + var result = substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + ignoreReturns = oldIgnoreReturns; + return result; + } } } - extractMethod_1.extractFunctionInScope = extractFunctionInScope; + function getStatementsOrClassElements(scope) { + if (ts.isFunctionLike(scope)) { + var body = scope.body; + if (ts.isBlock(body)) { + return body.statements; + } + } + else if (ts.isModuleBlock(scope) || ts.isSourceFile(scope)) { + return scope.statements; + } + else if (ts.isClassLike(scope)) { + return scope.members; + } + else { + ts.assertTypeIsNever(scope); + } + return ts.emptyArray; + } + function getNodeToInsertBefore(minPos, scope) { + return ts.find(getStatementsOrClassElements(scope), function (child) { + return child.pos >= minPos && ts.isFunctionLike(child) && !ts.isConstructorDeclaration(child); + }); + } + function getPropertyAssignmentsForWrites(writes) { + return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + } function isReadonlyArray(v) { return ts.isArray(v); } @@ -75343,21 +75877,50 @@ var ts; Usage[Usage["Read"] = 1] = "Read"; Usage[Usage["Write"] = 2] = "Write"; })(Usage || (Usage = {})); - function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker) { + function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker, cancellationToken) { + var allTypeParameterUsages = ts.createMap(); var usagesPerScope = []; var substitutionsPerScope = []; var errorsPerScope = []; var visibleDeclarationsInExtractedRange = []; for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { var _ = scopes_1[_i]; - usagesPerScope.push({ usages: ts.createMap(), substitutions: ts.createMap() }); + usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); errorsPerScope.push([]); } var seenUsages = ts.createMap(); var target = isReadonlyArray(targetRange.range) ? ts.createBlock(targetRange.range) : targetRange.range; var containingLexicalScopeOfExtraction = ts.isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : ts.getEnclosingBlockScopeContainer(scopes[0]); + var unmodifiedNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; + var inGenericContext = isInGenericContext(unmodifiedNode); collectUsages(target); + if (inGenericContext && !isReadonlyArray(targetRange.range)) { + var contextualType = checker.getContextualType(targetRange.range); + recordTypeParameterUsages(contextualType); + } + if (allTypeParameterUsages.size > 0) { + var seenTypeParameterUsages = ts.createMap(); + var i_1 = 0; + for (var curr = unmodifiedNode; curr !== undefined && i_1 < scopes.length; curr = curr.parent) { + if (curr === scopes[i_1]) { + seenTypeParameterUsages.forEach(function (typeParameter, id) { + usagesPerScope[i_1].typeParameterUsages.set(id, typeParameter); + }); + i_1++; + } + if (ts.isDeclarationWithTypeParameters(curr) && curr.typeParameters) { + for (var _a = 0, _b = curr.typeParameters; _a < _b.length; _a++) { + var typeParameterDecl = _b[_a]; + var typeParameter = checker.getTypeAtLocation(typeParameterDecl); + if (allTypeParameterUsages.has(typeParameter.id.toString())) { + seenTypeParameterUsages.set(typeParameter.id.toString(), typeParameter); + } + } + } + } + ts.Debug.assert(i_1 === scopes.length); + } var _loop_8 = function (i) { var hasWrite = false; var readonlyClassPropertyWrite = undefined; @@ -75375,7 +75938,7 @@ var ts; errorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); } else if (readonlyClassPropertyWrite && i > 0) { - errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor)); } }; for (var i = 0; i < scopes.length; i++) { @@ -75385,8 +75948,35 @@ var ts; ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } return { target: target, usagesPerScope: usagesPerScope, errorsPerScope: errorsPerScope }; + function hasTypeParameters(node) { + return ts.isDeclarationWithTypeParameters(node) && + node.typeParameters !== undefined && + node.typeParameters.length > 0; + } + function isInGenericContext(node) { + for (; node; node = node.parent) { + if (hasTypeParameters(node)) { + return true; + } + } + return false; + } + function recordTypeParameterUsages(type) { + var symbolWalker = checker.getSymbolWalker(function () { return (cancellationToken.throwIfCancellationRequested(), true); }); + var visitedTypes = symbolWalker.walkType(type).visitedTypes; + for (var _i = 0, visitedTypes_1 = visitedTypes; _i < visitedTypes_1.length; _i++) { + var visitedType = visitedTypes_1[_i]; + if (visitedType.flags & 16384) { + allTypeParameterUsages.set(visitedType.id.toString(), visitedType); + } + } + } function collectUsages(node, valueUsage) { if (valueUsage === void 0) { valueUsage = 1; } + if (inGenericContext) { + var type = checker.getTypeAtLocation(node); + recordTypeParameterUsages(type); + } if (ts.isDeclaration(node) && node.symbol) { visibleDeclarationsInExtractedRange.push(node.symbol); } @@ -75428,7 +76018,9 @@ var ts; } } function recordUsagebySymbol(identifier, usage, isTypeName) { - var symbol = checker.getSymbolAtLocation(identifier); + var symbol = identifier.parent && ts.isShorthandPropertyAssignment(identifier.parent) && identifier.parent.name === identifier + ? checker.getShorthandAssignmentValueSymbol(identifier.parent) + : checker.getSymbolAtLocation(identifier); if (!symbol) { return undefined; } @@ -75452,7 +76044,7 @@ var ts; if (!declInFile) { return undefined; } - if (ts.rangeContainsRange(enclosingTextRange, declInFile)) { + if (ts.rangeContainsStartEnd(enclosingTextRange, declInFile.getStart(), declInFile.end)) { return undefined; } if (targetRange.facts & RangeFacts.IsGenerator && usage === 2) { @@ -75473,7 +76065,9 @@ var ts; substitutionsPerScope[i].set(symbolId, substitution); } else if (isTypeName) { - errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + if (!(symbol.flags & 262144)) { + errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } } else { usagesPerScope[i].usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); @@ -76059,6 +76653,10 @@ var ts; } } break; + case 194: + if (ts.getSpecialPropertyAssignmentKind(node) !== 0) { + addDeclaration(node); + } default: ts.forEachChild(node, visit); } @@ -76366,7 +76964,7 @@ var ts; oldSettings.noResolve !== newSettings.noResolve || oldSettings.jsx !== newSettings.jsx || oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.disableSizeLimit !== newSettings.disableSizeLimit || oldSettings.baseUrl !== newSettings.baseUrl || !ts.equalOwnProperties(oldSettings.paths, newSettings.paths)); var compilerHost = { @@ -76495,17 +77093,17 @@ var ts; } function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } function getSemanticDiagnostics(fileName) { synchronizeHostData(); var targetSourceFile = getValidSourceFile(fileName); var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; + return semanticDiagnostics.slice(); } var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return ts.concatenate(semanticDiagnostics, declarationDiagnostics); + return semanticDiagnostics.concat(declarationDiagnostics); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); @@ -76534,7 +77132,7 @@ var ts; return undefined; } var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); + var symbol = getSymbolAtLocationForQuickInfo(node, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { case 71: @@ -76567,6 +77165,20 @@ var ts; tags: displayPartsDocumentationsAndKind.tags }; } + function getSymbolAtLocationForQuickInfo(node, checker) { + if ((ts.isIdentifier(node) || ts.isStringLiteral(node)) + && ts.isPropertyAssignment(node.parent) + && node.parent.name === node) { + var type = checker.getContextualType(node.parent.parent); + if (type) { + var property = checker.getPropertyOfType(type, ts.getTextOfIdentifierOrLiteral(node)); + if (property) { + return property; + } + } + } + return checker.getSymbolAtLocation(node); + } function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); @@ -76624,7 +77236,19 @@ var ts; } function getReferences(fileName, position, options) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); + var sourceFiles = []; + if (options && options.isForRename) { + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + if (!program.isSourceFileDefaultLibrary(sourceFile)) { + sourceFiles.push(sourceFile); + } + } + } + else { + sourceFiles = program.getSourceFiles().slice(); + } + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -76929,7 +77553,7 @@ var ts; startPosition: startPosition, endPosition: endPosition, program: getProgram(), - newLineCharacter: host.getNewLine(), + newLineCharacter: formatOptions ? formatOptions.newLineCharacter : host.getNewLine(), rulesProvider: getRuleProvider(formatOptions), cancellationToken: cancellationToken }; @@ -77008,7 +77632,7 @@ var ts; nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); } ts.forEachChild(node, walk); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; ts.forEachChild(jsDoc, walk); @@ -77570,8 +78194,8 @@ var ts; { start: start, end: end, text: text, code: code, category: category, source: source }; } function allEditsBeforePos(edits, pos) { - for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { - var edit = edits_1[_i]; + for (var _i = 0, edits_2 = edits; _i < edits_2.length; _i++) { + var edit = edits_2[_i]; if (ts.textSpanEnd(edit.span) >= pos) { return false; } @@ -78052,7 +78676,7 @@ var ts; }; Session.prototype.semanticCheck = function (file, project) { try { - var diags = []; + var diags = server.emptyArray; if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } @@ -78740,12 +79364,12 @@ var ts; return undefined; } if (simplifiedResult) { - var span_17 = helpItems.applicableSpan; + var span_18 = helpItems.applicableSpan; return { items: helpItems.items, applicableSpan: { - start: scriptInfo.positionToLineOffset(span_17.start), - end: scriptInfo.positionToLineOffset(span_17.start + span_17.length) + start: scriptInfo.positionToLineOffset(span_18.start), + end: scriptInfo.positionToLineOffset(span_18.start + span_18.length) }, selectedItemIndex: helpItems.selectedItemIndex, argumentIndex: helpItems.argumentIndex, @@ -78947,7 +79571,7 @@ var ts; var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var _b = this.extractPositionAndRange(args, scriptInfo), position = _b.position, textRange = _b.textRange; - var result = project.getLanguageService().getEditsForRefactor(file, this.projectService.getFormatCodeOptions(), position || textRange, args.refactor, args.action); + var result = project.getLanguageService().getEditsForRefactor(file, args.formatOptions ? server.convertFormatOptions(args.formatOptions) : this.projectService.getFormatCodeOptions(), position || textRange, args.refactor, args.action); if (result === undefined) { return { edits: [] @@ -79051,6 +79675,9 @@ var ts; return; } var fileNamesInProject = fileNames.filter(function (value) { return value.indexOf("lib.d.ts") < 0; }); + if (fileNamesInProject.length === 0) { + return; + } var highPriorityFiles = []; var mediumPriorityFiles = []; var lowPriorityFiles = []; @@ -79065,7 +79692,7 @@ var ts; else { var info = this.projectService.getScriptInfo(fileNameInProject); if (!info.isScriptOpen()) { - if (fileNameInProject.indexOf(".d.ts") > 0) { + if (ts.fileExtensionIs(fileNameInProject, ".d.ts")) { veryLowPriorityFiles.push(fileNameInProject); } else { @@ -79077,11 +79704,9 @@ var ts; } } } - fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); - if (fileNamesInProject.length > 0) { - var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(next, checkList, delay, false); - } + var sortedFiles = highPriorityFiles.concat(mediumPriorityFiles, lowPriorityFiles, veryLowPriorityFiles); + var checkList = sortedFiles.map(function (fileName) { return ({ fileName: fileName, project: project }); }); + this.updateErrorCheck(next, checkList, delay, false); }; Session.prototype.getCanonicalFileName = function (fileName) { var name = this.host.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); @@ -80019,16 +80644,18 @@ var ts; }()); server.TextStorage = TextStorage; var ScriptInfo = (function () { - function ScriptInfo(host, fileName, scriptKind, hasMixedContent) { + function ScriptInfo(host, fileName, scriptKind, hasMixedContent, isDynamic) { if (hasMixedContent === void 0) { hasMixedContent = false; } + if (isDynamic === void 0) { isDynamic = false; } this.host = host; this.fileName = fileName; this.scriptKind = scriptKind; this.hasMixedContent = hasMixedContent; + this.isDynamic = isDynamic; this.containingProjects = []; this.path = ts.toPath(fileName, host.getCurrentDirectory(), ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames)); this.textStorage = new TextStorage(host, fileName); - if (hasMixedContent) { + if (hasMixedContent || isDynamic) { this.textStorage.reload(""); } this.scriptKind = scriptKind @@ -80045,7 +80672,7 @@ var ts; }; ScriptInfo.prototype.close = function () { this.isOpen = false; - this.textStorage.useText(this.hasMixedContent ? "" : undefined); + this.textStorage.useText(this.hasMixedContent || this.isDynamic ? "" : undefined); this.markContainingProjectsAsDirty(); }; ScriptInfo.prototype.getSnapshot = function () { @@ -80154,7 +80781,7 @@ var ts; this.host.writeFile(fileName, snap.getText(0, snap.getLength())); }; ScriptInfo.prototype.reloadFromFile = function (tempFileName) { - if (this.hasMixedContent) { + if (this.hasMixedContent || this.isDynamic) { this.reload(""); } else { @@ -80490,7 +81117,7 @@ var ts; var server; (function (server) { function shouldEmitFile(scriptInfo) { - return !scriptInfo.hasMixedContent; + return !scriptInfo.hasMixedContent && !scriptInfo.isDynamic; } server.shouldEmitFile = shouldEmitFile; var BuilderFileInfo = (function () { @@ -80618,7 +81245,7 @@ var ts; }; NonModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { var info = this.getOrCreateFileInfo(scriptInfo.path); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var singleFileResult = scriptInfo.hasMixedContent || scriptInfo.isDynamic ? [] : [scriptInfo.fileName]; if (info.updateShapeSignature()) { var options = this.project.getCompilerOptions(); if (options && (options.out || options.outFile)) { @@ -80715,7 +81342,7 @@ var ts; }; ModuleBuilder.prototype.getFilesAffectedBy = function (scriptInfo) { this.ensureProjectDependencyGraphUpToDate(); - var singleFileResult = scriptInfo.hasMixedContent ? [] : [scriptInfo.fileName]; + var singleFileResult = scriptInfo.hasMixedContent || scriptInfo.isDynamic ? [] : [scriptInfo.fileName]; var fileInfo = this.getFileInfo(scriptInfo.path); if (!fileInfo || !fileInfo.updateShapeSignature()) { return singleFileResult; @@ -81178,24 +81805,23 @@ var ts; var file = changedFiles_1[_i]; this.cachedUnresolvedImportsPerFile.remove(file); } - var unresolvedImports; - if (hasChanges || changedFiles.length) { - var result = []; - for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { - var sourceFile = _b[_a]; - this.extractUnresolvedImportsFromSourceFile(sourceFile, result); - } - this.lastCachedUnresolvedImportsList = server.toDeduplicatedSortedArray(result); - } - unresolvedImports = this.lastCachedUnresolvedImportsList; - var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, unresolvedImports, hasChanges); - if (this.setTypings(cachedTypings)) { - hasChanges = this.updateGraphWorker() || hasChanges; - } if (this.languageServiceEnabled) { + if (hasChanges || changedFiles.length) { + var result = []; + for (var _a = 0, _b = this.program.getSourceFiles(); _a < _b.length; _a++) { + var sourceFile = _b[_a]; + this.extractUnresolvedImportsFromSourceFile(sourceFile, result); + } + this.lastCachedUnresolvedImportsList = server.toDeduplicatedSortedArray(result); + } + var cachedTypings = this.projectService.typingsCache.getTypingsForProject(this, this.lastCachedUnresolvedImportsList, hasChanges); + if (this.setTypings(cachedTypings)) { + hasChanges = this.updateGraphWorker() || hasChanges; + } this.builder.onProjectUpdateGraph(); } else { + this.lastCachedUnresolvedImportsList = undefined; this.builder.clear(); } if (hasChanges) { @@ -81338,7 +81964,8 @@ var ts; return { info: info, projectErrors: this.getGlobalProjectErrors() }; } var lastReportedFileNames_1 = this.lastReportedFileNames; - var currentFiles_1 = ts.arrayToSet(this.getFileNames()); + var externalFiles = this.getExternalFiles().map(function (f) { return server.toNormalizedPath(f); }); + var currentFiles_1 = ts.arrayToSet(this.getFileNames().concat(externalFiles)); var added_1 = []; var removed_1 = []; var updated = updatedFileNames ? ts.arrayFrom(updatedFileNames.keys()) : []; @@ -81358,7 +81985,8 @@ var ts; } else { var projectFileNames = this.getFileNames(); - this.lastReportedFileNames = ts.arrayToSet(projectFileNames); + var externalFiles = this.getExternalFiles().map(function (f) { return server.toNormalizedPath(f); }); + this.lastReportedFileNames = ts.arrayToSet(projectFileNames.concat(externalFiles)); this.lastReportedVersion = this.projectStructureVersion; return { info: info, files: projectFileNames, projectErrors: this.getGlobalProjectErrors() }; } @@ -81526,8 +82154,11 @@ var ts; } if (this.projectService.globalPlugins) { var _loop_10 = function (globalPluginName) { + if (!globalPluginName) + return "continue"; if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) return "continue"; + this_2.projectService.logger.info("Loading global plugin " + globalPluginName); this_2.enablePlugin({ name: globalPluginName, global: true }, searchPaths); }; var this_2 = this; @@ -81539,6 +82170,7 @@ var ts; }; ConfiguredProject.prototype.enablePlugin = function (pluginConfigEntry, searchPaths) { var _this = this; + this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(",")); var log = function (message) { _this.projectService.logger.info(message); }; @@ -81550,7 +82182,7 @@ var ts; return; } } - this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name + " anywhere in paths: " + searchPaths.join(",")); + this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name); }; ConfiguredProject.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { @@ -81566,7 +82198,16 @@ var ts; serverHost: this.projectService.host }; var pluginModule = pluginModuleFactory({ typescript: ts }); - this.languageService = pluginModule.create(info); + var newLS = pluginModule.create(info); + for (var _i = 0, _a = Object.keys(this.languageService); _i < _a.length; _i++) { + var k = _a[_i]; + if (!(k in newLS)) { + this.projectService.logger.info("Plugin activation warning: Missing proxied method " + k + " in created LS. Patching."); + newLS[k] = this.languageService[k]; + } + } + this.projectService.logger.info("Plugin validation succeded"); + this.languageService = newLS; this.plugins.push(pluginModule); } catch (e) { @@ -81595,6 +82236,9 @@ var ts; } catch (e) { _this.projectService.logger.info("A plugin threw an exception in getExternalFiles: " + e); + if (e.stack) { + _this.projectService.logger.info(e.stack); + } } })); }; @@ -81830,11 +82474,13 @@ var ts; getFileName: function (x) { return x; }, getScriptKind: function (_) { return undefined; }, hasMixedContent: function (fileName, extraFileExtensions) { return ts.some(extraFileExtensions, function (ext) { return ext.isMixedContent && ts.fileExtensionIs(fileName, ext.extension); }); }, + isDynamicFile: function (x) { return x[0] === "^"; }, }; var externalFilePropertyReader = { getFileName: function (x) { return x.fileName; }, getScriptKind: function (x) { return tryConvertScriptKindName(x.scriptKind); }, - hasMixedContent: function (x) { return x.hasMixedContent; } + hasMixedContent: function (x) { return x.hasMixedContent; }, + isDynamicFile: function (x) { return x.fileName[0] === "^"; }, }; function findProjectByName(projectName, projects) { for (var _i = 0, projects_2 = projects; _i < projects_2.length; _i++) { @@ -82488,7 +83134,8 @@ var ts; var _this = this; var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + var filesToAdd = projectOptions.files.concat(project.getExternalFiles()); + this.addFilesToProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); if (!sizeLimitExceeded) { this.watchConfigDirectoryForProject(project, projectOptions); @@ -82509,15 +83156,16 @@ var ts; var errors; for (var _i = 0, files_4 = files; _i < files_4.length; _i++) { var f = files_4[_i]; - var rootFilename = propertyReader.getFileName(f); + var rootFileName = propertyReader.getFileName(f); var scriptKind = propertyReader.getScriptKind(f); var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - if (this.host.fileExists(rootFilename)) { - var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName === rootFilename, undefined, scriptKind, hasMixedContent); + var isDynamicFile = propertyReader.isDynamicFile(f); + if (isDynamicFile || this.host.fileExists(rootFileName)) { + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFileName), clientFileName === rootFileName, undefined, scriptKind, hasMixedContent, isDynamicFile); project.addRoot(info); } else { - (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFilename)); + (errors || (errors = [])).push(createFileNotFoundDiagnostic(rootFileName)); } } project.setProjectErrors(ts.concatenate(configFileErrors, errors)); @@ -82545,7 +83193,8 @@ var ts; for (var _i = 0, newUncheckedFiles_1 = newUncheckedFiles; _i < newUncheckedFiles_1.length; _i++) { var f = newUncheckedFiles_1[_i]; var newRootFile = propertyReader.getFileName(f); - if (!this.host.fileExists(newRootFile)) { + var isDynamic = propertyReader.isDynamicFile(f); + if (!isDynamic && !this.host.fileExists(newRootFile)) { (projectErrors || (projectErrors = [])).push(createFileNotFoundDiagnostic(newRootFile)); continue; } @@ -82556,7 +83205,7 @@ var ts; if (!scriptInfo) { var scriptKind = propertyReader.getScriptKind(f); var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); - scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent); + scriptInfo = this.getOrCreateScriptInfoForNormalizedPath(normalizedPath, false, undefined, scriptKind, hasMixedContent, isDynamic); } } newRootScriptInfos.push(scriptInfo); @@ -82695,16 +83344,16 @@ var ts; }; ProjectService.prototype.watchClosedScriptInfo = function (info) { var _this = this; - if (!info.hasMixedContent) { + if (!info.hasMixedContent && !info.isDynamic) { var fileName_3 = info.fileName; info.setWatcher(this.host.watchFile(fileName_3, function (_) { return _this.onSourceFileChanged(fileName_3); })); } }; - ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent) { + ProjectService.prototype.getOrCreateScriptInfoForNormalizedPath = function (fileName, openedByClient, fileContent, scriptKind, hasMixedContent, isDynamic) { var info = this.getScriptInfoForNormalizedPath(fileName); if (!info) { - if (openedByClient || this.host.fileExists(fileName)) { - info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent); + if (openedByClient || isDynamic || this.host.fileExists(fileName)) { + info = new server.ScriptInfo(this.host, fileName, scriptKind, hasMixedContent, isDynamic); this.filenameToScriptInfo.set(info.path, info); if (openedByClient) { if (fileContent === undefined) { @@ -82853,7 +83502,7 @@ var ts; for (var _i = 0, openFiles_1 = openFiles; _i < openFiles_1.length; _i++) { var file = openFiles_1[_i]; var scriptInfo = this.getScriptInfo(file.fileName); - ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen()); + ts.Debug.assert(!scriptInfo || !scriptInfo.isScriptOpen(), "Script should not exist and not be open already"); var normalizedPath = scriptInfo ? scriptInfo.fileName : server.toNormalizedPath(file.fileName); this.openClientFileWithNormalizedPath(normalizedPath, file.content, tryConvertScriptKindName(file.scriptKind), file.hasMixedContent); } @@ -82891,7 +83540,9 @@ var ts; var configuredProject = this.findConfiguredProjectByProjectName(configFile); if (configuredProject && configuredProject.deleteOpenRef() === 0) { this.removeProject(configuredProject); + return true; } + return false; }; ProjectService.prototype.closeExternalProject = function (uncheckedFileName, suppressRefresh) { if (suppressRefresh === void 0) { suppressRefresh = false; } diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index dd56f51d4ac..b6598e9f617 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -446,6 +446,9 @@ declare namespace ts { modifiers?: ModifiersArray; parent?: Node; } + interface JSDocContainer { + } + type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken; interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } @@ -458,7 +461,7 @@ declare namespace ts { type EqualsToken = Token; type AsteriskToken = Token; type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token; + type EndOfFileToken = Token & JSDocContainer; type AtToken = Token; type ReadonlyToken = Token; type AwaitKeywordToken = Token; @@ -500,6 +503,7 @@ declare namespace ts { } interface Decorator extends Node { kind: SyntaxKind.Decorator; + parent?: NamedDeclaration; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends NamedDeclaration { @@ -510,16 +514,18 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclaration extends NamedDeclaration { + interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; - type?: TypeNode; + type: TypeNode | undefined; } - interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } type BindingName = Identifier | BindingPattern; @@ -535,7 +541,7 @@ declare namespace ts { parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration { + interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -552,14 +558,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement { + interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement { + interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; questionToken?: QuestionToken; name: PropertyName; @@ -571,27 +577,30 @@ declare namespace ts { name?: PropertyName; } type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement { + interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement { + interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement { + interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } interface VariableLikeDeclaration extends NamedDeclaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; - name?: DeclarationName; + name: DeclarationName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; @@ -619,7 +628,7 @@ declare namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - interface FunctionLikeDeclarationBase extends SignatureDeclaration { + interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; @@ -632,16 +641,16 @@ declare namespace ts { name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclaration, TypeElement { + interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement { + interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; @@ -651,20 +660,20 @@ declare namespace ts { kind: SyntaxKind.SemicolonClassElement; parent?: ClassDeclaration | ClassExpression; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { + interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } @@ -678,10 +687,10 @@ declare namespace ts { kind: SyntaxKind.ThisType; } type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionTypeNode extends TypeNode, SignatureDeclaration { + interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { + interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; @@ -692,6 +701,7 @@ declare namespace ts { } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; + parent?: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } @@ -736,7 +746,6 @@ declare namespace ts { } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; - parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -744,7 +753,7 @@ declare namespace ts { } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; - literal: Expression; + literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; @@ -879,12 +888,12 @@ declare namespace ts { } type FunctionBody = Block; type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase { + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase { + interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; @@ -930,7 +939,7 @@ declare namespace ts { expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression { + interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } @@ -940,6 +949,7 @@ declare namespace ts { } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; + parent?: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } /** @@ -1107,11 +1117,11 @@ declare namespace ts { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement { + interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement { + interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } @@ -1192,7 +1202,7 @@ declare namespace ts { statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement { + interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; @@ -1214,19 +1224,21 @@ declare namespace ts { block: Block; } type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclaration extends NamedDeclaration { + interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; name?: Identifier; } - interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } + type ClassLikeDeclaration = ClassDeclaration | ClassExpression; interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; @@ -1236,7 +1248,7 @@ declare namespace ts { name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement { + interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; @@ -1249,26 +1261,26 @@ declare namespace ts { token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement { + interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration { + interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent?: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement { + interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } type ModuleName = Identifier | StringLiteral; type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement { + interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent?: ModuleBody | SourceFile; name: ModuleName; @@ -1295,7 +1307,7 @@ declare namespace ts { * - import x = require("mod"); * - import x = M.x; */ - interface ImportEqualsDeclaration extends DeclarationStatement { + interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent?: SourceFile | ModuleBlock; name: Identifier; @@ -1407,7 +1419,7 @@ declare namespace ts { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } interface JSDocVariadicType extends JSDocType { @@ -1417,6 +1429,7 @@ declare namespace ts { type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; + parent?: HasJSDoc; tags: NodeArray | undefined; comment: string | undefined; } @@ -1472,7 +1485,6 @@ declare namespace ts { interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; jsDocPropertyTags?: ReadonlyArray; - jsDocTypeTag?: JSDocTypeTag; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } @@ -1547,10 +1559,10 @@ declare namespace ts { endOfFileToken: Token; fileName: string; text: string; - amdDependencies: AmdDependency[]; + amdDependencies: ReadonlyArray; moduleName: string; - referencedFiles: FileReference[]; - typeReferenceDirectives: FileReference[]; + referencedFiles: ReadonlyArray; + typeReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1566,7 +1578,7 @@ declare namespace ts { } interface Bundle extends Node { kind: SyntaxKind.Bundle; - sourceFiles: SourceFile[]; + sourceFiles: ReadonlyArray; } interface JsonSourceFile extends SourceFile { jsonObject?: ObjectLiteralExpression; @@ -1589,7 +1601,7 @@ declare namespace ts { readFile(path: string): string | undefined; } interface WriteFileCallback { - (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray): void; + (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray): void; } class OperationCanceledException { } @@ -1602,11 +1614,11 @@ declare namespace ts { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): string[]; + getRootFileNames(): ReadonlyArray; /** * Get a list of files in the program */ - getSourceFiles(): SourceFile[]; + getSourceFiles(): ReadonlyArray; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1618,15 +1630,16 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** - * Gets a type checker that can be used to semantically analyze source fils in the program. + * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; } interface CustomTransformers { /** Custom transformers to evaluate before built-in transformations. */ @@ -1669,7 +1682,7 @@ declare namespace ts { interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: Diagnostic[]; + diagnostics: ReadonlyArray; emittedFiles: string[]; } interface TypeChecker { @@ -1970,6 +1983,7 @@ declare namespace ts { IndexedAccess = 524288, NonPrimitive = 16777216, Literal = 224, + Unit = 6368, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, StringLike = 262178, @@ -2172,7 +2186,7 @@ declare namespace ts { interface PluginImport { name: string; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | null | undefined; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; @@ -2372,6 +2386,11 @@ declare namespace ts { * If accessing a non-index file, this should include its name e.g. "foo/bar". */ name: string; + /** + * Name of a submodule within this package. + * May be "". + */ + subModuleName: string; /** Version of the package, e.g. "1.2.3" */ version: string; } @@ -2388,14 +2407,15 @@ declare namespace ts { interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName?: string; + packageId?: PackageId; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective; failedLookupLocations: string[]; } interface CompilerHost extends ModuleResolutionHost { - getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined; + getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined; getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; getDefaultLibLocation?(): string; @@ -2460,7 +2480,8 @@ declare namespace ts { SourceFile = 0, Expression = 1, IdentifierName = 2, - Unspecified = 3, + MappedTypeParameter = 3, + Unspecified = 4, } interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ @@ -2639,6 +2660,9 @@ declare namespace ts { /** The version of the TypeScript compiler release */ const version: string; } +declare namespace ts { + function isExternalModuleNameRelative(moduleName: string): boolean; +} declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { @@ -2834,7 +2858,60 @@ declare namespace ts { * @returns The unescaped identifier text. */ function unescapeIdentifier(id: string): string; - function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined; + function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + /** + * Gets the JSDoc parameter tags for the node if present. + * + * @remarks Returns any JSDoc param tag that matches the provided + * parameter, whether a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the param + * tag on the containing function expression would be first. + * + * Does not return tags for binding patterns, because JSDoc matches + * parameters by name and binding patterns do not have a name. + */ + function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray | undefined; + /** + * Return true if the node has JSDoc parameter tags. + * + * @remarks Includes parameter tags that are not directly on the node, + * for example on a variable declaration whose initializer is a function expression. + */ + function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean; + /** Gets the JSDoc augments tag for the node if present */ + function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined; + /** Gets the JSDoc class tag for the node if present */ + function getJSDocClassTag(node: Node): JSDocClassTag | undefined; + /** Gets the JSDoc return tag for the node if present */ + function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined; + /** Gets the JSDoc template tag for the node if present */ + function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined; + /** Gets the JSDoc type tag for the node if present and valid */ + function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined; + /** + * Gets the type node for the node if provided via JSDoc. + * + * @remarks The search includes any JSDoc param tag that relates + * to the provided parameter, for example a type tag on the + * parameter itself, or a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are examined first, so in the previous example, the type + * tag directly on the node would be returned. + */ + function getJSDocType(node: Node): TypeNode | undefined; + /** + * Gets the return type node for the node if provided via JSDoc's return tag. + * + * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function + * gets the type from inside the braces. + */ + function getJSDocReturnType(node: Node): TypeNode | undefined; + /** Get all JSDoc tags related to a node, including those on parent nodes. */ + function getJSDocTags(node: Node): ReadonlyArray | undefined; } declare namespace ts { function isNumericLiteral(node: Node): node is NumericLiteral; @@ -3184,8 +3261,8 @@ declare namespace ts { function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; - function createLiteralTypeNode(literal: Expression): LiteralTypeNode; - function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode; + function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; + function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; @@ -3214,6 +3291,7 @@ declare namespace ts { function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3231,8 +3309,13 @@ declare namespace ts { function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; + function createTemplateHead(text: string): TemplateHead; + function createTemplateMiddle(text: string): TemplateMiddle; + function createTemplateTail(text: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; @@ -3388,10 +3471,12 @@ declare namespace ts { function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; function createCommaList(elements: ReadonlyArray): CommaListExpression; function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: SourceFile[]): Bundle; - function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; + function createBundle(sourceFiles: ReadonlyArray): Bundle; + function updateBundle(node: Bundle, sourceFiles: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression; function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -3575,8 +3660,8 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; + function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' @@ -3591,7 +3676,7 @@ declare namespace ts { * @param oldProgram - Reuses an old program structure. * @returns A 'Program' object. */ - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; + function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; @@ -3700,7 +3785,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): number[]; + getLineStarts(): ReadonlyArray; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -3917,7 +4002,7 @@ declare namespace ts { * Represents a single refactoring action - for example, the "Extract Method..." refactor might * offer several actions, each corresponding to a surround class or closure to extract into. */ - type RefactorActionInfo = { + interface RefactorActionInfo { /** * The programmatic name of the refactoring action */ @@ -3928,16 +4013,16 @@ declare namespace ts { * so this description should make sense by itself if the parent is inlineable=true */ description: string; - }; + } /** * A set of edits to make in response to a refactor action, plus an optional * location where renaming should be invoked from */ - type RefactorEditInfo = { + interface RefactorEditInfo { edits: FileTextChanges[]; - renameFilename?: string; - renameLocation?: number; - }; + renameFilename: string | undefined; + renameLocation: number | undefined; + } interface TextInsertion { newText: string; /** The position in newText the caret should point to after the insertion. */ diff --git a/lib/typescript.js b/lib/typescript.js index f1356d558c6..4128b5d17fa 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -800,6 +800,7 @@ var ts; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 6368] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; /* @internal */ TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; @@ -1200,6 +1201,7 @@ var ts; EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; + /*@internal*/ EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); /** * Used by the checker, this enum keeps track of external emit helpers that should be type @@ -1242,7 +1244,8 @@ var ts; EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; EmitHint[EmitHint["Expression"] = 1] = "Expression"; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; - EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; + EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); /*@internal*/ @@ -1349,6 +1352,15 @@ var ts; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); +(function (ts) { + function isExternalModuleNameRelative(moduleName) { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + // Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module. + return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; +})(ts || (ts = {})); /* @internal */ (function (ts) { // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. @@ -1375,7 +1387,6 @@ var ts; return new MapCtr(); } ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap; - /* @internal */ function createSymbolTable(symbols) { var result = createMap(); if (symbols) { @@ -2063,6 +2074,32 @@ var ts; return to; } ts.addRange = addRange; + /** + * @return Whether the value was added. + */ + function pushIfUnique(array, toAdd) { + if (contains(array, toAdd)) { + return false; + } + else { + array.push(toAdd); + return true; + } + } + ts.pushIfUnique = pushIfUnique; + /** + * Unlike `pushIfUnique`, this can take `undefined` as an input, and returns a new array. + */ + function appendIfUnique(array, toAdd) { + if (array) { + pushIfUnique(array, toAdd); + return array; + } + else { + return [toAdd]; + } + } + ts.appendIfUnique = appendIfUnique; /** * Stable sort of an array. Elements equal to each other maintain their relative position in the array. */ @@ -2236,11 +2273,6 @@ var ts; ts.getProperty = getProperty; /** * Gets the owned, enumerable property keys of a map-like. - * - * NOTE: This is intended for use with MapLike objects. For Map objects, use - * Object.keys instead as it offers better performance. - * - * @param map A map-like. */ function getOwnKeys(map) { var keys = []; @@ -2252,6 +2284,16 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getOwnValues(sparseArray) { + var values = []; + for (var key in sparseArray) { + if (hasOwnProperty.call(sparseArray, key)) { + values.push(sparseArray[key]); + } + } + return values; + } + ts.getOwnValues = getOwnValues; function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { @@ -2426,6 +2468,9 @@ var ts; /** Does nothing. */ function noop() { } ts.noop = noop; + /** Returns its argument. */ + function identity(x) { return x; } + ts.identity = identity; /** Throws an error because a function is not implemented. */ function notImplemented() { throw new Error("Not implemented"); @@ -2503,12 +2548,11 @@ var ts; } ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { - var end = start + length; Debug.assertGreaterThanOrEqual(start, 0); Debug.assertGreaterThanOrEqual(length, 0); if (file) { Debug.assertLessThanOrEqual(start, file.text.length); - Debug.assertLessThanOrEqual(end, file.text.length); + Debug.assertLessThanOrEqual(start + length, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2768,21 +2812,13 @@ var ts; return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } ts.isUrl = isUrl; - /* @internal */ function pathIsRelative(path) { return /^\.\.?($|[\\/])/.test(path); } ts.pathIsRelative = pathIsRelative; - function isExternalModuleNameRelative(moduleName) { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - // Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module. - return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; /** @deprecated Use `!isExternalModuleNameRelative(moduleName)` instead. */ function moduleHasNonRelativeName(moduleName) { - return !isExternalModuleNameRelative(moduleName); + return !ts.isExternalModuleNameRelative(moduleName); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; function getEmitScriptTarget(compilerOptions) { @@ -2803,7 +2839,6 @@ var ts; return moduleResolution; } ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; - /* @internal */ function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { @@ -2821,7 +2856,7 @@ var ts; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { @@ -3021,17 +3056,14 @@ var ts; return true; } ts.containsPath = containsPath; - /* @internal */ function startsWith(str, prefix) { return str.lastIndexOf(prefix, 0) === 0; } ts.startsWith = startsWith; - /* @internal */ function removePrefix(str, prefix) { return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; - /* @internal */ function endsWith(str, suffix) { var expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -3045,7 +3077,6 @@ var ts; return path.length > extension.length && endsWith(path, extension); } ts.fileExtensionIs = fileExtensionIs; - /* @internal */ function fileExtensionIsOneOf(path, extensions) { for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { var extension = extensions_1[_i]; @@ -3061,7 +3092,6 @@ var ts; // proof. var reservedCharacterPattern = /[^\w\s\/]/g; var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - /* @internal */ ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; var filesMatcher = { @@ -3551,6 +3581,10 @@ var ts; throw e; } Debug.fail = fail; + function assertNever(member, message, stackCrawlMark) { + return fail(message || "Illegal value: " + member, stackCrawlMark || assertNever); + } + Debug.assertNever = assertNever; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -3617,7 +3651,6 @@ var ts; * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - /* @internal */ function matchPatternOrExact(patternStrings, candidate) { var patterns = []; for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { @@ -3634,7 +3667,6 @@ var ts; return findBestPatternMatch(patterns, function (_) { return _; }, candidate); } ts.matchPatternOrExact = matchPatternOrExact; - /* @internal */ function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; return prefix + "*" + suffix; @@ -3644,14 +3676,12 @@ var ts; * Given that candidate matches pattern, returns the text matching the '*'. * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" */ - /* @internal */ function matchedText(pattern, candidate) { Debug.assert(isPatternMatch(pattern, candidate)); return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); } ts.matchedText = matchedText; /** Return the object corresponding to the best pattern to match `candidate`. */ - /* @internal */ function findBestPatternMatch(values, getPattern, candidate) { var matchedValue = undefined; // use length of prefix as betterness criteria @@ -3673,7 +3703,6 @@ var ts; startsWith(candidate, prefix) && endsWith(candidate, suffix); } - /* @internal */ function tryParsePattern(pattern) { // This should be verified outside of here and a proper error thrown. Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); @@ -3719,6 +3748,12 @@ var ts; return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; + function and(f, g) { + return function (arg) { return f(arg) && g(arg); }; + } + ts.and = and; + function assertTypeIsNever(_) { } + ts.assertTypeIsNever = assertTypeIsNever; })(ts || (ts = {})); /// var ts; @@ -4320,8 +4355,8 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asteri_1202", "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_defaul_1203", "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), @@ -4641,7 +4676,9 @@ var ts; Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), - Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), + Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."), + The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, ts.DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4714,6 +4751,7 @@ var ts; A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"), + The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -4831,7 +4869,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), - Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), + Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."), @@ -4936,17 +4974,16 @@ var ts; Resolving_real_path_for_0_result_1: diag(6130, ts.DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."), Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, ts.DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."), File_name_0_has_a_1_extension_stripping_it: diag(6132, ts.DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."), - _0_is_declared_but_never_used: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6133", "'{0}' is declared but never used."), + _0_is_declared_but_its_value_is_never_read: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read."), Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."), Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."), The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, ts.DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."), Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, ts.DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."), - Property_0_is_declared_but_never_used: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_never_used_6138", "Property '{0}' is declared but never used."), + Property_0_is_declared_but_its_value_is_never_read: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read."), Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."), Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, ts.DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."), Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, ts.DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."), Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."), - Module_0_was_resolved_to_1_but_allowJs_is_not_set: diag(6143, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", "Module '{0}' was resolved to '{1}', but '--allowJs' is not set."), Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."), Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."), Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."), @@ -5037,6 +5074,7 @@ var ts; Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."), Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."), JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, ts.DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."), + JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, ts.DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."), Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), @@ -5084,7 +5122,7 @@ var ts; Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), - Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), + Extract_to_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_95004", "Extract to {0}"), }; })(ts || (ts = {})); /// @@ -5364,7 +5402,7 @@ var ts; ts.Debug.assert(res < lineStarts[line + 1]); } else if (debugText !== undefined) { - ts.Debug.assert(res < debugText.length); + ts.Debug.assert(res <= debugText.length); // Allow single character overflow for trailing newline } return res; } @@ -6889,7 +6927,6 @@ var ts; } ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriter = createSingleLineStringWriter(); - var stringWriterAcquired = false; function createSingleLineStringWriter() { var str = ""; var writeText = function (text) { return str += text; }; @@ -6915,15 +6952,14 @@ var ts; }; } function usingSingleLineStringWriter(action) { + var oldString = stringWriter.string(); try { - ts.Debug.assert(!stringWriterAcquired); - stringWriterAcquired = true; action(stringWriter); return stringWriter.string(); } finally { stringWriter.clear(); - stringWriterAcquired = false; + stringWriter.writeKeyword(oldString); } } ts.usingSingleLineStringWriter = usingSingleLineStringWriter; @@ -6957,7 +6993,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.version === b.version; + return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; @@ -7116,7 +7152,7 @@ var ts; if (ts.isJSDocNode(node)) { return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } // For a syntax list, it is possible that one of its children has JSDocComment nodes, while @@ -7157,6 +7193,19 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; + /** + * Note: it is expected that the `nodeArray` and the `node` are within the same file. + * For example, searching for a `SourceFile` in a `SourceFile[]` wouldn't work. + */ + function indexOfNode(nodeArray, node) { + return ts.binarySearch(nodeArray, node, compareNodePos); + } + ts.indexOfNode = indexOfNode; + function compareNodePos(_a, _b) { + var aPos = _a.pos; + var bPos = _b.pos; + return aPos < bPos ? -1 /* LessThan */ : bPos < aPos ? 1 /* GreaterThan */ : 0 /* EqualTo */; + } /** * Gets flags that control emit behavior of a node. */ @@ -7191,6 +7240,7 @@ var ts; case 16 /* TemplateTail */: return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -7304,6 +7354,34 @@ var ts; return false; } ts.isBlockScope = isBlockScope; + function isDeclarationWithTypeParameters(node) { + switch (node.kind) { + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 150 /* MethodSignature */: + case 157 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 273 /* JSDocFunctionType */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 282 /* JSDocTemplateTag */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return true; + default: + ts.assertTypeIsNever(node); + return false; + } + } + ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. function getEnclosingBlockScopeContainer(node) { @@ -8029,59 +8107,62 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 99 /* ThisKeyword */: - var parent = node.parent; - switch (parent.kind) { - case 226 /* VariableDeclaration */: - case 146 /* Parameter */: - case 149 /* PropertyDeclaration */: - case 148 /* PropertySignature */: - case 264 /* EnumMember */: - case 261 /* PropertyAssignment */: - case 176 /* BindingElement */: - return parent.initializer === node; - case 210 /* ExpressionStatement */: - case 211 /* IfStatement */: - case 212 /* DoStatement */: - case 213 /* WhileStatement */: - case 219 /* ReturnStatement */: - case 220 /* WithStatement */: - case 221 /* SwitchStatement */: - case 257 /* CaseClause */: - case 223 /* ThrowStatement */: - return parent.expression === node; - case 214 /* ForStatement */: - var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 227 /* VariableDeclarationList */) || - forStatement.condition === node || - forStatement.incrementor === node; - case 215 /* ForInStatement */: - case 216 /* ForOfStatement */: - var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227 /* VariableDeclarationList */) || - forInStatement.expression === node; - case 184 /* TypeAssertionExpression */: - case 202 /* AsExpression */: - return node === parent.expression; - case 205 /* TemplateSpan */: - return node === parent.expression; - case 144 /* ComputedPropertyName */: - return node === parent.expression; - case 147 /* Decorator */: - case 256 /* JsxExpression */: - case 255 /* JsxSpreadAttribute */: - case 263 /* SpreadAssignment */: - return true; - case 201 /* ExpressionWithTypeArguments */: - return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - default: - if (isPartOfExpression(parent)) { - return true; - } - } + return isInExpressionContext(node); + default: + return false; } - return false; } ts.isPartOfExpression = isPartOfExpression; + function isInExpressionContext(node) { + var parent = node.parent; + switch (parent.kind) { + case 226 /* VariableDeclaration */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 264 /* EnumMember */: + case 261 /* PropertyAssignment */: + case 176 /* BindingElement */: + return parent.initializer === node; + case 210 /* ExpressionStatement */: + case 211 /* IfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 219 /* ReturnStatement */: + case 220 /* WithStatement */: + case 221 /* SwitchStatement */: + case 257 /* CaseClause */: + case 223 /* ThrowStatement */: + return parent.expression === node; + case 214 /* ForStatement */: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 227 /* VariableDeclarationList */) || + forStatement.condition === node || + forStatement.incrementor === node; + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227 /* VariableDeclarationList */) || + forInStatement.expression === node; + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: + return node === parent.expression; + case 205 /* TemplateSpan */: + return node === parent.expression; + case 144 /* ComputedPropertyName */: + return node === parent.expression; + case 147 /* Decorator */: + case 256 /* JsxExpression */: + case 255 /* JsxSpreadAttribute */: + case 263 /* SpreadAssignment */: + return true; + case 201 /* ExpressionWithTypeArguments */: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + return isPartOfExpression(parent); + } + } + ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { return node.kind === 237 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 248 /* ExternalModuleReference */; } @@ -8261,14 +8342,6 @@ var ts; node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function hasJSDocParameterTags(node) { - return !!getFirstJSDocTag(node, 279 /* JSDocParameterTag */); - } - ts.hasJSDocParameterTags = hasJSDocParameterTags; - function getFirstJSDocTag(node, kind) { - var tags = getJSDocTags(node); - return ts.find(tags, function (doc) { return doc.kind === kind; }); - } function getAllJSDocs(node) { if (ts.isJSDocTypedefTag(node)) { return [node.parent]; @@ -8276,15 +8349,6 @@ var ts; return getJSDocCommentsAndTags(node); } ts.getAllJSDocs = getAllJSDocs; - function getJSDocTags(node) { - var tags = node.jsDocCache; - // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. - if (tags === undefined) { - node.jsDocCache = tags = ts.flatMap(getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); - } - return tags; - } - ts.getJSDocTags = getJSDocTags; function getJSDocCommentsAndTags(node) { var result; getJSDocCommentsAndTagsWorker(node); @@ -8324,23 +8388,17 @@ var ts; } // Pull parameter comments from declaring function as well if (node.kind === 146 /* Parameter */) { - result = ts.addRange(result, getJSDocParameterTags(node)); + result = ts.addRange(result, ts.getJSDocParameterTags(node)); } - if (isVariableLike(node) && node.initializer) { + if (isVariableLike(node) && node.initializer && ts.hasJSDocNodes(node.initializer)) { result = ts.addRange(result, node.initializer.jsDoc); } - result = ts.addRange(result, node.jsDoc); + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); + } } } - function getJSDocParameterTags(param) { - if (param.name && ts.isIdentifier(param.name)) { - var name_1 = param.name.escapedText; - return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); - } - // a binding pattern doesn't have a name, so it's not possible to match it a jsdoc parameter, which is identified by name - return undefined; - } - ts.getJSDocParameterTags = getJSDocParameterTags; + ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -8367,38 +8425,6 @@ var ts; return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; - function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 281 /* JSDocTypeTag */); - if (!tag && node.kind === 146 /* Parameter */) { - var paramTags = getJSDocParameterTags(node); - if (paramTags) { - tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); - } - } - return tag && tag.typeExpression && tag.typeExpression.type; - } - ts.getJSDocType = getJSDocType; - function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 277 /* JSDocAugmentsTag */); - } - ts.getJSDocAugmentsTag = getJSDocAugmentsTag; - function getJSDocClassTag(node) { - return getFirstJSDocTag(node, 278 /* JSDocClassTag */); - } - ts.getJSDocClassTag = getJSDocClassTag; - function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 280 /* JSDocReturnTag */); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocReturnType(node) { - var returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - ts.getJSDocReturnType = getJSDocReturnType; - function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 282 /* JSDocTemplateTag */); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { return isRestParameter(ts.lastOrUndefined(s.parameters)); } @@ -8410,7 +8436,7 @@ var ts; function isRestParameter(node) { if (isInJavaScriptFile(node)) { if (node.type && node.type.kind === 274 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274 /* JSDocVariadicType */; })) { + ts.forEach(ts.getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274 /* JSDocVariadicType */; })) { return true; } } @@ -8848,9 +8874,9 @@ var ts; || kind === 265 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); + function nodeIsSynthesized(range) { + return ts.positionIsSynthesized(range.pos) + || ts.positionIsSynthesized(range.end); } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFile(sourceFile) { @@ -9119,6 +9145,7 @@ var ts; "\u2029": "\\u2029", "\u0085": "\\u0085" // nextLine }); + var escapedNullRegExp = /\\0[0-9]/g; /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) @@ -9128,9 +9155,12 @@ var ts; var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; - return s.replace(escapedCharsRegExp, getReplacement); + return s.replace(escapedCharsRegExp, getReplacement).replace(escapedNullRegExp, nullReplacement); } ts.escapeString = escapeString; + function nullReplacement(c) { + return "\\x00" + c.charAt(c.length - 1); + } function getReplacement(c) { return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } @@ -9433,7 +9463,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocType(node); + return ts.getJSDocType(node); } } ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode; @@ -9446,7 +9476,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocReturnType(node); + return ts.getJSDocReturnType(node); } } ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode; @@ -9459,7 +9489,7 @@ var ts; return node.typeParameters; } if (isInJavaScriptFile(node)) { - var templateTag = getJSDocTemplateTag(node); + var templateTag = ts.getJSDocTemplateTag(node); return templateTag && templateTag.typeParameters; } } @@ -10127,6 +10157,45 @@ var ts; return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; + function isWriteOnlyAccess(node) { + return accessKind(node) === 1 /* Write */; + } + ts.isWriteOnlyAccess = isWriteOnlyAccess; + function isWriteAccess(node) { + return accessKind(node) !== 0 /* Read */; + } + ts.isWriteAccess = isWriteAccess; + var AccessKind; + (function (AccessKind) { + /** Only reads from a variable. */ + AccessKind[AccessKind["Read"] = 0] = "Read"; + /** Only writes to a variable without using the result. E.g.: `x++;`. */ + AccessKind[AccessKind["Write"] = 1] = "Write"; + /** Writes to a variable and uses the result as an expression. E.g.: `f(x++);`. */ + AccessKind[AccessKind["ReadWrite"] = 2] = "ReadWrite"; + })(AccessKind || (AccessKind = {})); + function accessKind(node) { + var parent = node.parent; + if (!parent) + return 0 /* Read */; + switch (parent.kind) { + case 193 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: + var operator = parent.operator; + return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 194 /* BinaryExpression */: + var _a = parent, left = _a.left, operatorToken = _a.operatorToken; + return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; + case 179 /* PropertyAccessExpression */: + return parent.name !== node ? 0 /* Read */ : accessKind(parent); + default: + return 0 /* Read */; + } + function writeOrReadWrite() { + // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. + return parent.parent && parent.parent.kind === 210 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + } + } })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -10526,6 +10595,63 @@ var ts; return id; } ts.unescapeIdentifier = unescapeIdentifier; + /** + * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should + * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol + * will be merged with) + */ + function nameForNamelessJSDocTypedef(declaration) { + var hostNode = declaration.parent.parent; + if (!hostNode) { + return undefined; + } + // Covers classes, functions - any named declaration host node + if (ts.isDeclaration(hostNode)) { + return getDeclarationIdentifier(hostNode); + } + // Covers remaining cases + switch (hostNode.kind) { + case 208 /* VariableStatement */: + if (hostNode.declarationList && + hostNode.declarationList.declarations[0]) { + return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); + } + return undefined; + case 210 /* ExpressionStatement */: + var expr = hostNode.expression; + switch (expr.kind) { + case 179 /* PropertyAccessExpression */: + return expr.name; + case 180 /* ElementAccessExpression */: + var arg = expr.argumentExpression; + if (ts.isIdentifier(arg)) { + return arg; + } + } + return undefined; + case 1 /* EndOfFileToken */: + return undefined; + case 185 /* ParenthesizedExpression */: { + return getDeclarationIdentifier(hostNode.expression); + } + case 222 /* LabeledStatement */: { + if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { + return getDeclarationIdentifier(hostNode.statement); + } + return undefined; + } + default: + ts.Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!"); + } + } + function getDeclarationIdentifier(node) { + var name = getNameOfDeclaration(node); + return ts.isIdentifier(name) ? name : undefined; + } + function getNameOfJSDocTypedef(declaration) { + return declaration.name || nameForNamelessJSDocTypedef(declaration); + } + ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef; function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; @@ -10545,11 +10671,124 @@ var ts; return undefined; } } + else if (declaration.kind === 283 /* JSDocTypedefTag */) { + return getNameOfJSDocTypedef(declaration); + } else { return declaration.name; } } ts.getNameOfDeclaration = getNameOfDeclaration; + /** + * Gets the JSDoc parameter tags for the node if present. + * + * @remarks Returns any JSDoc param tag that matches the provided + * parameter, whether a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the param + * tag on the containing function expression would be first. + * + * Does not return tags for binding patterns, because JSDoc matches + * parameters by name and binding patterns do not have a name. + */ + function getJSDocParameterTags(param) { + if (param.name && ts.isIdentifier(param.name)) { + var name_1 = param.name.escapedText; + return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); + } + // a binding pattern doesn't have a name, so it's not possible to match it a JSDoc parameter, which is identified by name + return undefined; + } + ts.getJSDocParameterTags = getJSDocParameterTags; + /** + * Return true if the node has JSDoc parameter tags. + * + * @remarks Includes parameter tags that are not directly on the node, + * for example on a variable declaration whose initializer is a function expression. + */ + function hasJSDocParameterTags(node) { + return !!getFirstJSDocTag(node, 279 /* JSDocParameterTag */); + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; + /** Gets the JSDoc augments tag for the node if present */ + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 277 /* JSDocAugmentsTag */); + } + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + /** Gets the JSDoc class tag for the node if present */ + function getJSDocClassTag(node) { + return getFirstJSDocTag(node, 278 /* JSDocClassTag */); + } + ts.getJSDocClassTag = getJSDocClassTag; + /** Gets the JSDoc return tag for the node if present */ + function getJSDocReturnTag(node) { + return getFirstJSDocTag(node, 280 /* JSDocReturnTag */); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + /** Gets the JSDoc template tag for the node if present */ + function getJSDocTemplateTag(node) { + return getFirstJSDocTag(node, 282 /* JSDocTemplateTag */); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + /** Gets the JSDoc type tag for the node if present and valid */ + function getJSDocTypeTag(node) { + // We should have already issued an error if there were multiple type jsdocs, so just use the first one. + var tag = getFirstJSDocTag(node, 281 /* JSDocTypeTag */); + if (tag && tag.typeExpression && tag.typeExpression.type) { + return tag; + } + return undefined; + } + ts.getJSDocTypeTag = getJSDocTypeTag; + /** + * Gets the type node for the node if provided via JSDoc. + * + * @remarks The search includes any JSDoc param tag that relates + * to the provided parameter, for example a type tag on the + * parameter itself, or a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are examined first, so in the previous example, the type + * tag directly on the node would be returned. + */ + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 281 /* JSDocTypeTag */); + if (!tag && node.kind === 146 /* Parameter */) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + /** + * Gets the return type node for the node if provided via JSDoc's return tag. + * + * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function + * gets the type from inside the braces. + */ + function getJSDocReturnType(node) { + var returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + ts.getJSDocReturnType = getJSDocReturnType; + /** Get all JSDoc tags related to a node, including those on parent nodes. */ + function getJSDocTags(node) { + var tags = node.jsDocCache; + // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. + if (tags === undefined) { + node.jsDocCache = tags = ts.flatMap(ts.getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); + } + return tags; + } + ts.getJSDocTags = getJSDocTags; + /** Get the first JSDoc tag of a specified kind, or undefined if not present. */ + function getFirstJSDocTag(node, kind) { + var tags = getJSDocTags(node); + return ts.find(tags, function (doc) { return doc.kind === kind; }); + } })(ts || (ts = {})); // Simple node tests of the form `node.kind === SyntaxKind.Foo`. (function (ts) { @@ -11213,8 +11452,7 @@ var ts; // Node Arrays /* @internal */ function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + return array.hasOwnProperty("pos") && array.hasOwnProperty("end"); } ts.isNodeArray = isNodeArray; // Literals @@ -11310,16 +11548,28 @@ var ts; } ts.isFunctionLike = isFunctionLike; /* @internal */ - function isFunctionLikeKind(kind) { + function isFunctionLikeDeclaration(node) { + return node && isFunctionLikeDeclarationKind(node.kind); + } + ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; + function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 152 /* Constructor */: - case 186 /* FunctionExpression */: case 228 /* FunctionDeclaration */: - case 187 /* ArrowFunction */: case 151 /* MethodDeclaration */: - case 150 /* MethodSignature */: + case 152 /* Constructor */: case 153 /* GetAccessor */: case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return true; + default: + return false; + } + } + /* @internal */ + function isFunctionLikeKind(kind) { + switch (kind) { + case 150 /* MethodSignature */: case 155 /* CallSignature */: case 156 /* ConstructSignature */: case 157 /* IndexSignature */: @@ -11327,10 +11577,16 @@ var ts; case 273 /* JSDocFunctionType */: case 161 /* ConstructorType */: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - return false; } ts.isFunctionLikeKind = isFunctionLikeKind; + /* @internal */ + function isFunctionOrModuleBlock(node) { + return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent); + } + ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; // Classes function isClassElement(node) { var kind = node.kind; @@ -11513,54 +11769,63 @@ var ts; || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; - function isLeftHandSideExpressionKind(kind) { - return kind === 179 /* PropertyAccessExpression */ - || kind === 180 /* ElementAccessExpression */ - || kind === 182 /* NewExpression */ - || kind === 181 /* CallExpression */ - || kind === 249 /* JsxElement */ - || kind === 250 /* JsxSelfClosingElement */ - || kind === 183 /* TaggedTemplateExpression */ - || kind === 177 /* ArrayLiteralExpression */ - || kind === 185 /* ParenthesizedExpression */ - || kind === 178 /* ObjectLiteralExpression */ - || kind === 199 /* ClassExpression */ - || kind === 186 /* FunctionExpression */ - || kind === 71 /* Identifier */ - || kind === 12 /* RegularExpressionLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 9 /* StringLiteral */ - || kind === 13 /* NoSubstitutionTemplateLiteral */ - || kind === 196 /* TemplateExpression */ - || kind === 86 /* FalseKeyword */ - || kind === 95 /* NullKeyword */ - || kind === 99 /* ThisKeyword */ - || kind === 101 /* TrueKeyword */ - || kind === 97 /* SuperKeyword */ - || kind === 91 /* ImportKeyword */ - || kind === 203 /* NonNullExpression */ - || kind === 204 /* MetaProperty */; - } /* @internal */ function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 192 /* PrefixUnaryExpression */ - || kind === 193 /* PostfixUnaryExpression */ - || kind === 188 /* DeleteExpression */ - || kind === 189 /* TypeOfExpression */ - || kind === 190 /* VoidExpression */ - || kind === 191 /* AwaitExpression */ - || kind === 184 /* TypeAssertionExpression */ - || isLeftHandSideExpressionKind(kind); + function isLeftHandSideExpressionKind(kind) { + switch (kind) { + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: + case 182 /* NewExpression */: + case 181 /* CallExpression */: + case 249 /* JsxElement */: + case 250 /* JsxSelfClosingElement */: + case 183 /* TaggedTemplateExpression */: + case 177 /* ArrayLiteralExpression */: + case 185 /* ParenthesizedExpression */: + case 178 /* ObjectLiteralExpression */: + case 199 /* ClassExpression */: + case 186 /* FunctionExpression */: + case 71 /* Identifier */: + case 12 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 196 /* TemplateExpression */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 99 /* ThisKeyword */: + case 101 /* TrueKeyword */: + case 97 /* SuperKeyword */: + case 203 /* NonNullExpression */: + case 204 /* MetaProperty */: + case 91 /* ImportKeyword */:// technically this is only an Expression if it's in a CallExpression + return true; + default: + return false; + } } /* @internal */ function isUnaryExpression(node) { return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionKind(kind) { + switch (kind) { + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: + case 188 /* DeleteExpression */: + case 189 /* TypeOfExpression */: + case 190 /* VoidExpression */: + case 191 /* AwaitExpression */: + case 184 /* TypeAssertionExpression */: + return true; + default: + return isLeftHandSideExpressionKind(kind); + } + } /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { @@ -11574,22 +11839,31 @@ var ts; } } ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; - function isExpressionKind(kind) { - return kind === 195 /* ConditionalExpression */ - || kind === 197 /* YieldExpression */ - || kind === 187 /* ArrowFunction */ - || kind === 194 /* BinaryExpression */ - || kind === 198 /* SpreadElement */ - || kind === 202 /* AsExpression */ - || kind === 200 /* OmittedExpression */ - || kind === 289 /* CommaListExpression */ - || isUnaryExpressionKind(kind); - } /* @internal */ + /** + * Determines whether a node is an expression based only on its kind. + * Use `isPartOfExpression` if not in transforms. + */ function isExpression(node) { return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isExpression = isExpression; + function isExpressionKind(kind) { + switch (kind) { + case 195 /* ConditionalExpression */: + case 197 /* YieldExpression */: + case 187 /* ArrowFunction */: + case 194 /* BinaryExpression */: + case 198 /* SpreadElement */: + case 202 /* AsExpression */: + case 200 /* OmittedExpression */: + case 289 /* CommaListExpression */: + case 288 /* PartiallyEmittedExpression */: + return true; + default: + return isUnaryExpressionKind(kind); + } + } function isAssertionExpression(node) { var kind = node.kind; return kind === 184 /* TypeAssertionExpression */ @@ -11865,6 +12139,12 @@ var ts; return node.kind >= 276 /* FirstJSDocTagNode */ && node.kind <= 285 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; + /** True if has jsdoc nodes attached to it. */ + /* @internal */ + function hasJSDocNodes(node) { + return !!node.jsDoc && node.jsDoc.length > 0; + } + ts.hasJSDocNodes = hasJSDocNodes; })(ts || (ts = {})); /// /// @@ -12301,9 +12581,11 @@ var ts; visitNode(cbNode, node.typeExpression); } case 285 /* JSDocTypeLiteral */: - for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { - var tag = _a[_i]; - visitNode(cbNode, tag); + if (node.jsDocPropertyTags) { + for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { + var tag = _a[_i]; + visitNode(cbNode, tag); + } } return; case 288 /* PartiallyEmittedExpression */: @@ -12599,7 +12881,7 @@ var ts; var saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDoc) { + if (ts.hasJSDocNodes(n)) { for (var _i = 0, _a = n.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; jsDoc.parent = n; @@ -12742,9 +13024,6 @@ var ts; function getNodePos() { return scanner.getStartPos(); } - function getNodeEnd() { - return scanner.getStartPos(); - } // Use this function to access the current token instead of reading the currentToken // variable. Since function results aren't narrowed in control flow analysis, this ensures // that the type checker doesn't make wrong assumptions about the type of the current @@ -12903,13 +13182,14 @@ var ts; kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } - function createNodeArray(elements, pos) { - var array = (elements || []); - if (!(pos >= 0)) { - pos = getNodePos(); - } + function createNodeArray(elements, pos, end) { + // Since the element list of a node array is typically created by starting with an empty array and + // repeatedly calling push(), the list may not have the optimal memory layout. We invoke slice() for + // small arrays (1 to 4 elements) to give the VM a chance to allocate an optimal representation. + var length = elements.length; + var array = (length >= 1 && length <= 4 ? elements.slice() : elements); array.pos = pos; - array.end = pos; + array.end = end === undefined ? scanner.getStartPos() : end; return array; } function finishNode(node, end) { @@ -12964,7 +13244,9 @@ var ts; nextToken(); return finishNode(node); } - return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + // Only for end of file because the error gets reported incorrectly on embedded script tags. + var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + return createMissingNode(71 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13246,20 +13528,20 @@ var ts; function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { var element = parseListElement(kind, parseElement); - result.push(element); + list.push(element); continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - result.end = getNodeEnd(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); @@ -13541,12 +13823,13 @@ var ts; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var commaStart = -1; // Meaning the previous token was not a comma while (true) { if (isListElement(kind, /*inErrorRecovery*/ false)) { var startPos = scanner.getStartPos(); - result.push(parseListElement(kind, parseElement)); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(26 /* CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma @@ -13583,6 +13866,8 @@ var ts; break; } } + parsingContext = saveParsingContext; + var result = createNodeArray(list, listPos); // Recording the trailing comma is deliberately done after the previous // loop, and not just if we see a list terminator. This is because the list // may have ended incorrectly, but it is still important to know if there @@ -13592,12 +13877,10 @@ var ts; // Always preserve a trailing comma by marking it on the NodeArray result.hasTrailingComma = true; } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; return result; } function createMissingList() { - return createNodeArray(); + return createNodeArray([], getNodePos()); } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -13662,12 +13945,12 @@ var ts; var template = createNode(196 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); - var templateSpans = createNodeArray(); + var list = []; + var listPos = getNodePos(); do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 15 /* TemplateMiddle */); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; + list.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(list).literal.kind === 15 /* TemplateMiddle */); + template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { @@ -13779,7 +14062,7 @@ var ts; var result = createNode(273 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); - return finishNode(result); + return addJSDocComment(finishNode(result)); } var node = createNode(159 /* TypeReference */); node.typeName = parseIdentifierName(); @@ -13848,9 +14131,10 @@ var ts; return token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 /* AtToken */ || isStartOfType(); + token() === 57 /* AtToken */ || + isStartOfType(/*inStartOfParameter*/ true); } - function parseParameter() { + function parseParameter(requireEqualsToken) { var node = createNode(146 /* Parameter */); if (token() === 99 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -13876,38 +14160,34 @@ var ts; } node.questionToken = parseOptionalToken(55 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ true); + node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(/*inParameter*/ true); - } function fillSignature(returnToken, flags, signature) { if (!(flags & 32 /* JSDoc */)) { signature.typeParameters = parseTypeParameters(); } signature.parameters = parseParameterList(flags); - var returnTokenRequired = returnToken === 36 /* EqualsGreaterThanToken */; - if (returnTokenRequired) { + signature.type = parseReturnType(returnToken, !!(flags & 4 /* Type */)); + } + function parseReturnType(returnToken, isType) { + return shouldParseReturnType(returnToken, isType) ? parseTypeOrTypePredicate() : undefined; + } + function shouldParseReturnType(returnToken, isType) { + if (returnToken === 36 /* EqualsGreaterThanToken */) { parseExpected(returnToken); - signature.type = parseTypeOrTypePredicate(); + return true; } - else if (parseOptional(returnToken)) { - signature.type = parseTypeOrTypePredicate(); + else if (parseOptional(56 /* ColonToken */)) { + return true; } - else if (flags & 4 /* Type */) { - var start = scanner.getTokenPos(); - var length_1 = scanner.getTextPos() - start; - var backwardToken = parseOptional(returnToken === 56 /* ColonToken */ ? 36 /* EqualsGreaterThanToken */ : 56 /* ColonToken */); - if (backwardToken) { - // This is easy to get backward, especially in type contexts, so parse the type anyway - signature.type = parseTypeOrTypePredicate(); - parseErrorAtPosition(start, length_1, ts.Diagnostics._0_expected, ts.tokenToString(returnToken)); - } + else if (isType && token() === 36 /* EqualsGreaterThanToken */) { + // This is easy to get backward, especially in type contexts, so parse the type anyway + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + nextToken(); + return true; } + return false; } function parseParameterList(flags) { // FormalParameters [Yield,Await]: (modified) @@ -13928,7 +14208,7 @@ var ts; var savedAwaitContext = inAwaitContext(); setYieldContext(!!(flags & 1 /* Yield */)); setAwaitContext(!!(flags & 2 /* Await */)); - var result = parseDelimitedList(16 /* Parameters */, flags & 32 /* JSDoc */ ? parseJSDocParameter : parseParameter); + var result = parseDelimitedList(16 /* Parameters */, flags & 32 /* JSDoc */ ? parseJSDocParameter : function () { return parseParameter(!!(flags & 8 /* RequireCompleteParameterList */)); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); if (!parseExpected(20 /* CloseParenToken */) && (flags & 8 /* RequireCompleteParameterList */)) { @@ -14024,7 +14304,7 @@ var ts; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); @@ -14167,7 +14447,7 @@ var ts; parseExpected(94 /* NewKeyword */); } fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */, node); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseKeywordAndNoDot() { var node = parseTokenNode(); @@ -14181,16 +14461,9 @@ var ts; unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } - var expression; - switch (token()) { - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - expression = parseLiteralLikeNode(token()); - break; - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - expression = parseTokenNode(); - } + var expression = token() === 101 /* TrueKeyword */ || token() === 86 /* FalseKeyword */ + ? parseTokenNode() + : parseLiteralLikeNode(token()); if (negative) { unaryMinusExpression.operand = expression; finishNode(unaryMinusExpression); @@ -14224,6 +14497,7 @@ var ts; return parseJSDocNodeWithType(274 /* JSDocVariadicType */); case 51 /* ExclamationToken */: return parseJSDocNodeWithType(271 /* JSDocNonNullableType */); + case 13 /* NoSubstitutionTemplateLiteral */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: @@ -14255,7 +14529,7 @@ var ts; return parseTypeReference(); } } - function isStartOfType() { + function isStartOfType(inStartOfParameter) { switch (token()) { case 119 /* AnyKeyword */: case 136 /* StringKeyword */: @@ -14280,13 +14554,16 @@ var ts; case 86 /* FalseKeyword */: case 134 /* ObjectKeyword */: case 39 /* AsteriskToken */: + case 55 /* QuestionToken */: + case 51 /* ExclamationToken */: + case 24 /* DotDotDotToken */: return true; case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral); + return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case 19 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. - return lookAhead(isStartOfParenthesizedOrFunctionType); + return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } @@ -14353,13 +14630,12 @@ var ts; parseOptional(operator); var type = parseConstituentType(); if (token() === operator) { - var types = createNodeArray([type], type.pos); + var types = [type]; while (parseOptional(operator)) { types.push(parseConstituentType()); } - types.end = getNodeEnd(); var node = createNode(kind, type.pos); - node.types = types; + node.types = createNodeArray(types, type.pos); type = finishNode(node); } return type; @@ -14545,7 +14821,7 @@ var ts; } return expr; } - function parseInitializer(inParameter) { + function parseInitializer(inParameter, requireEqualsToken) { if (token() !== 58 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse @@ -14560,6 +14836,13 @@ var ts; // do not try to parse initializer return undefined; } + if (inParameter && requireEqualsToken) { + // = is required when speculatively parsing arrow function parameters, + // so return a fake initializer as a signal that the equals token was missing + var result = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics._0_expected, "="); + result.escapedText = "= not found"; + return result; + } } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] @@ -14685,8 +14968,7 @@ var ts; var parameter = createNode(146 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); - node.parameters = createNodeArray([parameter], parameter.pos); - node.parameters.end = parameter.end; + node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); @@ -14835,8 +15117,7 @@ var ts; function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" if (token() === 120 /* AsyncKeyword */) { - var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === 1 /* True */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); return parseSimpleArrowFunctionExpression(expr, asyncModifier); @@ -14887,7 +15168,8 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { + if (!allowAmbiguity && ((token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) || + ts.find(node.parameters, function (p) { return p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"; }))) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -15447,7 +15729,8 @@ var ts; ts.Debug.fail("Unknown JSX child kind " + token()); } function parseJsxChildren(openingTagName) { - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var saveParsingContext = parsingContext; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { @@ -15467,12 +15750,11 @@ var ts; } var child = parseJsxChild(); if (child) { - result.push(child); + list.push(child); } } - result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseJsxAttributes() { var jsxAttributes = createNode(254 /* JsxAttributes */); @@ -16446,7 +16728,7 @@ var ts; var node = createNode(176 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { @@ -16462,7 +16744,7 @@ var ts; node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingPattern() { @@ -16496,7 +16778,7 @@ var ts; node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseNonParameterInitializer(); } return finishNode(node); } @@ -16699,7 +16981,8 @@ var ts; return false; } function parseDecorators() { - var decorators; + var list; + var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); if (!parseOptional(57 /* AtToken */)) { @@ -16708,17 +16991,9 @@ var ts; var decorator = createNode(147 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); - if (!decorators) { - decorators = createNodeArray([decorator], decoratorStart); - } - else { - decorators.push(decorator); - } + (list || (list = [])).push(decorator); } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; + return list && createNodeArray(list, listPos); } /* * There are situations in which a modifier like 'const' will appear unexpectedly, such as on a class member. @@ -16728,7 +17003,8 @@ var ts; * In such situations, 'permitInvalidConstAsModifier' should be set to true. */ function parseModifiers(permitInvalidConstAsModifier) { - var modifiers; + var list; + var listPos = getNodePos(); while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); @@ -16745,17 +17021,9 @@ var ts; } } var modifier = finishNode(createNode(modifierKind, modifierStart)); - if (!modifiers) { - modifiers = createNodeArray([modifier], modifierStart); - } - else { - modifiers.push(modifier); - } + (list || (list = [])).push(modifier); } - if (modifiers) { - modifiers.end = scanner.getStartPos(); - } - return modifiers; + return list && createNodeArray(list, listPos); } function parseModifiersForArrowFunction() { var modifiers; @@ -16765,7 +17033,6 @@ var ts; nextToken(); var modifier = finishNode(createNode(modifierKind, modifierStart)); modifiers = createNodeArray([modifier], modifierStart); - modifiers.end = scanner.getStartPos(); } return modifiers; } @@ -17323,11 +17590,11 @@ var ts; return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - // Parses out a JSDoc type expression. - /* @internal */ - function parseJSDocTypeExpression() { + function parseJSDocTypeExpression(requireBraces) { var result = createNode(267 /* JSDocTypeExpression */, scanner.getTokenPos()); - parseExpected(17 /* OpenBraceToken */); + if (!parseExpected(17 /* OpenBraceToken */) && requireBraces) { + return undefined; + } result.type = doInsideOfContext(1048576 /* JSDoc */, parseType); parseExpected(18 /* CloseBraceToken */); fixupParentReferences(result); @@ -17384,6 +17651,8 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; + var tagsPos; + var tagsEnd; var comments = []; var result; // Check for /** (JSDoc opening part) @@ -17507,7 +17776,7 @@ var ts; } function createJSDocComment() { var result = createNode(275 /* JSDocComment */, start); - result.tags = tags; + result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -17637,21 +17906,17 @@ var ts; function addTag(tag, comments) { tag.comment = comments.join(""); if (!tags) { - tags = createNodeArray([tag], tag.pos); + tags = [tag]; + tagsPos = tag.pos; } else { tags.push(tag); } - tags.end = tag.end; + tagsEnd = tag.end; } function tryParseTypeExpression() { - return tryParse(function () { - skipWhitespace(); - if (token() !== 17 /* OpenBraceToken */) { - return undefined; - } - return parseJSDocTypeExpression(); - }); + skipWhitespace(); + return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' @@ -17743,11 +18008,11 @@ var ts; var result = createNode(281 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); + result.typeExpression = parseJSDocTypeExpression(/*requireBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); + var typeExpression = parseJSDocTypeExpression(/*requireBraces*/ true); var result = createNode(277 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; @@ -17784,19 +18049,18 @@ var ts; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { var child = void 0; var jsdocTypeLiteral = void 0; - var alreadyHasTypeTag = false; + var childTypeTag = void 0; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildParameterOrPropertyTag(0 /* Property */); })) { if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(285 /* JSDocTypeLiteral */, start_3); } if (child.kind === 281 /* JSDocTypeTag */) { - if (alreadyHasTypeTag) { + if (childTypeTag) { break; } else { - jsdocTypeLiteral.jsDocTypeTag = child; - alreadyHasTypeTag = true; + childTypeTag = child; } } else { @@ -17810,7 +18074,9 @@ var ts; if (typeExpression && typeExpression.type.kind === 164 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = finishNode(jsdocTypeLiteral); + typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + childTypeTag.typeExpression : + finishNode(jsdocTypeLiteral); } } return finishNode(typedefTag); @@ -17905,7 +18171,8 @@ var ts; parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } // Type parameter list looks like '@template T,U,V' - var typeParameters = createNodeArray(); + var typeParameters = []; + var typeParametersPos = getNodePos(); while (true) { var name = parseJSDocIdentifierName(); skipWhitespace(); @@ -17928,9 +18195,8 @@ var ts; var result = createNode(282 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; + result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); - typeParameters.end = result.end; return result; } function nextJSDocToken() { @@ -18072,7 +18338,7 @@ var ts; ts.Debug.assert(text === newText.substring(node.pos, node.end)); } forEachChild(node, visitNode, visitArray); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDocComment = _a[_i]; forEachChild(jsDocComment, visitNode, visitArray); @@ -18622,9 +18888,11 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; if (!symbol.declarations) { - symbol.declarations = []; + symbol.declarations = [node]; + } + else { + symbol.declarations.push(node); } - symbol.declarations.push(node); if (symbolFlags & 1952 /* HasExports */ && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -18695,17 +18963,8 @@ var ts; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; case 283 /* JSDocTypedefTag */: - var parentNode = node.parent && node.parent.parent; - var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 208 /* VariableStatement */) { - if (parentNode.declarationList.declarations.length > 0) { - var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (ts.isIdentifier(nameIdentifier)) { - nameFromParentNode = nameIdentifier.escapedText; - } - } - } - return nameFromParentNode; + var name_2 = ts.getNameOfJSDocTypedef(node); + return typeof name_2 !== "undefined" ? name_2.escapedText : undefined; } } function getDisplayName(node) { @@ -18993,7 +19252,7 @@ var ts; // Binding of JsDocComment should be done before the current block scope container changes. // because the scope of JsDocComment should not be affected by whether the current node is a // container or not. - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { if (ts.isInJavaScriptFile(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var j = _a[_i]; @@ -19795,10 +20054,6 @@ var ts; lastContainer = next; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - // Just call this directly so that the return type of this function stays "void". - return declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific @@ -19995,6 +20250,9 @@ var ts; } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); + if (symbolFlags & 8 /* EnumMember */) { + symbol.parent = container.symbol; + } addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { @@ -20205,7 +20463,7 @@ var ts; inStrictMode = saveInStrictMode; } function bindJSDocTypedefTagIfAny(node) { - if (!node.jsDoc) { + if (!ts.hasJSDocNodes(node)) { return; } for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -21615,31 +21873,38 @@ var ts; return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } - var visitedTypes = ts.createMap(); // Key is id as string - var visitedSymbols = ts.createMap(); // Key is id as string + var visitedTypes = []; // Sparse array from id to type + var visitedSymbols = []; // Sparse array from id to symbol return { walkType: function (type) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitType(type); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitType(type); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, walkSymbol: function (symbol) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitSymbol(symbol); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitSymbol(symbol); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, }; function visitType(type) { if (!type) { return; } - var typeIdString = type.id.toString(); - if (visitedTypes.has(typeIdString)) { + if (visitedTypes[type.id]) { return; } - visitedTypes.set(typeIdString, type); + visitedTypes[type.id] = type; // Reuse visitSymbol to visit the type's symbol, // but be sure to bail on recuring into the type if accept declines the symbol. var shouldBail = visitSymbol(type.symbol); @@ -21675,23 +21940,15 @@ var ts; visitIndexedAccessType(type); } } - function visitTypeList(types) { - if (!types) { - return; - } - for (var i = 0; i < types.length; i++) { - visitType(types[i]); - } - } function visitTypeReference(type) { visitType(type.target); - visitTypeList(type.typeArguments); + ts.forEach(type.typeArguments, visitType); } function visitTypeParameter(type) { visitType(getConstraintFromTypeParameter(type)); } function visitUnionOrIntersectionType(type) { - visitTypeList(type.types); + ts.forEach(type.types, visitType); } function visitIndexType(type) { visitType(type.type); @@ -21711,7 +21968,7 @@ var ts; if (signature.typePredicate) { visitType(signature.typePredicate.type); } - visitTypeList(signature.typeParameters); + ts.forEach(signature.typeParameters, visitType); for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; visitSymbol(parameter); @@ -21721,8 +21978,8 @@ var ts; } function visitInterfaceType(interfaceT) { visitObjectType(interfaceT); - visitTypeList(interfaceT.typeParameters); - visitTypeList(getBaseTypes(interfaceT)); + ts.forEach(interfaceT.typeParameters, visitType); + ts.forEach(getBaseTypes(interfaceT), visitType); visitType(interfaceT.thisType); } function visitObjectType(type) { @@ -21749,11 +22006,11 @@ var ts; if (!symbol) { return; } - var symbolIdString = ts.getSymbolId(symbol).toString(); - if (visitedSymbols.has(symbolIdString)) { + var symbolId = ts.getSymbolId(symbol); + if (visitedSymbols[symbolId]) { return; } - visitedSymbols.set(symbolIdString, symbol); + visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { return true; } @@ -21813,7 +22070,7 @@ var ts; return undefined; } ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); - return resolved.path; + return { fileName: resolved.path, packageId: resolved.packageId }; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { @@ -21928,12 +22185,12 @@ var ts; var resolvedTypeReferenceDirective; if (resolved) { if (!options.preserveSymlinks) { - resolved = realPath(resolved, host, traceEnabled); + resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); } if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -22333,7 +22590,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension, packageId: undefined }; + return noPackageId({ path: path_1, ext: extension }); } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -22515,32 +22772,41 @@ var ts; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } + var _a = considerPackageJson + ? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state) + : { packageJsonContent: undefined, packageId: undefined }, packageJsonContent = _a.packageJsonContent, packageId = _a.packageId; + return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent)); + } + function loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent) { + var fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - var packageId; - if (considerPackageJson) { - var packageJsonPath = pathToPackageJson(candidate); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var jsonContent = readJson(packageJsonPath, state.host); - if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { - packageId = { name: jsonContent.name, version: jsonContent.version }; - } - var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); - if (fromPackageJson) { - return withPackageId(packageId, fromPackageJson); - } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, _a) { + var host = _a.host, traceEnabled = _a.traceEnabled; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); + var packageJsonPath = pathToPackageJson(nodeModuleDirectory); + if (directoryExists && host.fileExists(packageJsonPath)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); + var packageJsonContent = readJson(packageJsonPath, host); + var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" + ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version } + : undefined; + return { packageJsonContent: packageJsonContent, packageId: packageId }; + } + else { + if (directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); + return { packageJsonContent: undefined, packageId: undefined }; } - return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); @@ -22588,9 +22854,20 @@ var ts; return ts.combinePaths(directory, "package.json"); } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { + var _a = getPackageName(moduleName), packageName = _a.packageName, rest = _a.rest; + var packageRootPath = ts.combinePaths(nodeModulesFolder, packageName); + var _b = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state), packageJsonContent = _b.packageJsonContent, packageId = _b.packageId; var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + var pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent); + return withPackageId(packageId, pathAndExtension); + } + function getPackageName(moduleName) { + var idx = moduleName.indexOf(ts.directorySeparator); + if (moduleName[0] === "@") { + idx = moduleName.indexOf(ts.directorySeparator, idx + 1); + } + return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache); @@ -22801,6 +23078,7 @@ var ts; var enumCount = 0; var symbolInstantiationDepth = 0; var emptySymbols = ts.createSymbolTable(); + var identityMapper = ts.identity; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -22961,12 +23239,13 @@ var ts; return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); }, getApparentType: getApparentType, - getAllPossiblePropertiesOfType: getAllPossiblePropertiesOfType, + isArrayLikeType: isArrayLikeType, + getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, resolveName: function (name, location, meaning) { - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); }, getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; @@ -23055,7 +23334,8 @@ var ts; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; var flowLoopCount = 0; - var visitedFlowCount = 0; + var sharedFlowCount = 0; + var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var resolutionTargets = []; @@ -23070,8 +23350,8 @@ var ts; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; - var visitedFlowNodes = []; - var visitedFlowTypes = []; + var sharedFlowNodes = []; + var sharedFlowTypes = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -23205,6 +23485,7 @@ var ts; })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -23288,7 +23569,7 @@ var ts; } function cloneSymbol(symbol) { var result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations.slice(0); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; @@ -23387,6 +23668,7 @@ var ts; mergeSymbol(mainModule, moduleAugmentation.symbol); } else { + // moduleName will be a StringLiteral since this is not `declare global`. error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); } } @@ -23555,13 +23837,17 @@ var ts; }); } } - // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and - // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with - // the given name can be found. - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, suggestedNameNotFoundMessage) { - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); + /** + * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and + * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with + * the given name can be found. + * + * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters. + */ + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, suggestedNameNotFoundMessage) { + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, getSymbol, suggestedNameNotFoundMessage); } - function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, lookup, suggestedNameNotFoundMessage) { + function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, lookup, suggestedNameNotFoundMessage) { var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -23780,10 +24066,16 @@ var ts; // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. // If `result === lastLocation.symbol`, that means that we are somewhere inside `lastLocation` looking up a name, and resolving to `lastLocation` itself. // That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used. - if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { + if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { + if (lastLocation) { + ts.Debug.assert(lastLocation.kind === 265 /* SourceFile */); + if (lastLocation.commonJsModuleIndicator && name === "exports") { + return lastLocation.symbol; + } + } result = lookup(globals, name, meaning); } if (!result) { @@ -23917,7 +24209,7 @@ var ts; } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { if (meaning === 1920 /* Namespace */) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 /* Type */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 /* Type */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -23941,7 +24233,7 @@ var ts; error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 /* Type */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 /* Type */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -23951,14 +24243,14 @@ var ts; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { if (meaning & (107455 /* Value */ & ~1024 /* NamespaceModule */ & ~793064 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } else if (meaning & (793064 /* Type */ & ~1024 /* NamespaceModule */ & ~107455 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~793064 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~793064 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -23991,11 +24283,17 @@ var ts; return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 237 /* ImportEqualsDeclaration */) { + switch (node.kind) { + case 237 /* ImportEqualsDeclaration */: return node; - } - return ts.findAncestor(node, ts.isImportDeclaration); + case 239 /* ImportClause */: + return node.parent; + case 240 /* NamespaceImport */: + return node.parent.parent; + case 242 /* ImportSpecifier */: + return node.parent.parent.parent; + default: + return undefined; } } function getDeclarationOfAliasSymbol(symbol) { @@ -24248,7 +24546,7 @@ var ts; var symbol; if (name.kind === 71 /* Identifier */) { var message = meaning === 1920 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name); + symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name, /*isUse*/ true); if (!symbol) { return undefined; } @@ -24295,7 +24593,7 @@ var ts; undefined; } else { - ts.Debug.fail("Unknown entity name kind."); + ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -24346,13 +24644,13 @@ var ts; } } // May be an untyped module. If so, ignore resolutionDiagnostic. - if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } else if (noImplicitAny && moduleNotFoundError) { - var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + var errorInfo = !resolvedModule.isExternalLibraryImport ? undefined : ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } @@ -24465,10 +24763,9 @@ var ts; // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error. function visit(symbol) { - if (!(symbol && symbol.flags & 1952 /* HasExports */ && !ts.contains(visitedSymbols, symbol))) { + if (!(symbol && symbol.flags & 1952 /* HasExports */ && ts.pushIfUnique(visitedSymbols, symbol))) { return; } - visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder var exportStars = symbol.exports.get("__export" /* ExportStar */); @@ -24616,65 +24913,61 @@ var ts; return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - return getAccessibleSymbolChainFromSymbolTableWorker(symbols, []); + if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { + return undefined; } - function getAccessibleSymbolChainFromSymbolTableWorker(symbols, visitedSymbolTables) { - if (ts.contains(visitedSymbolTables, symbols)) { + var visitedSymbolTables = []; + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function getAccessibleSymbolChainFromSymbolTable(symbols) { + if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - visitedSymbolTables.push(symbols); var result = trySymbolTable(symbols); visitedSymbolTables.pop(); return result; - function canQualifySymbol(symbolFromSymbolTable, meaning) { - // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolFromSymbolTable or alias resolution matches the symbol, - // check the symbol can be qualified, it is only then this symbol is accessible - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - function trySymbolTable(symbols) { - // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols.get(symbol.escapedName))) { - return [symbol]; - } - // Check if symbol is any of the alias - return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */)) { - if (!useOnlyExternalAliasing || // We can use any type of alias to get the name - // Is this external alias, then use it to name - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { - return [symbolFromSymbolTable]; - } - // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain - // but only if the symbolFromSymbolTable can be qualified - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTableWorker(resolvedImportedSymbol.exports, visitedSymbolTables) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } } - if (symbol && !isPropertyOrMethodDeclarationSymbol(symbol)) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function canQualifySymbol(symbolFromSymbolTable, meaning) { + // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible + return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) || + // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too + !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) + // and if symbolFromSymbolTable or alias resolution matches the symbol, + // check the symbol can be qualified, it is only then this symbol is accessible + !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + function isUMDExportSymbol(symbol) { + return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + } + function trySymbolTable(symbols) { + // If symbol is directly available by its name in the symbol table + if (isAccessible(symbols.get(symbol.escapedName))) { + return [symbol]; + } + // Check if symbol is any of the alias + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 2097152 /* Alias */ + && symbolFromSymbolTable.escapedName !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */) + && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) + // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name + && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { + return [symbolFromSymbolTable]; + } + // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain + // but only if the symbolFromSymbolTable can be qualified + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + }); } } function needsQualification(symbol, enclosingDeclaration, meaning) { @@ -24813,14 +25106,7 @@ var ts; // since we will do the emitting later in trackSymbol. if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } + aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, anyImportSyntax); } return true; } @@ -24848,7 +25134,7 @@ var ts; meaning = 793064 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { accessibility: 1 /* NotAccessible */, @@ -24882,7 +25168,7 @@ var ts; var writer = ts.createTextWriter(""); var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(3 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = compilerOptions.noErrorTruncation || flags & 8 /* NoTruncation */ ? undefined : 100; if (maxLength && result.length >= maxLength) { @@ -25174,14 +25460,14 @@ var ts; var i = 0; var qualifiedName = void 0; if (outerTypeParameters) { - var length_2 = outerTypeParameters.length; - while (i < length_2) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { @@ -25457,29 +25743,6 @@ var ts; } } } - function getNameOfSymbol(symbol, context) { - var declaration = ts.firstOrUndefined(symbol.declarations); - if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - return ts.declarationNameToString(name); - } - if (declaration.parent && declaration.parent.kind === 226 /* VariableDeclaration */) { - return ts.declarationNameToString(declaration.parent.name); - } - if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { - context.encounteredError = true; - } - switch (declaration.kind) { - case 199 /* ClassExpression */: - return "(Anonymous class)"; - case 186 /* FunctionExpression */: - case 187 /* ArrowFunction */: - return "(Anonymous function)"; - } - } - return ts.unescapeLeadingUnderscores(symbol.escapedName); - } } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { return ts.usingSingleLineStringWriter(function (writer) { @@ -25537,9 +25800,9 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { - return type.flags & 32 /* StringLiteral */ ? "\"" + ts.escapeString(type.value) + "\"" : "" + type.value; + return type.flags & 32 /* StringLiteral */ ? '"' + ts.escapeString(type.value) + '"' : "" + type.value; } - function getNameOfSymbol(symbol) { + function getNameOfSymbol(symbol, context) { if (symbol.declarations && symbol.declarations.length) { var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); @@ -25549,6 +25812,9 @@ var ts; if (declaration.parent && declaration.parent.kind === 226 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } + if (context && !context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { + context.encounteredError = true; + } switch (declaration.kind) { case 199 /* ClassExpression */: return "(Anonymous class)"; @@ -25557,6 +25823,12 @@ var ts; return "(Anonymous function)"; } } + if (symbol.syntheticLiteralTypeOrigin) { + var stringValue = symbol.syntheticLiteralTypeOrigin.value; + if (!ts.isIdentifierText(stringValue, compilerOptions.target)) { + return "\"" + ts.escapeString(stringValue, 34 /* doubleQuote */) + "\""; + } + } return ts.unescapeLeadingUnderscores(symbol.escapedName); } function getSymbolDisplayBuilder() { @@ -25794,14 +26066,14 @@ var ts; var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_3 = outerTypeParameters.length; - while (i < length_3) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { // Find group of type arguments for type parameters with the same declaring container. var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_3 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { @@ -26349,7 +26621,7 @@ var ts; function collectLinkedAliases(node) { var exportSymbol; if (node.parent && node.parent.kind === 243 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); + exportSymbol = resolveName(node.parent, node.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node, /*isUse*/ false); } else if (node.parent.kind === 246 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); @@ -26363,14 +26635,12 @@ var ts; ts.forEach(declarations, function (declaration) { getNodeLinks(declaration).isVisible = true; var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } + ts.pushIfUnique(result, resultNode); if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, undefined, undefined); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -26393,8 +26663,8 @@ var ts; var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { // A cycle was found - var length_4 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_4; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -27104,38 +27374,50 @@ var ts; for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } + typeParameters = ts.appendIfUnique(typeParameters, tp); } return typeParameters; } - // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function - // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and - // returns the same array. - function appendOuterTypeParameters(typeParameters, node) { + // Return the outer type parameters of a node or undefined if the node has no outer type parameters. + function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; if (!node) { - return typeParameters; + return undefined; } - if (node.kind === 229 /* ClassDeclaration */ || node.kind === 199 /* ClassExpression */ || - node.kind === 228 /* FunctionDeclaration */ || node.kind === 186 /* FunctionExpression */ || - node.kind === 151 /* MethodDeclaration */ || node.kind === 187 /* ArrowFunction */) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } + switch (node.kind) { + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 150 /* MethodSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 273 /* JSDocFunctionType */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 231 /* TypeAliasDeclaration */: + case 282 /* JSDocTemplateTag */: + case 172 /* MappedType */: + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + if (node.kind === 172 /* MappedType */) { + return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); + } + var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray); + var thisType = includeThisTypes && + (node.kind === 229 /* ClassDeclaration */ || node.kind === 199 /* ClassExpression */ || node.kind === 230 /* InterfaceDeclaration */) && + getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; + return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230 /* InterfaceDeclaration */); - return appendOuterTypeParameters(/*typeParameters*/ undefined, declaration); + return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. @@ -27189,7 +27471,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig; }); + return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJavaScriptFile(location)) : sig; }); } /** * The base constructor of a class can resolve to @@ -27280,7 +27562,7 @@ var ts; var valueDecl = type.symbol.valueDeclaration; if (valueDecl && ts.isInJavaScriptFile(valueDecl)) { var augTag = ts.getJSDocAugmentsTag(type.symbol.valueDeclaration); - if (augTag) { + if (augTag && augTag.typeExpression && augTag.typeExpression.type) { baseType = getTypeFromTypeNode(augTag.typeExpression.type); } } @@ -27410,7 +27692,9 @@ var ts; var declaration = ts.find(symbol.declarations, function (d) { return d.kind === 283 /* JSDocTypedefTag */ || d.kind === 231 /* TypeAliasDeclaration */; }); - var type = getTypeFromTypeNode(declaration.kind === 283 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type); + var typeNode = declaration.kind === 283 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type; + // If typeNode is missing, we will error in checkJSDocTypedefTag. + var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -27761,7 +28045,7 @@ var ts; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -27798,9 +28082,7 @@ var ts; if (!match) { return undefined; } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } + result = ts.appendIfUnique(result, match); } return result; } @@ -28009,7 +28291,14 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t, propertySymbol) { + function addMemberForKeyType(t, propertySymbolOrIndex) { + var propertySymbol; + // forEachType delegates to forEach, which calls with a numeric second argument + // the type system currently doesn't catch this incompatibility, so we annotate + // the function ourselves to indicate the runtime behavior and deal with it here + if (typeof propertySymbolOrIndex === "object") { + propertySymbol = propertySymbolOrIndex; + } // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. @@ -28029,6 +28318,7 @@ var ts; prop.syntheticOrigin = propertySymbol; prop.declarations = propertySymbol.declarations; } + prop.syntheticLiteralTypeOrigin = t; members.set(propName, prop); } else if (t.flags & 2 /* String */) { @@ -28151,26 +28441,22 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getAllPossiblePropertiesOfType(type) { - if (type.flags & 65536 /* Union */) { - var props = ts.createSymbolTable(); - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var memberType = _a[_i]; - if (memberType.flags & 8190 /* Primitive */) { - continue; - } - for (var _b = 0, _c = getPropertiesOfType(memberType); _b < _c.length; _b++) { - var escapedName = _c[_b].escapedName; - if (!props.has(escapedName)) { - props.set(escapedName, createUnionOrIntersectionProperty(type, escapedName)); - } + function getAllPossiblePropertiesOfTypes(types) { + var unionType = getUnionType(types); + if (!(unionType.flags & 65536 /* Union */)) { + return getPropertiesOfType(unionType); + } + var props = ts.createSymbolTable(); + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var memberType = types_2[_i]; + for (var _a = 0, _b = getPropertiesOfType(memberType); _a < _b.length; _a++) { + var escapedName = _b[_a].escapedName; + if (!props.has(escapedName)) { + props.set(escapedName, createUnionOrIntersectionProperty(unionType, escapedName)); } } - return ts.arrayFrom(props.values()); - } - else { - return getPropertiesOfType(type); } + return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : @@ -28237,8 +28523,8 @@ var ts; if (t.flags & 196608 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_2 = types_2[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); @@ -28316,20 +28602,15 @@ var ts; var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; var checkFlags = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } + props = ts.appendIfUnique(props, prop); checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 64 /* ContainsPublic */ : 0) | (modifiers & 16 /* Protected */ ? 128 /* ContainsProtected */ : 0) | @@ -28479,12 +28760,7 @@ var ts; var result; ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) { var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - if (!result) { - result = []; - } - result.push(tp); - } + result = ts.appendIfUnique(result, tp); }); return result; } @@ -28520,7 +28796,7 @@ var ts; if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -28583,11 +28859,10 @@ var ts; * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScript) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - var isJavaScript = ts.isInJavaScriptFile(location); if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; @@ -28626,7 +28901,7 @@ var ts; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455 /* Value */, undefined, undefined); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -28822,8 +29097,8 @@ var ts; } return anyType; } - function getSignatureInstantiation(signature, typeArguments) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); + function getSignatureInstantiation(signature, typeArguments, isJavascript) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -28836,12 +29111,27 @@ var ts; return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true); } function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true); - } - return signature.erasedSignatureCache; + return signature.typeParameters ? + signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : + signature; + } + function createErasedSignature(signature) { + // Create an instantiation of the signature where all type arguments are the any type. + return instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true); + } + function getCanonicalSignature(signature) { + return signature.typeParameters ? + signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) : + signature; + } + function createCanonicalSignature(signature) { + // Create an instantiation of the signature where each unconstrained type parameter is replaced with + // its original. When a generic class or interface is instantiated, each generic method in the class or + // interface is instantiated with a fresh set of cloned type parameters (which we need to handle scenarios + // where different generations of the same type parameter are in scope). This leads to a lot of new type + // identities, and potentially a lot of work comparing those identities, so here we create an instantiation + // that uses the original type identities for all unconstrained type parameters. + return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJavaScriptFile(signature.declaration)); } function getOrCreateTypeFromSignature(signature) { // There are two ways to declare a construct signature, one is by declaring a class constructor @@ -28911,12 +29201,12 @@ var ts; function getTypeListId(types) { var result = ""; if (types) { - var length_5 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_5) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_5 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -28937,8 +29227,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -28977,7 +29267,8 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { + var isJavascript = ts.isInJavaScriptFile(node); + if (!isJavascript && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), minTypeArgumentCount, typeParameters.length); @@ -28986,7 +29277,7 @@ var ts; // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJavascript)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -29002,7 +29293,7 @@ var ts; var id = getTypeListId(typeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJavaScriptFile(symbol.valueDeclaration))))); } return instantiation; } @@ -29214,7 +29505,8 @@ var ts; return getGlobalSymbol(name, 793064 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); + // Don't track references for global symbols anyway, so value if `isReference` is arbitrary + return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false); } function getGlobalType(name, arity, reportErrors) { var symbol = getGlobalTypeSymbol(name, reportErrors); @@ -29374,6 +29666,22 @@ var ts; function containsType(types, type) { return binarySearchTypes(types, type) >= 0; } + // Return true if the given intersection type contains (a) more than one unit type or (b) an object + // type and a nullable type (null or undefined). + function isEmptyIntersectionType(type) { + var combined = 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (t.flags & 6368 /* Unit */ && combined & 6368 /* Unit */) { + return true; + } + combined |= t.flags; + if (combined & 6144 /* Nullable */ && combined & (32768 /* Object */ | 16777216 /* NonPrimitive */)) { + return true; + } + } + return false; + } function addTypeToUnion(typeSet, type) { var flags = type.flags; if (flags & 65536 /* Union */) { @@ -29390,7 +29698,11 @@ var ts; if (!(flags & 2097152 /* ContainsWideningType */)) typeSet.containsNonWideningType = true; } - else if (!(flags & 8192 /* Never */)) { + else if (!(flags & 8192 /* Never */ || flags & 131072 /* Intersection */ && isEmptyIntersectionType(type))) { + // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are + // another form of 'never' (in that they have an empty value domain). We could in theory turn + // intersections of unit types into 'never' upon construction, but deferring the reduction makes it + // easier to reason about their origin. if (flags & 2 /* String */) typeSet.containsString = true; if (flags & 4 /* Number */) @@ -29410,14 +29722,14 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -29425,8 +29737,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -29519,6 +29831,12 @@ var ts; type = createType(65536 /* Union */ | propagatedFlags); unionTypes.set(id, type); type.types = types; + /* + 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. + (In the language service, the order may depend on the order in which a user takes actions, such as hovering over symbols.) + It's important that we create equivalent union types only once, so that's an unfortunate side effect. + */ type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } @@ -29560,8 +29878,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -29608,7 +29926,7 @@ var ts; type = createType(131072 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; - type.aliasSymbol = aliasSymbol; + type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. type.aliasTypeArguments = aliasTypeArguments; } return type; @@ -29720,21 +30038,6 @@ var ts; } return anyType; } - function getIndexedAccessForMappedType(type, indexType, accessNode) { - if (accessNode) { - // Check if the index type is assignable to 'keyof T' for the object type. - if (!isTypeAssignableTo(indexType, getIndexType(type))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); - return unknownType; - } - if (accessNode.kind === 180 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { - error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - } - } - var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); - var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); - } function isGenericObjectType(type) { return type.flags & 540672 /* TypeVariable */ ? true : getObjectFlags(type) & 32 /* Mapped */ ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : @@ -29757,12 +30060,14 @@ var ts; } return false; } - // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or - // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a - // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed - // access types with default property values as expressed by D. + // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return + // undefined if no transformation is possible. function getTransformedIndexedAccessType(type) { var objectType = type.objectType; + // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or + // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a + // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed + // access types with default property values as expressed by D. if (objectType.flags & 131072 /* Intersection */ && isGenericObjectType(objectType) && ts.some(objectType.types, isStringIndexOnlyType)) { var regularTypes = []; var stringIndexTypes = []; @@ -29780,19 +30085,22 @@ var ts; getIntersectionType(stringIndexTypes) ]); } - return undefined; - } - function getIndexedAccessType(objectType, indexType, accessNode) { - // If the object type is a mapped type { [P in K]: E }, where K is generic, we instantiate E using a mapper + // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we // construct the type Box. if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); + var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [type.indexType]); + var objectTypeMapper = objectType.mapper; + var templateMapper = objectTypeMapper ? combineTypeMappers(objectTypeMapper, mapper) : mapper; + return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - // Otherwise, if the index type is generic, or if the object type is generic and doesn't originate in an - // expression, we are performing a higher-order index access where we cannot meaningfully access the properties - // of the object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates - // in an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' + return undefined; + } + function getIndexedAccessType(objectType, indexType, accessNode) { + // If the index type is generic, or if the object type is generic and doesn't originate in an expression, + // we are performing a higher-order index access where we cannot meaningfully access the properties of the + // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in + // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 1 /* Any */) { @@ -29807,8 +30115,10 @@ var ts; return type; } // In the following we resolve T[K] to the type of the property in T selected by K. + // We treat boolean as different from other unions to improve errors; + // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 65536 /* Union */ && !(indexType.flags & 8190 /* Primitive */)) { + if (indexType.flags & 65536 /* Union */ && !(indexType.flags & 8 /* Boolean */)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -29892,7 +30202,10 @@ var ts; return mapType(right, function (t) { return getSpreadType(left, t); }); } if (right.flags & 16777216 /* NonPrimitive */) { - return emptyObjectType; + return nonPrimitiveType; + } + if (right.flags & (136 /* BooleanLike */ | 84 /* NumberLike */ | 262178 /* StringLike */ | 272 /* EnumLike */)) { + return left; } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); @@ -30120,10 +30433,6 @@ var ts; function instantiateSignatures(signatures, mapper) { return instantiateList(signatures, mapper, instantiateSignature); } - function instantiateCached(type, mapper, instantiator) { - var instantiations = mapper.instantiations || (mapper.instantiations = []); - return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); - } function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -30142,11 +30451,9 @@ var ts; } function createTypeMapper(sources, targets) { ts.Debug.assert(targets === undefined || sources.length === targets.length); - var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : makeArrayTypeMapper(sources, targets); - mapper.mappedTypes = sources; - return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, /*targets*/ undefined); @@ -30156,9 +30463,7 @@ var ts; * This is used during inference when instantiating type parameter defaults. */ function createBackreferenceMapper(typeParameters, index) { - var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; - mapper.mappedTypes = typeParameters; - return mapper; + return function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; } function isInferenceContext(mapper) { return !!mapper.signature; @@ -30168,18 +30473,11 @@ var ts; createInferenceContext(mapper.signature, mapper.flags | 2 /* NoDefault */, mapper.compareTypes, mapper.inferences) : mapper; } - function identityMapper(type) { - return type; - } function combineTypeMappers(mapper1, mapper2) { - var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); - return mapper; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function createReplacementMapper(source, target, baseMapper) { - var mapper = function (t) { return t === source ? target : baseMapper(t); }; - mapper.mappedTypes = baseMapper.mappedTypes; - return mapper; + return function (t) { return t === source ? target : baseMapper(t); }; } function cloneTypeParameter(typeParameter) { var result = createType(16384 /* TypeParameter */); @@ -30246,15 +30544,57 @@ var ts; if (symbol.valueDeclaration) { result.valueDeclaration = symbol.valueDeclaration; } + if (symbol.isRestParameter) { + result.isRestParameter = symbol.isRestParameter; + } return result; } - function instantiateAnonymousType(type, mapper) { - var result = createObjectType(16 /* Anonymous */ | 64 /* Instantiated */, type.symbol); - result.target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - result.mapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); - return result; + function getAnonymousTypeInstantiation(type, mapper) { + var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var symbol = target.symbol; + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (!typeParameters) { + // The first time an anonymous type is instantiated we compute and store a list of the type + // parameters that are in scope (and therefore potentially referenced). For type literals that + // aren't the right hand side of a generic type alias declaration we optimize by reducing the + // set of type parameters to those that are actually referenced somewhere in the literal. + var declaration_1 = symbol.declarations[0]; + var outerTypeParameters = getOuterTypeParameters(declaration_1, /*includeThisTypes*/ true) || ts.emptyArray; + typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + ts.filter(outerTypeParameters, function (tp) { return isTypeParameterReferencedWithin(tp, declaration_1); }) : + outerTypeParameters; + links.typeParameters = typeParameters; + if (typeParameters.length) { + links.instantiations = ts.createMap(); + links.instantiations.set(getTypeListId(typeParameters), target); + } + } + if (typeParameters.length) { + // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the + // mapper to the type parameters to produce the effective list of type arguments, and compute the + // instantiation cache key from the type IDs of the type arguments. + var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; + var typeArguments = ts.map(typeParameters, combinedMapper); + var id = getTypeListId(typeArguments); + var result = links.instantiations.get(id); + if (!result) { + var newMapper = createTypeMapper(typeParameters, typeArguments); + result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + links.instantiations.set(id, result); + } + return result; + } + return type; + } + function isTypeParameterReferencedWithin(tp, node) { + return tp.isThisType ? ts.forEachChild(node, checkThis) : ts.forEachChild(node, checkIdentifier); + function checkThis(node) { + return node.kind === 169 /* ThisType */ || ts.forEachChild(node, checkThis); + } + function checkIdentifier(node) { + return node.kind === 71 /* Identifier */ && ts.isPartOfTypeNode(node) && getTypeFromTypeNode(node) === tp || ts.forEachChild(node, checkIdentifier); + } } function instantiateMappedType(type, mapper) { // Check if we have a homomorphic mapped type, i.e. a type of the form { [P in keyof T]: X } for some @@ -30270,160 +30610,61 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + return instantiateAnonymousType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); } } } - return instantiateMappedObjectType(type, mapper); + return instantiateAnonymousType(type, mapper); } function isMappableType(type) { return type.flags & (16384 /* TypeParameter */ | 32768 /* Object */ | 131072 /* Intersection */ | 524288 /* IndexedAccess */); } - function instantiateMappedObjectType(type, mapper) { - var result = createObjectType(32 /* Mapped */ | 64 /* Instantiated */, type.symbol); - result.declaration = type.declaration; - result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + function instantiateAnonymousType(type, mapper) { + var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); + if (type.objectFlags & 32 /* Mapped */) { + result.declaration = type.declaration; + } + result.target = type; + result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { - if (!(symbol.declarations && symbol.declarations.length)) { - return false; - } - var mappedTypes = mapper.mappedTypes; - // Starting with the parent of the symbol's declaration, check if the mapper maps any of - // the type parameters introduced by enclosing declarations. We just pick the first - // declaration since multiple declarations will all have the same parent anyway. - return !!ts.findAncestor(symbol.declarations[0], function (node) { - if (node.kind === 233 /* ModuleDeclaration */ || node.kind === 265 /* SourceFile */) { - return "quit"; - } - switch (node.kind) { - case 160 /* FunctionType */: - case 161 /* ConstructorType */: - case 228 /* FunctionDeclaration */: - case 151 /* MethodDeclaration */: - case 150 /* MethodSignature */: - case 152 /* Constructor */: - case 155 /* CallSignature */: - case 156 /* ConstructSignature */: - case 157 /* IndexSignature */: - case 153 /* GetAccessor */: - case 154 /* SetAccessor */: - case 186 /* FunctionExpression */: - case 187 /* ArrowFunction */: - case 229 /* ClassDeclaration */: - case 199 /* ClassExpression */: - case 230 /* InterfaceDeclaration */: - case 231 /* TypeAliasDeclaration */: - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (typeParameters) { - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var d = typeParameters_1[_i]; - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) { - return true; - } - } - } - if (ts.isClassLike(node) || node.kind === 230 /* InterfaceDeclaration */) { - var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; - if (thisType && ts.contains(mappedTypes, thisType)) { - return true; - } - } - break; - case 172 /* MappedType */: - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { - return true; - } - break; - case 273 /* JSDocFunctionType */: - var func = node; - for (var _a = 0, _b = func.parameters; _a < _b.length; _a++) { - var p = _b[_a]; - if (ts.contains(mappedTypes, getTypeOfNode(p))) { - return true; - } - } - break; - } - }); - } - function isTopLevelTypeAlias(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 265 /* SourceFile */ || parentKind === 234 /* ModuleBlock */; - } - return false; - } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - // If we are instantiating a type that has a top-level type alias, obtain the instantiation through - // the type alias instead in order to share instantiations for the same type arguments. This can - // dramatically reduce the number of structurally identical types we generate. Note that we can only - // perform this optimization for top-level type aliases. Consider: - // - // function f1(x: T) { - // type Foo = { x: X, t: T }; - // let obj: Foo = { x: x }; - // return obj; - // } - // function f2(x: U) { return f1(x); } - // let z = f2(42); - // - // Above, the declaration of f2 has an inferred return type that is an instantiation of f1's Foo - // equivalent to { x: U, t: U }. When instantiating this return type, we can't go back to Foo's - // cache because all cached instantiations are of the form { x: ???, t: T }, i.e. they have not been - // instantiated for T. Instead, we need to further instantiate the { x: U, t: U } form. - if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { - if (type.aliasTypeArguments) { - return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + if (type.flags & 16384 /* TypeParameter */) { + return mapper(type); + } + if (type.flags & 32768 /* Object */) { + if (type.objectFlags & 16 /* Anonymous */) { + // If the anonymous type originates in a declaration of a function, method, class, or + // interface, in an object type literal, or in an object literal expression, we may need + // to instantiate the type because it might reference a type parameter. + return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations ? + getAnonymousTypeInstantiation(type, mapper) : type; + } + if (type.objectFlags & 32 /* Mapped */) { + return getAnonymousTypeInstantiation(type, mapper); + } + if (type.objectFlags & 4 /* Reference */) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } - return type; } - return instantiateTypeNoAlias(type, mapper); - } - return type; - } - function instantiateTypeNoAlias(type, mapper) { - if (type.flags & 16384 /* TypeParameter */) { - return mapper(type); - } - if (type.flags & 32768 /* Object */) { - if (type.objectFlags & 16 /* Anonymous */) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. We skip instantiation - // if none of the type parameters that are in scope in the type's declaration are mapped by - // the given mapper, however we can only do that analysis if the type isn't itself an - // instantiation. - return type.symbol && - type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && - (type.objectFlags & 64 /* Instantiated */ || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateCached(type, mapper, instantiateAnonymousType) : type; + if (type.flags & 65536 /* Union */ && !(type.flags & 8190 /* Primitive */)) { + return getUnionType(instantiateTypes(type.types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 32 /* Mapped */) { - return instantiateCached(type, mapper, instantiateMappedType); + if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 4 /* Reference */) { - return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); + if (type.flags & 262144 /* Index */) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288 /* IndexedAccess */) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - } - if (type.flags & 65536 /* Union */ && !(type.flags & 8190 /* Primitive */)) { - return getUnionType(instantiateTypes(type.types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 131072 /* Intersection */) { - return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 262144 /* Index */) { - return getIndexType(instantiateType(type.type, mapper)); - } - if (type.flags & 524288 /* IndexedAccess */) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } return type; } @@ -30437,6 +30678,7 @@ var ts; switch (node.kind) { case 186 /* FunctionExpression */: case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); case 178 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); @@ -30450,9 +30692,6 @@ var ts; (isContextSensitive(node.left) || isContextSensitive(node.right)); case 261 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 151 /* MethodDeclaration */: - case 150 /* MethodSignature */: - return isContextSensitiveFunctionLikeDeclaration(node); case 185 /* ParenthesizedExpression */: return isContextSensitive(node.expression); case 254 /* JsxAttributes */: @@ -30569,7 +30808,8 @@ var ts; if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { return 0 /* False */; } - if (source.typeParameters) { + if (source.typeParameters && source.typeParameters !== target.typeParameters) { + target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } var result = -1 /* True */; @@ -30842,7 +31082,14 @@ var ts; var targetStack; var maybeCount = 0; var depth = 0; - var expandingFlags = 0; + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var expandingFlags = 0 /* None */; var overflow = false; var isIntersectionConstituent = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); @@ -31060,10 +31307,21 @@ var ts; else { // use the property's value declaration if the property is assigned inside the literal itself var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; })) { - errorNode = prop.valueDeclaration; + var propDeclaration = prop.valueDeclaration; + ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); + errorNode = propDeclaration; + if (ts.isIdentifier(propDeclaration.name)) { + suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + } + } + if (suggestion !== undefined) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2, symbolToString(prop), typeToString(target), ts.unescapeLeadingUnderscores(suggestion)); + } + else { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } } return { value: true }; @@ -31229,11 +31487,11 @@ var ts; targetStack[depth] = target; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) - expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) - expandingFlags |= 2; - var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; + if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, depth)) + expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) + expandingFlags |= 2 /* Target */; + var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -31287,7 +31545,7 @@ var ts; else if (target.flags & 524288 /* IndexedAccess */) { // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - var constraint = getConstraintOfType(target); + var constraint = getConstraintOfIndexedAccess(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -31326,7 +31584,7 @@ var ts; else if (source.flags & 524288 /* IndexedAccess */) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - var constraint = getConstraintOfType(source); + var constraint = getConstraintOfIndexedAccess(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -31414,22 +31672,21 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128 /* ObjectLiteral */); + var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); + if (unmatchedProperty) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + } + return 0 /* False */; + } var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128 /* ObjectLiteral */); for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var targetProp = properties_3[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 16777216 /* Optional */) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0 /* False */; - } - } - else if (!(targetProp.flags & 4194304 /* Prototype */)) { + if (!(targetProp.flags & 4194304 /* Prototype */)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp && sourceProp !== targetProp) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -31737,13 +31994,14 @@ var ts; return type.flags & 16384 /* TypeParameter */ && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + return getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" * where A.id=111 and number.id=12 */ - function getTypeReferenceId(type, typeParameters) { + function getTypeReferenceId(type, typeParameters, depth) { + if (depth === void 0) { depth = 0; } var result = "" + type.target.id; for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { var t = _a[_i]; @@ -31755,6 +32013,9 @@ var ts; } result += "=" + index; } + else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; + } else { result += "-" + t.id; } @@ -31958,8 +32219,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -32000,7 +32261,7 @@ var ts; return !!getPropertyOfType(type, "0"); } function isUnitType(type) { - return (type.flags & (224 /* Literal */ | 2048 /* Undefined */ | 4096 /* Null */)) !== 0; + return !!(type.flags & 6368 /* Unit */); } function isLiteralType(type) { return type.flags & 8 /* Boolean */ ? true : @@ -32032,8 +32293,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -32276,7 +32537,6 @@ var ts; function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; - context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; @@ -32317,7 +32577,7 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = getObjectFlags(type); - return !!(type.flags & 540672 /* TypeVariable */ || + return !!(type.flags & (540672 /* TypeVariable */ | 262144 /* Index */) || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || @@ -32375,18 +32635,18 @@ var ts; return inference.candidates && getUnionType(inference.candidates, /*subtypeReduction*/ true); } } - function isPossiblyAssignableTo(source, target) { + function getUnmatchedProperty(source, target, requireOptionalProperties) { var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; - if (!(targetProp.flags & (16777216 /* Optional */ | 4194304 /* Prototype */))) { - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!sourceProp) { - return false; + return targetProp; } } } - return true; + return undefined; } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } @@ -32483,6 +32743,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 262144 /* Index */ && target.flags & 262144 /* Index */) { + inferFromTypes(source.type, target.type); + } + else if (source.flags & 524288 /* IndexedAccess */ && target.flags & 524288 /* IndexedAccess */) { + inferFromTypes(source.objectType, target.objectType); + inferFromTypes(source.indexType, target.indexType); + } else if (target.flags & 196608 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; @@ -32508,7 +32775,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 196608 /* UnionOrIntersection */) { + else if (source.flags & 65536 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -32518,7 +32785,7 @@ var ts; } else { source = getApparentType(source); - if (source.flags & 32768 /* Object */) { + if (source.flags & (32768 /* Object */ | 131072 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -32557,6 +32824,12 @@ var ts; return undefined; } function inferFromObjectTypes(source, target) { + if (isGenericMappedType(source) && isGenericMappedType(target)) { + // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer + // from S to T and from X to Y. + inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + } if (getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); if (constraintType.flags & 262144 /* Index */) { @@ -32586,7 +32859,7 @@ var ts; } // Infer from the members of source and target only if the two types are possibly related. We check // in both directions because we may be inferring for a co-variant or a contra-variant position. - if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + if (!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) || !getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false)) { inferFromProperties(source, target); inferFromSignatures(source, target, 0 /* Call */); inferFromSignatures(source, target, 1 /* Construct */); @@ -32597,7 +32870,7 @@ var ts; var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -32643,8 +32916,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32734,7 +33007,8 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = !ts.nodeIsMissing(node) && resolveName(node, node.escapedText, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + links.resolvedSymbol = !ts.nodeIsMissing(node) && + resolveName(node, node.escapedText, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node, !ts.isWriteOnlyAccess(node), ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } @@ -32915,8 +33189,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -33183,8 +33457,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -33264,8 +33538,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33319,15 +33593,25 @@ var ts; } return false; } + function reportFlowControlError(node) { + var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); + var sourceFile = ts.getSourceFileOfNode(node); + var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; + var flowDepth = 0; + if (flowAnalysisDisabled) { + return unknownType; + } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810175 /* Narrowable */)) { return declaredType; } - var visitedFlowStart = visitedFlowCount; + var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); - visitedFlowCount = visitedFlowStart; + sharedFlowCount = sharedFlowStart; // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without @@ -33338,60 +33622,70 @@ var ts; } return resultType; function getTypeAtFlowNode(flow) { + if (flowDepth === 2500) { + // We have made 2500 recursive invocations. To avoid overflowing the call stack we report an error + // and disable further control flow analysis in the containing function or module body. + flowAnalysisDisabled = true; + reportFlowControlError(reference); + return unknownType; + } + flowDepth++; while (true) { - if (flow.flags & 1024 /* Shared */) { + var flags = flow.flags; + if (flags & 1024 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. - for (var i = visitedFlowStart; i < visitedFlowCount; i++) { - if (visitedFlowNodes[i] === flow) { - return visitedFlowTypes[i]; + for (var i = sharedFlowStart; i < sharedFlowCount; i++) { + if (sharedFlowNodes[i] === flow) { + flowDepth--; + return sharedFlowTypes[i]; } } } var type = void 0; - if (flow.flags & 4096 /* AfterFinally */) { + if (flags & 4096 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flow.flags & 2048 /* PreFinally */) { + else if (flags & 2048 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; continue; } - else if (flow.flags & 16 /* Assignment */) { + else if (flags & 16 /* Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 96 /* Condition */) { + else if (flags & 96 /* Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flow.flags & 128 /* SwitchClause */) { + else if (flags & 128 /* SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flow.flags & 12 /* Label */) { + else if (flags & 12 /* Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flow.flags & 4 /* BranchLabel */ ? + type = flags & 4 /* BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flow.flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 2 /* Start */) { + else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && reference.kind !== 179 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { @@ -33406,12 +33700,13 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flow.flags & 1024 /* Shared */) { + if (flags & 1024 /* Shared */) { // Record visited node and the associated type in the cache. - visitedFlowNodes[visitedFlowCount] = flow; - visitedFlowTypes[visitedFlowCount] = type; - visitedFlowCount++; + sharedFlowNodes[sharedFlowCount] = flow; + sharedFlowTypes[sharedFlowCount] = type; + sharedFlowCount++; } + flowDepth--; return type; } } @@ -33447,30 +33742,32 @@ var ts; return undefined; } function getTypeAtFlowArrayMutation(flow) { - var node = flow.node; - var expr = node.kind === 181 /* CallExpression */ ? - node.expression.expression : - node.left.expression; - if (isMatchingReference(reference, getReferenceCandidate(expr))) { - var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); - if (getObjectFlags(type) & 256 /* EvolvingArray */) { - var evolvedType_1 = type; - if (node.kind === 181 /* CallExpression */) { - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var arg = _a[_i]; - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + if (declaredType === autoType || declaredType === autoArrayType) { + var node = flow.node; + var expr = node.kind === 181 /* CallExpression */ ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (getObjectFlags(type) & 256 /* EvolvingArray */) { + var evolvedType_1 = type; + if (node.kind === 181 /* CallExpression */) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } } - } - else { - var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + else { + var indexType = getTypeOfExpression(node.left.argumentExpression); + if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); } - return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + return flowType; } - return flowType; } return undefined; } @@ -33530,9 +33827,7 @@ var ts; if (type === declaredType && declaredType === initialType) { return type; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control // flow using the instanceof operator or a user defined type predicate. @@ -33598,9 +33893,7 @@ var ts; if (cached_1) { return cached_1; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control // flow using the instanceof operator or a user defined type predicate. @@ -34571,7 +34864,8 @@ var ts; } } } - if (noImplicitThis || ts.isInJavaScriptFile(func)) { + var inJs = ts.isInJavaScriptFile(func); + if (noImplicitThis || inJs) { var containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { // We have an object literal method. Check if the containing object literal has a contextual type @@ -34598,10 +34892,19 @@ var ts; } // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. - if (func.parent.kind === 194 /* BinaryExpression */ && func.parent.operatorToken.kind === 58 /* EqualsToken */) { - var target = func.parent.left; + var parent = func.parent; + if (parent.kind === 194 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + var target = parent.left; if (target.kind === 179 /* PropertyAccessExpression */ || target.kind === 180 /* ElementAccessExpression */) { - return checkExpressionCached(target.expression); + var expression = target.expression; + // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` + if (inJs && ts.isIdentifier(expression)) { + var sourceFile = ts.getSourceFileOfNode(parent); + if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) { + return undefined; + } + } + return checkExpressionCached(expression); } } } @@ -34776,7 +35079,7 @@ var ts; // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { - type = getTypeOfExpression(binaryExpression.left); + type = getTypeOfExpression(binaryExpression.left, /*cache*/ true); } return type; } @@ -34834,16 +35137,10 @@ var ts; // the type of the property with the numeric name N in T, if one exists. Otherwise, if T has a numeric index signature, // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated // type of T. - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getApparentTypeOfContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1 /* Number */) - || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false); - } - return undefined; + function getContextualTypeForElementExpression(arrayContextualType, index) { + return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) + || getIndexTypeOfContextualType(arrayContextualType, 1 /* Number */) + || getIteratedTypeOrElementType(arrayContextualType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. function getContextualTypeForConditionalOperand(node) { @@ -34948,15 +35245,21 @@ var ts; return getContextualTypeForObjectLiteralElement(parent); case 263 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 177 /* ArrayLiteralExpression */: - return getContextualTypeForElementExpression(node); + case 177 /* ArrayLiteralExpression */: { + var arrayLiteral = parent; + var type = getApparentTypeOfContextualType(arrayLiteral); + return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); + } case 195 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); case 205 /* TemplateSpan */: ts.Debug.assert(parent.parent.kind === 196 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 185 /* ParenthesizedExpression */: - return getContextualType(parent); + case 185 /* ParenthesizedExpression */: { + // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. + var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); + } case 256 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); case 253 /* JsxAttribute */: @@ -35028,8 +35331,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -35072,8 +35375,9 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); - for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { - var e = elements_1[_i]; + var contextualType = getApparentTypeOfContextualType(node); + for (var index = 0; index < elements.length; index++) { + var e = elements[index]; if (inDestructuringPattern && e.kind === 198 /* SpreadElement */) { // Given the following situation: // var c: {}; @@ -35095,7 +35399,8 @@ var ts; } } else { - var type = checkExpressionForMutableLocation(e, checkMode); + var elementContextualType = getContextualTypeForElementExpression(contextualType, index); + var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === 198 /* SpreadElement */; @@ -35108,9 +35413,9 @@ var ts; type.pattern = node; return type; } - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - var pattern = contextualType.pattern; + var contextualType_1 = getApparentTypeOfContextualType(node); + if (contextualType_1 && contextualTypeIsTupleLikeType(contextualType_1)) { + var pattern = contextualType_1.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. if (pattern && (pattern.kind === 175 /* ArrayBindingPattern */ || pattern.kind === 177 /* ArrayLiteralExpression */)) { @@ -35118,7 +35423,7 @@ var ts; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.typeArguments[i]); + elementTypes.push(contextualType_1.typeArguments[i]); } else { if (patternElement.kind !== 200 /* OmittedExpression */) { @@ -35230,6 +35535,7 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; + var literalName = void 0; if (memberDecl.kind === 261 /* PropertyAssignment */ || memberDecl.kind === 262 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { @@ -35239,6 +35545,12 @@ var ts; } var type = void 0; if (memberDecl.kind === 261 /* PropertyAssignment */) { + if (memberDecl.name.kind === 144 /* ComputedPropertyName */) { + var t = checkComputedPropertyName(memberDecl.name); + if (t.flags & 224 /* Literal */) { + literalName = ts.escapeLeadingUnderscores("" + t.value); + } + } type = checkPropertyAssignment(memberDecl, checkMode); } else if (memberDecl.kind === 151 /* MethodDeclaration */) { @@ -35253,7 +35565,7 @@ var ts; type = jsdocType; } typeFlags |= type.flags; - var prop = createSymbol(4 /* Property */ | member.flags, member.escapedName); + var prop = createSymbol(4 /* Property */ | member.flags, literalName || member.escapedName); if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. @@ -35262,7 +35574,7 @@ var ts; if (isOptional) { prop.flags |= 16777216 /* Optional */; } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; } } @@ -35316,7 +35628,7 @@ var ts; ts.Debug.assert(memberDecl.kind === 153 /* GetAccessor */ || memberDecl.kind === 154 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -35377,7 +35689,8 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */ | 16777216 /* NonPrimitive */) || + return !!(type.flags & (1 /* Any */ | 16777216 /* NonPrimitive */) || + getFalsyFlags(type) & 7392 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 32768 /* Object */ && !isGenericMappedType(type) || type.flags & 196608 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -35622,8 +35935,9 @@ var ts; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { var signature = signatures_3[_i]; if (signature.typeParameters) { - var typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + var isJavascript = ts.isInJavaScriptFile(node); + var typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0, isJavascript); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); } else { instantiatedSignatures.push(signature); @@ -36016,7 +36330,7 @@ var ts; // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(); - var reactSym = resolveName(node.tagName, reactNamespace, 107455 /* Value */, reactRefErr, reactNamespace); + var reactSym = resolveName(node.tagName, reactNamespace, 107455 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted @@ -36264,19 +36578,8 @@ var ts; } return unknownType; } - if (prop.valueDeclaration) { - if (isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - if (prop.valueDeclaration.kind === 229 /* ClassDeclaration */ && - node.parent && node.parent.kind !== 159 /* TypeReference */ && - !ts.isInAmbientContext(prop.valueDeclaration) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - } - markPropertyAsReferenced(prop); + checkPropertyNotUsedBeforeDeclaration(prop, node, right); + markPropertyAsReferenced(prop, node); getNodeLinks(node).resolvedSymbol = prop; checkPropertyAccessibility(node, left, apparentType, prop); var propType = getDeclaredOrApparentType(prop, node); @@ -36298,6 +36601,61 @@ var ts; var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { + var valueDeclaration = prop.valueDeclaration; + if (!valueDeclaration) { + return; + } + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) + && !isPropertyDeclaredInAncestorClass(prop)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + else if (valueDeclaration.kind === 229 /* ClassDeclaration */ && + node.parent.kind !== 159 /* TypeReference */ && + !ts.isInAmbientContext(valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + } + function isInPropertyInitializer(node) { + return !!ts.findAncestor(node, function (node) { + switch (node.kind) { + case 149 /* PropertyDeclaration */: + return true; + case 261 /* PropertyAssignment */: + // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. + return false; + default: + return ts.isPartOfExpression(node) ? false : "quit"; + } + }); + } + /** + * It's possible that "prop.valueDeclaration" is a local declaration, but the property was also declared in a superclass. + * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. + */ + function isPropertyDeclaredInAncestorClass(prop) { + var classType = getTypeOfSymbol(prop.parent); + while (true) { + classType = getSuperClass(classType); + if (!classType) { + return false; + } + var superProperty = getPropertyOfObjectType(classType, prop.escapedName); + if (superProperty && superProperty.valueDeclaration) { + return true; + } + } + } + function getSuperClass(classType) { + var x = getBaseTypes(classType); + if (x.length === 0) { + return undefined; + } + ts.Debug.assert(x.length === 1); + return x[0]; + } function reportNonexistentProperty(propNode, containingType) { var errorInfo; if (containingType.flags & 65536 /* Union */ && !(containingType.flags & 8190 /* Primitive */)) { @@ -36310,8 +36668,8 @@ var ts; } } var suggestion = getSuggestionForNonexistentProperty(propNode, containingType); - if (suggestion) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); + if (suggestion !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), ts.unescapeLeadingUnderscores(suggestion)); } else { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); @@ -36323,7 +36681,7 @@ var ts; return suggestion && suggestion.escapedName; } function getSuggestionForNonexistentSymbol(location, name, meaning) { - var result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, function (symbols, name, meaning) { + var result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ false, function (symbols, name, meaning) { var symbol = getSymbol(symbols, name, meaning); if (symbol) { // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function @@ -36402,11 +36760,12 @@ var ts; } return bestCandidate; } - function markPropertyAsReferenced(prop) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly) { if (prop && noUnusedIdentifiers && (prop.flags & 106500 /* ClassMember */) && - prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8 /* Private */)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8 /* Private */) + && !(nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly))) { if (ts.getCheckFlags(prop) & 1 /* Instantiated */) { getSymbolLinks(prop).target.isReferenced = true; } @@ -36415,15 +36774,6 @@ var ts; } } } - function isInPropertyInitializer(node) { - while (node) { - if (node.parent && node.parent.kind === 149 /* PropertyDeclaration */ && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } function isValidPropertyAccess(node, propertyName) { var left = node.kind === 179 /* PropertyAccessExpression */ ? node.expression @@ -36648,7 +36998,6 @@ var ts; var argCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - var isDecorator; var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". @@ -36678,7 +37027,6 @@ var ts; } } else if (node.kind === 147 /* Decorator */) { - isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } @@ -36738,7 +37086,7 @@ var ts; if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 4 /* ReturnType */); } - return getSignatureInstantiation(signature, getInferredTypes(context)); + return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJavaScriptFile(contextualSignature.declaration)); } function inferTypeArguments(node, signature, args, excludeArgument, context) { // Clear out all the inference results from the last time inferTypeArguments was called on this context @@ -36756,7 +37104,7 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (ts.isExpression(node)) { + if (node.kind !== 147 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -36772,7 +37120,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -37415,8 +37763,9 @@ var ts; candidate = originalCandidate; if (candidate.typeParameters) { var typeArgumentTypes = void 0; + var isJavascript = ts.isInJavaScriptFile(candidate.declaration); if (typeArguments) { - typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript); if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) { candidateForTypeArgumentError = originalCandidate; break; @@ -37425,7 +37774,7 @@ var ts; else { typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); } if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { candidateForArgumentError = candidate; @@ -37559,15 +37908,6 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - // If the expression is a class of abstract type, then it cannot be instantiated. - // Note, only class declarations can be declared abstract. - // In the case of a merged class-module or class-interface declaration, - // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasModifier(valueDecl, 128 /* Abstract */)) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); - return resolveErrorCall(node); - } // TS 1.0 spec: 4.11 // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. @@ -37586,6 +37926,15 @@ var ts; if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && ts.hasModifier(valueDecl, 128 /* Abstract */)) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } // If expressionType's apparent type is an object type with no construct signatures but @@ -37732,8 +38081,8 @@ var ts; if (elementType.flags & 65536 /* Union */) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var type = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -37759,7 +38108,7 @@ var ts; // This code-path is called by language service return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } - ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); + ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } /** * Resolve a signature of a given call-like expression. @@ -37791,18 +38140,32 @@ var ts; * file. */ function isJavaScriptConstructor(node) { - if (ts.isInJavaScriptFile(node)) { + if (node && ts.isInJavaScriptFile(node)) { // If the node has a @class tag, treat it like a constructor. if (ts.getJSDocClassTag(node)) return true; // If the symbol of the node has members, treat it like a constructor. var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : - ts.isVariableDeclaration(node) && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : + ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; return symbol && symbol.members !== undefined; } return false; } + function getJavaScriptClassType(symbol) { + if (ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = getSymbolOfNode(symbol.valueDeclaration.initializer); + } + if (isJavaScriptConstructor(symbol.valueDeclaration)) { + return getInferredClassType(symbol); + } + if (symbol.flags & 3 /* Variable */) { + var valueType = getTypeOfSymbol(symbol); + if (valueType.symbol && !isInferredClassType(valueType) && isJavaScriptConstructor(valueType.symbol.valueDeclaration)) { + return getInferredClassType(valueType.symbol); + } + } + } function getInferredClassType(symbol) { var links = getSymbolLinks(symbol); if (!links.inferredClassType) { @@ -37842,13 +38205,11 @@ var ts; var funcSymbol = node.expression.kind === 71 /* Identifier */ ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { - funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + var type = funcSymbol && getJavaScriptClassType(funcSymbol); + if (type) { + return type; } - if (funcSymbol && funcSymbol.flags & 16 /* Function */ && (funcSymbol.members || ts.getJSDocClassTag(funcSymbol.valueDeclaration))) { - return getInferredClassType(funcSymbol); - } - else if (noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -37914,7 +38275,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) throw ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (!resolvedRequire) { // project does not contain symbol named 'require' - assume commonjs require return true; @@ -38022,8 +38383,9 @@ var ts; } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.lastOrUndefined(signature.parameters); - if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { + if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } @@ -38169,9 +38531,7 @@ var ts; ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } }); return aggregatedTypes; @@ -38219,9 +38579,7 @@ var ts; if (type.flags & 8192 /* Never */) { hasReturnOfTypeNever = true; } - else if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } else { hasReturnWithNoExpression = true; @@ -38232,9 +38590,7 @@ var ts; return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { - if (!ts.contains(aggregatedTypes, undefinedType)) { - aggregatedTypes.push(undefinedType); - } + ts.pushIfUnique(aggregatedTypes, undefinedType); } return aggregatedTypes; } @@ -38539,8 +38895,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -39097,20 +39453,6 @@ var ts; var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } - function checkLiteralExpression(node) { - switch (node.kind) { - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: - return getFreshTypeOfLiteralType(getLiteralType(node.text)); - case 8 /* NumericLiteral */: - checkGrammarNumericLiteral(node); - return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101 /* TrueKeyword */: - return trueType; - case 86 /* FalseKeyword */: - return falseType; - } - } function checkTemplateExpression(node) { // We just want to check each expressions, but we are unconcerned with // the type of each expression, as any value may be coerced into a string. @@ -39173,9 +39515,13 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, checkMode) { + function checkExpressionForMutableLocation(node, checkMode, contextualType) { + if (arguments.length === 2) { + contextualType = getContextualType(node); + } var type = checkExpression(node, checkMode); - return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); + var shouldWiden = isTypeAssertion(node) || isLiteralContextualType(contextualType); + return shouldWiden ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, checkMode) { // Do not use hasDynamicName here, because that returns false for well known symbols. @@ -39279,13 +39625,9 @@ var ts; return type; } function checkParenthesizedExpression(node, checkMode) { - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - var typecasts = ts.flatMap(node.jsDoc, function (doc) { return ts.filter(doc.tags, function (tag) { return tag.kind === 281 /* JSDocTypeTag */; }); }); - if (typecasts && typecasts.length) { - // We should have already issued an error if there were multiple type jsdocs - var cast_1 = typecasts[0]; - return checkAssertionWorker(cast_1, cast_1.typeExpression.type, node.expression, checkMode); - } + var tag = ts.isInJavaScriptFile(node) ? ts.getJSDocTypeTag(node) : undefined; + if (tag) { + return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -39301,10 +39643,14 @@ var ts; return nullWideningType; case 13 /* NoSubstitutionTemplateLiteral */: case 9 /* StringLiteral */: + return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(node); + return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101 /* TrueKeyword */: + return trueType; case 86 /* FalseKeyword */: - return checkLiteralExpression(node); + return falseType; case 196 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: @@ -39920,7 +40266,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, ts.isInJavaScriptFile(typeArgumentNodes[i])); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -39994,6 +40340,10 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + if (accessNode.kind === 180 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + getObjectFlags(objectType) & 32 /* Mapped */ && objectType.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + } return type; } // Check if we're indexing with a numeric type and if either object or index types @@ -40296,6 +40646,8 @@ var ts; switch (d.kind) { case 230 /* InterfaceDeclaration */: case 231 /* TypeAliasDeclaration */: + // A jsdoc typedef is, by definition, a type alias + case 283 /* JSDocTypedefTag */: return 2 /* ExportType */; case 233 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ @@ -40304,7 +40656,10 @@ var ts; case 229 /* ClassDeclaration */: case 232 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; + // The below options all declare an Alias, which is allowed to merge with other values within the importing module case 237 /* ImportEqualsDeclaration */: + case 240 /* NamespaceImport */: + case 239 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -40613,8 +40968,11 @@ var ts; markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node)); } function markEntityNameOrEntityExpressionAsReference(typeName) { - var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.escapedText, (typeName.kind === 71 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (!typeName) + return; + var rootName = getFirstIdentifier(typeName); + var meaning = (typeName.kind === 71 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ && symbolIsValue(rootSymbol) @@ -40738,22 +41096,13 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } - function checkJSDoc(node) { - if (!ts.isInJavaScriptFile(node)) { - return; - } - ts.forEach(node.jsDoc, checkSourceElement); - } - function checkJSDocComment(node) { - if (node.tags) { - for (var _i = 0, _a = node.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - checkSourceElement(tag); - } + function checkJSDocTypedefTag(node) { + if (!node.typeExpression) { + // If the node had `@property` tags, `typeExpression` would have been set to the first property tag. + error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags); } } function checkFunctionOrMethodDeclaration(node) { - checkJSDoc(node); checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); @@ -40879,11 +41228,11 @@ var ts; !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { - error(name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(local.escapedName)); + error(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(local.escapedName)); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return errorUnusedLocal(ts.getNameOfDeclaration(d) || d, ts.unescapeLeadingUnderscores(local.escapedName)); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d, ts.unescapeLeadingUnderscores(local.escapedName)); }); } } }); @@ -40896,15 +41245,17 @@ var ts; } return false; } - function errorUnusedLocal(node, name) { + function errorUnusedLocal(declaration, name) { + var node = ts.getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 226 /* VariableDeclaration */ && ts.isForInOrOfStatement(declaration.parent.parent)) { + var declaration_2 = ts.getRootDeclaration(node.parent); + if ((declaration_2.kind === 226 /* VariableDeclaration */ && ts.isForInOrOfStatement(declaration_2.parent.parent)) || + declaration_2.kind === 145 /* TypeParameter */) { return; } } if (!isRemovedPropertyFromObjectSpread(node.kind === 71 /* Identifier */ ? node.parent : node)) { - error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + error(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name); } } function parameterNameStartsWithUnderscore(parameterName) { @@ -40920,14 +41271,14 @@ var ts; var member = _a[_i]; if (member.kind === 151 /* MethodDeclaration */ || member.kind === 149 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.hasModifier(member, 8 /* Private */)) { - error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); + error(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { - error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); + error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } } @@ -40947,8 +41298,8 @@ var ts; } for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { var typeParameter = _a[_i]; - if (!getMergedSymbol(typeParameter.symbol).isReferenced) { - error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); + if (!getMergedSymbol(typeParameter.symbol).isReferenced && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } } @@ -40961,7 +41312,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - errorUnusedLocal(ts.getNameOfDeclaration(declaration), ts.unescapeLeadingUnderscores(local.escapedName)); + errorUnusedLocal(declaration, ts.unescapeLeadingUnderscores(local.escapedName)); } } } @@ -40973,7 +41324,14 @@ var ts; if (node.kind === 207 /* Block */) { checkGrammarStatementInAmbientContext(node); } - ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionOrModuleBlock(node)) { + var saveFlowAnalysisDisabled = flowAnalysisDisabled; + ts.forEach(node.statements, checkSourceElement); + flowAnalysisDisabled = saveFlowAnalysisDisabled; + } + else { + ts.forEach(node.statements, checkSourceElement); + } if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -41143,7 +41501,7 @@ var ts; if (symbol.flags & 1 /* FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) throw ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { @@ -41191,7 +41549,7 @@ var ts; else if (n.kind === 71 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name - var symbol = resolveName(n, n.escapedText, 107455 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + var symbol = resolveName(n, n.escapedText, 107455 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; } @@ -41268,7 +41626,7 @@ var ts; var parentType = getTypeForBindingElementParent(parent); var name = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); - markPropertyAsReferenced(property); + markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined); // A destructuring is never a write-only reference. if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); } @@ -42955,9 +43313,9 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { + if (modulekind >= ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -42988,7 +43346,7 @@ var ts; if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } - if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015) { + if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015 && modulekind !== ts.ModuleKind.ESNext) { checkExternalEmitHelpers(node, 32768 /* ExportStar */); } } @@ -43007,7 +43365,7 @@ var ts; var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, - /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.unescapeLeadingUnderscores(exportedName.escapedText)); } @@ -43042,10 +43400,13 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); + if (ts.isInAmbientContext(node) && !ts.isEntityNameExpression(node.expression)) { + grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); + } if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES2015) { + if (modulekind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { // system modules does not support export assignment @@ -43079,7 +43440,7 @@ var ts; if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) { return; } - var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor); if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) @@ -43096,15 +43457,25 @@ var ts; }); links.exportsChecked = true; } - function isNotOverload(declaration) { - return (declaration.kind !== 228 /* FunctionDeclaration */ && declaration.kind !== 151 /* MethodDeclaration */) || - !!declaration.body; - } + } + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 228 /* FunctionDeclaration */ && declaration.kind !== 151 /* MethodDeclaration */) || + !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } + if (ts.isInJavaScriptFile(node) && node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var tags = _a[_i].tags; + ts.forEach(tags, checkSourceElement); + } + } var kind = node.kind; if (cancellationToken) { // Only bother checking on a few construct kinds. We don't want to be excessively @@ -43158,8 +43529,8 @@ var ts; case 168 /* ParenthesizedType */: case 170 /* TypeOperator */: return checkSourceElement(node.type); - case 275 /* JSDocComment */: - return checkJSDocComment(node); + case 283 /* JSDocTypedefTag */: + return checkJSDocTypedefTag(node); case 279 /* JSDocParameterTag */: return checkSourceElement(node.typeExpression); case 273 /* JSDocFunctionType */: @@ -43304,6 +43675,7 @@ var ts; ts.clear(potentialNewTargetCollisions); deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; + flowAnalysisDisabled = false; ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalModule(node)) { @@ -43674,12 +44046,14 @@ var ts; return sig.thisParameter; } } + if (ts.isInExpressionContext(node)) { + return checkExpression(node).symbol; + } // falls through - case 97 /* SuperKeyword */: - var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); - return type.symbol; case 169 /* ThisType */: - return getTypeFromTypeNode(node).symbol; + return getTypeFromThisTypeNode(node).symbol; + case 97 /* SuperKeyword */: + return checkExpression(node).symbol; case 123 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; @@ -43699,13 +44073,17 @@ var ts; // falls through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { - var objectType = getTypeOfExpression(node.parent.expression); - return getPropertyOfType(objectType, node.text); - } - break; + var objectType = ts.isElementAccessExpression(node.parent) + ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined + : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) + ? getTypeFromTypeNode(node.parent.parent.objectType) + : undefined; + return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); + case 79 /* DefaultKeyword */: + return getSymbolOfNode(node.parent); + default: + return undefined; } - return undefined; } function getShorthandAssignmentValueSymbol(location) { // The function returns a value symbol of an identifier in the short-hand property assignment. @@ -43853,9 +44231,9 @@ var ts; function getRootSymbols(symbol) { if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { var symbols_4 = []; - var name_2 = symbol.escapedName; + var name_3 = symbol.escapedName; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_2); + var symbol = getPropertyOfType(t, name_3); if (symbol) { symbols_4.push(symbol); } @@ -43976,7 +44354,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (!!resolveName(container.parent, symbol.escapedName, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + if (resolveName(container.parent, symbol.escapedName, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -44155,6 +44533,15 @@ var ts; return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { + // ensure both `typeName` and `location` are parse tree nodes. + typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + if (!typeName) + return ts.TypeReferenceSerializationKind.Unknown; + if (location) { + location = ts.getParseTreeNode(location); + if (!location) + return ts.TypeReferenceSerializationKind.Unknown; + } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. @@ -44244,7 +44631,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 107455 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return resolveName(location, reference.escapedText, 107455 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(reference) { if (!ts.isGeneratedIdentifier(reference)) { @@ -44547,7 +44934,7 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -44569,12 +44956,6 @@ var ts; case 113 /* ProtectedKeyword */: case 112 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 113 /* ProtectedKeyword */) { - lastProtected = modifier; - } - else if (modifier.kind === 112 /* PrivateKeyword */) { - lastPrivate = modifier; - } if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } @@ -45089,7 +45470,7 @@ var ts; currentKind = SetAccessor; } else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -45372,7 +45753,7 @@ var ts; } } } - if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } @@ -45393,8 +45774,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var element = elements_1[_i]; if (!ts.isOmittedExpression(element)) { return checkESModuleMarker(element.name); } @@ -45409,8 +45790,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var element = elements_3[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -45908,7 +46289,7 @@ var ts; || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer - ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node; } ts.updateParameter = updateParameter; @@ -46531,13 +46912,26 @@ var ts; return node; } ts.createArrowFunction = createArrowFunction; - function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { + function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody, bodyOrUndefined) { + var equalsGreaterThanToken; + var body; + if (bodyOrUndefined === undefined) { + equalsGreaterThanToken = node.equalsGreaterThanToken; + body = ts.cast(equalsGreaterThanTokenOrBody, ts.isConciseBody); + } + else { + equalsGreaterThanToken = ts.cast(equalsGreaterThanTokenOrBody, function (n) { + return n.kind === 36 /* EqualsGreaterThanToken */; + }); + body = bodyOrUndefined; + } return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type + || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } ts.updateArrowFunction = updateArrowFunction; @@ -46642,11 +47036,23 @@ var ts; return node; } ts.createConditional = createConditional; - function updateConditional(node, condition, whenTrue, whenFalse) { + function updateConditional(node, condition) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + if (args.length === 2) { + var whenTrue_1 = args[0], whenFalse_1 = args[1]; + return updateConditional(node, condition, node.questionToken, whenTrue_1, node.colonToken, whenFalse_1); + } + ts.Debug.assert(args.length === 4); + var questionToken = args[0], whenTrue = args[1], colonToken = args[2], whenFalse = args[3]; return node.condition !== condition + || node.questionToken !== questionToken || node.whenTrue !== whenTrue + || node.colonToken !== colonToken || node.whenFalse !== whenFalse - ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node) : node; } ts.updateConditional = updateConditional; @@ -46664,6 +47070,30 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; + function createTemplateHead(text) { + var node = createSynthesizedNode(14 /* TemplateHead */); + node.text = text; + return node; + } + ts.createTemplateHead = createTemplateHead; + function createTemplateMiddle(text) { + var node = createSynthesizedNode(15 /* TemplateMiddle */); + node.text = text; + return node; + } + ts.createTemplateMiddle = createTemplateMiddle; + function createTemplateTail(text) { + var node = createSynthesizedNode(16 /* TemplateTail */); + node.text = text; + return node; + } + ts.createTemplateTail = createTemplateTail; + function createNoSubstitutionTemplateLiteral(text) { + var node = createSynthesizedNode(13 /* NoSubstitutionTemplateLiteral */); + node.text = text; + return node; + } + ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { var node = createSynthesizedNode(197 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; @@ -47795,6 +48225,17 @@ var ts; /*argumentsArray*/ paramValue ? [paramValue] : []); } ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression; + function createImmediatelyInvokedArrowFunction(statements, param, paramValue) { + return createCall(createArrowFunction( + /*modifiers*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ param ? [param] : [], + /*type*/ undefined, + /*equalsGreaterThanToken*/ undefined, createBlock(statements, /*multiLine*/ true)), + /*typeArguments*/ undefined, + /*argumentsArray*/ paramValue ? [paramValue] : []); + } + ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { return createBinary(left, 26 /* CommaToken */, right); } @@ -48044,9 +48485,7 @@ var ts; var emitNode = getOrCreateEmitNode(node); for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { var helper = helpers_1[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } + emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper); } } return node; @@ -48088,9 +48527,7 @@ var ts; var helper = sourceEmitHelpers[i]; if (predicate(helper)) { helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } + targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper); } else if (helpersRemoved > 0) { sourceEmitHelpers[i - helpersRemoved] = helper; @@ -49055,11 +49492,9 @@ var ts; return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 178 /* ObjectLiteralExpression */ || leftmostExpressionKind === 186 /* FunctionExpression */) { - return ts.setTextRange(ts.createParen(expression), expression); - } + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 178 /* ObjectLiteralExpression */ || leftmostExpressionKind === 186 /* FunctionExpression */) { + return ts.setTextRange(ts.createParen(expression), expression); } return expression; } @@ -49195,9 +49630,31 @@ var ts; case 288 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } + /** + * Determines whether a node is a parenthesized expression that can be ignored when recreating outer expressions. + * + * A parenthesized expression can be ignored when all of the following are true: + * + * - It's `pos` and `end` are not -1 + * - It does not have a custom source map range + * - It does not have a custom comment range + * - It does not have synthetic leading or trailing comments + * + * If an outermost parenthesized expression is ignored, but the containing expression requires a parentheses around + * the expression to maintain precedence, a new parenthesized expression should be created automatically when + * the containing expression is created/updated. + */ + function isIgnorableParen(node) { + return node.kind === 185 /* ParenthesizedExpression */ + && ts.nodeIsSynthesized(node) + && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) + && ts.nodeIsSynthesized(ts.getCommentRange(node)) + && !ts.some(ts.getSyntheticLeadingComments(node)) + && !ts.some(ts.getSyntheticTrailingComments(node)); + } function recreateOuterExpressions(outerExpression, innerExpression, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } - if (outerExpression && isOuterExpression(outerExpression, kinds)) { + if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression)); } return innerExpression; @@ -49223,7 +49680,8 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var create = hasExportStarsToExportValues && moduleKind !== ts.ModuleKind.System - && moduleKind !== ts.ModuleKind.ES2015; + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { @@ -49793,7 +50251,7 @@ var ts; case 186 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 187 /* ArrowFunction */: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 188 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 189 /* TypeOfExpression */: @@ -49809,7 +50267,7 @@ var ts; case 194 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 195 /* ConditionalExpression */: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 196 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 197 /* YieldExpression */: @@ -50649,7 +51107,7 @@ var ts; else { // export class x { } var name = node.name; - if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { + if (name && !uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); uniqueExports.set(ts.unescapeLeadingUnderscores(name.escapedText), true); exportedNames = ts.append(exportedNames, name); @@ -51047,7 +51505,7 @@ var ts; */ function createDestructuringPropertyAccess(flattenContext, value, propertyName) { if (ts.isComputedPropertyName(propertyName)) { - var argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, /*reuseIdentifierExpressions*/ false, /*location*/ propertyName); + var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), /*reuseIdentifierExpressions*/ false, /*location*/ propertyName); return ts.createElementAccess(value, argumentExpression); } else if (ts.isStringOrNumericLiteral(propertyName)) { @@ -51316,6 +51774,23 @@ var ts; * @param node The node to visit. */ function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 238 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 243 /* ExportAssignment */: + case 244 /* ExportDeclaration */: + return visitEllidableStatement(node); + default: + return visitorWorker(node); + } + } + function visitEllidableStatement(node) { + var parsed = ts.getParseTreeNode(node); + if (parsed !== node) { + // If the node has been transformed by a `before` transformer, perform no ellision on it + // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes + return node; + } switch (node.kind) { case 238 /* ImportDeclaration */: return visitImportDeclaration(node); @@ -51326,7 +51801,7 @@ var ts; case 244 /* ExportDeclaration */: return visitExportDeclaration(node); default: - return visitorWorker(node); + ts.Debug.fail("Unhandled ellided statement"); } } /** @@ -51567,7 +52042,7 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && - !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } /** @@ -51667,10 +52142,12 @@ var ts; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); ts.addRange(statements, context.endLexicalEnvironment()); + var iife = ts.createImmediatelyInvokedArrowFunction(statements); + ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); var varStatement = ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), - /*type*/ undefined, ts.createImmediatelyInvokedFunctionExpression(statements)) + /*type*/ undefined, iife) ])); ts.setOriginalNode(varStatement, node); ts.setCommentRange(varStatement, node); @@ -52773,7 +53250,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = currentScope; + name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -53028,7 +53505,7 @@ var ts; function visitArrowFunction(node) { var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context)); + /*type*/ undefined, node.equalsGreaterThanToken, ts.visitFunctionBody(node.body, visitor, context)); return updated; } /** @@ -53278,6 +53755,7 @@ var ts; return isExportOfNamespace(node) || (isExternalModuleExport(node) && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System); } /** @@ -53983,8 +54461,6 @@ var ts; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - // These variables contain state that changes as we descend into the tree. - var currentSourceFile; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. * They are persisted between each SourceFile transformation and should not be reset. @@ -54006,10 +54482,8 @@ var ts; if (node.isDeclarationFile) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -54104,7 +54578,7 @@ var ts; function visitArrowFunction(node) { return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -54435,8 +54909,8 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { - var e = elements_4[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; if (e.kind === 263 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); @@ -54454,7 +54928,7 @@ var ts; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } else { - chunkObject.push(e); + chunkObject.push(ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } } } @@ -54693,7 +55167,7 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); var updated = ts.updateArrowFunction(node, node.modifiers, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node)); + /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; return updated; } @@ -55689,58 +56163,12 @@ var ts; && node.kind === 219 /* ReturnStatement */ && !node.expression; } - function isClassLikeVariableStatement(node) { - if (!ts.isVariableStatement(node)) - return false; - var variable = ts.singleOrUndefined(node.declarationList.declarations); - return variable - && variable.initializer - && ts.isIdentifier(variable.name) - && (ts.isClassLike(variable.initializer) - || (ts.isAssignmentExpression(variable.initializer) - && ts.isIdentifier(variable.initializer.left) - && ts.isClassLike(variable.initializer.right))); - } - function isTypeScriptClassWrapper(node) { - var call = ts.tryCast(node, ts.isCallExpression); - if (!call || ts.isParseTreeNode(call) || - ts.some(call.typeArguments) || - ts.some(call.arguments)) { - return false; - } - var func = ts.tryCast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression); - if (!func || ts.isParseTreeNode(func) || - ts.some(func.typeParameters) || - ts.some(func.parameters) || - func.type || - !func.body) { - return false; - } - var statements = func.body.statements; - if (statements.length < 2) { - return false; - } - var firstStatement = statements[0]; - if (ts.isParseTreeNode(firstStatement) || - !ts.isClassLike(firstStatement) && - !isClassLikeVariableStatement(firstStatement)) { - return false; - } - var lastStatement = ts.elementAt(statements, -1); - var returnStatement = ts.tryCast(ts.isVariableStatement(lastStatement) ? ts.elementAt(statements, -2) : lastStatement, ts.isReturnStatement); - if (!returnStatement || - !returnStatement.expression || - !ts.isIdentifier(ts.skipOuterExpressions(returnStatement.expression))) { - return false; - } - return true; - } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 207 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) - || isTypeScriptClassWrapper(node); + || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } function visitor(node) { if (shouldVisitNode(node)) { @@ -57875,7 +58303,7 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (isTypeScriptClassWrapper(node)) { + if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } if (node.transformFlags & 64 /* ES2015 */) { @@ -57917,7 +58345,7 @@ var ts; // }()) // We skip any outer expressions in a number of places to get to the innermost // expression, but we will restore them later to preserve comments and source maps. - var body = ts.cast(ts.skipOuterExpressions(node.expression), ts.isFunctionExpression).body; + var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); // The class statements are the statements generated by visiting the first statement of the // body (1), while all other statements are added to remainingStatements (2) var classStatements = ts.visitNodes(body.statements, visitor, ts.isStatement, 0, 1); @@ -58820,7 +59248,6 @@ var ts; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - var currentSourceFile; var renamedCatchVariables; var renamedCatchVariableDeclarations; var inGeneratorFunctionBody; @@ -58867,10 +59294,8 @@ var ts; if (node.isDeclarationFile || (node.transformFlags & 512 /* ContainsGenerator */) === 0) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } /** @@ -61437,6 +61862,7 @@ var ts; */ function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var umdHeader = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -61456,13 +61882,13 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") - ])) + ]))) ]))) ], /*multiLine*/ true), @@ -61588,17 +62014,20 @@ var ts; */ function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); - statements.push(statement); + var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, importCallExpressionVisitor); + if (expressionResult) { + if (emitAsReturn) { + var statement = ts.createReturn(expressionResult); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536 /* NoComments */); + statements.push(statement); + } } } } @@ -62143,7 +62572,7 @@ var ts; return statements; } if (ts.hasModifier(decl, 1 /* Export */)) { - var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : ts.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -63352,7 +63781,8 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; - return ts.createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + return ts.setCommentRange(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // // Top-Level or Nested Source Element Visitors @@ -67105,8 +67535,15 @@ var ts; comments.reset(); setWriter(/*output*/ undefined); } + // TODO: Should this just be `emit`? + // See https://github.com/Microsoft/TypeScript/pull/18284#discussion_r137611034 + function emitIfPresent(node) { + if (node) { + emit(node); + } + } function emit(node) { - pipelineEmitWithNotification(3 /* Unspecified */, node); + pipelineEmitWithNotification(4 /* Unspecified */, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2 /* IdentifierName */, node); @@ -67144,7 +67581,8 @@ var ts; case 0 /* SourceFile */: return pipelineEmitSourceFile(node); case 2 /* IdentifierName */: return pipelineEmitIdentifierName(node); case 1 /* Expression */: return pipelineEmitExpression(node); - case 3 /* Unspecified */: return pipelineEmitUnspecified(node); + case 3 /* MappedTypeParameter */: return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + case 4 /* Unspecified */: return pipelineEmitUnspecified(node); } } function pipelineEmitSourceFile(node) { @@ -67155,6 +67593,11 @@ var ts; ts.Debug.assertNode(node, ts.isIdentifier); emitIdentifier(node); } + function emitMappedTypeParameter(node) { + emit(node.name); + write(" in "); + emit(node.constraint); + } function pipelineEmitUnspecified(node) { var kind = node.kind; // Reserved words @@ -67544,9 +67987,9 @@ var ts; function emitParameter(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } @@ -67561,7 +68004,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); write(";"); } @@ -67569,7 +68012,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); write(";"); @@ -67578,7 +68021,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); @@ -67587,9 +68030,9 @@ var ts; function emitMethodDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.asteriskToken, "*"); + emitIfPresent(node.asteriskToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } function emitConstructor(node) { @@ -67662,10 +68105,8 @@ var ts; } function emitTypeLiteral(node) { write("{"); - // If the literal is empty, do not add spaces between braces. - if (node.members.length > 0) { - emitList(node, node.members, ts.getEmitFlags(node) & 1 /* SingleLine */ ? 448 /* SingleLineTypeLiteralMembers */ : 65 /* MultiLineTypeLiteralMembers */); - } + var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 448 /* SingleLineTypeLiteralMembers */ : 65 /* MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 262144 /* NoSpaceIfEmpty */); write("}"); } function emitArrayType(node) { @@ -67712,13 +68153,14 @@ var ts; writeLine(); increaseIndent(); } - writeIfPresent(node.readonlyToken, "readonly "); + if (node.readonlyToken) { + emit(node.readonlyToken); + write(" "); + } write("["); - emit(node.typeParameter.name); - write(" in "); - emit(node.typeParameter.constraint); + pipelineEmitWithNotification(3 /* MappedTypeParameter */, node.typeParameter); write("]"); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); write(": "); emit(node.type); write(";"); @@ -67761,7 +68203,7 @@ var ts; } function emitBindingElement(node) { emitWithSuffix(node.propertyName, ": "); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); } @@ -67770,30 +68212,19 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else { - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); - } + var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; + emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); } function emitObjectLiteralExpression(node) { - var properties = node.properties; - if (properties.length === 0) { - write("{}"); + var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + if (indentedFlag) { + increaseIndent(); } - else { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; - if (indentedFlag) { - increaseIndent(); - } - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, properties, 978 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); - if (indentedFlag) { - decreaseIndent(); - } + var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; + emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + if (indentedFlag) { + decreaseIndent(); } } function emitPropertyAccessExpression(node) { @@ -67880,7 +68311,8 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParametersForArrow(node, node.parameters); emitWithPrefix(": ", node.type); - write(" =>"); + write(" "); + emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { write("delete "); @@ -67947,12 +68379,12 @@ var ts; var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); increaseIndentIf(indentBeforeQuestion, " "); - write("?"); + emit(node.questionToken); increaseIndentIf(indentAfterQuestion, " "); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); increaseIndentIf(indentBeforeColon, " "); - write(":"); + emit(node.colonToken); increaseIndentIf(indentAfterColon, " "); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); @@ -67962,7 +68394,8 @@ var ts; emitList(node, node.templateSpans, 131072 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - write(node.asteriskToken ? "yield*" : "yield"); + write("yield"); + emit(node.asteriskToken); emitExpressionWithPrefix(" ", node.expression); } function emitSpreadExpression(node) { @@ -68003,28 +68436,17 @@ var ts; // Statements // function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); - write(" "); - writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); - } - else { - writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); - emitBlockStatements(node); - // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted - increaseIndent(); - emitLeadingCommentsOfPosition(node.statements.end); - decreaseIndent(); - writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); - } + writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); + writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } - function emitBlockStatements(node) { - if (ts.getEmitFlags(node) & 1 /* SingleLine */) { - emitList(node, node.statements, 384 /* SingleLineBlockStatements */); - } - else { - emitList(node, node.statements, 65 /* MultiLineBlockStatements */); - } + function emitBlockStatements(node, forceSingleLine) { + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineBlockStatements */ : 65 /* MultiLineBlockStatements */; + emitList(node, node.statements, format); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -68205,7 +68627,9 @@ var ts; function emitFunctionDeclarationOrExpression(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.asteriskToken ? "function* " : "function "); + write("function"); + emitIfPresent(node.asteriskToken); + write(" "); emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -68223,7 +68647,7 @@ var ts; if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3 /* Unspecified */, body, emitBlockCallback); + onEmitNode(4 /* Unspecified */, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -68233,7 +68657,7 @@ var ts; pushNameGenerationScope(); emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3 /* Unspecified */, body, emitBlockCallback); + onEmitNode(4 /* Unspecified */, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -68378,7 +68802,9 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); + if (~node.flags & 512 /* GlobalAugmentation */) { + write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); + } emit(node.name); var body = node.body; while (body.kind === 233 /* ModuleDeclaration */) { @@ -68390,16 +68816,11 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isEmptyBlock(node)) { - write("{ }"); - } - else { - pushNameGenerationScope(); - write("{"); - emitBlockStatements(node); - write("}"); - popNameGenerationScope(); - } + pushNameGenerationScope(); + write("{"); + emitBlockStatements(node, /*forceSingleLine*/ isEmptyBlock(node)); + write("}"); + popNameGenerationScope(); } function emitCaseBlock(node) { writeToken(17 /* OpenBraceToken */, node.pos); @@ -68550,9 +68971,7 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); - if (node.dotDotDotToken) { - write("..."); - } + emitIfPresent(node.dotDotDotToken); emitExpression(node.expression); write("}"); } @@ -68600,13 +69019,12 @@ var ts; // Note: we can't use parentNode.end as such position includes statements. emitTrailingCommentsOfPosition(statements.pos); } + var format = 81985 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { write(" "); - emit(statements[0]); - } - else { - emitList(parentNode, statements, 81985 /* CaseOrDefaultClauseStatements */); + format &= ~(1 /* MultiLine */ | 64 /* Indented */); } + emitList(parentNode, statements, format); } function emitHeritageClause(node) { write(" "); @@ -68827,7 +69245,7 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emit(parameters[0]); + emitList(parentNode, parameters, 1360 /* Parameters */ & ~1024 /* Parenthesis */); } else { emitParameters(parentNode, parameters); @@ -68849,8 +69267,14 @@ var ts; if (isUndefined && format & 8192 /* OptionalIfUndefined */) { return; } - var isEmpty = isUndefined || children.length === 0 || start >= children.length || count === 0; + var isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & 16384 /* OptionalIfEmpty */) { + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } return; } if (format & 7680 /* BracketsMask */) { @@ -68864,7 +69288,7 @@ var ts; if (format & 1 /* MultiLine */) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 128 /* SpaceBetweenBraces */ && !(format & 262144 /* NoSpaceIfEmpty */)) { write(" "); } } @@ -68944,7 +69368,7 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + if (previousSibling && delimiter && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { emitLeadingCommentsOfPosition(previousSibling.end); } // Decrease the indent, if requested. @@ -68983,11 +69407,6 @@ var ts; write(text); } } - function writeIfPresent(node, text) { - if (node) { - write(text); - } - } function writeToken(token, pos, contextNode) { return onEmitSourceMapOfToken ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) @@ -68997,7 +69416,7 @@ var ts; if (onBeforeEmitToken) { onBeforeEmitToken(node); } - writeTokenText(node.kind); + write(ts.tokenToString(node.kind)); if (onAfterEmitToken) { onAfterEmitToken(node); } @@ -69151,10 +69570,6 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); - } function isEmptyBlock(block) { return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); @@ -69463,6 +69878,8 @@ var ts; ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; // Precomputed Formats ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; @@ -69473,7 +69890,7 @@ var ts; ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; @@ -69680,7 +70097,7 @@ var ts; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -69704,7 +70121,7 @@ var ts; var redForegroundEscapeSequence = "\u001b[91m"; var yellowForegroundEscapeSequence = "\u001b[93m"; var blueForegroundEscapeSequence = "\u001b[93m"; - var gutterStyleSequence = "\u001b[100;30m"; + var gutterStyleSequence = "\u001b[30;47m"; var gutterSeparator = " "; var resetEscapeSequence = "\u001b[0m"; var ellipsis = "..."; @@ -69729,9 +70146,9 @@ var ts; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; if (diagnostic.file) { - var start = diagnostic.start, length_6 = diagnostic.length, file = diagnostic.file; + var start = diagnostic.start, length_5 = diagnostic.length, file = diagnostic.file; var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; - var _b = ts.getLineAndCharacterOfPosition(file, start + length_6), lastLine = _b.line, lastLineChar = _b.character; + var _b = ts.getLineAndCharacterOfPosition(file, start + length_5), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; @@ -69739,12 +70156,12 @@ var ts; if (hasMoreThanFiveLines) { gutterWidth = Math.max(ellipsis.length, gutterWidth); } - output += ts.sys.newLine; + output += host.getNewLine(); for (var i = firstLine; i <= lastLine; i++) { // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); @@ -69754,7 +70171,7 @@ var ts; lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + ts.sys.newLine; + output += lineContent + host.getNewLine(); // Output the gutter and the error span for the line using tildes. output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; output += redForegroundEscapeSequence; @@ -69773,15 +70190,15 @@ var ts; output += lineContent.replace(/./g, "~"); } output += resetEscapeSequence; - output += ts.sys.newLine; + output += host.getNewLine(); } - output += ts.sys.newLine; + output += host.getNewLine(); output += relativeFileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } var categoryColor = getCategoryFormat(diagnostic.category); var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine); - output += ts.sys.newLine; + output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); + output += host.getNewLine(); } return output; } @@ -69870,6 +70287,8 @@ var ts; ts.performance.mark("beforeProgram"); host = host || createCompilerHost(options); var skipDefaultLib = options.noLib; + var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); + var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName()); var programDiagnostics = ts.createDiagnosticCollection(); var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); @@ -69936,12 +70355,11 @@ var ts; // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file if (!options.lib) { - processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib*/ true); + processRootFile(getDefaultLibraryFileName(), /*isDefaultLib*/ true); } else { - var libDirectory_1 = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(host.getDefaultLibFileName(options)); ts.forEach(options.lib, function (libFileName) { - processRootFile(ts.combinePaths(libDirectory_1, libFileName), /*isDefaultLib*/ true); + processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true); }); } } @@ -69976,6 +70394,7 @@ var ts; getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + isSourceFileDefaultLibrary: isSourceFileDefaultLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, sourceFileToPackageName: sourceFileToPackageName, @@ -70267,7 +70686,7 @@ var ts; var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var moduleNames = getModuleNames(newSourceFile); var oldProgramState = { program: oldProgram, file: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); // ensure that module resolution results are still correct @@ -70344,6 +70763,15 @@ var ts; function isSourceFileFromExternalLibrary(file) { return sourceFilesFoundSearchingNodeModules.get(file.path); } + function isSourceFileDefaultLibrary(file) { + if (file.hasNoDefaultLib) { + return true; + } + if (defaultLibraryPath && defaultLibraryPath.length !== 0) { + return ts.containsPath(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ !host.useCaseSensitiveFileNames()); + } + return ts.compareStrings(file.fileName, getDefaultLibraryFileName(), /*ignoreCase*/ !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } @@ -70485,9 +70913,7 @@ var ts; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - return ts.isSourceFileJavaScript(sourceFile) - ? ts.filter(diagnostics, shouldReportDiagnostic) - : diagnostics; + return ts.filter(diagnostics, shouldReportDiagnostic); }); } /** @@ -70724,16 +71150,15 @@ var ts; return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); + processSourceFile(ts.normalizePath(fileName), isDefaultLib, /*packageId*/ undefined); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function getTextOfLiteral(literal) { - return literal.text; + return a.kind === 9 /* StringLiteral */ + ? b.kind === 9 /* StringLiteral */ && a.text === b.text + : b.kind === 71 /* Identifier */ && a.escapedText === b.escapedText; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -70789,7 +71214,7 @@ var ts; break; case 233 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { - var moduleName = node.name; // TODO: GH#17347 + var moduleName = node.name; var nameText = ts.getTextOfIdentifierOrLiteral(moduleName); // Ambient module declarations can be interpreted as augmentations for some existing external modules. // This will happen in two cases: @@ -70869,8 +71294,8 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, /*packageId*/ undefined); }, function (diagnostic) { + function processSourceFile(fileName, isDefaultLib, packageId, refFile, refPos, refEnd) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -70942,7 +71367,7 @@ var ts; } }); if (packageId) { - var packageIdKey = packageId.name + "@" + packageId.version; + var packageIdKey = packageId.name + "/" + packageId.subModuleName + "@" + packageId.version; var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. @@ -70994,7 +71419,7 @@ var ts; function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, /*packageId*/ undefined, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -71020,7 +71445,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -71038,7 +71463,7 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } } @@ -71068,8 +71493,7 @@ var ts; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. - var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9 /* StringLiteral */; }); - var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var moduleNames = getModuleNames(file); var oldProgramState = { program: oldProgram, file: file, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState); ts.Debug.assert(resolutions.length === moduleNames.length); @@ -71080,7 +71504,8 @@ var ts; continue; } var isFromNodeModulesSearch = resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var isJsFile = !ts.extensionIsTypeScript(resolution.extension); + var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; var resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { currentNodeModulesDepth++; @@ -71093,7 +71518,12 @@ var ts; var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. - var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; + var shouldAddFile = resolvedFileName + && !getResolutionDiagnostic(options, resolution) + && !options.noResolve + && i < file.imports.length + && !elideImport + && !(isJsFile && !options.allowJs); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -71429,7 +71859,7 @@ var ts; return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + return options.allowJs || !options.noImplicitAny ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } } ts.getResolutionDiagnostic = getResolutionDiagnostic; @@ -71437,6 +71867,18 @@ var ts; ts.Debug.assert(names.every(function (name) { return name !== undefined; }), "A name is undefined.", function () { return JSON.stringify(names); }); return names; } + function getModuleNames(_a) { + var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations; + var res = imports.map(function (i) { return i.text; }); + for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { + var aug = moduleAugmentations_1[_i]; + if (aug.kind === 9 /* StringLiteral */) { + res.push(aug.text); + } + // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. + } + return res; + } })(ts || (ts = {})); /// /// @@ -72431,7 +72873,7 @@ var ts; errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } var value = convertPropertyValueToJson(element.initializer, option); - if (typeof keyText !== "undefined" && typeof value !== "undefined") { + if (typeof keyText !== "undefined") { result[keyText] = value; // Notify key value set, if user asked for it if (jsonConversionNotifier && @@ -72471,7 +72913,7 @@ var ts; reportInvalidOptionValue(option && option.type !== "boolean"); return false; case 95 /* NullKeyword */: - reportInvalidOptionValue(!!option); + reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword case 9 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { @@ -72536,6 +72978,8 @@ var ts; } function isCompilerOptionsValue(option, value) { if (option) { + if (isNullOrUndefined(value)) + return true; // All options are undefinable/nullable if (option.type === "list") { return ts.isArray(value); } @@ -72720,6 +73164,15 @@ var ts; } } ts.setConfigFileInOptions = setConfigFileInOptions; + function isNullOrUndefined(x) { + // tslint:disable-next-line:no-null-keyword + return x === undefined || x === null; + } + function directoryOfCombinedPath(fileName, basePath) { + // Use the `identity` function to avoid canonicalizing the path, as it must remain noncanonical + // until consistient casing errors are reported + return ts.getDirectoryPath(ts.toPath(fileName, basePath, ts.identity)); + } /** * Parse the contents of a config file from json or json source file (tsconfig.json). * @param json The contents of the config file to parse @@ -72752,7 +73205,7 @@ var ts; }; function getFileNames() { var fileNames; - if (ts.hasProperty(raw, "files")) { + if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw["files"])) { if (ts.isArray(raw["files"])) { fileNames = raw["files"]; if (fileNames.length === 0) { @@ -72764,7 +73217,7 @@ var ts; } } var includeSpecs; - if (ts.hasProperty(raw, "include")) { + if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw["include"])) { if (ts.isArray(raw["include"])) { includeSpecs = raw["include"]; } @@ -72773,7 +73226,7 @@ var ts; } } var excludeSpecs; - if (ts.hasProperty(raw, "exclude")) { + if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw["exclude"])) { if (ts.isArray(raw["exclude"])) { excludeSpecs = raw["exclude"]; } @@ -72790,7 +73243,7 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !ts.hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); } @@ -72860,7 +73313,8 @@ var ts; errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, ts.createCompilerDiagnostic); + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, ts.createCompilerDiagnostic); } } return { raw: json, options: options, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath }; @@ -72882,7 +73336,8 @@ var ts; onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) { switch (key) { case "extends": - extendedConfigPath = getExtendsConfigPath(value, host, basePath, getCanonicalFileName, errors, function (message, arg0) { + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(value, host, newBase, getCanonicalFileName, errors, function (message, arg0) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0); }); return; @@ -73038,6 +73493,8 @@ var ts; } } function normalizeOptionValue(option, basePath, value) { + if (isNullOrUndefined(value)) + return undefined; if (option.type === "list") { var listOption_1 = option; if (listOption_1.element.isFilePath || typeof listOption_1.element.type !== "string") { @@ -73060,6 +73517,8 @@ var ts; return value; } function convertJsonOptionOfCustomType(opt, value, errors) { + if (isNullOrUndefined(value)) + return undefined; var key = value.toLowerCase(); var val = opt.type.get(key); if (val !== undefined) { @@ -73186,7 +73645,7 @@ var ts; if (fileNames) { for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); + var file = ts.getNormalizedAbsolutePath(fileName, basePath); literalFileMap.set(keyMapper(file), file); } } @@ -73871,25 +74330,24 @@ var ts; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { - switch (node.parent.kind) { - case 149 /* PropertyDeclaration */: - case 148 /* PropertySignature */: - case 261 /* PropertyAssignment */: - case 264 /* EnumMember */: - case 151 /* MethodDeclaration */: - case 150 /* MethodSignature */: - case 153 /* GetAccessor */: - case 154 /* SetAccessor */: - case 233 /* ModuleDeclaration */: - return ts.getNameOfDeclaration(node.parent) === node; - case 180 /* ElementAccessExpression */: - return node.parent.argumentExpression === node; - case 144 /* ComputedPropertyName */: - return true; - } + switch (node.parent.kind) { + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 261 /* PropertyAssignment */: + case 264 /* EnumMember */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 233 /* ModuleDeclaration */: + return ts.getNameOfDeclaration(node.parent) === node; + case 180 /* ElementAccessExpression */: + return node.parent.argumentExpression === node; + case 144 /* ComputedPropertyName */: + return true; + case 173 /* LiteralType */: + return node.parent.parent.kind === 171 /* IndexedAccessType */; } - return false; } ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; function isExpressionOfExternalModuleImportEqualsDeclaration(node) { @@ -73969,6 +74427,28 @@ var ts; return "alias" /* alias */; case 283 /* JSDocTypedefTag */: return "type" /* typeElement */; + case 194 /* BinaryExpression */: + var kind = ts.getSpecialPropertyAssignmentKind(node); + var right = node.right; + switch (kind) { + case 0 /* None */: + return "" /* unknown */; + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + var rightKind = getNodeKind(right); + return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; + case 3 /* PrototypeProperty */: + return "method" /* memberFunctionElement */; // instance method + case 4 /* ThisProperty */: + return "property" /* memberVariableElement */; // property + case 5 /* Property */: + // static method / property + return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + default: { + ts.assertTypeIsNever(kind); + return "" /* unknown */; + } + } default: return "" /* unknown */; } @@ -74172,7 +74652,7 @@ var ts; return undefined; } var children = list.getChildren(); - var listItemIndex = ts.indexOf(children, node); + var listItemIndex = ts.indexOfNode(children, node); return { listItemIndex: listItemIndex, list: list @@ -74954,7 +75434,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_7 = dense[i + 1]; + var length_6 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -74963,8 +75443,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_7, classification: convertClassification(type) }); - lastEnd = start + length_7; + entries.push({ length: length_6, classification: convertClassification(type) }); + lastEnd = start + length_6; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -75517,6 +75997,7 @@ var ts; // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) { + // TODO: This should be predicated on `token["kind"]` being compatible with `HasJSDoc["kind"]` docCommentAndDiagnostics.jsDoc.parent = token; classifyJSDocComment(docCommentAndDiagnostics.jsDoc); return; @@ -75968,8 +76449,8 @@ var ts; continue; } var start = completePrefix.length; - var length_8 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_8))); + var length_7 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_7))); } return result; } @@ -76263,7 +76744,7 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, request = completionData.request, keywordFilters = completionData.keywordFilters; + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, allowStringLiteral = completionData.allowStringLiteral, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, request = completionData.request, keywordFilters = completionData.keywordFilters; if (sourceFile.languageVariant === 1 /* JSX */ && location && location.parent && location.parent.kind === 252 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, @@ -76289,14 +76770,14 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log, allowStringLiteral); getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); } else { if ((!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { return undefined; } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log, allowStringLiteral); } // TODO add filter for keyword based on type/value/namespace and also location // Add all keywords if @@ -76319,7 +76800,7 @@ var ts; return; } uniqueNames.set(realName, true); - var displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true); + var displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true, /*allowStringLiteral*/ false); if (displayName) { entries.push({ name: displayName, @@ -76330,11 +76811,11 @@ var ts; } }); } - function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral) { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral); if (!displayName) { return undefined; } @@ -76352,13 +76833,13 @@ var ts; sortText: "0", }; } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log, allowStringLiteral) { var start = ts.timestamp(); var uniqueNames = ts.createMap(); if (symbols) { for (var _i = 0, symbols_5 = symbols; _i < symbols_5.length; _i++) { var symbol = symbols_5[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral); if (entry) { var id = entry.name; if (!uniqueNames.has(id)) { @@ -76438,7 +76919,7 @@ var ts; var type = typeChecker.getContextualType(element.parent); var entries = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log, /*allowStringLiteral*/ true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } @@ -76462,7 +76943,7 @@ var ts; var type = typeChecker.getTypeAtLocation(node.expression); var entries = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log, /*allowStringLiteral*/ true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } @@ -76493,7 +76974,7 @@ var ts; addStringLiteralCompletionsFromType(t, result, typeChecker, uniques); } } - else if (type.flags & 32 /* StringLiteral */) { + else if (type.flags & 32 /* StringLiteral */ && !(type.flags & 256 /* EnumLiteral */)) { var name = type.value; if (!uniques.has(name)) { uniques.set(name, true); @@ -76510,12 +76991,12 @@ var ts; // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location = completionData.location; + var symbols = completionData.symbols, location = completionData.location, allowStringLiteral_1 = completionData.allowStringLiteral; // Find the symbol with the matching entry name. // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral_1) === entryName ? s : undefined; }); if (symbol) { var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { @@ -76546,11 +77027,15 @@ var ts; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, allowStringLiteral = completionData.allowStringLiteral; // Find the symbol with the matching entry name. // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return completionData && ts.forEach(completionData.symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false) === entryName ? s : undefined; }); + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral) === entryName ? s : undefined; }); } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; function getCompletionData(typeChecker, log, sourceFile, position) { @@ -76618,7 +77103,7 @@ var ts; } } if (request) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request: request, keywordFilters: 0 /* None */ }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, allowStringLiteral: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request: request, keywordFilters: 0 /* None */ }; } if (!insideJsDocTagTypeExpression) { // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal @@ -76705,6 +77190,7 @@ var ts; var semanticStart = ts.timestamp(); var isGlobalCompletion = false; var isMemberCompletion; + var allowStringLiteral = false; var isNewIdentifierLocation; var keywordFilters = 0 /* None */; var symbols = []; @@ -76740,7 +77226,7 @@ var ts; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request: request, keywordFilters: keywordFilters }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, allowStringLiteral: allowStringLiteral, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request: request, keywordFilters: keywordFilters }; function isTagWithTypeExpression(tag) { switch (tag.kind) { case 277 /* JSDocAugmentsTag */: @@ -77073,6 +77559,7 @@ var ts; function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { // We're looking up possible property names from contextual/inferred/declared type. isMemberCompletion = true; + allowStringLiteral = true; var typeMembers; var existingMembers; if (objectLikeContainer.kind === 178 /* ObjectLiteralExpression */) { @@ -77082,7 +77569,7 @@ var ts; var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return false; - typeMembers = typeChecker.getAllPossiblePropertiesOfType(typeForObject); + typeMembers = getPropertiesForCompletion(typeForObject, typeChecker); existingMembers = objectLikeContainer.properties; } else { @@ -77641,7 +78128,7 @@ var ts; * * @return undefined if the name is of external module */ - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral) { var name = symbol.name; if (!name) return undefined; @@ -77654,19 +78141,20 @@ var ts; return undefined; } } - return getCompletionEntryDisplayName(name, target, performCharacterChecks); + return getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral); } /** * Get a displayName from a given for completion list, performing any necessary quotes stripping * and checking whether the name is valid identifier name. */ - function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + function getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral) { // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. if (performCharacterChecks && !ts.isIdentifierText(name, target)) { - return undefined; + // TODO: GH#18169 + return allowStringLiteral ? JSON.stringify(name) : undefined; } return name; } @@ -77773,6 +78261,20 @@ var ts; return node.parent; } } + /** + * Gets all properties on a type, but if that type is a union of several types, + * tries to only include those types which declare properties, not methods. + * This ensures that we don't try providing completions for all the methods on e.g. Array. + */ + function getPropertiesForCompletion(type, checker) { + if (!(type.flags & 65536 /* Union */)) { + return checker.getPropertiesOfType(type); + } + var types = type.types; + var filteredTypes = types.filter(function (memberType) { return !(memberType.flags & 8190 /* Primitive */ || checker.isArrayLikeType(memberType)); }); + // If there are no property-only types, just provide completions for every type as usual. + return checker.getAllPossiblePropertiesOfTypes(filteredTypes); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -78365,12 +78867,11 @@ var ts; var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); var entry = bucket.get(path); if (!entry) { - ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind); entry = { sourceFile: sourceFile, - languageServiceRefCount: 0, + languageServiceRefCount: 1, owners: [] }; bucket.set(path, entry); @@ -78382,14 +78883,14 @@ var ts; if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); } - } - // If we're acquiring, then this is the first time this LS is asking for this document. - // Increase our ref count so we know there's another LS using the document. If we're - // not acquiring, then that means the LS is 'updating' the file instead, and that means - // it has already acquired the document previously. As such, we do not need to increase - // the ref count. - if (acquiring) { - entry.languageServiceRefCount++; + // If we're acquiring, then this is the first time this LS is asking for this document. + // Increase our ref count so we know there's another LS using the document. If we're + // not acquiring, then that means the LS is 'updating' the file instead, and that means + // it has already acquired the document previously. As such, we do not need to increase + // the ref count. + if (acquiring) { + entry.languageServiceRefCount++; + } } return entry.sourceFile; } @@ -78571,7 +79072,6 @@ var ts; * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. */ function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, checker, isForRename) { - var exportName = exportSymbol.escapedName; var importSearches = []; var singleReferences = []; function addSearch(location, symbol) { @@ -78603,10 +79103,10 @@ var ts; searchForNamedImport(decl.exportClause); return; } - if (!decl.importClause) { + var importClause = decl.importClause; + if (!importClause) { return; } - var importClause = decl.importClause; var namedBindings = importClause.namedBindings; if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { handleNamespaceImportLike(namedBindings.name); @@ -78626,7 +79126,6 @@ var ts; } // 'default' might be accessed as a named import `{ default as foo }`. if (!isForRename && exportKind === 1 /* Default */) { - ts.Debug.assert(exportName === "default"); searchForNamedImport(namedBindings); } } @@ -78638,35 +79137,40 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || importName.escapedText === exportName)) { + if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } function searchForNamedImport(namedBindings) { - if (namedBindings) { - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name = element.name, propertyName = element.propertyName; - if ((propertyName || name).escapedText !== exportName) { - continue; - } - if (propertyName) { - // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. - singleReferences.push(propertyName); - if (!isForRename) { - // Search locally for `bar`. - addSearch(name, checker.getSymbolAtLocation(name)); - } - } - else { - var localSymbol = element.kind === 246 /* ExportSpecifier */ && element.propertyName - ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. - : checker.getSymbolAtLocation(name); - addSearch(name, localSymbol); + if (!namedBindings) { + return; + } + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name = element.name, propertyName = element.propertyName; + if (!isNameMatch((propertyName || name).escapedText)) { + continue; + } + if (propertyName) { + // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. + singleReferences.push(propertyName); + if (!isForRename) { + // Search locally for `bar`. + addSearch(name, checker.getSymbolAtLocation(name)); } } + else { + var localSymbol = element.kind === 246 /* ExportSpecifier */ && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } } } + function isNameMatch(name) { + // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports + return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default"; + } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ function findNamespaceReExports(sourceFileLike, name, checker) { @@ -78842,7 +79346,8 @@ var ts; // Get the symbol for the `export =` node; its parent is the module it's the export of. var exportingModuleSymbol = ex.symbol.parent; ts.Debug.assert(!!exportingModuleSymbol); - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: 2 /* ExportEquals */ } }; + var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -78874,7 +79379,11 @@ var ts; if (importedSymbol.escapedName === "export=") { importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker); } - if (symbolName(importedSymbol) === symbol.escapedName) { + // If the import has a different name than the export, do not continue searching. + // If `importedName` is undefined, do continue searching as the export is anonymous. + // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) + var importedName = symbolName(importedSymbol); + if (importedName === undefined || importedName === "default" || importedName === symbol.escapedName) { return __assign({ kind: 0 /* Import */, symbol: importedSymbol }, isImport); } } @@ -79066,8 +79575,8 @@ var ts; case "symbol": { var symbol = def.symbol, node_2 = def.node; var _a = getDefinitionKindAndDisplayParts(symbol, node_2, checker), displayParts_1 = _a.displayParts, kind_1 = _a.kind; - var name_3 = displayParts_1.map(function (p) { return p.text; }).join(""); - return { node: node_2, name: name_3, kind: kind_1, displayParts: displayParts_1 }; + var name_4 = displayParts_1.map(function (p) { return p.text; }).join(""); + return { node: node_2, name: name_4, kind: kind_1, displayParts: displayParts_1 }; } case "label": { var node_3 = def.node; @@ -79075,8 +79584,8 @@ var ts; } case "keyword": { var node_4 = def.node; - var name_4 = ts.tokenToString(node_4.kind); - return { node: node_4, name: name_4, kind: "keyword" /* keyword */, displayParts: [{ text: name_4, kind: "keyword" /* keyword */ }] }; + var name_5 = ts.tokenToString(node_4.kind); + return { node: node_4, name: name_5, kind: "keyword" /* keyword */, displayParts: [{ text: name_5, kind: "keyword" /* keyword */ }] }; } case "this": { var node_5 = def.node; @@ -79117,8 +79626,10 @@ var ts; return { fileName: node.getSourceFile().fileName, textSpan: getTextSpan(node), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isAnyDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node), + isWriteAccess: isWriteAccessForReference(node), + isDefinition: node.kind === 79 /* DefaultKeyword */ + || ts.isAnyDeclarationName(node) + || ts.isLiteralComputedPropertyDeclarationName(node), isInString: isInString }; } @@ -79160,7 +79671,7 @@ var ts; } var node = entry.node, isInString = entry.isInString; var fileName = entry.node.getSourceFile().fileName; - var writeAccess = isWriteAccess(node); + var writeAccess = isWriteAccessForReference(node); var span = { textSpan: getTextSpan(node), kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, @@ -79179,20 +79690,8 @@ var ts; return ts.createTextSpanFromBounds(start, end); } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ - function isWriteAccess(node) { - if (ts.isAnyDeclarationName(node)) { - return true; - } - var parent = node.parent; - switch (parent && parent.kind) { - case 193 /* PostfixUnaryExpression */: - case 192 /* PrefixUnaryExpression */: - return true; - case 194 /* BinaryExpression */: - return parent.left === node && ts.isAssignmentOperator(parent.operatorToken.kind); - default: - return false; - } + function isWriteAccessForReference(node) { + return node.kind === 79 /* DefaultKeyword */ || ts.isAnyDeclarationName(node) || ts.isWriteAccess(node); } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -79617,7 +80116,7 @@ var ts; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node && node.kind) { + switch (node.kind) { case 71 /* Identifier */: return node.text.length === searchSymbolName.length; case 9 /* StringLiteral */: @@ -79625,6 +80124,8 @@ var ts; node.text.length === searchSymbolName.length; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; + case 79 /* DefaultKeyword */: + return "default".length === searchSymbolName.length; default: return false; } @@ -80237,20 +80738,24 @@ var ts; var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); if (bindingElementPropertySymbol) { result.push(bindingElementPropertySymbol); + addRootSymbols(bindingElementPropertySymbol); } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - for (var _i = 0, _a = checker.getRootSymbols(symbol); _i < _a.length; _i++) { - var rootSymbol = _a[_i]; - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ ts.createSymbolTable(), checker); - } - } + addRootSymbols(symbol); return result; + function addRootSymbols(sym) { + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + for (var _i = 0, _a = checker.getRootSymbols(sym); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== sym) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ ts.createSymbolTable(), checker); + } + } + } } /** * Find symbol of the given property-name and add the symbol to the given result array @@ -80333,30 +80838,35 @@ var ts; // then include the binding element in the related symbols // let { a } : { a }; var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); - if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; + if (bindingElementPropertySymbol) { + var fromBindingElement = findRootSymbol(bindingElementPropertySymbol); + if (fromBindingElement) + return fromBindingElement; } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return ts.forEach(state.checker.getRootSymbols(referenceSymbol), function (rootSymbol) { - // if it is in the list, then we are done - if (search.includes(rootSymbol)) { - return rootSymbol; - } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - // Parents will only be defined if implementations is true - if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { - return undefined; + return findRootSymbol(referenceSymbol); + function findRootSymbol(sym) { + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return ts.forEach(state.checker.getRootSymbols(sym), function (rootSymbol) { + // if it is in the list, then we are done + if (search.includes(rootSymbol)) { + return rootSymbol; } - var result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ ts.createSymbolTable(), state.checker); - return ts.find(result, search.includes); - } - return undefined; - }); + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + // Parents will only be defined if implementations is true + if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { + return undefined; + } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ ts.createSymbolTable(), state.checker); + return ts.find(result, search.includes); + } + return undefined; + }); + } } function getNameFromObjectLiteralElement(node) { if (node.name.kind === 144 /* ComputedPropertyName */) { @@ -80979,52 +81489,32 @@ var ts; if (!tokenAtPos || tokenStart < position) { return undefined; } - // TODO: add support for: - // - enums/enum members - // - interfaces - // - property declarations - // - potentially property assignments - var commentOwner; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case 228 /* FunctionDeclaration */: - case 151 /* MethodDeclaration */: - case 152 /* Constructor */: - case 229 /* ClassDeclaration */: - case 208 /* VariableStatement */: - break findOwner; - case 265 /* SourceFile */: - return undefined; - case 233 /* ModuleDeclaration */: - // If in walking up the tree, we hit a a nested namespace declaration, - // then we must be somewhere within a dotted namespace name; however we don't - // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 233 /* ModuleDeclaration */) { - return undefined; - } - break findOwner; - } + var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + if (!commentOwnerInfo) { + return undefined; } - if (!commentOwner || commentOwner.getStart() < position) { + var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters; + if (commentOwner.getStart() < position) { return undefined; } - var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; // replace non-whitespace characters in prefix with spaces. var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0; i < parameters.length; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 71 /* Identifier */ ? - currentName.escapedText : - "param" + i; - if (isJavaScriptFile) { - docParams += indentationStr + " * @param {any} " + paramName + newLine; - } - else { - docParams += indentationStr + " * @param " + paramName + newLine; + if (parameters) { + for (var i = 0; i < parameters.length; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 71 /* Identifier */ ? + currentName.escapedText : + "param" + i; + if (isJavaScriptFile) { + docParams += indentationStr + " * @param {any} " + paramName + newLine; + } + else { + docParams += indentationStr + " * @param " + paramName + newLine; + } } } // A doc comment consists of the following @@ -81043,18 +81533,46 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; - function getParametersForJsDocOwningNode(commentOwner) { - if (ts.isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } - if (commentOwner.kind === 208 /* VariableStatement */) { - var varStatement = commentOwner; - var varDeclarations = varStatement.declarationList.declarations; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + function getCommentOwnerInfo(tokenAtPos) { + // TODO: add support for: + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 152 /* Constructor */: + var parameters = commentOwner.parameters; + return { commentOwner: commentOwner, parameters: parameters }; + case 229 /* ClassDeclaration */: + return { commentOwner: commentOwner }; + case 208 /* VariableStatement */: { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer + ? getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer) + : undefined; + return { commentOwner: commentOwner, parameters: parameters_1 }; + } + case 265 /* SourceFile */: + return undefined; + case 233 /* ModuleDeclaration */: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + return commentOwner.parent.kind === 233 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 194 /* BinaryExpression */: { + var be = commentOwner; + if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { + return undefined; + } + var parameters_2 = ts.isFunctionLike(be.right) ? be.right.parameters : ts.emptyArray; + return { commentOwner: commentOwner, parameters: parameters_2 }; + } } } - return ts.emptyArray; } /** * Digs into an an initializer or RHS operand of an assignment operation @@ -81303,32 +81821,7 @@ var ts; return "continue"; } ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { - if (declarations) { - // First do a quick check to see if the name of the declaration matches the - // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); - if (!matches) { - return; // continue to next named declarations - } - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - // It was a match! If the pattern has dots in it, then also see if the - // declaration container matches as well. - if (patternMatcher.patternContainsDots) { - var containers = getContainers(declaration); - if (!containers) { - return true; // Break out of named declarations and go to the next source file. - } - matches = patternMatcher.getMatches(containers, name); - if (!matches) { - return; // continue to next named declarations - } - } - var fileName = sourceFile.fileName; - var matchKind = bestMatchKind(matches); - rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); - } - } + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, rawItems); }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] @@ -81336,134 +81829,159 @@ var ts; var sourceFile = sourceFiles_8[_i]; _loop_6(sourceFile); } - // Remove imports when the imported declaration is already in the list and has the same name. - rawItems = ts.filter(rawItems, function (item) { - var decl = item.declaration; - if (decl.kind === 239 /* ImportClause */ || decl.kind === 242 /* ImportSpecifier */ || decl.kind === 237 /* ImportEqualsDeclaration */) { - var importer = checker.getSymbolAtLocation(decl.name); - var imported = checker.getAliasedSymbol(importer); - return importer.escapedName !== imported.escapedName; - } - else { - return true; - } - }); rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { rawItems = rawItems.slice(0, maxResultCount); } - var items = ts.map(rawItems, createNavigateToItem); - return items; - function allMatchesAreCaseSensitive(matches) { - ts.Debug.assert(matches.length > 0); - // This is a case sensitive match, only if all the submatches were case sensitive. - for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { - var match = matches_2[_i]; - if (!match.isCaseSensitive) { + return rawItems.map(createNavigateToItem); + } + NavigateTo.getNavigateToItems = getNavigateToItems; + function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { + // First do a quick check to see if the name of the declaration matches the + // last portion of the (possibly) dotted name they're searching for. + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); + if (!matches) { + return; // continue to next named declarations + } + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + if (!shouldKeepItem(declaration, checker)) { + continue; + } + // It was a match! If the pattern has dots in it, then also see if the + // declaration container matches as well. + var containerMatches = matches; + if (patternMatcher.patternContainsDots) { + containerMatches = patternMatcher.getMatches(getContainers(declaration), name); + if (!containerMatches) { + continue; + } + } + var matchKind = bestMatchKind(containerMatches); + var isCaseSensitive = allMatchesAreCaseSensitive(containerMatches); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: isCaseSensitive, declaration: declaration }); + } + } + function shouldKeepItem(declaration, checker) { + switch (declaration.kind) { + case 239 /* ImportClause */: + case 242 /* ImportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + var importer = checker.getSymbolAtLocation(declaration.name); + var imported = checker.getAliasedSymbol(importer); + return importer.escapedName !== imported.escapedName; + default: + return true; + } + } + function allMatchesAreCaseSensitive(matches) { + ts.Debug.assert(matches.length > 0); + // This is a case sensitive match, only if all the submatches were case sensitive. + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; + if (!match.isCaseSensitive) { + return false; + } + } + return true; + } + function tryAddSingleDeclarationName(declaration, containers) { + if (declaration) { + var name = ts.getNameOfDeclaration(declaration); + if (name) { + var text = ts.getTextOfIdentifierOrLiteral(name); + if (text !== undefined) { + containers.unshift(text); + } + else if (name.kind === 144 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ true); + } + else { + // Don't know how to add this. return false; } } - return true; - } - function tryAddSingleDeclarationName(declaration, containers) { - if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - var text = ts.getTextOfIdentifierOrLiteral(name); - if (text !== undefined) { - containers.unshift(text); - } - else if (name.kind === 144 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ true); - } - else { - // Don't know how to add this. - return false; - } - } - } - return true; - } - // Only added the names of computed properties if they're simple dotted expressions, like: - // - // [X.Y.Z]() { } - function tryAddComputedPropertyName(expression, containers, includeLastPortion) { - var text = ts.getTextOfIdentifierOrLiteral(expression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; - } - if (expression.kind === 179 /* PropertyAccessExpression */) { - var propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true); - } - return false; - } - function getContainers(declaration) { - var containers = []; - // First, if we started with a computed property name, then add all but the last - // portion into the container array. - var name = ts.getNameOfDeclaration(declaration); - if (name.kind === 144 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; - } - } - // Now, walk up our containers, adding all their names to the container array. - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } - declaration = ts.getContainerNode(declaration); - } - return containers; - } - function bestMatchKind(matches) { - ts.Debug.assert(matches.length > 0); - var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { - var match = matches_3[_i]; - var kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } - return bestMatchKind; - } - function compareNavigateToItems(i1, i2) { - // TODO(cyrusn): get the gamut of comparisons that VS already uses here. - // Right now we just sort by kind first, and then by name of the item. - // We first sort case insensitively. So "Aaa" will come before "bar". - // Then we sort case sensitively, so "aaa" will come before "Aaa". - return i1.matchKind - i2.matchKind || - ts.compareStringsCaseInsensitive(i1.name, i2.name) || - ts.compareStrings(i1.name, i2.name); - } - function createNavigateToItem(rawItem) { - var declaration = rawItem.declaration; - var container = ts.getContainerNode(declaration); - var containerName = container && ts.getNameOfDeclaration(container); - return { - name: rawItem.name, - kind: ts.getNodeKind(declaration), - kindModifiers: ts.getNodeModifiers(declaration), - matchKind: ts.PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromNode(declaration), - // TODO(jfreeman): What should be the containerName when the container has a computed name? - containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ - }; } + return true; + } + // Only added the names of computed properties if they're simple dotted expressions, like: + // + // [X.Y.Z]() { } + function tryAddComputedPropertyName(expression, containers, includeLastPortion) { + var text = ts.getTextOfIdentifierOrLiteral(expression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); + } + return true; + } + if (expression.kind === 179 /* PropertyAccessExpression */) { + var propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); + } + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true); + } + return false; + } + function getContainers(declaration) { + var containers = []; + // First, if we started with a computed property name, then add all but the last + // portion into the container array. + var name = ts.getNameOfDeclaration(declaration); + if (name.kind === 144 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + return undefined; + } + } + // Now, walk up our containers, adding all their names to the container array. + declaration = ts.getContainerNode(declaration); + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; + } + declaration = ts.getContainerNode(declaration); + } + return containers; + } + function bestMatchKind(matches) { + ts.Debug.assert(matches.length > 0); + var bestMatchKind = ts.PatternMatchKind.camelCase; + for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { + var match = matches_3[_i]; + var kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; + } + } + return bestMatchKind; + } + function compareNavigateToItems(i1, i2) { + // TODO(cyrusn): get the gamut of comparisons that VS already uses here. + // Right now we just sort by kind first, and then by name of the item. + // We first sort case insensitively. So "Aaa" will come before "bar". + // Then we sort case sensitively, so "aaa" will come before "Aaa". + return i1.matchKind - i2.matchKind || + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); + } + function createNavigateToItem(rawItem) { + var declaration = rawItem.declaration; + var container = ts.getContainerNode(declaration); + var containerName = container && ts.getNameOfDeclaration(container); + return { + name: rawItem.name, + kind: ts.getNodeKind(declaration), + kindModifiers: ts.getNodeModifiers(declaration), + matchKind: ts.PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: ts.createTextSpanFromNode(declaration), + // TODO(jfreeman): What should be the containerName when the container has a computed name? + containerName: containerName ? containerName.text : "", + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ + }; } - NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); /// @@ -81647,17 +82165,24 @@ var ts; break; case 176 /* BindingElement */: case 226 /* VariableDeclaration */: - var decl = node; - var name = decl.name; + var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - // For `const x = function() {}`, just use the function node, not the const. - addChildrenRecursively(decl.initializer); + else if (initializer && isFunctionOrClassExpression(initializer)) { + if (initializer.name) { + // Don't add a node for the VariableDeclaration, just for the initializer. + addChildrenRecursively(initializer); + } + else { + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); + } } else { - addNodeWithRecursiveChild(decl, decl.initializer); + addNodeWithRecursiveChild(node, initializer); } break; case 187 /* ArrowFunction */: @@ -81667,8 +82192,8 @@ var ts; break; case 232 /* EnumDeclaration */: startNode(node); - for (var _d = 0, _e = node.members; _d < _e.length; _d++) { - var member = _e[_d]; + for (var _e = 0, _f = node.members; _e < _f.length; _e++) { + var member = _f[_e]; if (!isComputedProperty(member)) { addLeafNode(member); } @@ -81679,8 +82204,8 @@ var ts; case 199 /* ClassExpression */: case 230 /* InterfaceDeclaration */: startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; + for (var _g = 0, _h = node.members; _g < _h.length; _g++) { + var member = _h[_g]; addChildrenRecursively(member); } endNode(); @@ -81697,13 +82222,15 @@ var ts; addLeafNode(node); break; default: - ts.forEach(node.jsDoc, function (jsDoc) { - ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 283 /* JSDocTypedefTag */) { - addLeafNode(tag); - } + if (ts.hasJSDocNodes(node)) { + ts.forEach(node.jsDoc, function (jsDoc) { + ts.forEach(jsDoc.tags, function (tag) { + if (tag.kind === 283 /* JSDocTypedefTag */) { + addLeafNode(tag); + } + }); }); - }); + } ts.forEachChild(node, addChildrenRecursively); } } @@ -82038,7 +82565,14 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 186 /* FunctionExpression */ || node.kind === 187 /* ArrowFunction */ || node.kind === 199 /* ClassExpression */; + switch (node.kind) { + case 187 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 199 /* ClassExpression */: + return true; + default: + return false; + } } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -82049,11 +82583,15 @@ var ts; (function (OutliningElementsCollector) { var collapseText = "..."; var maxDepth = 20; + var defaultLabel = "#region"; + var regionMatch = new RegExp("^\\s*//\\s*#(end)?region(?:\\s+(.*))?$"); function collectElements(sourceFile, cancellationToken) { var elements = []; var depth = 0; + var regions = []; walk(sourceFile); - return elements; + gatherRegions(); + return elements.sort(function (span1, span2) { return span1.textSpan.start - span2.textSpan.start; }); /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse, useFullStart) { if (hintSpanNode && startElement && endElement) { @@ -82122,6 +82660,36 @@ var ts; function autoCollapse(node) { return ts.isFunctionBlock(node) && node.parent.kind !== 187 /* ArrowFunction */; } + function gatherRegions() { + var lineStarts = sourceFile.getLineStarts(); + for (var i = 0; i < lineStarts.length; i++) { + var currentLineStart = lineStarts[i]; + var lineEnd = lineStarts[i + 1] - 1 || sourceFile.getEnd(); + var comment = sourceFile.text.substring(currentLineStart, lineEnd); + var result = comment.match(regionMatch); + if (result && !ts.isInComment(sourceFile, currentLineStart)) { + if (!result[1]) { + var start = sourceFile.getFullText().indexOf("//", currentLineStart); + var textSpan = ts.createTextSpanFromBounds(start, lineEnd); + var region = { + textSpan: textSpan, + hintSpan: textSpan, + bannerText: result[2] || defaultLabel, + autoCollapse: false + }; + regions.push(region); + } + else { + var region = regions.pop(); + if (region) { + region.textSpan.length = lineEnd - region.textSpan.start; + region.hintSpan.length = lineEnd - region.textSpan.start; + elements.push(region); + } + } + } + } + } function walk(n) { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -83030,13 +83598,11 @@ var ts; } // skip open bracket token = nextToken(); - var i = 0; // scan until ']' or EOF while (token !== 22 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names if (token === 9 /* StringLiteral */) { recordModuleName(); - i++; } token = nextToken(); } @@ -83197,10 +83763,16 @@ var ts; return ts.createTextSpan(start, width); } function nodeIsEligibleForRename(node) { - return node.kind === 71 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node); + switch (node.kind) { + case 71 /* Identifier */: + case 9 /* StringLiteral */: + case 99 /* ThisKeyword */: + return true; + case 8 /* NumericLiteral */: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); + default: + return false; + } } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); @@ -83537,8 +84109,7 @@ var ts; if (isTypeParameterList) { isVariadic = false; // type parameter lists are not variadic prefixDisplayParts.push(ts.punctuationPart(27 /* LessThanToken */)); - // Use `.mapper` to ensure we get the generic type arguments even if this is an instantiated version of the signature. - var typeParameters = candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; + var typeParameters = (candidateSignature.target || candidateSignature).typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : ts.emptyArray; suffixDisplayParts.push(ts.punctuationPart(29 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { @@ -83676,7 +84247,8 @@ var ts; if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { return "property" /* memberVariableElement */; } - ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); + // May be a Function if this was from `typeof N` with `namespace N { function f();. }`. + ts.Debug.assert(!!(rootSymbolFlags & (8192 /* Method */ | 16 /* Function */))); }); if (!unionPropertyKind) { // If this was union of all methods, @@ -84270,10 +84842,6 @@ var ts; (function (formatting) { var standardScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); var jsxScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); - /** - * Scanner that is currently used for formatting - */ - var scanner; var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -84283,9 +84851,8 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); - function getFormattingScanner(text, languageVariant, startPos, endPos) { - ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { + var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -84294,38 +84861,28 @@ var ts; var savedPos; var lastScanAction; var lastTokenInfo; - return { + var res = cb({ advance: advance, readTokenInfo: readTokenInfo, isOnToken: isOnToken, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, - close: function () { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; + }); + lastTokenInfo = undefined; + scanner.setText(undefined); + return res; function advance() { - ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - if (trailingTrivia) { - ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; - } - else { - wasNewLine = false; - } + wasNewLine = trailingTrivia && ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; + } + else { + scanner.scan(); } leadingTrivia = undefined; trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } var pos = scanner.getStartPos(); // Read leading trivia and token while (pos < endPos) { @@ -84341,23 +84898,18 @@ var ts; kind: t }; pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; - } - leadingTrivia.push(item); + leadingTrivia = ts.append(leadingTrivia, item); } savedPos = scanner.getStartPos(); } function shouldRescanGreaterThanToken(node) { - if (node) { - switch (node.kind) { - case 31 /* GreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - return true; - } + switch (node.kind) { + case 31 /* GreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanToken */: + return true; } return false; } @@ -84368,13 +84920,14 @@ var ts; case 251 /* JsxOpeningElement */: case 252 /* JsxClosingElement */: case 250 /* JsxSelfClosingElement */: - return node.kind === 71 /* Identifier */; + // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. + return ts.isKeyword(node.kind) || node.kind === 71 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 10 /* JsxText */; + return node.kind === 10 /* JsxText */; } function shouldRescanSlashToken(container) { return container.kind === 12 /* RegularExpressionLiteral */; @@ -84387,15 +84940,7 @@ var ts; return t === 41 /* SlashToken */ || t === 63 /* SlashEqualsToken */; } function readTokenInfo(n) { - ts.Debug.assert(scanner !== undefined); - if (!isOnToken()) { - // scanner is not on the token (either advance was not called yet or scanner is already past the end position) - return { - leadingTrivia: leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } + ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. var expectedScanAction = shouldRescanGreaterThanToken(n) @@ -84424,32 +84969,7 @@ var ts; scanner.setTextPos(savedPos); scanner.scan(); } - var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 29 /* GreaterThanToken */) { - currentToken = scanner.reScanGreaterToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 1 /* RescanGreaterThanToken */; - } - else if (expectedScanAction === 2 /* RescanSlashToken */ && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 2 /* RescanSlashToken */; - } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 18 /* CloseBraceToken */) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = 3 /* RescanTemplateToken */; - } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 71 /* Identifier */) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = 4 /* RescanJsxIdentifier */; - } - else if (expectedScanAction === 5 /* RescanJsxText */) { - currentToken = scanner.reScanJsxToken(); - lastScanAction = 5 /* RescanJsxText */; - } - else { - lastScanAction = 0 /* Scan */; - } + var currentToken = getNextToken(n, expectedScanAction); var token = { pos: scanner.getStartPos(), end: scanner.getTextPos(), @@ -84482,8 +85002,46 @@ var ts; lastTokenInfo = { leadingTrivia: leadingTrivia, trailingTrivia: trailingTrivia, token: token }; return fixTokenKind(lastTokenInfo, n); } + function getNextToken(n, expectedScanAction) { + var token = scanner.getToken(); + lastScanAction = 0 /* Scan */; + switch (expectedScanAction) { + case 1 /* RescanGreaterThanToken */: + if (token === 29 /* GreaterThanToken */) { + lastScanAction = 1 /* RescanGreaterThanToken */; + var newToken = scanner.reScanGreaterToken(); + ts.Debug.assert(n.kind === newToken); + return newToken; + } + break; + case 2 /* RescanSlashToken */: + if (startsWithSlashToken(token)) { + lastScanAction = 2 /* RescanSlashToken */; + var newToken = scanner.reScanSlashToken(); + ts.Debug.assert(n.kind === newToken); + return newToken; + } + break; + case 3 /* RescanTemplateToken */: + if (token === 18 /* CloseBraceToken */) { + lastScanAction = 3 /* RescanTemplateToken */; + return scanner.reScanTemplateToken(); + } + break; + case 4 /* RescanJsxIdentifier */: + lastScanAction = 4 /* RescanJsxIdentifier */; + return scanner.scanJsxIdentifier(); + case 5 /* RescanJsxText */: + lastScanAction = 5 /* RescanJsxText */; + return scanner.reScanJsxToken(); + case 0 /* Scan */: + break; + default: + ts.Debug.assertNever(expectedScanAction); + } + return token; + } function isOnToken() { - ts.Debug.assert(scanner !== undefined); var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); @@ -84623,11 +85181,6 @@ var ts; this.Operation = Operation; this.Flag = Flag; } - Rule.prototype.toString = function () { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; - }; return Rule; }()); formatting.Rule = Rule; @@ -85021,16 +85574,16 @@ var ts; this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - } - Rules.prototype.getRuleName = function (rule) { - var o = this; - for (var name in o) { - if (o[name] === rule) { - return name; + if (ts.Debug.isDebugging) { + var o = this; + for (var name in o) { + var rule = o[name]; + if (rule instanceof formatting.Rule) { + rule.debugName = name; + } } } - throw new Error("Unknown rule"); - }; + } /// /// Contexts /// @@ -85188,8 +85741,8 @@ var ts; return true; case 207 /* Block */: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 187 /* ArrowFunction */ && - blockParent.kind !== 186 /* FunctionExpression */) { + // In a codefix scenario, we can't rely on parents being set. So just always return true. + if (!blockParent || blockParent.kind !== 187 /* ArrowFunction */ && blockParent.kind !== 186 /* FunctionExpression */) { return true; } } @@ -85635,15 +86188,9 @@ var ts; var RulesProvider = /** @class */ (function () { function RulesProvider() { this.globalRules = new formatting.Rules(); - var activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); + var activeRules = this.globalRules.HighPriorityCommonRules.concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); this.rulesMap = formatting.RulesMap.create(activeRules); } - RulesProvider.prototype.getRuleName = function (rule) { - return this.globalRules.getRuleName(rule); - }; - RulesProvider.prototype.getRuleByName = function (name) { - return this.globalRules[name]; - }; RulesProvider.prototype.getRulesMap = function () { return this.rulesMap; }; @@ -85918,8 +86465,8 @@ var ts; /* @internal */ function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, rulesProvider) { var range = { pos: 0, end: sourceFileLike.text.length }; - return formatSpanWorker(range, node, initialIndentation, delta, formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), rulesProvider.getFormatOptions(), rulesProvider, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors - sourceFileLike); + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, rulesProvider.getFormatOptions(), rulesProvider, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; function formatNodeLines(node, sourceFile, options, rulesProvider, requestKind) { @@ -85935,7 +86482,7 @@ var ts; function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { // find the smallest node that fully wraps the range and compute the initial indentation for the node var enclosingNode = findEnclosingNode(originalRange, sourceFile); - return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); + return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), scanner, options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { // formatting context is used by rules provider @@ -85962,7 +86509,6 @@ var ts; trimTrailingWhitespacesForRemainingRange(); } } - formattingScanner.close(); return edits; // local functions /** Tries to compute the indentation for a list element. @@ -86201,6 +86747,7 @@ var ts; return inheritedIndentation; } function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { + ts.Debug.assert(ts.isNodeArray(nodes)); var listStartToken = getOpenTokenForList(parent, nodes); var listEndToken = getCloseTokenForOpenToken(listStartToken); var listDynamicIndentation = parentDynamicIndentation; @@ -87120,6 +87667,8 @@ var ts; case 241 /* NamedImports */: case 246 /* ExportSpecifier */: case 242 /* ImportSpecifier */: + case 261 /* PropertyAssignment */: + case 149 /* PropertyDeclaration */: return true; } return false; @@ -87174,15 +87723,21 @@ var ts; * It can be changed to side-table later if we decide that current design is too invasive. */ function getPos(n) { - return n["__pos"]; + var result = n["__pos"]; + ts.Debug.assert(typeof result === "number"); + return result; } function setPos(n, pos) { + ts.Debug.assert(typeof pos === "number"); n["__pos"] = pos; } function getEnd(n) { - return n["__end"]; + var result = n["__end"]; + ts.Debug.assert(typeof result === "number"); + return result; } function setEnd(n, end) { + ts.Debug.assert(typeof end === "number"); n["__end"] = end; } var Position; @@ -87237,7 +87792,9 @@ var ts; return position === Position.Start ? start : fullStart; } // get start position of the line following the line that contains fullstart position - var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + // (but only if the fullstart isn't the very beginning of the file) + var nextLineStart = fullStart > 0 ? 1 : 0; + var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + nextLineStart, sourceFile); // skip whitespaces/newlines adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); @@ -87267,9 +87824,6 @@ var ts; } return s; } - function getNewlineKind(context) { - return context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - } var ChangeTracker = /** @class */ (function () { function ChangeTracker(newLine, rulesProvider, validator) { this.newLine = newLine; @@ -87278,8 +87832,8 @@ var ts; this.changes = []; this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); } - ChangeTracker.fromCodeFixContext = function (context) { - return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + ChangeTracker.fromContext = function (context) { + return new ChangeTracker(context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */, context.rulesProvider); }; ChangeTracker.prototype.deleteRange = function (sourceFile, range) { this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); @@ -87305,7 +87859,7 @@ var ts; ts.Debug.fail("node is not a list element"); return this; } - var index = containingList.indexOf(node); + var index = ts.indexOfNode(containingList, node); if (index < 0) { return this; } @@ -87430,7 +87984,7 @@ var ts; ts.Debug.fail("node is not a list element"); return this; } - var index = containingList.indexOf(after); + var index = ts.indexOfNode(containingList, after); if (index < 0) { return this; } @@ -87646,10 +88200,9 @@ var ts; var options = { newLine: newLine, target: sourceFile && sourceFile.languageVersion }; var writer = new Writer(ts.getNewLineCharacter(options)); var printer = ts.createPrinter(options, writer); - printer.writeNode(3 /* Unspecified */, node, sourceFile, writer); + printer.writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } - textChanges.getNonformattedText = getNonformattedText; function applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, rulesProvider) { var lineMap = ts.computeLineStarts(nonFormattedText.text); var file = { @@ -87660,7 +88213,6 @@ var ts; var changes = ts.formatting.formatNodeGivenIndentation(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); return applyChanges(nonFormattedText.text, changes); } - textChanges.applyFormatting = applyFormatting; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var change = changes[i]; @@ -87675,13 +88227,10 @@ var ts; function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes - var newNode = ts.nodeIsSynthesized(visited) - ? visited - : (Proxy.prototype = visited, new Proxy()); + var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited); newNode.pos = getPos(node); newNode.end = getEnd(node); return newNode; - function Proxy() { } } function assignPositionsToNodeArray(nodes, visitor, test, start, count) { var visited = ts.visitNodes(nodes, visitor, test, start, count); @@ -87817,7 +88366,15 @@ var ts; ts.forEach(fixes, function (f) { var actions = f.getCodeActions(context); if (actions && actions.length > 0) { - allActions = allActions.concat(actions); + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + if (action === undefined) { + context.host.log("Action for error code " + context.errorCode + " added an invalid action entry; please log a bug"); + } + else { + allActions.push(action); + } + } } }); return allActions; @@ -87849,6 +88406,10 @@ var ts; } refactor_1.getEditsForRefactor = getEditsForRefactor; })(refactor = ts.refactor || (ts.refactor = {})); + function getRefactorContextLength(context) { + return context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + } + ts.getRefactorContextLength = getRefactorContextLength; })(ts || (ts = {})); /* @internal */ var ts; @@ -87868,7 +88429,7 @@ var ts; var leftText = qualifiedName.left.getText(sourceFile); var rightText = qualifiedName.right.getText(sourceFile); var replacement = ts.createIndexedAccessTypeNode(ts.createTypeReferenceNode(qualifiedName.left, /*typeArguments*/ undefined), ts.createLiteralTypeNode(ts.createLiteral(rightText))); - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, qualifiedName, replacement); return [{ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Rewrite_as_the_indexed_access_type_0), [leftText + "[\"" + rightText + "\"]"]), @@ -88006,7 +88567,7 @@ var ts; } var className = classDeclaration.name.getText(); var staticInitialization = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier(className), tokenName), ts.createIdentifier("undefined"))); - var staticInitializationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var staticInitializationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); staticInitializationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classDeclaration, staticInitialization, { suffix: context.newLineCharacter }); var initializeStaticAction = { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_static_property_0), [tokenName]), @@ -88021,7 +88582,7 @@ var ts; return actions; } var propertyInitialization = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), tokenName), ts.createIdentifier("undefined"))); - var propertyInitializationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var propertyInitializationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); propertyInitializationChangeTracker.insertNodeAt(classDeclarationSourceFile, classConstructor.body.getEnd() - 1, propertyInitialization, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); var initializeAction = { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]), @@ -88051,7 +88612,7 @@ var ts; /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); - var propertyChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var propertyChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter }); (actions || (actions = [])).push({ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Declare_property_0), [tokenName]), @@ -88069,7 +88630,7 @@ var ts; var indexSignature = ts.createIndexSignature( /*decorators*/ undefined, /*modifiers*/ undefined, [indexingParameter], typeNode); - var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); indexSignatureChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, indexSignature, { suffix: context.newLineCharacter }); actions.push({ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_property_0), [tokenName]), @@ -88082,7 +88643,7 @@ var ts; if (token.parent.parent.kind === 181 /* CallExpression */) { var callExpression = token.parent.parent; var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic); - var methodDeclarationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var methodDeclarationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); return { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(makeStatic ? @@ -88225,7 +88786,7 @@ var ts; } } } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); changeTracker.deleteNode(sourceFile, superCall); return [{ @@ -88258,7 +88819,7 @@ var ts; if (token.kind !== 123 /* ConstructorKeyword */) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var superCall = ts.createStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ ts.emptyArray)); changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ @@ -88292,7 +88853,7 @@ var ts; if (!(extendsToken && extendsToken.kind === 85 /* ExtendsKeyword */)) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, extendsToken, ts.createToken(108 /* ImplementsKeyword */)); // We replace existing keywords with commas. for (var i = 1; i < heritageClauses.length; i++) { @@ -88323,7 +88884,7 @@ var ts; if (token.kind !== 71 /* Identifier */) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createThis(), token)); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), @@ -88340,8 +88901,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code + ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code, + ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code ], getCodeActions: function (context) { var sourceFile = context.sourceFile; @@ -88491,19 +89052,19 @@ var ts; } } function deleteNode(n) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNode(sourceFile, n)); } function deleteRange(range) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteRange(sourceFile, range)); } function deleteNodeInList(n) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNodeInList(sourceFile, n)); } function deleteNodeRange(start, end) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNodeRange(sourceFile, start, end)); } function replaceNode(n, newNode) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).replaceNode(sourceFile, n, newNode)); } function makeChange(changeTracker) { return { @@ -88527,11 +89088,32 @@ var ts; function getActionsForJSDocTypes(context) { var sourceFile = context.sourceFile; var node = ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); - var decl = ts.findAncestor(node, function (n) { return n.kind === 226 /* VariableDeclaration */; }); + // NOTE: Some locations are not handled yet: + // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments + var decl = ts.findAncestor(node, function (n) { + return n.kind === 202 /* AsExpression */ || + n.kind === 155 /* CallSignature */ || + n.kind === 156 /* ConstructSignature */ || + n.kind === 228 /* FunctionDeclaration */ || + n.kind === 153 /* GetAccessor */ || + n.kind === 157 /* IndexSignature */ || + n.kind === 172 /* MappedType */ || + n.kind === 151 /* MethodDeclaration */ || + n.kind === 150 /* MethodSignature */ || + n.kind === 146 /* Parameter */ || + n.kind === 149 /* PropertyDeclaration */ || + n.kind === 148 /* PropertySignature */ || + n.kind === 154 /* SetAccessor */ || + n.kind === 231 /* TypeAliasDeclaration */ || + n.kind === 184 /* TypeAssertionExpression */ || + n.kind === 226 /* VariableDeclaration */; + }); if (!decl) return; var checker = context.program.getTypeChecker(); var jsdocType = decl.type; + if (!jsdocType) + return; var original = ts.getTextOfNode(jsdocType); var type = checker.getTypeFromTypeNode(jsdocType); var actions = [createAction(jsdocType, sourceFile.fileName, original, checker.typeToString(type, /*enclosingDeclaration*/ undefined, 8 /* NoTruncation */))]; @@ -88734,28 +89316,21 @@ var ts; if (cached) { return cached; } - var existingDeclarations = []; - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importModuleSpecifier = _a[_i]; - var importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); - if (importSymbol === moduleSymbol) { - existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); - } - } + var existingDeclarations = ts.mapDefined(sourceFile.imports, function (importModuleSpecifier) { + return checker.getSymbolAtLocation(importModuleSpecifier) === moduleSymbol ? getImportDeclaration(importModuleSpecifier) : undefined; + }); cachedImportDeclarations[moduleSymbolId] = existingDeclarations; return existingDeclarations; - function getImportDeclaration(moduleSpecifier) { - var node = moduleSpecifier; - while (node) { - if (node.kind === 238 /* ImportDeclaration */) { - return node; - } - if (node.kind === 237 /* ImportEqualsDeclaration */) { - return node; - } - node = node.parent; + function getImportDeclaration(_a) { + var parent = _a.parent; + switch (parent.kind) { + case 238 /* ImportDeclaration */: + return parent; + case 248 /* ExternalModuleReference */: + return parent.parent; + default: + return undefined; } - return undefined; } } function getUniqueSymbolId(symbol) { @@ -89164,7 +89739,7 @@ var ts; } } function createChangeTracker() { - return ts.textChanges.ChangeTracker.fromCodeFixContext(context); + return ts.textChanges.ChangeTracker.fromContext(context); } function createCodeAction(description, diagnosticArgs, changes, kind, moduleSpecifier) { return { @@ -89251,7 +89826,7 @@ var ts; (function (codefix) { function newNodesToChanges(newNodes, insertAfter, context) { var sourceFile = context.sourceFile; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) { var newNode = newNodes_1[_i]; changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); @@ -89538,7 +90113,7 @@ var ts; return undefined; } var ctorDeclaration = ctorSymbol.valueDeclaration; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { @@ -89568,7 +90143,9 @@ var ts; deleteCallback(); } return { - edits: changeTracker.getChanges() + edits: changeTracker.getChanges(), + renameFilename: undefined, + renameLocation: undefined, }; function deleteNode(node, inList) { if (inList === void 0) { inList = false; } @@ -89730,7 +90307,7 @@ var ts; refactor.registerRefactor(extractMethod); /** Compute the associated code actions */ function getAvailableActions(context) { - var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: ts.getRefactorContextLength(context) }); var targetRange = rangeToExtract.targetRange; if (targetRange === undefined) { return undefined; @@ -89744,15 +90321,15 @@ var ts; var usedNames = ts.createMap(); var i = 0; for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) { - var extr = extractions_1[_i]; + var _a = extractions_1[_i], scopeDescription = _a.scopeDescription, errors = _a.errors; // Skip these since we don't have a way to report errors yet - if (extr.errors && extr.errors.length) { + if (errors.length) { continue; } // Don't issue refactorings with duplicated names. // Scopes come back in "innermost first" order, so extractions will // preferentially go into nearer scopes - var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_to_0.message, [scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -89775,17 +90352,13 @@ var ts; }]; } function getEditsForAction(context, actionName) { - var length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; - var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: length }); + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: ts.getRefactorContextLength(context) }); var targetRange = rangeToExtract.targetRange; var parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); ts.Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); var index = +parsedIndexMatch[1]; ts.Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); - var extractions = getPossibleExtractions(targetRange, context, index); - // Scope is no longer valid from when the user issued the refactor (??) - ts.Debug.assert(extractions !== undefined, "The extraction went missing? How?"); - return ({ edits: extractions[0].changes }); + return getExtractionAtIndex(targetRange, context, index); } // Move these into diagnostic messages if they become user-facing var Messages; @@ -89818,15 +90391,19 @@ var ts; * The range is in a function which needs the 'static' modifier in a class */ RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; - })(RangeFacts = extractMethod_1.RangeFacts || (extractMethod_1.RangeFacts = {})); + })(RangeFacts || (RangeFacts = {})); /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array * of statements representing the minimum set of nodes needed to extract the entire span. This * process may fail, in which case a set of errors is returned instead (these are currently * not shown to the user, but can be used by us diagnostically) */ + // exported only for tests function getRangeToExtract(sourceFile, span) { - var length = span.length || 0; + var length = span.length; + if (length === 0) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.StatementOrExpressionExpected)] }; + } // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); @@ -89893,22 +90470,13 @@ var ts; if (errors) { return { errors: errors }; } - // If our selection is the expression in an ExpressionStatement, expand - // the selection to include the enclosing Statement (this stops us - // from trying to care about the return value of the extracted function - // and eliminates double semicolon insertion in certain scenarios) - var range = ts.isStatement(start) - ? [start] - : start.parent && start.parent.kind === 210 /* ExpressionStatement */ - ? [start.parent] - : start; - return { targetRange: { range: range, facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations: declarations } }; } function createErrorResult(sourceFile, start, length, message) { return { errors: [ts.createFileDiagnostic(sourceFile, start, length, message)] }; } function checkRootNode(node) { - if (ts.isIdentifier(node)) { + if (ts.isIdentifier(ts.isExpressionStatement(node) ? node.expression : node)) { return [ts.createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; @@ -89946,7 +90514,7 @@ var ts; PermittedJumps[PermittedJumps["Continue"] = 2] = "Continue"; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); - if (!ts.isStatement(nodeToCheck) && !(ts.isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + if (!ts.isStatement(nodeToCheck) && !(ts.isPartOfExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; } if (ts.isInAmbientContext(nodeToCheck)) { @@ -90010,45 +90578,30 @@ var ts; return false; } var savedPermittedJumps = permittedJumps; - if (node.parent) { - switch (node.parent.kind) { - case 211 /* IfStatement */: - if (node.parent.thenStatement === node || node.parent.elseStatement === node) { - // forbid all jumps inside thenStatement or elseStatement - permittedJumps = 0 /* None */; - } - break; - case 224 /* TryStatement */: - if (node.parent.tryBlock === node) { - // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; - } - else if (node.parent.finallyBlock === node) { - // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; - } - break; - case 260 /* CatchClause */: - if (node.parent.block === node) { - // forbid all jumps inside the block of catch clause - permittedJumps = 0 /* None */; - } - break; - case 257 /* CaseClause */: - if (node.expression !== node) { - // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; - } - break; - default: - if (ts.isIterationStatement(node.parent, /*lookInLabeledStatements*/ false)) { - if (node.parent.statement === node) { - // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; - } - } - break; - } + switch (node.kind) { + case 211 /* IfStatement */: + permittedJumps = 0 /* None */; + break; + case 224 /* TryStatement */: + // forbid all jumps inside try blocks + permittedJumps = 0 /* None */; + break; + case 207 /* Block */: + if (node.parent && node.parent.kind === 224 /* TryStatement */ && node.finallyBlock === node) { + // allow unconditional returns from finally blocks + permittedJumps = 4 /* Return */; + } + break; + case 257 /* CaseClause */: + // allow unlabeled break inside case clauses + permittedJumps |= 1 /* Break */; + break; + default: + if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { + // allow unlabeled break/continue inside loops + permittedJumps |= 1 /* Break */ | 2 /* Continue */; + } + break; } switch (node.kind) { case 169 /* ThisType */: @@ -90074,7 +90627,7 @@ var ts; } } else { - if (!(permittedJumps & (218 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 218 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); } @@ -90104,6 +90657,19 @@ var ts; } } extractMethod_1.getRangeToExtract = getRangeToExtract; + function getStatementOrExpressionRange(node) { + if (ts.isStatement(node)) { + return [node]; + } + else if (ts.isPartOfExpression(node)) { + // If our selection is the expression in an ExpressionStatement, expand + // the selection to include the enclosing Statement (this stops us + // from trying to care about the return value of the extracted function + // and eliminates double semicolon insertion in certain scenarios) + return ts.isExpressionStatement(node.parent) ? [node.parent] : node; + } + return undefined; + } function isValidExtractionTarget(node) { // Note that we don't use isFunctionLike because we don't want to put the extracted closure *inside* a method return (node.kind === 228 /* FunctionDeclaration */) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node); @@ -90144,14 +90710,29 @@ var ts; } return scopes; } - extractMethod_1.collectEnclosingScopes = collectEnclosingScopes; + // exported only for tests + function getExtractionAtIndex(targetRange, context, requestedChangesIndex) { + var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, _b = _a.readsAndWrites, target = _b.target, usagesPerScope = _b.usagesPerScope, errorsPerScope = _b.errorsPerScope; + ts.Debug.assert(!errorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); + context.cancellationToken.throwIfCancellationRequested(); + return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context); + } + extractMethod_1.getExtractionAtIndex = getExtractionAtIndex; /** * Given a piece of text to extract ('targetRange'), computes a list of possible extractions. * Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes * or an error explaining why we can't extract into that scope. */ - function getPossibleExtractions(targetRange, context, requestedChangesIndex) { - if (requestedChangesIndex === void 0) { requestedChangesIndex = undefined; } + // exported only for tests + function getPossibleExtractions(targetRange, context) { + var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, errorsPerScope = _a.readsAndWrites.errorsPerScope; + // Need the inner type annotation to avoid https://github.com/Microsoft/TypeScript/issues/7547 + return scopes.map(function (scope, i) { + return ({ scopeDescription: getDescriptionForScope(scope), errors: errorsPerScope[i] }); + }); + } + extractMethod_1.getPossibleExtractions = getPossibleExtractions; + function getPossibleExtractionsWorker(targetRange, context) { var sourceFile = context.file; if (targetRange === undefined) { return undefined; @@ -90161,87 +90742,67 @@ var ts; return undefined; } var enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); - var _a = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker()), target = _a.target, usagesPerScope = _a.usagesPerScope, errorsPerScope = _a.errorsPerScope; - context.cancellationToken.throwIfCancellationRequested(); - if (requestedChangesIndex !== undefined) { - if (errorsPerScope[requestedChangesIndex].length) { - return undefined; - } - return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; - } - else { - return scopes.map(function (scope, i) { - var errors = errorsPerScope[i]; - if (errors.length) { - return { - scope: scope, - scopeDescription: getDescriptionForScope(scope), - errors: errors - }; - } - return { scope: scope, scopeDescription: getDescriptionForScope(scope) }; - }); - } + var readsAndWrites = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker(), context.cancellationToken); + return { scopes: scopes, readsAndWrites: readsAndWrites }; } - extractMethod_1.getPossibleExtractions = getPossibleExtractions; function getDescriptionForScope(scope) { - if (ts.isFunctionLike(scope)) { - switch (scope.kind) { - case 152 /* Constructor */: - return "constructor"; - case 186 /* FunctionExpression */: - return scope.name - ? "function expression " + scope.name.getText() - : "anonymous function expression"; - case 228 /* FunctionDeclaration */: - return "function " + scope.name.getText(); - case 187 /* ArrowFunction */: - return "arrow function"; - case 151 /* MethodDeclaration */: - return "method " + scope.name.getText(); - case 153 /* GetAccessor */: - return "get " + scope.name.getText(); - case 154 /* SetAccessor */: - return "set " + scope.name.getText(); - } - } - else if (ts.isModuleBlock(scope)) { - return "namespace " + scope.parent.name.getText(); - } - else if (ts.isClassLike(scope)) { - return scope.kind === 229 /* ClassDeclaration */ - ? "class " + scope.name.text - : scope.name.text - ? "class expression " + scope.name.text - : "anonymous class expression"; - } - else if (ts.isSourceFile(scope)) { - return "file '" + scope.fileName + "'"; - } - else { - return "unknown"; + return ts.isFunctionLikeDeclaration(scope) + ? "inner function in " + getDescriptionForFunctionLikeDeclaration(scope) + : ts.isClassLike(scope) + ? "method in " + getDescriptionForClassLikeDeclaration(scope) + : "function in " + getDescriptionForModuleLikeDeclaration(scope); + } + function getDescriptionForFunctionLikeDeclaration(scope) { + switch (scope.kind) { + case 152 /* Constructor */: + return "constructor"; + case 186 /* FunctionExpression */: + return scope.name + ? "function expression '" + scope.name.text + "'" + : "anonymous function expression"; + case 228 /* FunctionDeclaration */: + return "function '" + scope.name.text + "'"; + case 187 /* ArrowFunction */: + return "arrow function"; + case 151 /* MethodDeclaration */: + return "method '" + scope.name.getText(); + case 153 /* GetAccessor */: + return "'get " + scope.name.getText() + "'"; + case 154 /* SetAccessor */: + return "'set " + scope.name.getText() + "'"; + default: + ts.Debug.assertNever(scope); } } - function getUniqueName(isNameOkay) { + function getDescriptionForClassLikeDeclaration(scope) { + return scope.kind === 229 /* ClassDeclaration */ + ? "class '" + scope.name.text + "'" + : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + } + function getDescriptionForModuleLikeDeclaration(scope) { + return scope.kind === 234 /* ModuleBlock */ + ? "namespace '" + scope.parent.name.getText() + "'" + : scope.externalModuleIndicator ? "module scope" : "global scope"; + } + function getUniqueName(fileText) { var functionNameText = "newFunction"; - if (isNameOkay(functionNameText)) { - return functionNameText; - } - var i = 1; - while (!isNameOkay(functionNameText = "newFunction_" + i)) { - i++; + for (var i = 1; fileText.indexOf(functionNameText) !== -1; i++) { + functionNameText = "newFunction_" + i; } return functionNameText; } + /** + * Result of 'extractRange' operation for a specific scope. + * Stores either a list of changes that should be applied to extract a range or a list of errors + */ function extractFunctionInScope(node, scope, _a, range, context) { - var usagesInScope = _a.usages, substitutions = _a.substitutions; + var usagesInScope = _a.usages, typeParameterUsages = _a.typeParameterUsages, substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted function var file = scope.getSourceFile(); - var functionNameText = getUniqueName(function (n) { return !file.identifiers.has(n); }); + var functionNameText = getUniqueName(file.text); var isJS = ts.isInJavaScriptFile(scope); var functionName = ts.createIdentifier(functionNameText); - var functionReference = ts.createIdentifier(functionNameText); var returnType = undefined; var parameters = []; var callArguments = []; @@ -90266,13 +90827,23 @@ var ts; } callArguments.push(ts.createIdentifier(name)); }); - // Provide explicit return types for contexutally-typed functions + var typeParametersAndDeclarations = ts.arrayFrom(typeParameterUsages.values()).map(function (type) { return ({ type: type, declaration: getFirstDeclaration(type) }); }); + var sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder); + var typeParameters = sortedTypeParametersAndDeclarations.length === 0 + ? undefined + : sortedTypeParametersAndDeclarations.map(function (t) { return t.declaration; }); + // Strictly speaking, we should check whether each name actually binds to the appropriate type + // parameter. In cases of shadowing, they may not. + var callTypeArguments = typeParameters !== undefined + ? typeParameters.map(function (decl) { return ts.createTypeReferenceNode(decl.name, /*typeArguments*/ undefined); }) + : undefined; + // Provide explicit return types for contextually-typed functions // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); returnType = checker.typeToTypeNode(contextualType); } - var _b = transformFunctionBody(node), body = _b.body, returnValueProperty = _b.returnValueProperty; + var _b = transformFunctionBody(node, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files @@ -90284,22 +90855,27 @@ var ts; modifiers.push(ts.createToken(120 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, - /*questionToken*/ undefined, - /*typeParameters*/ [], parameters, returnType, body); + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, - /*typeParameters*/ [], parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + } + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); + var minInsertionPos = (isReadonlyArray(range.range) ? ts.lastOrUndefined(range.range) : range.range).end; + var nodeToInsertBefore = getNodeToInsertBefore(minInsertionPos, scope); + if (nodeToInsertBefore) { + changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); - // insert function at the end of the scope - changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); var newNodes = []; // replace range with function call - var call = ts.createCall(ts.isClassLike(scope) ? ts.createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.getText()) : ts.createThis(), functionReference) : functionReference, - /*typeArguments*/ undefined, callArguments); + var called = getCalledExpression(scope, range, functionNameText); + var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference + callArguments); if (range.facts & RangeFacts.IsGenerator) { call = ts.createYield(ts.createToken(39 /* AsteriskToken */), call); } @@ -90323,6 +90899,9 @@ var ts; } else { newNodes.push(ts.createStatement(ts.createBinary(assignments[0].name, 58 /* EqualsToken */, call))); + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(ts.createReturn()); + } } } else { @@ -90355,67 +90934,164 @@ var ts; else { changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); } - return { - scope: scope, - scopeDescription: getDescriptionForScope(scope), - changes: changeTracker.getChanges() - }; - function getPropertyAssignmentsForWrites(writes) { - return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + var edits = changeTracker.getChanges(); + var renameRange = isReadonlyArray(range.range) ? range.range[0] : range.range; + var renameFilename = renameRange.getSourceFile().fileName; + var renameLocation = getRenameLocation(edits, renameFilename, functionNameText); + return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + } + function getRenameLocation(edits, renameFilename, functionNameText) { + var delta = 0; + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; + ts.Debug.assert(fileName === renameFilename); + for (var _b = 0, textChanges_2 = textChanges_1; _b < textChanges_2.length; _b++) { + var change = textChanges_2[_b]; + var span_17 = change.span, newText = change.newText; + // TODO(acasey): We are assuming that the call expression comes before the function declaration, + // because we want the new cursor to be on the call expression, + // which is closer to where the user was before extracting the function. + var index = newText.indexOf(functionNameText); + if (index !== -1) { + return span_17.start + delta + index; + } + delta += newText.length - span_17.length; + } } - function generateReturnValueProperty() { - return "__return"; + throw new Error(); // Didn't find the text we inserted? + } + function getFirstDeclaration(type) { + var firstDeclaration = undefined; + var symbol = type.symbol; + if (symbol && symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { + firstDeclaration = declaration; + } + } } - function transformFunctionBody(body) { - if (ts.isBlock(body) && !writes && substitutions.size === 0) { - // already block, no writes to propagate back, no substitutions - can use node as is - return { body: ts.createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; - } - var returnValueProperty; - var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); - // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions - if (writes || substitutions.size) { - var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); - if (writes && !(range.facts & RangeFacts.HasReturn) && ts.isStatement(body)) { - // add return at the end to propagate writes back in case if control flow falls out of the function body - // it is ok to know that range has at least one return since it we only allow unconditional returns - var assignments = getPropertyAssignmentsForWrites(writes); - if (assignments.length === 1) { - rewrittenStatements.push(ts.createReturn(assignments[0].name)); - } - else { - rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); - } + return firstDeclaration; + } + function compareTypesByDeclarationOrder(_a, _b) { + var type1 = _a.type, declaration1 = _a.declaration; + var type2 = _b.type, declaration2 = _b.declaration; + if (declaration1) { + if (declaration2) { + var positionDiff = declaration1.pos - declaration2.pos; + if (positionDiff !== 0) { + return positionDiff; } - return { body: ts.createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty: returnValueProperty }; } else { - return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; + return 1; // Sort undeclared type parameters to the front. } - function visitor(node) { - if (node.kind === 219 /* ReturnStatement */ && writes) { - var assignments = getPropertyAssignmentsForWrites(writes); - if (node.expression) { - if (!returnValueProperty) { - returnValueProperty = generateReturnValueProperty(); - } - assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); - } - if (assignments.length === 1) { - return ts.createReturn(assignments[0].name); - } - else { - return ts.createReturn(ts.createObjectLiteral(assignments)); - } + } + else if (declaration2) { + return -1; // Sort undeclared type parameters to the front. + } + var name1 = type1.symbol ? type1.symbol.getName() : ""; + var name2 = type2.symbol ? type2.symbol.getName() : ""; + var nameDiff = ts.compareStrings(name1, name2); + if (nameDiff !== 0) { + return nameDiff; + } + // IDs are guaranteed to be unique, so this ensures a total ordering. + return type1.id - type2.id; + } + function getCalledExpression(scope, range, functionNameText) { + var functionReference = ts.createIdentifier(functionNameText); + if (ts.isClassLike(scope)) { + var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); + return ts.createPropertyAccess(lhs, functionReference); + } + else { + return functionReference; + } + } + function transformFunctionBody(body, writes, substitutions, hasReturn) { + if (ts.isBlock(body) && !writes && substitutions.size === 0) { + // already block, no writes to propagate back, no substitutions - can use node as is + return { body: ts.createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; + } + var returnValueProperty; + var ignoreReturns = false; + var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); + // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions + if (writes || substitutions.size) { + var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); + if (writes && !hasReturn && ts.isStatement(body)) { + // add return at the end to propagate writes back in case if control flow falls out of the function body + // it is ok to know that range has at least one return since it we only allow unconditional returns + var assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(ts.createReturn(assignments[0].name)); } else { - var substitution = substitutions.get(ts.getNodeId(node).toString()); - return substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); } } + return { body: ts.createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty: returnValueProperty }; + } + else { + return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; + } + function visitor(node) { + if (!ignoreReturns && node.kind === 219 /* ReturnStatement */ && writes) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (node.expression) { + if (!returnValueProperty) { + returnValueProperty = "__return"; + } + assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); + } + if (assignments.length === 1) { + return ts.createReturn(assignments[0].name); + } + else { + return ts.createReturn(ts.createObjectLiteral(assignments)); + } + } + else { + var oldIgnoreReturns = ignoreReturns; + ignoreReturns = ignoreReturns || ts.isFunctionLike(node) || ts.isClassLike(node); + var substitution = substitutions.get(ts.getNodeId(node).toString()); + var result = substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + ignoreReturns = oldIgnoreReturns; + return result; + } } } - extractMethod_1.extractFunctionInScope = extractFunctionInScope; + function getStatementsOrClassElements(scope) { + if (ts.isFunctionLike(scope)) { + var body = scope.body; + if (ts.isBlock(body)) { + return body.statements; + } + } + else if (ts.isModuleBlock(scope) || ts.isSourceFile(scope)) { + return scope.statements; + } + else if (ts.isClassLike(scope)) { + return scope.members; + } + else { + ts.assertTypeIsNever(scope); + } + return ts.emptyArray; + } + /** + * If `scope` contains a function after `minPos`, then return the first such function. + * Otherwise, return `undefined`. + */ + function getNodeToInsertBefore(minPos, scope) { + return ts.find(getStatementsOrClassElements(scope), function (child) { + return child.pos >= minPos && ts.isFunctionLike(child) && !ts.isConstructorDeclaration(child); + }); + } + function getPropertyAssignmentsForWrites(writes) { + return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + } function isReadonlyArray(v) { return ts.isArray(v); } @@ -90440,7 +91116,8 @@ var ts; // value should be passed to extracted method and propagated back Usage[Usage["Write"] = 2] = "Write"; })(Usage || (Usage = {})); - function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker) { + function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker, cancellationToken) { + var allTypeParameterUsages = ts.createMap(); // Key is type ID var usagesPerScope = []; var substitutionsPerScope = []; var errorsPerScope = []; @@ -90448,14 +91125,50 @@ var ts; // initialize results for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { var _ = scopes_1[_i]; - usagesPerScope.push({ usages: ts.createMap(), substitutions: ts.createMap() }); + usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); errorsPerScope.push([]); } var seenUsages = ts.createMap(); var target = isReadonlyArray(targetRange.range) ? ts.createBlock(targetRange.range) : targetRange.range; var containingLexicalScopeOfExtraction = ts.isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : ts.getEnclosingBlockScopeContainer(scopes[0]); + var unmodifiedNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; + var inGenericContext = isInGenericContext(unmodifiedNode); collectUsages(target); + // Unfortunately, this code takes advantage of the knowledge that the generated method + // will use the contextual type of an expression as the return type of the extracted + // method (and will therefore "use" all the types involved). + if (inGenericContext && !isReadonlyArray(targetRange.range)) { + var contextualType = checker.getContextualType(targetRange.range); + recordTypeParameterUsages(contextualType); + } + if (allTypeParameterUsages.size > 0) { + var seenTypeParameterUsages = ts.createMap(); // Key is type ID + var i_1 = 0; + for (var curr = unmodifiedNode; curr !== undefined && i_1 < scopes.length; curr = curr.parent) { + if (curr === scopes[i_1]) { + // Copy current contents of seenTypeParameterUsages into scope. + seenTypeParameterUsages.forEach(function (typeParameter, id) { + usagesPerScope[i_1].typeParameterUsages.set(id, typeParameter); + }); + i_1++; + } + // Note that we add the current node's type parameters *after* updating the corresponding scope. + if (ts.isDeclarationWithTypeParameters(curr) && curr.typeParameters) { + for (var _a = 0, _b = curr.typeParameters; _a < _b.length; _a++) { + var typeParameterDecl = _b[_a]; + var typeParameter = checker.getTypeAtLocation(typeParameterDecl); + if (allTypeParameterUsages.has(typeParameter.id.toString())) { + seenTypeParameterUsages.set(typeParameter.id.toString(), typeParameter); + } + } + } + } + // If we didn't get through all the scopes, then there were some that weren't in our + // parent chain (impossible at time of writing). A conservative solution would be to + // copy allTypeParameterUsages into all remaining scopes. + ts.Debug.assert(i_1 === scopes.length); + } var _loop_8 = function (i) { var hasWrite = false; var readonlyClassPropertyWrite = undefined; @@ -90473,7 +91186,7 @@ var ts; errorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); } else if (readonlyClassPropertyWrite && i > 0) { - errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor)); } }; for (var i = 0; i < scopes.length; i++) { @@ -90485,8 +91198,38 @@ var ts; ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } return { target: target, usagesPerScope: usagesPerScope, errorsPerScope: errorsPerScope }; + function hasTypeParameters(node) { + return ts.isDeclarationWithTypeParameters(node) && + node.typeParameters !== undefined && + node.typeParameters.length > 0; + } + function isInGenericContext(node) { + for (; node; node = node.parent) { + if (hasTypeParameters(node)) { + return true; + } + } + return false; + } + function recordTypeParameterUsages(type) { + // PERF: This is potentially very expensive. `type` could be a library type with + // a lot of properties, each of which the walker will visit. Unfortunately, the + // solution isn't as trivial as filtering to user types because of (e.g.) Array. + var symbolWalker = checker.getSymbolWalker(function () { return (cancellationToken.throwIfCancellationRequested(), true); }); + var visitedTypes = symbolWalker.walkType(type).visitedTypes; + for (var _i = 0, visitedTypes_1 = visitedTypes; _i < visitedTypes_1.length; _i++) { + var visitedType = visitedTypes_1[_i]; + if (visitedType.flags & 16384 /* TypeParameter */) { + allTypeParameterUsages.set(visitedType.id.toString(), visitedType); + } + } + } function collectUsages(node, valueUsage) { if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (inGenericContext) { + var type = checker.getTypeAtLocation(node); + recordTypeParameterUsages(type); + } if (ts.isDeclaration(node) && node.symbol) { visibleDeclarationsInExtractedRange.push(node.symbol); } @@ -90531,7 +91274,11 @@ var ts; } } function recordUsagebySymbol(identifier, usage, isTypeName) { - var symbol = checker.getSymbolAtLocation(identifier); + // If the identifier is both a property name and its value, we're only interested in its value + // (since the name is a declaration and will be included in the extracted range). + var symbol = identifier.parent && ts.isShorthandPropertyAssignment(identifier.parent) && identifier.parent.name === identifier + ? checker.getShorthandAssignmentValueSymbol(identifier.parent) + : checker.getSymbolAtLocation(identifier); if (!symbol) { // cannot find symbol - do nothing return undefined; @@ -90565,7 +91312,7 @@ var ts; if (!declInFile) { return undefined; } - if (ts.rangeContainsRange(enclosingTextRange, declInFile)) { + if (ts.rangeContainsStartEnd(enclosingTextRange, declInFile.getStart(), declInFile.end)) { // declaration is located in range to be extracted - do nothing return undefined; } @@ -90589,7 +91336,11 @@ var ts; substitutionsPerScope[i].set(symbolId, substitution); } else if (isTypeName) { - errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument + // so there's no problem. + if (!(symbol.flags & 262144 /* TypeParameter */)) { + errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } } else { usagesPerScope[i].usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); @@ -91237,6 +91988,11 @@ var ts; } } break; + case 194 /* BinaryExpression */: + if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { + addDeclaration(node); + } + // falls through default: ts.forEachChild(node, visit); } @@ -91582,7 +92338,7 @@ var ts; oldSettings.noResolve !== newSettings.noResolve || oldSettings.jsx !== newSettings.jsx || oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.disableSizeLimit !== newSettings.disableSizeLimit || oldSettings.baseUrl !== newSettings.baseUrl || !ts.equalOwnProperties(oldSettings.paths, newSettings.paths)); // Now create a new compiler @@ -91760,7 +92516,7 @@ var ts; /// Diagnostics function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } /** * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors @@ -91773,11 +92529,11 @@ var ts; // Therefore only get diagnostics for given file. var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; + return semanticDiagnostics.slice(); } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return ts.concatenate(semanticDiagnostics, declarationDiagnostics); + return semanticDiagnostics.concat(declarationDiagnostics); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); @@ -91806,7 +92562,7 @@ var ts; return undefined; } var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); + var symbol = getSymbolAtLocationForQuickInfo(node, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { @@ -91841,6 +92597,20 @@ var ts; tags: displayPartsDocumentationsAndKind.tags }; } + function getSymbolAtLocationForQuickInfo(node, checker) { + if ((ts.isIdentifier(node) || ts.isStringLiteral(node)) + && ts.isPropertyAssignment(node.parent) + && node.parent.name === node) { + var type = checker.getContextualType(node.parent.parent); + if (type) { + var property = checker.getPropertyOfType(type, ts.getTextOfIdentifierOrLiteral(node)); + if (property) { + return property; + } + } + } + return checker.getSymbolAtLocation(node); + } /// Goto definition function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); @@ -91903,7 +92673,20 @@ var ts; } function getReferences(fileName, position, options) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); + // Exclude default library when renaming as commonly user don't want to change that file. + var sourceFiles = []; + if (options && options.isForRename) { + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + if (!program.isSourceFileDefaultLibrary(sourceFile)) { + sourceFiles.push(sourceFile); + } + } + } + else { + sourceFiles = program.getSourceFiles().slice(); + } + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -92304,7 +93087,7 @@ var ts; startPosition: startPosition, endPosition: endPosition, program: getProgram(), - newLineCharacter: host.getNewLine(), + newLineCharacter: formatOptions ? formatOptions.newLineCharacter : host.getNewLine(), rulesProvider: getRuleProvider(formatOptions), cancellationToken: cancellationToken }; @@ -92385,7 +93168,7 @@ var ts; nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); } ts.forEachChild(node, walk); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; ts.forEachChild(jsDoc, walk); diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 0b54986035c..4bce953f667 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -446,6 +446,9 @@ declare namespace ts { modifiers?: ModifiersArray; parent?: Node; } + interface JSDocContainer { + } + type HasJSDoc = ParameterDeclaration | CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | PropertySignature | ArrowFunction | ParenthesizedExpression | SpreadAssignment | ShorthandPropertyAssignment | PropertyAssignment | FunctionExpression | LabeledStatement | ExpressionStatement | VariableStatement | FunctionDeclaration | ConstructorDeclaration | MethodDeclaration | PropertyDeclaration | AccessorDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumMember | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | EndOfFileToken; interface NodeArray extends ReadonlyArray, TextRange { hasTrailingComma?: boolean; } @@ -458,7 +461,7 @@ declare namespace ts { type EqualsToken = Token; type AsteriskToken = Token; type EqualsGreaterThanToken = Token; - type EndOfFileToken = Token; + type EndOfFileToken = Token & JSDocContainer; type AtToken = Token; type ReadonlyToken = Token; type AwaitKeywordToken = Token; @@ -500,6 +503,7 @@ declare namespace ts { } interface Decorator extends Node { kind: SyntaxKind.Decorator; + parent?: NamedDeclaration; expression: LeftHandSideExpression; } interface TypeParameterDeclaration extends NamedDeclaration { @@ -510,16 +514,18 @@ declare namespace ts { default?: TypeNode; expression?: Expression; } - interface SignatureDeclaration extends NamedDeclaration { + interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { + kind: SignatureDeclaration["kind"]; name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; - type?: TypeNode; + type: TypeNode | undefined; } - interface CallSignatureDeclaration extends SignatureDeclaration, TypeElement { + type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; + interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.CallSignature; } - interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { + interface ConstructSignatureDeclaration extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.ConstructSignature; } type BindingName = Identifier | BindingPattern; @@ -535,7 +541,7 @@ declare namespace ts { parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } - interface ParameterDeclaration extends NamedDeclaration { + interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.Parameter; parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; @@ -552,14 +558,14 @@ declare namespace ts { name: BindingName; initializer?: Expression; } - interface PropertySignature extends TypeElement { + interface PropertySignature extends TypeElement, JSDocContainer { kind: SyntaxKind.PropertySignature; name: PropertyName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; } - interface PropertyDeclaration extends ClassElement { + interface PropertyDeclaration extends ClassElement, JSDocContainer { kind: SyntaxKind.PropertyDeclaration; questionToken?: QuestionToken; name: PropertyName; @@ -571,27 +577,30 @@ declare namespace ts { name?: PropertyName; } type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; - interface PropertyAssignment extends ObjectLiteralElement { + interface PropertyAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.PropertyAssignment; name: PropertyName; questionToken?: QuestionToken; initializer: Expression; } - interface ShorthandPropertyAssignment extends ObjectLiteralElement { + interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.ShorthandPropertyAssignment; name: Identifier; questionToken?: QuestionToken; equalsToken?: Token; objectAssignmentInitializer?: Expression; } - interface SpreadAssignment extends ObjectLiteralElement { + interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { + parent: ObjectLiteralExpression; kind: SyntaxKind.SpreadAssignment; expression: Expression; } interface VariableLikeDeclaration extends NamedDeclaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; - name?: DeclarationName; + name: DeclarationName; questionToken?: QuestionToken; type?: TypeNode; initializer?: Expression; @@ -619,7 +628,7 @@ declare namespace ts { * - MethodDeclaration * - AccessorDeclaration */ - interface FunctionLikeDeclarationBase extends SignatureDeclaration { + interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; asteriskToken?: AsteriskToken; questionToken?: QuestionToken; @@ -632,16 +641,16 @@ declare namespace ts { name?: Identifier; body?: FunctionBody; } - interface MethodSignature extends SignatureDeclaration, TypeElement { + interface MethodSignature extends SignatureDeclarationBase, TypeElement { kind: SyntaxKind.MethodSignature; name: PropertyName; } - interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.MethodDeclaration; name: PropertyName; body?: FunctionBody; } - interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement { + interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { kind: SyntaxKind.Constructor; parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; @@ -651,20 +660,20 @@ declare namespace ts { kind: SyntaxKind.SemicolonClassElement; parent?: ClassDeclaration | ClassExpression; } - interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.GetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } - interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement { + interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { kind: SyntaxKind.SetAccessor; parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; - interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { + interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } @@ -678,10 +687,10 @@ declare namespace ts { kind: SyntaxKind.ThisType; } type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; - interface FunctionTypeNode extends TypeNode, SignatureDeclaration { + interface FunctionTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { + interface ConstructorTypeNode extends TypeNode, SignatureDeclarationBase { kind: SyntaxKind.ConstructorType; } type TypeReferenceType = TypeReferenceNode | ExpressionWithTypeArguments; @@ -692,6 +701,7 @@ declare namespace ts { } interface TypePredicateNode extends TypeNode { kind: SyntaxKind.TypePredicate; + parent?: SignatureDeclaration; parameterName: Identifier | ThisTypeNode; type: TypeNode; } @@ -736,7 +746,6 @@ declare namespace ts { } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; - parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -744,7 +753,7 @@ declare namespace ts { } interface LiteralTypeNode extends TypeNode { kind: SyntaxKind.LiteralType; - literal: Expression; + literal: BooleanLiteral | LiteralExpression | PrefixUnaryExpression; } interface StringLiteral extends LiteralExpression { kind: SyntaxKind.StringLiteral; @@ -879,12 +888,12 @@ declare namespace ts { } type FunctionBody = Block; type ConciseBody = FunctionBody | Expression; - interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase { + interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.FunctionExpression; name?: Identifier; body: FunctionBody; } - interface ArrowFunction extends Expression, FunctionLikeDeclarationBase { + interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { kind: SyntaxKind.ArrowFunction; equalsGreaterThanToken: EqualsGreaterThanToken; body: ConciseBody; @@ -930,7 +939,7 @@ declare namespace ts { expression: Expression; literal: TemplateMiddle | TemplateTail; } - interface ParenthesizedExpression extends PrimaryExpression { + interface ParenthesizedExpression extends PrimaryExpression, JSDocContainer { kind: SyntaxKind.ParenthesizedExpression; expression: Expression; } @@ -940,6 +949,7 @@ declare namespace ts { } interface SpreadElement extends Expression { kind: SyntaxKind.SpreadElement; + parent?: ArrayLiteralExpression | CallExpression | NewExpression; expression: Expression; } /** @@ -1107,11 +1117,11 @@ declare namespace ts { kind: SyntaxKind.Block; statements: NodeArray; } - interface VariableStatement extends Statement { + interface VariableStatement extends Statement, JSDocContainer { kind: SyntaxKind.VariableStatement; declarationList: VariableDeclarationList; } - interface ExpressionStatement extends Statement { + interface ExpressionStatement extends Statement, JSDocContainer { kind: SyntaxKind.ExpressionStatement; expression: Expression; } @@ -1192,7 +1202,7 @@ declare namespace ts { statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; - interface LabeledStatement extends Statement { + interface LabeledStatement extends Statement, JSDocContainer { kind: SyntaxKind.LabeledStatement; label: Identifier; statement: Statement; @@ -1214,19 +1224,21 @@ declare namespace ts { block: Block; } type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration | JSDocTemplateTag; - interface ClassLikeDeclaration extends NamedDeclaration { + interface ClassLikeDeclarationBase extends NamedDeclaration, JSDocContainer { + kind: SyntaxKind.ClassDeclaration | SyntaxKind.ClassExpression; name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; members: NodeArray; } - interface ClassDeclaration extends ClassLikeDeclaration, DeclarationStatement { + interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { kind: SyntaxKind.ClassDeclaration; name?: Identifier; } - interface ClassExpression extends ClassLikeDeclaration, PrimaryExpression { + interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { kind: SyntaxKind.ClassExpression; } + type ClassLikeDeclaration = ClassDeclaration | ClassExpression; interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; @@ -1236,7 +1248,7 @@ declare namespace ts { name?: PropertyName; questionToken?: QuestionToken; } - interface InterfaceDeclaration extends DeclarationStatement { + interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.InterfaceDeclaration; name: Identifier; typeParameters?: NodeArray; @@ -1249,26 +1261,26 @@ declare namespace ts { token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; types: NodeArray; } - interface TypeAliasDeclaration extends DeclarationStatement { + interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.TypeAliasDeclaration; name: Identifier; typeParameters?: NodeArray; type: TypeNode; } - interface EnumMember extends NamedDeclaration { + interface EnumMember extends NamedDeclaration, JSDocContainer { kind: SyntaxKind.EnumMember; parent?: EnumDeclaration; name: PropertyName; initializer?: Expression; } - interface EnumDeclaration extends DeclarationStatement { + interface EnumDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.EnumDeclaration; name: Identifier; members: NodeArray; } type ModuleName = Identifier | StringLiteral; type ModuleBody = NamespaceBody | JSDocNamespaceBody; - interface ModuleDeclaration extends DeclarationStatement { + interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ModuleDeclaration; parent?: ModuleBody | SourceFile; name: ModuleName; @@ -1295,7 +1307,7 @@ declare namespace ts { * - import x = require("mod"); * - import x = M.x; */ - interface ImportEqualsDeclaration extends DeclarationStatement { + interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { kind: SyntaxKind.ImportEqualsDeclaration; parent?: SourceFile | ModuleBlock; name: Identifier; @@ -1407,7 +1419,7 @@ declare namespace ts { kind: SyntaxKind.JSDocOptionalType; type: TypeNode; } - interface JSDocFunctionType extends JSDocType, SignatureDeclaration { + interface JSDocFunctionType extends JSDocType, SignatureDeclarationBase { kind: SyntaxKind.JSDocFunctionType; } interface JSDocVariadicType extends JSDocType { @@ -1417,6 +1429,7 @@ declare namespace ts { type JSDocTypeReferencingNode = JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; interface JSDoc extends Node { kind: SyntaxKind.JSDocComment; + parent?: HasJSDoc; tags: NodeArray | undefined; comment: string | undefined; } @@ -1472,7 +1485,6 @@ declare namespace ts { interface JSDocTypeLiteral extends JSDocType { kind: SyntaxKind.JSDocTypeLiteral; jsDocPropertyTags?: ReadonlyArray; - jsDocTypeTag?: JSDocTypeTag; /** If true, then this type literal represents an *array* of its type. */ isArrayType?: boolean; } @@ -1547,10 +1559,10 @@ declare namespace ts { endOfFileToken: Token; fileName: string; text: string; - amdDependencies: AmdDependency[]; + amdDependencies: ReadonlyArray; moduleName: string; - referencedFiles: FileReference[]; - typeReferenceDirectives: FileReference[]; + referencedFiles: ReadonlyArray; + typeReferenceDirectives: ReadonlyArray; languageVariant: LanguageVariant; isDeclarationFile: boolean; /** @@ -1566,7 +1578,7 @@ declare namespace ts { } interface Bundle extends Node { kind: SyntaxKind.Bundle; - sourceFiles: SourceFile[]; + sourceFiles: ReadonlyArray; } interface JsonSourceFile extends SourceFile { jsonObject?: ObjectLiteralExpression; @@ -1589,7 +1601,7 @@ declare namespace ts { readFile(path: string): string | undefined; } interface WriteFileCallback { - (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray): void; + (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray): void; } class OperationCanceledException { } @@ -1602,11 +1614,11 @@ declare namespace ts { /** * Get a list of root file names that were passed to a 'createProgram' */ - getRootFileNames(): string[]; + getRootFileNames(): ReadonlyArray; /** * Get a list of files in the program */ - getSourceFiles(): SourceFile[]; + getSourceFiles(): ReadonlyArray; /** * Emits the JavaScript and declaration files. If targetSourceFile is not specified, then * the JavaScript and declaration files will be produced for all the files in this program. @@ -1618,15 +1630,16 @@ declare namespace ts { * will be invoked when writing the JavaScript and declaration files. */ emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; - getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; - getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; - getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; + getOptionsDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getGlobalDiagnostics(cancellationToken?: CancellationToken): ReadonlyArray; + getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getSemanticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /** - * Gets a type checker that can be used to semantically analyze source fils in the program. + * Gets a type checker that can be used to semantically analyze source files in the program. */ getTypeChecker(): TypeChecker; + isSourceFileFromExternalLibrary(file: SourceFile): boolean; } interface CustomTransformers { /** Custom transformers to evaluate before built-in transformations. */ @@ -1669,7 +1682,7 @@ declare namespace ts { interface EmitResult { emitSkipped: boolean; /** Contains declaration emit diagnostics */ - diagnostics: Diagnostic[]; + diagnostics: ReadonlyArray; emittedFiles: string[]; } interface TypeChecker { @@ -1970,6 +1983,7 @@ declare namespace ts { IndexedAccess = 524288, NonPrimitive = 16777216, Literal = 224, + Unit = 6368, StringOrNumberLiteral = 96, PossiblyFalsy = 7406, StringLike = 262178, @@ -2172,7 +2186,7 @@ declare namespace ts { interface PluginImport { name: string; } - type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[]; + type CompilerOptionsValue = string | number | boolean | (string | number)[] | string[] | MapLike | PluginImport[] | null | undefined; interface CompilerOptions { allowJs?: boolean; allowSyntheticDefaultImports?: boolean; @@ -2372,6 +2386,11 @@ declare namespace ts { * If accessing a non-index file, this should include its name e.g. "foo/bar". */ name: string; + /** + * Name of a submodule within this package. + * May be "". + */ + subModuleName: string; /** Version of the package, e.g. "1.2.3" */ version: string; } @@ -2388,14 +2407,15 @@ declare namespace ts { interface ResolvedTypeReferenceDirective { primary: boolean; resolvedFileName?: string; + packageId?: PackageId; } interface ResolvedTypeReferenceDirectiveWithFailedLookupLocations { resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective; failedLookupLocations: string[]; } interface CompilerHost extends ModuleResolutionHost { - getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined; + getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined; getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; getDefaultLibLocation?(): string; @@ -2460,7 +2480,8 @@ declare namespace ts { SourceFile = 0, Expression = 1, IdentifierName = 2, - Unspecified = 3, + MappedTypeParameter = 3, + Unspecified = 4, } interface TransformationContext { /** Gets the compiler options supplied to the transformer. */ @@ -2639,6 +2660,9 @@ declare namespace ts { /** The version of the TypeScript compiler release */ const version: string; } +declare namespace ts { + function isExternalModuleNameRelative(moduleName: string): boolean; +} declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; declare namespace ts { @@ -2834,7 +2858,60 @@ declare namespace ts { * @returns The unescaped identifier text. */ function unescapeIdentifier(id: string): string; - function getNameOfDeclaration(declaration: Declaration): DeclarationName | undefined; + function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | undefined; + function getNameOfDeclaration(declaration: Declaration | Expression): DeclarationName | undefined; + /** + * Gets the JSDoc parameter tags for the node if present. + * + * @remarks Returns any JSDoc param tag that matches the provided + * parameter, whether a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the param + * tag on the containing function expression would be first. + * + * Does not return tags for binding patterns, because JSDoc matches + * parameters by name and binding patterns do not have a name. + */ + function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray | undefined; + /** + * Return true if the node has JSDoc parameter tags. + * + * @remarks Includes parameter tags that are not directly on the node, + * for example on a variable declaration whose initializer is a function expression. + */ + function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean; + /** Gets the JSDoc augments tag for the node if present */ + function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined; + /** Gets the JSDoc class tag for the node if present */ + function getJSDocClassTag(node: Node): JSDocClassTag | undefined; + /** Gets the JSDoc return tag for the node if present */ + function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined; + /** Gets the JSDoc template tag for the node if present */ + function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined; + /** Gets the JSDoc type tag for the node if present and valid */ + function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined; + /** + * Gets the type node for the node if provided via JSDoc. + * + * @remarks The search includes any JSDoc param tag that relates + * to the provided parameter, for example a type tag on the + * parameter itself, or a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are examined first, so in the previous example, the type + * tag directly on the node would be returned. + */ + function getJSDocType(node: Node): TypeNode | undefined; + /** + * Gets the return type node for the node if provided via JSDoc's return tag. + * + * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function + * gets the type from inside the braces. + */ + function getJSDocReturnType(node: Node): TypeNode | undefined; + /** Get all JSDoc tags related to a node, including those on parent nodes. */ + function getJSDocTags(node: Node): ReadonlyArray | undefined; } declare namespace ts { function isNumericLiteral(node: Node): node is NumericLiteral; @@ -3184,8 +3261,8 @@ declare namespace ts { function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; - function createLiteralTypeNode(literal: Expression): LiteralTypeNode; - function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode; + function createLiteralTypeNode(literal: LiteralTypeNode["literal"]): LiteralTypeNode; + function updateLiteralTypeNode(node: LiteralTypeNode, literal: LiteralTypeNode["literal"]): LiteralTypeNode; function createObjectBindingPattern(elements: ReadonlyArray): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: ReadonlyArray): ObjectBindingPattern; function createArrayBindingPattern(elements: ReadonlyArray): ArrayBindingPattern; @@ -3214,6 +3291,7 @@ declare namespace ts { function updateFunctionExpression(node: FunctionExpression, modifiers: ReadonlyArray | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: Block): FunctionExpression; function createArrowFunction(modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: ReadonlyArray | undefined, typeParameters: ReadonlyArray | undefined, parameters: ReadonlyArray, type: TypeNode | undefined, equalsGreaterThanToken: Token, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -3231,8 +3309,13 @@ declare namespace ts { function createConditional(condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; function createConditional(condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; function updateConditional(node: ConditionalExpression, condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + function updateConditional(node: ConditionalExpression, condition: Expression, questionToken: Token, whenTrue: Expression, colonToken: Token, whenFalse: Expression): ConditionalExpression; function createTemplateExpression(head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: ReadonlyArray): TemplateExpression; + function createTemplateHead(text: string): TemplateHead; + function createTemplateMiddle(text: string): TemplateMiddle; + function createTemplateTail(text: string): TemplateTail; + function createNoSubstitutionTemplateLiteral(text: string): NoSubstitutionTemplateLiteral; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; @@ -3388,10 +3471,12 @@ declare namespace ts { function updatePartiallyEmittedExpression(node: PartiallyEmittedExpression, expression: Expression): PartiallyEmittedExpression; function createCommaList(elements: ReadonlyArray): CommaListExpression; function updateCommaList(node: CommaListExpression, elements: ReadonlyArray): CommaListExpression; - function createBundle(sourceFiles: SourceFile[]): Bundle; - function updateBundle(node: Bundle, sourceFiles: SourceFile[]): Bundle; + function createBundle(sourceFiles: ReadonlyArray): Bundle; + function updateBundle(node: Bundle, sourceFiles: ReadonlyArray): Bundle; function createImmediatelyInvokedFunctionExpression(statements: Statement[]): CallExpression; function createImmediatelyInvokedFunctionExpression(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: Statement[]): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; function createComma(left: Expression, right: Expression): Expression; function createLessThan(left: Expression, right: Expression): Expression; function createAssignment(left: ObjectLiteralExpression | ArrayLiteralExpression, right: Expression): DestructuringAssignment; @@ -3575,8 +3660,8 @@ declare namespace ts { getCanonicalFileName(fileName: string): string; getNewLine(): string; } - function formatDiagnostics(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; - function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string; + function formatDiagnostics(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; + function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string; function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string; /** * Create a new 'Program' instance. A Program is an immutable collection of 'SourceFile's and a 'CompilerOptions' @@ -3591,7 +3676,7 @@ declare namespace ts { * @param oldProgram - Reuses an old program structure. * @returns A 'Program' object. */ - function createProgram(rootNames: string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; + function createProgram(rootNames: ReadonlyArray, options: CompilerOptions, host?: CompilerHost, oldProgram?: Program): Program; } declare namespace ts { function parseCommandLine(commandLine: ReadonlyArray, readFile?: (path: string) => string | undefined): ParsedCommandLine; @@ -3700,7 +3785,7 @@ declare namespace ts { interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; getLineEndOfPosition(pos: number): number; - getLineStarts(): number[]; + getLineStarts(): ReadonlyArray; getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } @@ -3917,7 +4002,7 @@ declare namespace ts { * Represents a single refactoring action - for example, the "Extract Method..." refactor might * offer several actions, each corresponding to a surround class or closure to extract into. */ - type RefactorActionInfo = { + interface RefactorActionInfo { /** * The programmatic name of the refactoring action */ @@ -3928,16 +4013,16 @@ declare namespace ts { * so this description should make sense by itself if the parent is inlineable=true */ description: string; - }; + } /** * A set of edits to make in response to a refactor action, plus an optional * location where renaming should be invoked from */ - type RefactorEditInfo = { + interface RefactorEditInfo { edits: FileTextChanges[]; - renameFilename?: string; - renameLocation?: number; - }; + renameFilename: string | undefined; + renameLocation: number | undefined; + } interface TextInsertion { newText: string; /** The position in newText the caret should point to after the insertion. */ diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index f1356d558c6..4128b5d17fa 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -800,6 +800,7 @@ var ts; /* @internal */ TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 6368] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; /* @internal */ TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; @@ -1200,6 +1201,7 @@ var ts; EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; + /*@internal*/ EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); /** * Used by the checker, this enum keeps track of external emit helpers that should be type @@ -1242,7 +1244,8 @@ var ts; EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; EmitHint[EmitHint["Expression"] = 1] = "Expression"; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; - EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; + EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); /*@internal*/ @@ -1349,6 +1352,15 @@ var ts; /** The version of the TypeScript compiler release */ ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); +(function (ts) { + function isExternalModuleNameRelative(moduleName) { + // TypeScript 1.0 spec (April 2014): 11.2.1 + // An external module name is "relative" if the first term is "." or "..". + // Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module. + return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; +})(ts || (ts = {})); /* @internal */ (function (ts) { // More efficient to create a collator once and use its `compare` than to call `a.localeCompare(b)` many times. @@ -1375,7 +1387,6 @@ var ts; return new MapCtr(); } ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap; - /* @internal */ function createSymbolTable(symbols) { var result = createMap(); if (symbols) { @@ -2063,6 +2074,32 @@ var ts; return to; } ts.addRange = addRange; + /** + * @return Whether the value was added. + */ + function pushIfUnique(array, toAdd) { + if (contains(array, toAdd)) { + return false; + } + else { + array.push(toAdd); + return true; + } + } + ts.pushIfUnique = pushIfUnique; + /** + * Unlike `pushIfUnique`, this can take `undefined` as an input, and returns a new array. + */ + function appendIfUnique(array, toAdd) { + if (array) { + pushIfUnique(array, toAdd); + return array; + } + else { + return [toAdd]; + } + } + ts.appendIfUnique = appendIfUnique; /** * Stable sort of an array. Elements equal to each other maintain their relative position in the array. */ @@ -2236,11 +2273,6 @@ var ts; ts.getProperty = getProperty; /** * Gets the owned, enumerable property keys of a map-like. - * - * NOTE: This is intended for use with MapLike objects. For Map objects, use - * Object.keys instead as it offers better performance. - * - * @param map A map-like. */ function getOwnKeys(map) { var keys = []; @@ -2252,6 +2284,16 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getOwnValues(sparseArray) { + var values = []; + for (var key in sparseArray) { + if (hasOwnProperty.call(sparseArray, key)) { + values.push(sparseArray[key]); + } + } + return values; + } + ts.getOwnValues = getOwnValues; function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { @@ -2426,6 +2468,9 @@ var ts; /** Does nothing. */ function noop() { } ts.noop = noop; + /** Returns its argument. */ + function identity(x) { return x; } + ts.identity = identity; /** Throws an error because a function is not implemented. */ function notImplemented() { throw new Error("Not implemented"); @@ -2503,12 +2548,11 @@ var ts; } ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { - var end = start + length; Debug.assertGreaterThanOrEqual(start, 0); Debug.assertGreaterThanOrEqual(length, 0); if (file) { Debug.assertLessThanOrEqual(start, file.text.length); - Debug.assertLessThanOrEqual(end, file.text.length); + Debug.assertLessThanOrEqual(start + length, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2768,21 +2812,13 @@ var ts; return path && !isRootedDiskPath(path) && path.indexOf("://") !== -1; } ts.isUrl = isUrl; - /* @internal */ function pathIsRelative(path) { return /^\.\.?($|[\\/])/.test(path); } ts.pathIsRelative = pathIsRelative; - function isExternalModuleNameRelative(moduleName) { - // TypeScript 1.0 spec (April 2014): 11.2.1 - // An external module name is "relative" if the first term is "." or "..". - // Update: We also consider a path like `C:\foo.ts` "relative" because we do not search for it in `node_modules` or treat it as an ambient module. - return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; /** @deprecated Use `!isExternalModuleNameRelative(moduleName)` instead. */ function moduleHasNonRelativeName(moduleName) { - return !isExternalModuleNameRelative(moduleName); + return !ts.isExternalModuleNameRelative(moduleName); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; function getEmitScriptTarget(compilerOptions) { @@ -2803,7 +2839,6 @@ var ts; return moduleResolution; } ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind; - /* @internal */ function hasZeroOrOneAsteriskCharacter(str) { var seenAsterisk = false; for (var i = 0; i < str.length; i++) { @@ -2821,7 +2856,7 @@ var ts; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { @@ -3021,17 +3056,14 @@ var ts; return true; } ts.containsPath = containsPath; - /* @internal */ function startsWith(str, prefix) { return str.lastIndexOf(prefix, 0) === 0; } ts.startsWith = startsWith; - /* @internal */ function removePrefix(str, prefix) { return startsWith(str, prefix) ? str.substr(prefix.length) : str; } ts.removePrefix = removePrefix; - /* @internal */ function endsWith(str, suffix) { var expectedPos = str.length - suffix.length; return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; @@ -3045,7 +3077,6 @@ var ts; return path.length > extension.length && endsWith(path, extension); } ts.fileExtensionIs = fileExtensionIs; - /* @internal */ function fileExtensionIsOneOf(path, extensions) { for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) { var extension = extensions_1[_i]; @@ -3061,7 +3092,6 @@ var ts; // proof. var reservedCharacterPattern = /[^\w\s\/]/g; var wildcardCharCodes = [42 /* asterisk */, 63 /* question */]; - /* @internal */ ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"]; var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))"; var filesMatcher = { @@ -3551,6 +3581,10 @@ var ts; throw e; } Debug.fail = fail; + function assertNever(member, message, stackCrawlMark) { + return fail(message || "Illegal value: " + member, stackCrawlMark || assertNever); + } + Debug.assertNever = assertNever; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -3617,7 +3651,6 @@ var ts; * Return an exact match if possible, or a pattern match, or undefined. * (These are verified by verifyCompilerOptions to have 0 or 1 "*" characters.) */ - /* @internal */ function matchPatternOrExact(patternStrings, candidate) { var patterns = []; for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) { @@ -3634,7 +3667,6 @@ var ts; return findBestPatternMatch(patterns, function (_) { return _; }, candidate); } ts.matchPatternOrExact = matchPatternOrExact; - /* @internal */ function patternText(_a) { var prefix = _a.prefix, suffix = _a.suffix; return prefix + "*" + suffix; @@ -3644,14 +3676,12 @@ var ts; * Given that candidate matches pattern, returns the text matching the '*'. * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" */ - /* @internal */ function matchedText(pattern, candidate) { Debug.assert(isPatternMatch(pattern, candidate)); return candidate.substr(pattern.prefix.length, candidate.length - pattern.suffix.length); } ts.matchedText = matchedText; /** Return the object corresponding to the best pattern to match `candidate`. */ - /* @internal */ function findBestPatternMatch(values, getPattern, candidate) { var matchedValue = undefined; // use length of prefix as betterness criteria @@ -3673,7 +3703,6 @@ var ts; startsWith(candidate, prefix) && endsWith(candidate, suffix); } - /* @internal */ function tryParsePattern(pattern) { // This should be verified outside of here and a proper error thrown. Debug.assert(hasZeroOrOneAsteriskCharacter(pattern)); @@ -3719,6 +3748,12 @@ var ts; return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; + function and(f, g) { + return function (arg) { return f(arg) && g(arg); }; + } + ts.and = and; + function assertTypeIsNever(_) { } + ts.assertTypeIsNever = assertTypeIsNever; })(ts || (ts = {})); /// var ts; @@ -4320,8 +4355,8 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asteri_1202", "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_defaul_1203", "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), @@ -4641,7 +4676,9 @@ var ts; Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), - Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), + Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."), + The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, ts.DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4714,6 +4751,7 @@ var ts; A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"), + The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -4831,7 +4869,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), - Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), + Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."), @@ -4936,17 +4974,16 @@ var ts; Resolving_real_path_for_0_result_1: diag(6130, ts.DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."), Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, ts.DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."), File_name_0_has_a_1_extension_stripping_it: diag(6132, ts.DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."), - _0_is_declared_but_never_used: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6133", "'{0}' is declared but never used."), + _0_is_declared_but_its_value_is_never_read: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read."), Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."), Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."), The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, ts.DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."), Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, ts.DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."), - Property_0_is_declared_but_never_used: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_never_used_6138", "Property '{0}' is declared but never used."), + Property_0_is_declared_but_its_value_is_never_read: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read."), Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."), Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, ts.DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."), Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, ts.DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."), Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."), - Module_0_was_resolved_to_1_but_allowJs_is_not_set: diag(6143, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", "Module '{0}' was resolved to '{1}', but '--allowJs' is not set."), Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."), Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."), Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."), @@ -5037,6 +5074,7 @@ var ts; Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."), Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."), JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, ts.DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."), + JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, ts.DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."), Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), @@ -5084,7 +5122,7 @@ var ts; Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), - Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), + Extract_to_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_95004", "Extract to {0}"), }; })(ts || (ts = {})); /// @@ -5364,7 +5402,7 @@ var ts; ts.Debug.assert(res < lineStarts[line + 1]); } else if (debugText !== undefined) { - ts.Debug.assert(res < debugText.length); + ts.Debug.assert(res <= debugText.length); // Allow single character overflow for trailing newline } return res; } @@ -6889,7 +6927,6 @@ var ts; } ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriter = createSingleLineStringWriter(); - var stringWriterAcquired = false; function createSingleLineStringWriter() { var str = ""; var writeText = function (text) { return str += text; }; @@ -6915,15 +6952,14 @@ var ts; }; } function usingSingleLineStringWriter(action) { + var oldString = stringWriter.string(); try { - ts.Debug.assert(!stringWriterAcquired); - stringWriterAcquired = true; action(stringWriter); return stringWriter.string(); } finally { stringWriter.clear(); - stringWriterAcquired = false; + stringWriter.writeKeyword(oldString); } } ts.usingSingleLineStringWriter = usingSingleLineStringWriter; @@ -6957,7 +6993,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.version === b.version; + return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; @@ -7116,7 +7152,7 @@ var ts; if (ts.isJSDocNode(node)) { return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } // For a syntax list, it is possible that one of its children has JSDocComment nodes, while @@ -7157,6 +7193,19 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; + /** + * Note: it is expected that the `nodeArray` and the `node` are within the same file. + * For example, searching for a `SourceFile` in a `SourceFile[]` wouldn't work. + */ + function indexOfNode(nodeArray, node) { + return ts.binarySearch(nodeArray, node, compareNodePos); + } + ts.indexOfNode = indexOfNode; + function compareNodePos(_a, _b) { + var aPos = _a.pos; + var bPos = _b.pos; + return aPos < bPos ? -1 /* LessThan */ : bPos < aPos ? 1 /* GreaterThan */ : 0 /* EqualTo */; + } /** * Gets flags that control emit behavior of a node. */ @@ -7191,6 +7240,7 @@ var ts; case 16 /* TemplateTail */: return "}" + escapeText(node.text, 96 /* backtick */) + "`"; case 8 /* NumericLiteral */: + case 12 /* RegularExpressionLiteral */: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -7304,6 +7354,34 @@ var ts; return false; } ts.isBlockScope = isBlockScope; + function isDeclarationWithTypeParameters(node) { + switch (node.kind) { + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 150 /* MethodSignature */: + case 157 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 273 /* JSDocFunctionType */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 282 /* JSDocTemplateTag */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return true; + default: + ts.assertTypeIsNever(node); + return false; + } + } + ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; // Gets the nearest enclosing block scope container that has the provided node // as a descendant, that is not the provided node. function getEnclosingBlockScopeContainer(node) { @@ -8029,59 +8107,62 @@ var ts; case 8 /* NumericLiteral */: case 9 /* StringLiteral */: case 99 /* ThisKeyword */: - var parent = node.parent; - switch (parent.kind) { - case 226 /* VariableDeclaration */: - case 146 /* Parameter */: - case 149 /* PropertyDeclaration */: - case 148 /* PropertySignature */: - case 264 /* EnumMember */: - case 261 /* PropertyAssignment */: - case 176 /* BindingElement */: - return parent.initializer === node; - case 210 /* ExpressionStatement */: - case 211 /* IfStatement */: - case 212 /* DoStatement */: - case 213 /* WhileStatement */: - case 219 /* ReturnStatement */: - case 220 /* WithStatement */: - case 221 /* SwitchStatement */: - case 257 /* CaseClause */: - case 223 /* ThrowStatement */: - return parent.expression === node; - case 214 /* ForStatement */: - var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 227 /* VariableDeclarationList */) || - forStatement.condition === node || - forStatement.incrementor === node; - case 215 /* ForInStatement */: - case 216 /* ForOfStatement */: - var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227 /* VariableDeclarationList */) || - forInStatement.expression === node; - case 184 /* TypeAssertionExpression */: - case 202 /* AsExpression */: - return node === parent.expression; - case 205 /* TemplateSpan */: - return node === parent.expression; - case 144 /* ComputedPropertyName */: - return node === parent.expression; - case 147 /* Decorator */: - case 256 /* JsxExpression */: - case 255 /* JsxSpreadAttribute */: - case 263 /* SpreadAssignment */: - return true; - case 201 /* ExpressionWithTypeArguments */: - return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - default: - if (isPartOfExpression(parent)) { - return true; - } - } + return isInExpressionContext(node); + default: + return false; } - return false; } ts.isPartOfExpression = isPartOfExpression; + function isInExpressionContext(node) { + var parent = node.parent; + switch (parent.kind) { + case 226 /* VariableDeclaration */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 264 /* EnumMember */: + case 261 /* PropertyAssignment */: + case 176 /* BindingElement */: + return parent.initializer === node; + case 210 /* ExpressionStatement */: + case 211 /* IfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 219 /* ReturnStatement */: + case 220 /* WithStatement */: + case 221 /* SwitchStatement */: + case 257 /* CaseClause */: + case 223 /* ThrowStatement */: + return parent.expression === node; + case 214 /* ForStatement */: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 227 /* VariableDeclarationList */) || + forStatement.condition === node || + forStatement.incrementor === node; + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227 /* VariableDeclarationList */) || + forInStatement.expression === node; + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: + return node === parent.expression; + case 205 /* TemplateSpan */: + return node === parent.expression; + case 144 /* ComputedPropertyName */: + return node === parent.expression; + case 147 /* Decorator */: + case 256 /* JsxExpression */: + case 255 /* JsxSpreadAttribute */: + case 263 /* SpreadAssignment */: + return true; + case 201 /* ExpressionWithTypeArguments */: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + return isPartOfExpression(parent); + } + } + ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { return node.kind === 237 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 248 /* ExternalModuleReference */; } @@ -8261,14 +8342,6 @@ var ts; node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function hasJSDocParameterTags(node) { - return !!getFirstJSDocTag(node, 279 /* JSDocParameterTag */); - } - ts.hasJSDocParameterTags = hasJSDocParameterTags; - function getFirstJSDocTag(node, kind) { - var tags = getJSDocTags(node); - return ts.find(tags, function (doc) { return doc.kind === kind; }); - } function getAllJSDocs(node) { if (ts.isJSDocTypedefTag(node)) { return [node.parent]; @@ -8276,15 +8349,6 @@ var ts; return getJSDocCommentsAndTags(node); } ts.getAllJSDocs = getAllJSDocs; - function getJSDocTags(node) { - var tags = node.jsDocCache; - // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. - if (tags === undefined) { - node.jsDocCache = tags = ts.flatMap(getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); - } - return tags; - } - ts.getJSDocTags = getJSDocTags; function getJSDocCommentsAndTags(node) { var result; getJSDocCommentsAndTagsWorker(node); @@ -8324,23 +8388,17 @@ var ts; } // Pull parameter comments from declaring function as well if (node.kind === 146 /* Parameter */) { - result = ts.addRange(result, getJSDocParameterTags(node)); + result = ts.addRange(result, ts.getJSDocParameterTags(node)); } - if (isVariableLike(node) && node.initializer) { + if (isVariableLike(node) && node.initializer && ts.hasJSDocNodes(node.initializer)) { result = ts.addRange(result, node.initializer.jsDoc); } - result = ts.addRange(result, node.jsDoc); + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); + } } } - function getJSDocParameterTags(param) { - if (param.name && ts.isIdentifier(param.name)) { - var name_1 = param.name.escapedText; - return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); - } - // a binding pattern doesn't have a name, so it's not possible to match it a jsdoc parameter, which is identified by name - return undefined; - } - ts.getJSDocParameterTags = getJSDocParameterTags; + ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ function getParameterSymbolFromJSDoc(node) { if (node.symbol) { @@ -8367,38 +8425,6 @@ var ts; return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; - function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 281 /* JSDocTypeTag */); - if (!tag && node.kind === 146 /* Parameter */) { - var paramTags = getJSDocParameterTags(node); - if (paramTags) { - tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); - } - } - return tag && tag.typeExpression && tag.typeExpression.type; - } - ts.getJSDocType = getJSDocType; - function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 277 /* JSDocAugmentsTag */); - } - ts.getJSDocAugmentsTag = getJSDocAugmentsTag; - function getJSDocClassTag(node) { - return getFirstJSDocTag(node, 278 /* JSDocClassTag */); - } - ts.getJSDocClassTag = getJSDocClassTag; - function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 280 /* JSDocReturnTag */); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocReturnType(node) { - var returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - ts.getJSDocReturnType = getJSDocReturnType; - function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 282 /* JSDocTemplateTag */); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { return isRestParameter(ts.lastOrUndefined(s.parameters)); } @@ -8410,7 +8436,7 @@ var ts; function isRestParameter(node) { if (isInJavaScriptFile(node)) { if (node.type && node.type.kind === 274 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274 /* JSDocVariadicType */; })) { + ts.forEach(ts.getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274 /* JSDocVariadicType */; })) { return true; } } @@ -8848,9 +8874,9 @@ var ts; || kind === 265 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); + function nodeIsSynthesized(range) { + return ts.positionIsSynthesized(range.pos) + || ts.positionIsSynthesized(range.end); } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFile(sourceFile) { @@ -9119,6 +9145,7 @@ var ts; "\u2029": "\\u2029", "\u0085": "\\u0085" // nextLine }); + var escapedNullRegExp = /\\0[0-9]/g; /** * Based heavily on the abstract 'Quote'/'QuoteJSONString' operation from ECMA-262 (24.3.2.2), * but augmented for a few select characters (e.g. lineSeparator, paragraphSeparator, nextLine) @@ -9128,9 +9155,12 @@ var ts; var escapedCharsRegExp = quoteChar === 96 /* backtick */ ? backtickQuoteEscapedCharsRegExp : quoteChar === 39 /* singleQuote */ ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; - return s.replace(escapedCharsRegExp, getReplacement); + return s.replace(escapedCharsRegExp, getReplacement).replace(escapedNullRegExp, nullReplacement); } ts.escapeString = escapeString; + function nullReplacement(c) { + return "\\x00" + c.charAt(c.length - 1); + } function getReplacement(c) { return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } @@ -9433,7 +9463,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocType(node); + return ts.getJSDocType(node); } } ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode; @@ -9446,7 +9476,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocReturnType(node); + return ts.getJSDocReturnType(node); } } ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode; @@ -9459,7 +9489,7 @@ var ts; return node.typeParameters; } if (isInJavaScriptFile(node)) { - var templateTag = getJSDocTemplateTag(node); + var templateTag = ts.getJSDocTemplateTag(node); return templateTag && templateTag.typeParameters; } } @@ -10127,6 +10157,45 @@ var ts; return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; + function isWriteOnlyAccess(node) { + return accessKind(node) === 1 /* Write */; + } + ts.isWriteOnlyAccess = isWriteOnlyAccess; + function isWriteAccess(node) { + return accessKind(node) !== 0 /* Read */; + } + ts.isWriteAccess = isWriteAccess; + var AccessKind; + (function (AccessKind) { + /** Only reads from a variable. */ + AccessKind[AccessKind["Read"] = 0] = "Read"; + /** Only writes to a variable without using the result. E.g.: `x++;`. */ + AccessKind[AccessKind["Write"] = 1] = "Write"; + /** Writes to a variable and uses the result as an expression. E.g.: `f(x++);`. */ + AccessKind[AccessKind["ReadWrite"] = 2] = "ReadWrite"; + })(AccessKind || (AccessKind = {})); + function accessKind(node) { + var parent = node.parent; + if (!parent) + return 0 /* Read */; + switch (parent.kind) { + case 193 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: + var operator = parent.operator; + return operator === 43 /* PlusPlusToken */ || operator === 44 /* MinusMinusToken */ ? writeOrReadWrite() : 0 /* Read */; + case 194 /* BinaryExpression */: + var _a = parent, left = _a.left, operatorToken = _a.operatorToken; + return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0 /* Read */; + case 179 /* PropertyAccessExpression */: + return parent.name !== node ? 0 /* Read */ : accessKind(parent); + default: + return 0 /* Read */; + } + function writeOrReadWrite() { + // If grandparent is not an ExpressionStatement, this is used as an expression in addition to having a side effect. + return parent.parent && parent.parent.kind === 210 /* ExpressionStatement */ ? 1 /* Write */ : 2 /* ReadWrite */; + } + } })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -10526,6 +10595,63 @@ var ts; return id; } ts.unescapeIdentifier = unescapeIdentifier; + /** + * A JSDocTypedef tag has an _optional_ name field - if a name is not directly present, we should + * attempt to draw the name from the node the declaration is on (as that declaration is what its' symbol + * will be merged with) + */ + function nameForNamelessJSDocTypedef(declaration) { + var hostNode = declaration.parent.parent; + if (!hostNode) { + return undefined; + } + // Covers classes, functions - any named declaration host node + if (ts.isDeclaration(hostNode)) { + return getDeclarationIdentifier(hostNode); + } + // Covers remaining cases + switch (hostNode.kind) { + case 208 /* VariableStatement */: + if (hostNode.declarationList && + hostNode.declarationList.declarations[0]) { + return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); + } + return undefined; + case 210 /* ExpressionStatement */: + var expr = hostNode.expression; + switch (expr.kind) { + case 179 /* PropertyAccessExpression */: + return expr.name; + case 180 /* ElementAccessExpression */: + var arg = expr.argumentExpression; + if (ts.isIdentifier(arg)) { + return arg; + } + } + return undefined; + case 1 /* EndOfFileToken */: + return undefined; + case 185 /* ParenthesizedExpression */: { + return getDeclarationIdentifier(hostNode.expression); + } + case 222 /* LabeledStatement */: { + if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { + return getDeclarationIdentifier(hostNode.statement); + } + return undefined; + } + default: + ts.Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!"); + } + } + function getDeclarationIdentifier(node) { + var name = getNameOfDeclaration(node); + return ts.isIdentifier(name) ? name : undefined; + } + function getNameOfJSDocTypedef(declaration) { + return declaration.name || nameForNamelessJSDocTypedef(declaration); + } + ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef; function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; @@ -10545,11 +10671,124 @@ var ts; return undefined; } } + else if (declaration.kind === 283 /* JSDocTypedefTag */) { + return getNameOfJSDocTypedef(declaration); + } else { return declaration.name; } } ts.getNameOfDeclaration = getNameOfDeclaration; + /** + * Gets the JSDoc parameter tags for the node if present. + * + * @remarks Returns any JSDoc param tag that matches the provided + * parameter, whether a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the param + * tag on the containing function expression would be first. + * + * Does not return tags for binding patterns, because JSDoc matches + * parameters by name and binding patterns do not have a name. + */ + function getJSDocParameterTags(param) { + if (param.name && ts.isIdentifier(param.name)) { + var name_1 = param.name.escapedText; + return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); + } + // a binding pattern doesn't have a name, so it's not possible to match it a JSDoc parameter, which is identified by name + return undefined; + } + ts.getJSDocParameterTags = getJSDocParameterTags; + /** + * Return true if the node has JSDoc parameter tags. + * + * @remarks Includes parameter tags that are not directly on the node, + * for example on a variable declaration whose initializer is a function expression. + */ + function hasJSDocParameterTags(node) { + return !!getFirstJSDocTag(node, 279 /* JSDocParameterTag */); + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; + /** Gets the JSDoc augments tag for the node if present */ + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 277 /* JSDocAugmentsTag */); + } + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + /** Gets the JSDoc class tag for the node if present */ + function getJSDocClassTag(node) { + return getFirstJSDocTag(node, 278 /* JSDocClassTag */); + } + ts.getJSDocClassTag = getJSDocClassTag; + /** Gets the JSDoc return tag for the node if present */ + function getJSDocReturnTag(node) { + return getFirstJSDocTag(node, 280 /* JSDocReturnTag */); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + /** Gets the JSDoc template tag for the node if present */ + function getJSDocTemplateTag(node) { + return getFirstJSDocTag(node, 282 /* JSDocTemplateTag */); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + /** Gets the JSDoc type tag for the node if present and valid */ + function getJSDocTypeTag(node) { + // We should have already issued an error if there were multiple type jsdocs, so just use the first one. + var tag = getFirstJSDocTag(node, 281 /* JSDocTypeTag */); + if (tag && tag.typeExpression && tag.typeExpression.type) { + return tag; + } + return undefined; + } + ts.getJSDocTypeTag = getJSDocTypeTag; + /** + * Gets the type node for the node if provided via JSDoc. + * + * @remarks The search includes any JSDoc param tag that relates + * to the provided parameter, for example a type tag on the + * parameter itself, or a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are examined first, so in the previous example, the type + * tag directly on the node would be returned. + */ + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 281 /* JSDocTypeTag */); + if (!tag && node.kind === 146 /* Parameter */) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + /** + * Gets the return type node for the node if provided via JSDoc's return tag. + * + * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function + * gets the type from inside the braces. + */ + function getJSDocReturnType(node) { + var returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + ts.getJSDocReturnType = getJSDocReturnType; + /** Get all JSDoc tags related to a node, including those on parent nodes. */ + function getJSDocTags(node) { + var tags = node.jsDocCache; + // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. + if (tags === undefined) { + node.jsDocCache = tags = ts.flatMap(ts.getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); + } + return tags; + } + ts.getJSDocTags = getJSDocTags; + /** Get the first JSDoc tag of a specified kind, or undefined if not present. */ + function getFirstJSDocTag(node, kind) { + var tags = getJSDocTags(node); + return ts.find(tags, function (doc) { return doc.kind === kind; }); + } })(ts || (ts = {})); // Simple node tests of the form `node.kind === SyntaxKind.Foo`. (function (ts) { @@ -11213,8 +11452,7 @@ var ts; // Node Arrays /* @internal */ function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + return array.hasOwnProperty("pos") && array.hasOwnProperty("end"); } ts.isNodeArray = isNodeArray; // Literals @@ -11310,16 +11548,28 @@ var ts; } ts.isFunctionLike = isFunctionLike; /* @internal */ - function isFunctionLikeKind(kind) { + function isFunctionLikeDeclaration(node) { + return node && isFunctionLikeDeclarationKind(node.kind); + } + ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; + function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 152 /* Constructor */: - case 186 /* FunctionExpression */: case 228 /* FunctionDeclaration */: - case 187 /* ArrowFunction */: case 151 /* MethodDeclaration */: - case 150 /* MethodSignature */: + case 152 /* Constructor */: case 153 /* GetAccessor */: case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return true; + default: + return false; + } + } + /* @internal */ + function isFunctionLikeKind(kind) { + switch (kind) { + case 150 /* MethodSignature */: case 155 /* CallSignature */: case 156 /* ConstructSignature */: case 157 /* IndexSignature */: @@ -11327,10 +11577,16 @@ var ts; case 273 /* JSDocFunctionType */: case 161 /* ConstructorType */: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - return false; } ts.isFunctionLikeKind = isFunctionLikeKind; + /* @internal */ + function isFunctionOrModuleBlock(node) { + return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent); + } + ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; // Classes function isClassElement(node) { var kind = node.kind; @@ -11513,54 +11769,63 @@ var ts; || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; - function isLeftHandSideExpressionKind(kind) { - return kind === 179 /* PropertyAccessExpression */ - || kind === 180 /* ElementAccessExpression */ - || kind === 182 /* NewExpression */ - || kind === 181 /* CallExpression */ - || kind === 249 /* JsxElement */ - || kind === 250 /* JsxSelfClosingElement */ - || kind === 183 /* TaggedTemplateExpression */ - || kind === 177 /* ArrayLiteralExpression */ - || kind === 185 /* ParenthesizedExpression */ - || kind === 178 /* ObjectLiteralExpression */ - || kind === 199 /* ClassExpression */ - || kind === 186 /* FunctionExpression */ - || kind === 71 /* Identifier */ - || kind === 12 /* RegularExpressionLiteral */ - || kind === 8 /* NumericLiteral */ - || kind === 9 /* StringLiteral */ - || kind === 13 /* NoSubstitutionTemplateLiteral */ - || kind === 196 /* TemplateExpression */ - || kind === 86 /* FalseKeyword */ - || kind === 95 /* NullKeyword */ - || kind === 99 /* ThisKeyword */ - || kind === 101 /* TrueKeyword */ - || kind === 97 /* SuperKeyword */ - || kind === 91 /* ImportKeyword */ - || kind === 203 /* NonNullExpression */ - || kind === 204 /* MetaProperty */; - } /* @internal */ function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 192 /* PrefixUnaryExpression */ - || kind === 193 /* PostfixUnaryExpression */ - || kind === 188 /* DeleteExpression */ - || kind === 189 /* TypeOfExpression */ - || kind === 190 /* VoidExpression */ - || kind === 191 /* AwaitExpression */ - || kind === 184 /* TypeAssertionExpression */ - || isLeftHandSideExpressionKind(kind); + function isLeftHandSideExpressionKind(kind) { + switch (kind) { + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: + case 182 /* NewExpression */: + case 181 /* CallExpression */: + case 249 /* JsxElement */: + case 250 /* JsxSelfClosingElement */: + case 183 /* TaggedTemplateExpression */: + case 177 /* ArrayLiteralExpression */: + case 185 /* ParenthesizedExpression */: + case 178 /* ObjectLiteralExpression */: + case 199 /* ClassExpression */: + case 186 /* FunctionExpression */: + case 71 /* Identifier */: + case 12 /* RegularExpressionLiteral */: + case 8 /* NumericLiteral */: + case 9 /* StringLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 196 /* TemplateExpression */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 99 /* ThisKeyword */: + case 101 /* TrueKeyword */: + case 97 /* SuperKeyword */: + case 203 /* NonNullExpression */: + case 204 /* MetaProperty */: + case 91 /* ImportKeyword */:// technically this is only an Expression if it's in a CallExpression + return true; + default: + return false; + } } /* @internal */ function isUnaryExpression(node) { return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionKind(kind) { + switch (kind) { + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: + case 188 /* DeleteExpression */: + case 189 /* TypeOfExpression */: + case 190 /* VoidExpression */: + case 191 /* AwaitExpression */: + case 184 /* TypeAssertionExpression */: + return true; + default: + return isLeftHandSideExpressionKind(kind); + } + } /* @internal */ function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { @@ -11574,22 +11839,31 @@ var ts; } } ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; - function isExpressionKind(kind) { - return kind === 195 /* ConditionalExpression */ - || kind === 197 /* YieldExpression */ - || kind === 187 /* ArrowFunction */ - || kind === 194 /* BinaryExpression */ - || kind === 198 /* SpreadElement */ - || kind === 202 /* AsExpression */ - || kind === 200 /* OmittedExpression */ - || kind === 289 /* CommaListExpression */ - || isUnaryExpressionKind(kind); - } /* @internal */ + /** + * Determines whether a node is an expression based only on its kind. + * Use `isPartOfExpression` if not in transforms. + */ function isExpression(node) { return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isExpression = isExpression; + function isExpressionKind(kind) { + switch (kind) { + case 195 /* ConditionalExpression */: + case 197 /* YieldExpression */: + case 187 /* ArrowFunction */: + case 194 /* BinaryExpression */: + case 198 /* SpreadElement */: + case 202 /* AsExpression */: + case 200 /* OmittedExpression */: + case 289 /* CommaListExpression */: + case 288 /* PartiallyEmittedExpression */: + return true; + default: + return isUnaryExpressionKind(kind); + } + } function isAssertionExpression(node) { var kind = node.kind; return kind === 184 /* TypeAssertionExpression */ @@ -11865,6 +12139,12 @@ var ts; return node.kind >= 276 /* FirstJSDocTagNode */ && node.kind <= 285 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; + /** True if has jsdoc nodes attached to it. */ + /* @internal */ + function hasJSDocNodes(node) { + return !!node.jsDoc && node.jsDoc.length > 0; + } + ts.hasJSDocNodes = hasJSDocNodes; })(ts || (ts = {})); /// /// @@ -12301,9 +12581,11 @@ var ts; visitNode(cbNode, node.typeExpression); } case 285 /* JSDocTypeLiteral */: - for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { - var tag = _a[_i]; - visitNode(cbNode, tag); + if (node.jsDocPropertyTags) { + for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { + var tag = _a[_i]; + visitNode(cbNode, tag); + } } return; case 288 /* PartiallyEmittedExpression */: @@ -12599,7 +12881,7 @@ var ts; var saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDoc) { + if (ts.hasJSDocNodes(n)) { for (var _i = 0, _a = n.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; jsDoc.parent = n; @@ -12742,9 +13024,6 @@ var ts; function getNodePos() { return scanner.getStartPos(); } - function getNodeEnd() { - return scanner.getStartPos(); - } // Use this function to access the current token instead of reading the currentToken // variable. Since function results aren't narrowed in control flow analysis, this ensures // that the type checker doesn't make wrong assumptions about the type of the current @@ -12903,13 +13182,14 @@ var ts; kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } - function createNodeArray(elements, pos) { - var array = (elements || []); - if (!(pos >= 0)) { - pos = getNodePos(); - } + function createNodeArray(elements, pos, end) { + // Since the element list of a node array is typically created by starting with an empty array and + // repeatedly calling push(), the list may not have the optimal memory layout. We invoke slice() for + // small arrays (1 to 4 elements) to give the VM a chance to allocate an optimal representation. + var length = elements.length; + var array = (length >= 1 && length <= 4 ? elements.slice() : elements); array.pos = pos; - array.end = pos; + array.end = end === undefined ? scanner.getStartPos() : end; return array; } function finishNode(node, end) { @@ -12964,7 +13244,9 @@ var ts; nextToken(); return finishNode(node); } - return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + // Only for end of file because the error gets reported incorrectly on embedded script tags. + var reportAtCurrentPosition = token() === 1 /* EndOfFileToken */; + return createMissingNode(71 /* Identifier */, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -13246,20 +13528,20 @@ var ts; function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, /*inErrorRecovery*/ false)) { var element = parseListElement(kind, parseElement); - result.push(element); + list.push(element); continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - result.end = getNodeEnd(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); @@ -13541,12 +13823,13 @@ var ts; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var commaStart = -1; // Meaning the previous token was not a comma while (true) { if (isListElement(kind, /*inErrorRecovery*/ false)) { var startPos = scanner.getStartPos(); - result.push(parseListElement(kind, parseElement)); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(26 /* CommaToken */)) { // No need to check for a zero length node since we know we parsed a comma @@ -13583,6 +13866,8 @@ var ts; break; } } + parsingContext = saveParsingContext; + var result = createNodeArray(list, listPos); // Recording the trailing comma is deliberately done after the previous // loop, and not just if we see a list terminator. This is because the list // may have ended incorrectly, but it is still important to know if there @@ -13592,12 +13877,10 @@ var ts; // Always preserve a trailing comma by marking it on the NodeArray result.hasTrailingComma = true; } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; return result; } function createMissingList() { - return createNodeArray(); + return createNodeArray([], getNodePos()); } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -13662,12 +13945,12 @@ var ts; var template = createNode(196 /* TemplateExpression */); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); - var templateSpans = createNodeArray(); + var list = []; + var listPos = getNodePos(); do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 15 /* TemplateMiddle */); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; + list.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(list).literal.kind === 15 /* TemplateMiddle */); + template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { @@ -13779,7 +14062,7 @@ var ts; var result = createNode(273 /* JSDocFunctionType */); nextToken(); fillSignature(56 /* ColonToken */, 4 /* Type */ | 32 /* JSDoc */, result); - return finishNode(result); + return addJSDocComment(finishNode(result)); } var node = createNode(159 /* TypeReference */); node.typeName = parseIdentifierName(); @@ -13848,9 +14131,10 @@ var ts; return token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 /* AtToken */ || isStartOfType(); + token() === 57 /* AtToken */ || + isStartOfType(/*inStartOfParameter*/ true); } - function parseParameter() { + function parseParameter(requireEqualsToken) { var node = createNode(146 /* Parameter */); if (token() === 99 /* ThisKeyword */) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -13876,38 +14160,34 @@ var ts; } node.questionToken = parseOptionalToken(55 /* QuestionToken */); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ true); + node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(/*inParameter*/ true); - } function fillSignature(returnToken, flags, signature) { if (!(flags & 32 /* JSDoc */)) { signature.typeParameters = parseTypeParameters(); } signature.parameters = parseParameterList(flags); - var returnTokenRequired = returnToken === 36 /* EqualsGreaterThanToken */; - if (returnTokenRequired) { + signature.type = parseReturnType(returnToken, !!(flags & 4 /* Type */)); + } + function parseReturnType(returnToken, isType) { + return shouldParseReturnType(returnToken, isType) ? parseTypeOrTypePredicate() : undefined; + } + function shouldParseReturnType(returnToken, isType) { + if (returnToken === 36 /* EqualsGreaterThanToken */) { parseExpected(returnToken); - signature.type = parseTypeOrTypePredicate(); + return true; } - else if (parseOptional(returnToken)) { - signature.type = parseTypeOrTypePredicate(); + else if (parseOptional(56 /* ColonToken */)) { + return true; } - else if (flags & 4 /* Type */) { - var start = scanner.getTokenPos(); - var length_1 = scanner.getTextPos() - start; - var backwardToken = parseOptional(returnToken === 56 /* ColonToken */ ? 36 /* EqualsGreaterThanToken */ : 56 /* ColonToken */); - if (backwardToken) { - // This is easy to get backward, especially in type contexts, so parse the type anyway - signature.type = parseTypeOrTypePredicate(); - parseErrorAtPosition(start, length_1, ts.Diagnostics._0_expected, ts.tokenToString(returnToken)); - } + else if (isType && token() === 36 /* EqualsGreaterThanToken */) { + // This is easy to get backward, especially in type contexts, so parse the type anyway + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); + nextToken(); + return true; } + return false; } function parseParameterList(flags) { // FormalParameters [Yield,Await]: (modified) @@ -13928,7 +14208,7 @@ var ts; var savedAwaitContext = inAwaitContext(); setYieldContext(!!(flags & 1 /* Yield */)); setAwaitContext(!!(flags & 2 /* Await */)); - var result = parseDelimitedList(16 /* Parameters */, flags & 32 /* JSDoc */ ? parseJSDocParameter : parseParameter); + var result = parseDelimitedList(16 /* Parameters */, flags & 32 /* JSDoc */ ? parseJSDocParameter : function () { return parseParameter(!!(flags & 8 /* RequireCompleteParameterList */)); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); if (!parseExpected(20 /* CloseParenToken */) && (flags & 8 /* RequireCompleteParameterList */)) { @@ -14024,7 +14304,7 @@ var ts; node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); @@ -14167,7 +14447,7 @@ var ts; parseExpected(94 /* NewKeyword */); } fillSignature(36 /* EqualsGreaterThanToken */, 4 /* Type */, node); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseKeywordAndNoDot() { var node = parseTokenNode(); @@ -14181,16 +14461,9 @@ var ts; unaryMinusExpression.operator = 38 /* MinusToken */; nextToken(); } - var expression; - switch (token()) { - case 9 /* StringLiteral */: - case 8 /* NumericLiteral */: - expression = parseLiteralLikeNode(token()); - break; - case 101 /* TrueKeyword */: - case 86 /* FalseKeyword */: - expression = parseTokenNode(); - } + var expression = token() === 101 /* TrueKeyword */ || token() === 86 /* FalseKeyword */ + ? parseTokenNode() + : parseLiteralLikeNode(token()); if (negative) { unaryMinusExpression.operand = expression; finishNode(unaryMinusExpression); @@ -14224,6 +14497,7 @@ var ts; return parseJSDocNodeWithType(274 /* JSDocVariadicType */); case 51 /* ExclamationToken */: return parseJSDocNodeWithType(271 /* JSDocNonNullableType */); + case 13 /* NoSubstitutionTemplateLiteral */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: case 101 /* TrueKeyword */: @@ -14255,7 +14529,7 @@ var ts; return parseTypeReference(); } } - function isStartOfType() { + function isStartOfType(inStartOfParameter) { switch (token()) { case 119 /* AnyKeyword */: case 136 /* StringKeyword */: @@ -14280,13 +14554,16 @@ var ts; case 86 /* FalseKeyword */: case 134 /* ObjectKeyword */: case 39 /* AsteriskToken */: + case 55 /* QuestionToken */: + case 51 /* ExclamationToken */: + case 24 /* DotDotDotToken */: return true; case 38 /* MinusToken */: - return lookAhead(nextTokenIsNumericLiteral); + return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case 19 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. - return lookAhead(isStartOfParenthesizedOrFunctionType); + return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } @@ -14353,13 +14630,12 @@ var ts; parseOptional(operator); var type = parseConstituentType(); if (token() === operator) { - var types = createNodeArray([type], type.pos); + var types = [type]; while (parseOptional(operator)) { types.push(parseConstituentType()); } - types.end = getNodeEnd(); var node = createNode(kind, type.pos); - node.types = types; + node.types = createNodeArray(types, type.pos); type = finishNode(node); } return type; @@ -14545,7 +14821,7 @@ var ts; } return expr; } - function parseInitializer(inParameter) { + function parseInitializer(inParameter, requireEqualsToken) { if (token() !== 58 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse @@ -14560,6 +14836,13 @@ var ts; // do not try to parse initializer return undefined; } + if (inParameter && requireEqualsToken) { + // = is required when speculatively parsing arrow function parameters, + // so return a fake initializer as a signal that the equals token was missing + var result = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics._0_expected, "="); + result.escapedText = "= not found"; + return result; + } } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] @@ -14685,8 +14968,7 @@ var ts; var parameter = createNode(146 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); - node.parameters = createNodeArray([parameter], parameter.pos); - node.parameters.end = parameter.end; + node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); @@ -14835,8 +15117,7 @@ var ts; function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" if (token() === 120 /* AsyncKeyword */) { - var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === 1 /* True */) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); return parseSimpleArrowFunctionExpression(expr, asyncModifier); @@ -14887,7 +15168,8 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { + if (!allowAmbiguity && ((token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) || + ts.find(node.parameters, function (p) { return p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"; }))) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -15447,7 +15729,8 @@ var ts; ts.Debug.fail("Unknown JSX child kind " + token()); } function parseJsxChildren(openingTagName) { - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var saveParsingContext = parsingContext; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { @@ -15467,12 +15750,11 @@ var ts; } var child = parseJsxChild(); if (child) { - result.push(child); + list.push(child); } } - result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseJsxAttributes() { var jsxAttributes = createNode(254 /* JsxAttributes */); @@ -16446,7 +16728,7 @@ var ts; var node = createNode(176 /* BindingElement */); node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { @@ -16462,7 +16744,7 @@ var ts; node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingPattern() { @@ -16496,7 +16778,7 @@ var ts; node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseNonParameterInitializer(); } return finishNode(node); } @@ -16699,7 +16981,8 @@ var ts; return false; } function parseDecorators() { - var decorators; + var list; + var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); if (!parseOptional(57 /* AtToken */)) { @@ -16708,17 +16991,9 @@ var ts; var decorator = createNode(147 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); - if (!decorators) { - decorators = createNodeArray([decorator], decoratorStart); - } - else { - decorators.push(decorator); - } + (list || (list = [])).push(decorator); } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; + return list && createNodeArray(list, listPos); } /* * There are situations in which a modifier like 'const' will appear unexpectedly, such as on a class member. @@ -16728,7 +17003,8 @@ var ts; * In such situations, 'permitInvalidConstAsModifier' should be set to true. */ function parseModifiers(permitInvalidConstAsModifier) { - var modifiers; + var list; + var listPos = getNodePos(); while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); @@ -16745,17 +17021,9 @@ var ts; } } var modifier = finishNode(createNode(modifierKind, modifierStart)); - if (!modifiers) { - modifiers = createNodeArray([modifier], modifierStart); - } - else { - modifiers.push(modifier); - } + (list || (list = [])).push(modifier); } - if (modifiers) { - modifiers.end = scanner.getStartPos(); - } - return modifiers; + return list && createNodeArray(list, listPos); } function parseModifiersForArrowFunction() { var modifiers; @@ -16765,7 +17033,6 @@ var ts; nextToken(); var modifier = finishNode(createNode(modifierKind, modifierStart)); modifiers = createNodeArray([modifier], modifierStart); - modifiers.end = scanner.getStartPos(); } return modifiers; } @@ -17323,11 +17590,11 @@ var ts; return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - // Parses out a JSDoc type expression. - /* @internal */ - function parseJSDocTypeExpression() { + function parseJSDocTypeExpression(requireBraces) { var result = createNode(267 /* JSDocTypeExpression */, scanner.getTokenPos()); - parseExpected(17 /* OpenBraceToken */); + if (!parseExpected(17 /* OpenBraceToken */) && requireBraces) { + return undefined; + } result.type = doInsideOfContext(1048576 /* JSDoc */, parseType); parseExpected(18 /* CloseBraceToken */); fixupParentReferences(result); @@ -17384,6 +17651,8 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; + var tagsPos; + var tagsEnd; var comments = []; var result; // Check for /** (JSDoc opening part) @@ -17507,7 +17776,7 @@ var ts; } function createJSDocComment() { var result = createNode(275 /* JSDocComment */, start); - result.tags = tags; + result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -17637,21 +17906,17 @@ var ts; function addTag(tag, comments) { tag.comment = comments.join(""); if (!tags) { - tags = createNodeArray([tag], tag.pos); + tags = [tag]; + tagsPos = tag.pos; } else { tags.push(tag); } - tags.end = tag.end; + tagsEnd = tag.end; } function tryParseTypeExpression() { - return tryParse(function () { - skipWhitespace(); - if (token() !== 17 /* OpenBraceToken */) { - return undefined; - } - return parseJSDocTypeExpression(); - }); + skipWhitespace(); + return token() === 17 /* OpenBraceToken */ ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { // Looking for something like '[foo]', 'foo', '[foo.bar]' or 'foo.bar' @@ -17743,11 +18008,11 @@ var ts; var result = createNode(281 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); + result.typeExpression = parseJSDocTypeExpression(/*requireBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); + var typeExpression = parseJSDocTypeExpression(/*requireBraces*/ true); var result = createNode(277 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; @@ -17784,19 +18049,18 @@ var ts; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { var child = void 0; var jsdocTypeLiteral = void 0; - var alreadyHasTypeTag = false; + var childTypeTag = void 0; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildParameterOrPropertyTag(0 /* Property */); })) { if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(285 /* JSDocTypeLiteral */, start_3); } if (child.kind === 281 /* JSDocTypeTag */) { - if (alreadyHasTypeTag) { + if (childTypeTag) { break; } else { - jsdocTypeLiteral.jsDocTypeTag = child; - alreadyHasTypeTag = true; + childTypeTag = child; } } else { @@ -17810,7 +18074,9 @@ var ts; if (typeExpression && typeExpression.type.kind === 164 /* ArrayType */) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = finishNode(jsdocTypeLiteral); + typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + childTypeTag.typeExpression : + finishNode(jsdocTypeLiteral); } } return finishNode(typedefTag); @@ -17905,7 +18171,8 @@ var ts; parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } // Type parameter list looks like '@template T,U,V' - var typeParameters = createNodeArray(); + var typeParameters = []; + var typeParametersPos = getNodePos(); while (true) { var name = parseJSDocIdentifierName(); skipWhitespace(); @@ -17928,9 +18195,8 @@ var ts; var result = createNode(282 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; + result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); - typeParameters.end = result.end; return result; } function nextJSDocToken() { @@ -18072,7 +18338,7 @@ var ts; ts.Debug.assert(text === newText.substring(node.pos, node.end)); } forEachChild(node, visitNode, visitArray); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDocComment = _a[_i]; forEachChild(jsDocComment, visitNode, visitArray); @@ -18622,9 +18888,11 @@ var ts; symbol.flags |= symbolFlags; node.symbol = symbol; if (!symbol.declarations) { - symbol.declarations = []; + symbol.declarations = [node]; + } + else { + symbol.declarations.push(node); } - symbol.declarations.push(node); if (symbolFlags & 1952 /* HasExports */ && !symbol.exports) { symbol.exports = ts.createSymbolTable(); } @@ -18695,17 +18963,8 @@ var ts; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; case 283 /* JSDocTypedefTag */: - var parentNode = node.parent && node.parent.parent; - var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 208 /* VariableStatement */) { - if (parentNode.declarationList.declarations.length > 0) { - var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (ts.isIdentifier(nameIdentifier)) { - nameFromParentNode = nameIdentifier.escapedText; - } - } - } - return nameFromParentNode; + var name_2 = ts.getNameOfJSDocTypedef(node); + return typeof name_2 !== "undefined" ? name_2.escapedText : undefined; } } function getDisplayName(node) { @@ -18993,7 +19252,7 @@ var ts; // Binding of JsDocComment should be done before the current block scope container changes. // because the scope of JsDocComment should not be affected by whether the current node is a // container or not. - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { if (ts.isInJavaScriptFile(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var j = _a[_i]; @@ -19795,10 +20054,6 @@ var ts; lastContainer = next; } function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) { - // Just call this directly so that the return type of this function stays "void". - return declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific @@ -19995,6 +20250,9 @@ var ts; } function bindAnonymousDeclaration(node, symbolFlags, name) { var symbol = createSymbol(symbolFlags, name); + if (symbolFlags & 8 /* EnumMember */) { + symbol.parent = container.symbol; + } addDeclarationToSymbol(symbol, node, symbolFlags); } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { @@ -20205,7 +20463,7 @@ var ts; inStrictMode = saveInStrictMode; } function bindJSDocTypedefTagIfAny(node) { - if (!node.jsDoc) { + if (!ts.hasJSDocNodes(node)) { return; } for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { @@ -21615,31 +21873,38 @@ var ts; return getSymbolWalker; function getSymbolWalker(accept) { if (accept === void 0) { accept = function () { return true; }; } - var visitedTypes = ts.createMap(); // Key is id as string - var visitedSymbols = ts.createMap(); // Key is id as string + var visitedTypes = []; // Sparse array from id to type + var visitedSymbols = []; // Sparse array from id to symbol return { walkType: function (type) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitType(type); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitType(type); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, walkSymbol: function (symbol) { - visitedTypes.clear(); - visitedSymbols.clear(); - visitSymbol(symbol); - return { visitedTypes: ts.arrayFrom(visitedTypes.values()), visitedSymbols: ts.arrayFrom(visitedSymbols.values()) }; + try { + visitSymbol(symbol); + return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) }; + } + finally { + ts.clear(visitedTypes); + ts.clear(visitedSymbols); + } }, }; function visitType(type) { if (!type) { return; } - var typeIdString = type.id.toString(); - if (visitedTypes.has(typeIdString)) { + if (visitedTypes[type.id]) { return; } - visitedTypes.set(typeIdString, type); + visitedTypes[type.id] = type; // Reuse visitSymbol to visit the type's symbol, // but be sure to bail on recuring into the type if accept declines the symbol. var shouldBail = visitSymbol(type.symbol); @@ -21675,23 +21940,15 @@ var ts; visitIndexedAccessType(type); } } - function visitTypeList(types) { - if (!types) { - return; - } - for (var i = 0; i < types.length; i++) { - visitType(types[i]); - } - } function visitTypeReference(type) { visitType(type.target); - visitTypeList(type.typeArguments); + ts.forEach(type.typeArguments, visitType); } function visitTypeParameter(type) { visitType(getConstraintFromTypeParameter(type)); } function visitUnionOrIntersectionType(type) { - visitTypeList(type.types); + ts.forEach(type.types, visitType); } function visitIndexType(type) { visitType(type.type); @@ -21711,7 +21968,7 @@ var ts; if (signature.typePredicate) { visitType(signature.typePredicate.type); } - visitTypeList(signature.typeParameters); + ts.forEach(signature.typeParameters, visitType); for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; visitSymbol(parameter); @@ -21721,8 +21978,8 @@ var ts; } function visitInterfaceType(interfaceT) { visitObjectType(interfaceT); - visitTypeList(interfaceT.typeParameters); - visitTypeList(getBaseTypes(interfaceT)); + ts.forEach(interfaceT.typeParameters, visitType); + ts.forEach(getBaseTypes(interfaceT), visitType); visitType(interfaceT.thisType); } function visitObjectType(type) { @@ -21749,11 +22006,11 @@ var ts; if (!symbol) { return; } - var symbolIdString = ts.getSymbolId(symbol).toString(); - if (visitedSymbols.has(symbolIdString)) { + var symbolId = ts.getSymbolId(symbol); + if (visitedSymbols[symbolId]) { return; } - visitedSymbols.set(symbolIdString, symbol); + visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { return true; } @@ -21813,7 +22070,7 @@ var ts; return undefined; } ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); - return resolved.path; + return { fileName: resolved.path, packageId: resolved.packageId }; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { @@ -21928,12 +22185,12 @@ var ts; var resolvedTypeReferenceDirective; if (resolved) { if (!options.preserveSymlinks) { - resolved = realPath(resolved, host, traceEnabled); + resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); } if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -22333,7 +22590,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, /*onlyRecordFailures*/ false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension, packageId: undefined }; + return noPackageId({ path: path_1, ext: extension }); } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -22515,32 +22772,41 @@ var ts; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } + var _a = considerPackageJson + ? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state) + : { packageJsonContent: undefined, packageId: undefined }, packageJsonContent = _a.packageJsonContent, packageId = _a.packageId; + return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent)); + } + function loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent) { + var fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - var packageId; - if (considerPackageJson) { - var packageJsonPath = pathToPackageJson(candidate); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var jsonContent = readJson(packageJsonPath, state.host); - if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { - packageId = { name: jsonContent.name, version: jsonContent.version }; - } - var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); - if (fromPackageJson) { - return withPackageId(packageId, fromPackageJson); - } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, _a) { + var host = _a.host, traceEnabled = _a.traceEnabled; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); + var packageJsonPath = pathToPackageJson(nodeModuleDirectory); + if (directoryExists && host.fileExists(packageJsonPath)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results - failedLookupLocations.push(packageJsonPath); + var packageJsonContent = readJson(packageJsonPath, host); + var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" + ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version } + : undefined; + return { packageJsonContent: packageJsonContent, packageId: packageId }; + } + else { + if (directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + // record package json as one of failed lookup locations - in the future if this file will appear it will invalidate resolution results + failedLookupLocations.push(packageJsonPath); + return { packageJsonContent: undefined, packageId: undefined }; } - return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); @@ -22588,9 +22854,20 @@ var ts; return ts.combinePaths(directory, "package.json"); } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { + var _a = getPackageName(moduleName), packageName = _a.packageName, rest = _a.rest; + var packageRootPath = ts.combinePaths(nodeModulesFolder, packageName); + var _b = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state), packageJsonContent = _b.packageJsonContent, packageId = _b.packageId; var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + var pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent); + return withPackageId(packageId, pathAndExtension); + } + function getPackageName(moduleName) { + var idx = moduleName.indexOf(ts.directorySeparator); + if (moduleName[0] === "@") { + idx = moduleName.indexOf(ts.directorySeparator, idx + 1); + } + return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, /*typesOnly*/ false, cache); @@ -22801,6 +23078,7 @@ var ts; var enumCount = 0; var symbolInstantiationDepth = 0; var emptySymbols = ts.createSymbolTable(); + var identityMapper = ts.identity; var compilerOptions = host.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); @@ -22961,12 +23239,13 @@ var ts; return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); }, getApparentType: getApparentType, - getAllPossiblePropertiesOfType: getAllPossiblePropertiesOfType, + isArrayLikeType: isArrayLikeType, + getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes, getSuggestionForNonexistentProperty: function (node, type) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentProperty(node, type)); }, getSuggestionForNonexistentSymbol: function (location, name, meaning) { return ts.unescapeLeadingUnderscores(getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning)); }, getBaseConstraintOfType: getBaseConstraintOfType, resolveName: function (name, location, meaning) { - return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); }, getJsxNamespace: function () { return ts.unescapeLeadingUnderscores(getJsxNamespace()); }, }; @@ -23055,7 +23334,8 @@ var ts; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; var flowLoopCount = 0; - var visitedFlowCount = 0; + var sharedFlowCount = 0; + var flowAnalysisDisabled = false; var emptyStringType = getLiteralType(""); var zeroType = getLiteralType(0); var resolutionTargets = []; @@ -23070,8 +23350,8 @@ var ts; var flowLoopNodes = []; var flowLoopKeys = []; var flowLoopTypes = []; - var visitedFlowNodes = []; - var visitedFlowTypes = []; + var sharedFlowNodes = []; + var sharedFlowTypes = []; var potentialThisCollisions = []; var potentialNewTargetCollisions = []; var awaitedTypeStack = []; @@ -23205,6 +23485,7 @@ var ts; })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createSymbolTable(); builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol); + var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor); initializeTypeChecker(); return checker; function getJsxNamespace() { @@ -23288,7 +23569,7 @@ var ts; } function cloneSymbol(symbol) { var result = createSymbol(symbol.flags, symbol.escapedName); - result.declarations = symbol.declarations.slice(0); + result.declarations = symbol.declarations ? symbol.declarations.slice() : []; result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; @@ -23387,6 +23668,7 @@ var ts; mergeSymbol(mainModule, moduleAugmentation.symbol); } else { + // moduleName will be a StringLiteral since this is not `declare global`. error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text); } } @@ -23555,13 +23837,17 @@ var ts; }); } } - // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and - // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with - // the given name can be found. - function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, suggestedNameNotFoundMessage) { - return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); + /** + * Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and + * the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with + * the given name can be found. + * + * @param isUse If true, this will count towards --noUnusedLocals / --noUnusedParameters. + */ + function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, suggestedNameNotFoundMessage) { + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, getSymbol, suggestedNameNotFoundMessage); } - function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, lookup, suggestedNameNotFoundMessage) { + function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, lookup, suggestedNameNotFoundMessage) { var originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location var result; var lastLocation; @@ -23780,10 +24066,16 @@ var ts; // We just climbed up parents looking for the name, meaning that we started in a descendant node of `lastLocation`. // If `result === lastLocation.symbol`, that means that we are somewhere inside `lastLocation` looking up a name, and resolving to `lastLocation` itself. // That means that this is a self-reference of `lastLocation`, and shouldn't count this when considering whether `lastLocation` is used. - if (result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { + if (isUse && result && nameNotFoundMessage && noUnusedIdentifiers && result !== lastLocation.symbol) { result.isReferenced = true; } if (!result) { + if (lastLocation) { + ts.Debug.assert(lastLocation.kind === 265 /* SourceFile */); + if (lastLocation.commonJsModuleIndicator && name === "exports") { + return lastLocation.symbol; + } + } result = lookup(globals, name, meaning); } if (!result) { @@ -23917,7 +24209,7 @@ var ts; } function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) { if (meaning === 1920 /* Namespace */) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 /* Type */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 /* Type */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); var parent = errorLocation.parent; if (symbol) { if (ts.isQualifiedName(parent)) { @@ -23941,7 +24233,7 @@ var ts; error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; } - var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 /* Type */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 793064 /* Type */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol && !(symbol.flags & 1024 /* NamespaceModule */)) { error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name)); return true; @@ -23951,14 +24243,14 @@ var ts; } function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { if (meaning & (107455 /* Value */ & ~1024 /* NamespaceModule */ & ~793064 /* Type */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name)); return true; } } else if (meaning & (793064 /* Type */ & ~1024 /* NamespaceModule */ & ~107455 /* Value */)) { - var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~793064 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~793064 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)); if (symbol) { error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name)); return true; @@ -23991,11 +24283,17 @@ var ts; return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { - if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 237 /* ImportEqualsDeclaration */) { + switch (node.kind) { + case 237 /* ImportEqualsDeclaration */: return node; - } - return ts.findAncestor(node, ts.isImportDeclaration); + case 239 /* ImportClause */: + return node.parent; + case 240 /* NamespaceImport */: + return node.parent.parent; + case 242 /* ImportSpecifier */: + return node.parent.parent.parent; + default: + return undefined; } } function getDeclarationOfAliasSymbol(symbol) { @@ -24248,7 +24546,7 @@ var ts; var symbol; if (name.kind === 71 /* Identifier */) { var message = meaning === 1920 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; - symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name); + symbol = resolveName(location || name, name.escapedText, meaning, ignoreErrors ? undefined : message, name, /*isUse*/ true); if (!symbol) { return undefined; } @@ -24295,7 +24593,7 @@ var ts; undefined; } else { - ts.Debug.fail("Unknown entity name kind."); + ts.Debug.assertNever(name, "Unknown entity name kind."); } ts.Debug.assert((ts.getCheckFlags(symbol) & 1 /* Instantiated */) === 0, "Should never get an instantiated symbol here."); return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol); @@ -24346,13 +24644,13 @@ var ts; } } // May be an untyped module. If so, ignore resolutionDiagnostic. - if (resolvedModule && resolvedModule.isExternalLibraryImport && !ts.extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && !ts.extensionIsTypeScript(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) { if (isForAugmentation) { var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } else if (noImplicitAny && moduleNotFoundError) { - var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + var errorInfo = !resolvedModule.isExternalLibraryImport ? undefined : ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } @@ -24465,10 +24763,9 @@ var ts; // The ES6 spec permits export * declarations in a module to circularly reference the module itself. For example, // module 'a' can 'export * from "b"' and 'b' can 'export * from "a"' without error. function visit(symbol) { - if (!(symbol && symbol.flags & 1952 /* HasExports */ && !ts.contains(visitedSymbols, symbol))) { + if (!(symbol && symbol.flags & 1952 /* HasExports */ && ts.pushIfUnique(visitedSymbols, symbol))) { return; } - visitedSymbols.push(symbol); var symbols = ts.cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder var exportStars = symbol.exports.get("__export" /* ExportStar */); @@ -24616,65 +24913,61 @@ var ts; return rightMeaning === 107455 /* Value */ ? 107455 /* Value */ : 1920 /* Namespace */; } function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing) { - function getAccessibleSymbolChainFromSymbolTable(symbols) { - return getAccessibleSymbolChainFromSymbolTableWorker(symbols, []); + if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) { + return undefined; } - function getAccessibleSymbolChainFromSymbolTableWorker(symbols, visitedSymbolTables) { - if (ts.contains(visitedSymbolTables, symbols)) { + var visitedSymbolTables = []; + return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function getAccessibleSymbolChainFromSymbolTable(symbols) { + if (!ts.pushIfUnique(visitedSymbolTables, symbols)) { return undefined; } - visitedSymbolTables.push(symbols); var result = trySymbolTable(symbols); visitedSymbolTables.pop(); return result; - function canQualifySymbol(symbolFromSymbolTable, meaning) { - // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible - if (!needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning)) { - return true; - } - // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too - var accessibleParent = getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); - return !!accessibleParent; - } - function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { - if (symbol === (resolvedAliasSymbol || symbolFromSymbolTable)) { - // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) - // and if symbolFromSymbolTable or alias resolution matches the symbol, - // check the symbol can be qualified, it is only then this symbol is accessible - return !ts.forEach(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && - canQualifySymbol(symbolFromSymbolTable, meaning); - } - } - function trySymbolTable(symbols) { - // If symbol is directly available by its name in the symbol table - if (isAccessible(symbols.get(symbol.escapedName))) { - return [symbol]; - } - // Check if symbol is any of the alias - return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { - if (symbolFromSymbolTable.flags & 2097152 /* Alias */ - && symbolFromSymbolTable.escapedName !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */)) { - if (!useOnlyExternalAliasing || // We can use any type of alias to get the name - // Is this external alias, then use it to name - ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { - var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); - if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { - return [symbolFromSymbolTable]; - } - // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain - // but only if the symbolFromSymbolTable can be qualified - var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTableWorker(resolvedImportedSymbol.exports, visitedSymbolTables) : undefined; - if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { - return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); - } - } - } - }); - } } - if (symbol && !isPropertyOrMethodDeclarationSymbol(symbol)) { - return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable); + function canQualifySymbol(symbolFromSymbolTable, meaning) { + // If the symbol is equivalent and doesn't need further qualification, this symbol is accessible + return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) || + // If symbol needs qualification, make sure that parent is accessible, if it is then this symbol is accessible too + !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing); + } + function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol) { + return symbol === (resolvedAliasSymbol || symbolFromSymbolTable) && + // if the symbolFromSymbolTable is not external module (it could be if it was determined as ambient external module and would be in globals table) + // and if symbolFromSymbolTable or alias resolution matches the symbol, + // check the symbol can be qualified, it is only then this symbol is accessible + !ts.some(symbolFromSymbolTable.declarations, hasExternalModuleSymbol) && + canQualifySymbol(symbolFromSymbolTable, meaning); + } + function isUMDExportSymbol(symbol) { + return symbol && symbol.declarations && symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]); + } + function trySymbolTable(symbols) { + // If symbol is directly available by its name in the symbol table + if (isAccessible(symbols.get(symbol.escapedName))) { + return [symbol]; + } + // Check if symbol is any of the alias + return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { + if (symbolFromSymbolTable.flags & 2097152 /* Alias */ + && symbolFromSymbolTable.escapedName !== "export=" + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */) + && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration))) + // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name + && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))) { + var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); + if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol)) { + return [symbolFromSymbolTable]; + } + // Look in the exported members, if we can find accessibleSymbolChain, symbol is accessible using this chain + // but only if the symbolFromSymbolTable can be qualified + var accessibleSymbolsFromExports = resolvedImportedSymbol.exports ? getAccessibleSymbolChainFromSymbolTable(resolvedImportedSymbol.exports) : undefined; + if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) { + return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports); + } + } + }); } } function needsQualification(symbol, enclosingDeclaration, meaning) { @@ -24813,14 +25106,7 @@ var ts; // since we will do the emitting later in trackSymbol. if (shouldComputeAliasToMakeVisible) { getNodeLinks(declaration).isVisible = true; - if (aliasesToMakeVisible) { - if (!ts.contains(aliasesToMakeVisible, anyImportSyntax)) { - aliasesToMakeVisible.push(anyImportSyntax); - } - } - else { - aliasesToMakeVisible = [anyImportSyntax]; - } + aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, anyImportSyntax); } return true; } @@ -24848,7 +25134,7 @@ var ts; meaning = 793064 /* Type */; } var firstIdentifier = getFirstIdentifier(entityName); - var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); // Verify if the symbol is accessible return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || { accessibility: 1 /* NotAccessible */, @@ -24882,7 +25168,7 @@ var ts; var writer = ts.createTextWriter(""); var printer = ts.createPrinter(options); var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration); - printer.writeNode(3 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); + printer.writeNode(4 /* Unspecified */, typeNode, /*sourceFile*/ sourceFile, writer); var result = writer.getText(); var maxLength = compilerOptions.noErrorTruncation || flags & 8 /* NoTruncation */ ? undefined : 100; if (maxLength && result.length >= maxLength) { @@ -25174,14 +25460,14 @@ var ts; var i = 0; var qualifiedName = void 0; if (outerTypeParameters) { - var length_2 = outerTypeParameters.length; - while (i < length_2) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { // Find group of type arguments for type parameters with the same declaring container. var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { @@ -25457,29 +25743,6 @@ var ts; } } } - function getNameOfSymbol(symbol, context) { - var declaration = ts.firstOrUndefined(symbol.declarations); - if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - return ts.declarationNameToString(name); - } - if (declaration.parent && declaration.parent.kind === 226 /* VariableDeclaration */) { - return ts.declarationNameToString(declaration.parent.name); - } - if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { - context.encounteredError = true; - } - switch (declaration.kind) { - case 199 /* ClassExpression */: - return "(Anonymous class)"; - case 186 /* FunctionExpression */: - case 187 /* ArrowFunction */: - return "(Anonymous function)"; - } - } - return ts.unescapeLeadingUnderscores(symbol.escapedName); - } } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { return ts.usingSingleLineStringWriter(function (writer) { @@ -25537,9 +25800,9 @@ var ts; ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { - return type.flags & 32 /* StringLiteral */ ? "\"" + ts.escapeString(type.value) + "\"" : "" + type.value; + return type.flags & 32 /* StringLiteral */ ? '"' + ts.escapeString(type.value) + '"' : "" + type.value; } - function getNameOfSymbol(symbol) { + function getNameOfSymbol(symbol, context) { if (symbol.declarations && symbol.declarations.length) { var declaration = symbol.declarations[0]; var name = ts.getNameOfDeclaration(declaration); @@ -25549,6 +25812,9 @@ var ts; if (declaration.parent && declaration.parent.kind === 226 /* VariableDeclaration */) { return ts.declarationNameToString(declaration.parent.name); } + if (context && !context.encounteredError && !(context.flags & ts.NodeBuilderFlags.AllowAnonymousIdentifier)) { + context.encounteredError = true; + } switch (declaration.kind) { case 199 /* ClassExpression */: return "(Anonymous class)"; @@ -25557,6 +25823,12 @@ var ts; return "(Anonymous function)"; } } + if (symbol.syntheticLiteralTypeOrigin) { + var stringValue = symbol.syntheticLiteralTypeOrigin.value; + if (!ts.isIdentifierText(stringValue, compilerOptions.target)) { + return "\"" + ts.escapeString(stringValue, 34 /* doubleQuote */) + "\""; + } + } return ts.unescapeLeadingUnderscores(symbol.escapedName); } function getSymbolDisplayBuilder() { @@ -25794,14 +26066,14 @@ var ts; var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_3 = outerTypeParameters.length; - while (i < length_3) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { // Find group of type arguments for type parameters with the same declaring container. var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_3 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // When type parameters are their own type arguments for the whole group (i.e. we have // the default outer type arguments), we don't show the group. if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { @@ -26349,7 +26621,7 @@ var ts; function collectLinkedAliases(node) { var exportSymbol; if (node.parent && node.parent.kind === 243 /* ExportAssignment */) { - exportSymbol = resolveName(node.parent, node.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); + exportSymbol = resolveName(node.parent, node.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node, /*isUse*/ false); } else if (node.parent.kind === 246 /* ExportSpecifier */) { exportSymbol = getTargetOfExportSpecifier(node.parent, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */); @@ -26363,14 +26635,12 @@ var ts; ts.forEach(declarations, function (declaration) { getNodeLinks(declaration).isVisible = true; var resultNode = getAnyImportSyntax(declaration) || declaration; - if (!ts.contains(result, resultNode)) { - result.push(resultNode); - } + ts.pushIfUnique(result, resultNode); if (ts.isInternalModuleImportEqualsDeclaration(declaration)) { // Add the referenced top container visible var internalModuleReference = declaration.moduleReference; var firstIdentifier = getFirstIdentifier(internalModuleReference); - var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, undefined, undefined); + var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, undefined, undefined, /*isUse*/ false); if (importSymbol) { buildVisibleNodeList(importSymbol.declarations); } @@ -26393,8 +26663,8 @@ var ts; var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { // A cycle was found - var length_4 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_4; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -27104,38 +27374,50 @@ var ts; for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) { var declaration = declarations_2[_i]; var tp = getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)); - if (!typeParameters) { - typeParameters = [tp]; - } - else if (!ts.contains(typeParameters, tp)) { - typeParameters.push(tp); - } + typeParameters = ts.appendIfUnique(typeParameters, tp); } return typeParameters; } - // Appends the outer type parameters of a node to a set of type parameters and returns the resulting set. The function - // allocates a new array if the input type parameter set is undefined, but otherwise it modifies the set in-place and - // returns the same array. - function appendOuterTypeParameters(typeParameters, node) { + // Return the outer type parameters of a node or undefined if the node has no outer type parameters. + function getOuterTypeParameters(node, includeThisTypes) { while (true) { node = node.parent; if (!node) { - return typeParameters; + return undefined; } - if (node.kind === 229 /* ClassDeclaration */ || node.kind === 199 /* ClassExpression */ || - node.kind === 228 /* FunctionDeclaration */ || node.kind === 186 /* FunctionExpression */ || - node.kind === 151 /* MethodDeclaration */ || node.kind === 187 /* ArrowFunction */) { - var declarations = node.typeParameters; - if (declarations) { - return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); - } + switch (node.kind) { + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 150 /* MethodSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 273 /* JSDocFunctionType */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 231 /* TypeAliasDeclaration */: + case 282 /* JSDocTemplateTag */: + case 172 /* MappedType */: + var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes); + if (node.kind === 172 /* MappedType */) { + return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter))); + } + var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node) || ts.emptyArray); + var thisType = includeThisTypes && + (node.kind === 229 /* ClassDeclaration */ || node.kind === 199 /* ClassExpression */ || node.kind === 230 /* InterfaceDeclaration */) && + getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; + return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters; } } } // The outer type parameters are those defined by enclosing generic classes, methods, or functions. function getOuterTypeParametersOfClassOrInterface(symbol) { var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230 /* InterfaceDeclaration */); - return appendOuterTypeParameters(/*typeParameters*/ undefined, declaration); + return getOuterTypeParameters(declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. @@ -27189,7 +27471,7 @@ var ts; function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode); - return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig; }); + return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJavaScriptFile(location)) : sig; }); } /** * The base constructor of a class can resolve to @@ -27280,7 +27562,7 @@ var ts; var valueDecl = type.symbol.valueDeclaration; if (valueDecl && ts.isInJavaScriptFile(valueDecl)) { var augTag = ts.getJSDocAugmentsTag(type.symbol.valueDeclaration); - if (augTag) { + if (augTag && augTag.typeExpression && augTag.typeExpression.type) { baseType = getTypeFromTypeNode(augTag.typeExpression.type); } } @@ -27410,7 +27692,9 @@ var ts; var declaration = ts.find(symbol.declarations, function (d) { return d.kind === 283 /* JSDocTypedefTag */ || d.kind === 231 /* TypeAliasDeclaration */; }); - var type = getTypeFromTypeNode(declaration.kind === 283 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type); + var typeNode = declaration.kind === 283 /* JSDocTypedefTag */ ? declaration.typeExpression : declaration.type; + // If typeNode is missing, we will error in checkJSDocTypedefTag. + var type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; if (popTypeResolution()) { var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); if (typeParameters) { @@ -27761,7 +28045,7 @@ var ts; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -27798,9 +28082,7 @@ var ts; if (!match) { return undefined; } - if (!ts.contains(result, match)) { - (result || (result = [])).push(match); - } + result = ts.appendIfUnique(result, match); } return result; } @@ -28009,7 +28291,14 @@ var ts; forEachType(iterationType, addMemberForKeyType); } setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined); - function addMemberForKeyType(t, propertySymbol) { + function addMemberForKeyType(t, propertySymbolOrIndex) { + var propertySymbol; + // forEachType delegates to forEach, which calls with a numeric second argument + // the type system currently doesn't catch this incompatibility, so we annotate + // the function ourselves to indicate the runtime behavior and deal with it here + if (typeof propertySymbolOrIndex === "object") { + propertySymbol = propertySymbolOrIndex; + } // Create a mapper from T to the current iteration type constituent. Then, if the // mapped type is itself an instantiated type, combine the iteration mapper with the // instantiation mapper. @@ -28029,6 +28318,7 @@ var ts; prop.syntheticOrigin = propertySymbol; prop.declarations = propertySymbol.declarations; } + prop.syntheticLiteralTypeOrigin = t; members.set(propName, prop); } else if (t.flags & 2 /* String */) { @@ -28151,26 +28441,22 @@ var ts; getPropertiesOfUnionOrIntersectionType(type) : getPropertiesOfObjectType(type); } - function getAllPossiblePropertiesOfType(type) { - if (type.flags & 65536 /* Union */) { - var props = ts.createSymbolTable(); - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var memberType = _a[_i]; - if (memberType.flags & 8190 /* Primitive */) { - continue; - } - for (var _b = 0, _c = getPropertiesOfType(memberType); _b < _c.length; _b++) { - var escapedName = _c[_b].escapedName; - if (!props.has(escapedName)) { - props.set(escapedName, createUnionOrIntersectionProperty(type, escapedName)); - } + function getAllPossiblePropertiesOfTypes(types) { + var unionType = getUnionType(types); + if (!(unionType.flags & 65536 /* Union */)) { + return getPropertiesOfType(unionType); + } + var props = ts.createSymbolTable(); + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var memberType = types_2[_i]; + for (var _a = 0, _b = getPropertiesOfType(memberType); _a < _b.length; _a++) { + var escapedName = _b[_a].escapedName; + if (!props.has(escapedName)) { + props.set(escapedName, createUnionOrIntersectionProperty(unionType, escapedName)); } } - return ts.arrayFrom(props.values()); - } - else { - return getPropertiesOfType(type); } + return ts.arrayFrom(props.values()); } function getConstraintOfType(type) { return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : @@ -28237,8 +28523,8 @@ var ts; if (t.flags & 196608 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_2 = types_2[_i]; + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); @@ -28316,20 +28602,15 @@ var ts; var commonFlags = isUnion ? 0 /* None */ : 16777216 /* Optional */; var syntheticFlag = 4 /* SyntheticMethod */; var checkFlags = 0; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0; if (prop && !(modifiers & excludeModifiers)) { commonFlags &= prop.flags; - if (!props) { - props = [prop]; - } - else if (!ts.contains(props, prop)) { - props.push(prop); - } + props = ts.appendIfUnique(props, prop); checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 64 /* ContainsPublic */ : 0) | (modifiers & 16 /* Protected */ ? 128 /* ContainsProtected */ : 0) | @@ -28479,12 +28760,7 @@ var ts; var result; ts.forEach(ts.getEffectiveTypeParameterDeclarations(declaration), function (node) { var tp = getDeclaredTypeOfTypeParameter(node.symbol); - if (!ts.contains(result, tp)) { - if (!result) { - result = []; - } - result.push(tp); - } + result = ts.appendIfUnique(result, tp); }); return result; } @@ -28520,7 +28796,7 @@ var ts; if (ts.isExternalModuleNameRelative(moduleName)) { return undefined; } - var symbol = getSymbol(globals, "\"" + moduleName + "\"", 512 /* ValueModule */); + var symbol = getSymbol(globals, '"' + moduleName + '"', 512 /* ValueModule */); // merged symbol is module declaration symbol combined with all augmentations return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol; } @@ -28583,11 +28859,10 @@ var ts; * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScript) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - var isJavaScript = ts.isInJavaScriptFile(location); if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; @@ -28626,7 +28901,7 @@ var ts; var paramSymbol = param.symbol; // Include parameter symbol instead of property symbol in the signature if (paramSymbol && !!(paramSymbol.flags & 4 /* Property */) && !ts.isBindingPattern(param.name)) { - var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455 /* Value */, undefined, undefined); + var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 107455 /* Value */, undefined, undefined, /*isUse*/ false); paramSymbol = resolvedSymbol; } if (i === 0 && paramSymbol.escapedName === "this") { @@ -28822,8 +29097,8 @@ var ts; } return anyType; } - function getSignatureInstantiation(signature, typeArguments) { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); + function getSignatureInstantiation(signature, typeArguments, isJavascript) { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); var instantiations = signature.instantiations || (signature.instantiations = ts.createMap()); var id = getTypeListId(typeArguments); var instantiation = instantiations.get(id); @@ -28836,12 +29111,27 @@ var ts; return instantiateSignature(signature, createTypeMapper(signature.typeParameters, typeArguments), /*eraseTypeParameters*/ true); } function getErasedSignature(signature) { - if (!signature.typeParameters) - return signature; - if (!signature.erasedSignatureCache) { - signature.erasedSignatureCache = instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true); - } - return signature.erasedSignatureCache; + return signature.typeParameters ? + signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) : + signature; + } + function createErasedSignature(signature) { + // Create an instantiation of the signature where all type arguments are the any type. + return instantiateSignature(signature, createTypeEraser(signature.typeParameters), /*eraseTypeParameters*/ true); + } + function getCanonicalSignature(signature) { + return signature.typeParameters ? + signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) : + signature; + } + function createCanonicalSignature(signature) { + // Create an instantiation of the signature where each unconstrained type parameter is replaced with + // its original. When a generic class or interface is instantiated, each generic method in the class or + // interface is instantiated with a fresh set of cloned type parameters (which we need to handle scenarios + // where different generations of the same type parameter are in scope). This leads to a lot of new type + // identities, and potentially a lot of work comparing those identities, so here we create an instantiation + // that uses the original type identities for all unconstrained type parameters. + return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJavaScriptFile(signature.declaration)); } function getOrCreateTypeFromSignature(signature) { // There are two ways to declare a construct signature, one is by declaring a class constructor @@ -28911,12 +29201,12 @@ var ts; function getTypeListId(types) { var result = ""; if (types) { - var length_5 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_5) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_5 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -28937,8 +29227,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -28977,7 +29267,8 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { + var isJavascript = ts.isInJavaScriptFile(node); + if (!isJavascript && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), minTypeArgumentCount, typeParameters.length); @@ -28986,7 +29277,7 @@ var ts; // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJavascript)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -29002,7 +29293,7 @@ var ts; var id = getTypeListId(typeArguments); var instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateTypeNoAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJavaScriptFile(symbol.valueDeclaration))))); } return instantiation; } @@ -29214,7 +29505,8 @@ var ts; return getGlobalSymbol(name, 793064 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { - return resolveName(undefined, name, meaning, diagnostic, name); + // Don't track references for global symbols anyway, so value if `isReference` is arbitrary + return resolveName(undefined, name, meaning, diagnostic, name, /*isUse*/ false); } function getGlobalType(name, arity, reportErrors) { var symbol = getGlobalTypeSymbol(name, reportErrors); @@ -29374,6 +29666,22 @@ var ts; function containsType(types, type) { return binarySearchTypes(types, type) >= 0; } + // Return true if the given intersection type contains (a) more than one unit type or (b) an object + // type and a nullable type (null or undefined). + function isEmptyIntersectionType(type) { + var combined = 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var t = _a[_i]; + if (t.flags & 6368 /* Unit */ && combined & 6368 /* Unit */) { + return true; + } + combined |= t.flags; + if (combined & 6144 /* Nullable */ && combined & (32768 /* Object */ | 16777216 /* NonPrimitive */)) { + return true; + } + } + return false; + } function addTypeToUnion(typeSet, type) { var flags = type.flags; if (flags & 65536 /* Union */) { @@ -29390,7 +29698,11 @@ var ts; if (!(flags & 2097152 /* ContainsWideningType */)) typeSet.containsNonWideningType = true; } - else if (!(flags & 8192 /* Never */)) { + else if (!(flags & 8192 /* Never */ || flags & 131072 /* Intersection */ && isEmptyIntersectionType(type))) { + // We ignore 'never' types in unions. Likewise, we ignore intersections of unit types as they are + // another form of 'never' (in that they have an empty value domain). We could in theory turn + // intersections of unit types into 'never' upon construction, but deferring the reduction makes it + // easier to reason about their origin. if (flags & 2 /* String */) typeSet.containsString = true; if (flags & 4 /* Number */) @@ -29410,14 +29722,14 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -29425,8 +29737,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -29519,6 +29831,12 @@ var ts; type = createType(65536 /* Union */ | propagatedFlags); unionTypes.set(id, type); type.types = types; + /* + 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. + (In the language service, the order may depend on the order in which a user takes actions, such as hovering over symbols.) + It's important that we create equivalent union types only once, so that's an unfortunate side effect. + */ type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } @@ -29560,8 +29878,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -29608,7 +29926,7 @@ var ts; type = createType(131072 /* Intersection */ | propagatedFlags); intersectionTypes.set(id, type); type.types = typeSet; - type.aliasSymbol = aliasSymbol; + type.aliasSymbol = aliasSymbol; // See comment in `getUnionTypeFromSortedList`. type.aliasTypeArguments = aliasTypeArguments; } return type; @@ -29720,21 +30038,6 @@ var ts; } return anyType; } - function getIndexedAccessForMappedType(type, indexType, accessNode) { - if (accessNode) { - // Check if the index type is assignable to 'keyof T' for the object type. - if (!isTypeAssignableTo(indexType, getIndexType(type))) { - error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(type)); - return unknownType; - } - if (accessNode.kind === 180 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && type.declaration.readonlyToken) { - error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); - } - } - var mapper = createTypeMapper([getTypeParameterFromMappedType(type)], [indexType]); - var templateMapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; - return instantiateType(getTemplateTypeFromMappedType(type), templateMapper); - } function isGenericObjectType(type) { return type.flags & 540672 /* TypeVariable */ ? true : getObjectFlags(type) & 32 /* Mapped */ ? isGenericIndexType(getConstraintTypeFromMappedType(type)) : @@ -29757,12 +30060,14 @@ var ts; } return false; } - // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or - // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a - // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed - // access types with default property values as expressed by D. + // Transform an indexed access to a simpler form, if possible. Return the simpler form, or return + // undefined if no transformation is possible. function getTransformedIndexedAccessType(type) { var objectType = type.objectType; + // Given an indexed access type T[K], if T is an intersection containing one or more generic types and one or + // more object types with only a string index signature, e.g. '(U & V & { [x: string]: D })[K]', return a + // transformed type of the form '(U & V)[K] | D'. This allows us to properly reason about higher order indexed + // access types with default property values as expressed by D. if (objectType.flags & 131072 /* Intersection */ && isGenericObjectType(objectType) && ts.some(objectType.types, isStringIndexOnlyType)) { var regularTypes = []; var stringIndexTypes = []; @@ -29780,19 +30085,22 @@ var ts; getIntersectionType(stringIndexTypes) ]); } - return undefined; - } - function getIndexedAccessType(objectType, indexType, accessNode) { - // If the object type is a mapped type { [P in K]: E }, where K is generic, we instantiate E using a mapper + // If the object type is a mapped type { [P in K]: E }, where K is generic, instantiate E using a mapper // that substitutes the index type for P. For example, for an index access { [P in K]: Box }[X], we // construct the type Box. if (isGenericMappedType(objectType)) { - return getIndexedAccessForMappedType(objectType, indexType, accessNode); + var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [type.indexType]); + var objectTypeMapper = objectType.mapper; + var templateMapper = objectTypeMapper ? combineTypeMappers(objectTypeMapper, mapper) : mapper; + return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper); } - // Otherwise, if the index type is generic, or if the object type is generic and doesn't originate in an - // expression, we are performing a higher-order index access where we cannot meaningfully access the properties - // of the object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates - // in an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' + return undefined; + } + function getIndexedAccessType(objectType, indexType, accessNode) { + // If the index type is generic, or if the object type is generic and doesn't originate in an expression, + // we are performing a higher-order index access where we cannot meaningfully access the properties of the + // object type. Note that for a generic T and a non-generic K, we eagerly resolve T[K] if it originates in + // an expression. This is to preserve backwards compatibility. For example, an element access 'this["foo"]' // has always been resolved eagerly using the constraint type of 'this' at the given location. if (isGenericIndexType(indexType) || !(accessNode && accessNode.kind === 180 /* ElementAccessExpression */) && isGenericObjectType(objectType)) { if (objectType.flags & 1 /* Any */) { @@ -29807,8 +30115,10 @@ var ts; return type; } // In the following we resolve T[K] to the type of the property in T selected by K. + // We treat boolean as different from other unions to improve errors; + // skipping straight to getPropertyTypeForIndexType gives errors with 'boolean' instead of 'true'. var apparentObjectType = getApparentType(objectType); - if (indexType.flags & 65536 /* Union */ && !(indexType.flags & 8190 /* Primitive */)) { + if (indexType.flags & 65536 /* Union */ && !(indexType.flags & 8 /* Boolean */)) { var propTypes = []; for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) { var t = _a[_i]; @@ -29892,7 +30202,10 @@ var ts; return mapType(right, function (t) { return getSpreadType(left, t); }); } if (right.flags & 16777216 /* NonPrimitive */) { - return emptyObjectType; + return nonPrimitiveType; + } + if (right.flags & (136 /* BooleanLike */ | 84 /* NumberLike */ | 262178 /* StringLike */ | 272 /* EnumLike */)) { + return left; } var members = ts.createSymbolTable(); var skippedPrivateMembers = ts.createUnderscoreEscapedMap(); @@ -30120,10 +30433,6 @@ var ts; function instantiateSignatures(signatures, mapper) { return instantiateList(signatures, mapper, instantiateSignature); } - function instantiateCached(type, mapper, instantiator) { - var instantiations = mapper.instantiations || (mapper.instantiations = []); - return instantiations[type.id] || (instantiations[type.id] = instantiator(type, mapper)); - } function makeUnaryTypeMapper(source, target) { return function (t) { return t === source ? target : t; }; } @@ -30142,11 +30451,9 @@ var ts; } function createTypeMapper(sources, targets) { ts.Debug.assert(targets === undefined || sources.length === targets.length); - var mapper = sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : + return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : sources.length === 2 ? makeBinaryTypeMapper(sources[0], targets ? targets[0] : anyType, sources[1], targets ? targets[1] : anyType) : makeArrayTypeMapper(sources, targets); - mapper.mappedTypes = sources; - return mapper; } function createTypeEraser(sources) { return createTypeMapper(sources, /*targets*/ undefined); @@ -30156,9 +30463,7 @@ var ts; * This is used during inference when instantiating type parameter defaults. */ function createBackreferenceMapper(typeParameters, index) { - var mapper = function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; - mapper.mappedTypes = typeParameters; - return mapper; + return function (t) { return ts.indexOf(typeParameters, t) >= index ? emptyObjectType : t; }; } function isInferenceContext(mapper) { return !!mapper.signature; @@ -30168,18 +30473,11 @@ var ts; createInferenceContext(mapper.signature, mapper.flags | 2 /* NoDefault */, mapper.compareTypes, mapper.inferences) : mapper; } - function identityMapper(type) { - return type; - } function combineTypeMappers(mapper1, mapper2) { - var mapper = function (t) { return instantiateType(mapper1(t), mapper2); }; - mapper.mappedTypes = ts.concatenate(mapper1.mappedTypes, mapper2.mappedTypes); - return mapper; + return function (t) { return instantiateType(mapper1(t), mapper2); }; } function createReplacementMapper(source, target, baseMapper) { - var mapper = function (t) { return t === source ? target : baseMapper(t); }; - mapper.mappedTypes = baseMapper.mappedTypes; - return mapper; + return function (t) { return t === source ? target : baseMapper(t); }; } function cloneTypeParameter(typeParameter) { var result = createType(16384 /* TypeParameter */); @@ -30246,15 +30544,57 @@ var ts; if (symbol.valueDeclaration) { result.valueDeclaration = symbol.valueDeclaration; } + if (symbol.isRestParameter) { + result.isRestParameter = symbol.isRestParameter; + } return result; } - function instantiateAnonymousType(type, mapper) { - var result = createObjectType(16 /* Anonymous */ | 64 /* Instantiated */, type.symbol); - result.target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; - result.mapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; - result.aliasSymbol = type.aliasSymbol; - result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); - return result; + function getAnonymousTypeInstantiation(type, mapper) { + var target = type.objectFlags & 64 /* Instantiated */ ? type.target : type; + var symbol = target.symbol; + var links = getSymbolLinks(symbol); + var typeParameters = links.typeParameters; + if (!typeParameters) { + // The first time an anonymous type is instantiated we compute and store a list of the type + // parameters that are in scope (and therefore potentially referenced). For type literals that + // aren't the right hand side of a generic type alias declaration we optimize by reducing the + // set of type parameters to those that are actually referenced somewhere in the literal. + var declaration_1 = symbol.declarations[0]; + var outerTypeParameters = getOuterTypeParameters(declaration_1, /*includeThisTypes*/ true) || ts.emptyArray; + typeParameters = symbol.flags & 2048 /* TypeLiteral */ && !target.aliasTypeArguments ? + ts.filter(outerTypeParameters, function (tp) { return isTypeParameterReferencedWithin(tp, declaration_1); }) : + outerTypeParameters; + links.typeParameters = typeParameters; + if (typeParameters.length) { + links.instantiations = ts.createMap(); + links.instantiations.set(getTypeListId(typeParameters), target); + } + } + if (typeParameters.length) { + // We are instantiating an anonymous type that has one or more type parameters in scope. Apply the + // mapper to the type parameters to produce the effective list of type arguments, and compute the + // instantiation cache key from the type IDs of the type arguments. + var combinedMapper = type.objectFlags & 64 /* Instantiated */ ? combineTypeMappers(type.mapper, mapper) : mapper; + var typeArguments = ts.map(typeParameters, combinedMapper); + var id = getTypeListId(typeArguments); + var result = links.instantiations.get(id); + if (!result) { + var newMapper = createTypeMapper(typeParameters, typeArguments); + result = target.objectFlags & 32 /* Mapped */ ? instantiateMappedType(target, newMapper) : instantiateAnonymousType(target, newMapper); + links.instantiations.set(id, result); + } + return result; + } + return type; + } + function isTypeParameterReferencedWithin(tp, node) { + return tp.isThisType ? ts.forEachChild(node, checkThis) : ts.forEachChild(node, checkIdentifier); + function checkThis(node) { + return node.kind === 169 /* ThisType */ || ts.forEachChild(node, checkThis); + } + function checkIdentifier(node) { + return node.kind === 71 /* Identifier */ && ts.isPartOfTypeNode(node) && getTypeFromTypeNode(node) === tp || ts.forEachChild(node, checkIdentifier); + } } function instantiateMappedType(type, mapper) { // Check if we have a homomorphic mapped type, i.e. a type of the form { [P in keyof T]: X } for some @@ -30270,160 +30610,61 @@ var ts; if (typeVariable_1 !== mappedTypeVariable) { return mapType(mappedTypeVariable, function (t) { if (isMappableType(t)) { - return instantiateMappedObjectType(type, createReplacementMapper(typeVariable_1, t, mapper)); + return instantiateAnonymousType(type, createReplacementMapper(typeVariable_1, t, mapper)); } return t; }); } } } - return instantiateMappedObjectType(type, mapper); + return instantiateAnonymousType(type, mapper); } function isMappableType(type) { return type.flags & (16384 /* TypeParameter */ | 32768 /* Object */ | 131072 /* Intersection */ | 524288 /* IndexedAccess */); } - function instantiateMappedObjectType(type, mapper) { - var result = createObjectType(32 /* Mapped */ | 64 /* Instantiated */, type.symbol); - result.declaration = type.declaration; - result.mapper = type.mapper ? combineTypeMappers(type.mapper, mapper) : mapper; + function instantiateAnonymousType(type, mapper) { + var result = createObjectType(type.objectFlags | 64 /* Instantiated */, type.symbol); + if (type.objectFlags & 32 /* Mapped */) { + result.declaration = type.declaration; + } + result.target = type; + result.mapper = mapper; result.aliasSymbol = type.aliasSymbol; result.aliasTypeArguments = instantiateTypes(type.aliasTypeArguments, mapper); return result; } - function isSymbolInScopeOfMappedTypeParameter(symbol, mapper) { - if (!(symbol.declarations && symbol.declarations.length)) { - return false; - } - var mappedTypes = mapper.mappedTypes; - // Starting with the parent of the symbol's declaration, check if the mapper maps any of - // the type parameters introduced by enclosing declarations. We just pick the first - // declaration since multiple declarations will all have the same parent anyway. - return !!ts.findAncestor(symbol.declarations[0], function (node) { - if (node.kind === 233 /* ModuleDeclaration */ || node.kind === 265 /* SourceFile */) { - return "quit"; - } - switch (node.kind) { - case 160 /* FunctionType */: - case 161 /* ConstructorType */: - case 228 /* FunctionDeclaration */: - case 151 /* MethodDeclaration */: - case 150 /* MethodSignature */: - case 152 /* Constructor */: - case 155 /* CallSignature */: - case 156 /* ConstructSignature */: - case 157 /* IndexSignature */: - case 153 /* GetAccessor */: - case 154 /* SetAccessor */: - case 186 /* FunctionExpression */: - case 187 /* ArrowFunction */: - case 229 /* ClassDeclaration */: - case 199 /* ClassExpression */: - case 230 /* InterfaceDeclaration */: - case 231 /* TypeAliasDeclaration */: - var typeParameters = ts.getEffectiveTypeParameterDeclarations(node); - if (typeParameters) { - for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) { - var d = typeParameters_1[_i]; - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(d)))) { - return true; - } - } - } - if (ts.isClassLike(node) || node.kind === 230 /* InterfaceDeclaration */) { - var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; - if (thisType && ts.contains(mappedTypes, thisType)) { - return true; - } - } - break; - case 172 /* MappedType */: - if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { - return true; - } - break; - case 273 /* JSDocFunctionType */: - var func = node; - for (var _a = 0, _b = func.parameters; _a < _b.length; _a++) { - var p = _b[_a]; - if (ts.contains(mappedTypes, getTypeOfNode(p))) { - return true; - } - } - break; - } - }); - } - function isTopLevelTypeAlias(symbol) { - if (symbol.declarations && symbol.declarations.length) { - var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 265 /* SourceFile */ || parentKind === 234 /* ModuleBlock */; - } - return false; - } function instantiateType(type, mapper) { if (type && mapper !== identityMapper) { - // If we are instantiating a type that has a top-level type alias, obtain the instantiation through - // the type alias instead in order to share instantiations for the same type arguments. This can - // dramatically reduce the number of structurally identical types we generate. Note that we can only - // perform this optimization for top-level type aliases. Consider: - // - // function f1(x: T) { - // type Foo = { x: X, t: T }; - // let obj: Foo = { x: x }; - // return obj; - // } - // function f2(x: U) { return f1(x); } - // let z = f2(42); - // - // Above, the declaration of f2 has an inferred return type that is an instantiation of f1's Foo - // equivalent to { x: U, t: U }. When instantiating this return type, we can't go back to Foo's - // cache because all cached instantiations are of the form { x: ???, t: T }, i.e. they have not been - // instantiated for T. Instead, we need to further instantiate the { x: U, t: U } form. - if (type.aliasSymbol && isTopLevelTypeAlias(type.aliasSymbol)) { - if (type.aliasTypeArguments) { - return getTypeAliasInstantiation(type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); + if (type.flags & 16384 /* TypeParameter */) { + return mapper(type); + } + if (type.flags & 32768 /* Object */) { + if (type.objectFlags & 16 /* Anonymous */) { + // If the anonymous type originates in a declaration of a function, method, class, or + // interface, in an object type literal, or in an object literal expression, we may need + // to instantiate the type because it might reference a type parameter. + return type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations ? + getAnonymousTypeInstantiation(type, mapper) : type; + } + if (type.objectFlags & 32 /* Mapped */) { + return getAnonymousTypeInstantiation(type, mapper); + } + if (type.objectFlags & 4 /* Reference */) { + return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); } - return type; } - return instantiateTypeNoAlias(type, mapper); - } - return type; - } - function instantiateTypeNoAlias(type, mapper) { - if (type.flags & 16384 /* TypeParameter */) { - return mapper(type); - } - if (type.flags & 32768 /* Object */) { - if (type.objectFlags & 16 /* Anonymous */) { - // If the anonymous type originates in a declaration of a function, method, class, or - // interface, in an object type literal, or in an object literal expression, we may need - // to instantiate the type because it might reference a type parameter. We skip instantiation - // if none of the type parameters that are in scope in the type's declaration are mapped by - // the given mapper, however we can only do that analysis if the type isn't itself an - // instantiation. - return type.symbol && - type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && - (type.objectFlags & 64 /* Instantiated */ || isSymbolInScopeOfMappedTypeParameter(type.symbol, mapper)) ? - instantiateCached(type, mapper, instantiateAnonymousType) : type; + if (type.flags & 65536 /* Union */ && !(type.flags & 8190 /* Primitive */)) { + return getUnionType(instantiateTypes(type.types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 32 /* Mapped */) { - return instantiateCached(type, mapper, instantiateMappedType); + if (type.flags & 131072 /* Intersection */) { + return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); } - if (type.objectFlags & 4 /* Reference */) { - return createTypeReference(type.target, instantiateTypes(type.typeArguments, mapper)); + if (type.flags & 262144 /* Index */) { + return getIndexType(instantiateType(type.type, mapper)); + } + if (type.flags & 524288 /* IndexedAccess */) { + return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } - } - if (type.flags & 65536 /* Union */ && !(type.flags & 8190 /* Primitive */)) { - return getUnionType(instantiateTypes(type.types, mapper), /*subtypeReduction*/ false, type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 131072 /* Intersection */) { - return getIntersectionType(instantiateTypes(type.types, mapper), type.aliasSymbol, instantiateTypes(type.aliasTypeArguments, mapper)); - } - if (type.flags & 262144 /* Index */) { - return getIndexType(instantiateType(type.type, mapper)); - } - if (type.flags & 524288 /* IndexedAccess */) { - return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper)); } return type; } @@ -30437,6 +30678,7 @@ var ts; switch (node.kind) { case 186 /* FunctionExpression */: case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: return isContextSensitiveFunctionLikeDeclaration(node); case 178 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); @@ -30450,9 +30692,6 @@ var ts; (isContextSensitive(node.left) || isContextSensitive(node.right)); case 261 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 151 /* MethodDeclaration */: - case 150 /* MethodSignature */: - return isContextSensitiveFunctionLikeDeclaration(node); case 185 /* ParenthesizedExpression */: return isContextSensitive(node.expression); case 254 /* JsxAttributes */: @@ -30569,7 +30808,8 @@ var ts; if (!target.hasRestParameter && source.minArgumentCount > target.parameters.length) { return 0 /* False */; } - if (source.typeParameters) { + if (source.typeParameters && source.typeParameters !== target.typeParameters) { + target = getCanonicalSignature(target); source = instantiateSignatureInContextOf(source, target, /*contextualMapper*/ undefined, compareTypes); } var result = -1 /* True */; @@ -30842,7 +31082,14 @@ var ts; var targetStack; var maybeCount = 0; var depth = 0; - var expandingFlags = 0; + var ExpandingFlags; + (function (ExpandingFlags) { + ExpandingFlags[ExpandingFlags["None"] = 0] = "None"; + ExpandingFlags[ExpandingFlags["Source"] = 1] = "Source"; + ExpandingFlags[ExpandingFlags["Target"] = 2] = "Target"; + ExpandingFlags[ExpandingFlags["Both"] = 3] = "Both"; + })(ExpandingFlags || (ExpandingFlags = {})); + var expandingFlags = 0 /* None */; var overflow = false; var isIntersectionConstituent = false; ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); @@ -31060,10 +31307,21 @@ var ts; else { // use the property's value declaration if the property is assigned inside the literal itself var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations); + var suggestion = void 0; if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; })) { - errorNode = prop.valueDeclaration; + var propDeclaration = prop.valueDeclaration; + ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike); + errorNode = propDeclaration; + if (ts.isIdentifier(propDeclaration.name)) { + suggestion = getSuggestionForNonexistentProperty(propDeclaration.name, target); + } + } + if (suggestion !== undefined) { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2, symbolToString(prop), typeToString(target), ts.unescapeLeadingUnderscores(suggestion)); + } + else { + reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } - reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(target)); } } return { value: true }; @@ -31229,11 +31487,11 @@ var ts; targetStack[depth] = target; depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) - expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) - expandingFlags |= 2; - var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; + if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, depth)) + expandingFlags |= 1 /* Source */; + if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, depth)) + expandingFlags |= 2 /* Target */; + var result = expandingFlags !== 3 /* Both */ ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -31287,7 +31545,7 @@ var ts; else if (target.flags & 524288 /* IndexedAccess */) { // A type S is related to a type T[K] if S is related to A[K], where K is string-like and // A is the apparent type of S. - var constraint = getConstraintOfType(target); + var constraint = getConstraintOfIndexedAccess(target); if (constraint) { if (result = isRelatedTo(source, constraint, reportErrors)) { errorInfo = saveErrorInfo; @@ -31326,7 +31584,7 @@ var ts; else if (source.flags & 524288 /* IndexedAccess */) { // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and // A is the apparent type of S. - var constraint = getConstraintOfType(source); + var constraint = getConstraintOfIndexedAccess(source); if (constraint) { if (result = isRelatedTo(constraint, target, reportErrors)) { errorInfo = saveErrorInfo; @@ -31414,22 +31672,21 @@ var ts; if (relation === identityRelation) { return propertiesIdenticalTo(source, target); } + var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128 /* ObjectLiteral */); + var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties); + if (unmatchedProperty) { + if (reportErrors) { + reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(unmatchedProperty), typeToString(source)); + } + return 0 /* False */; + } var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); - var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128 /* ObjectLiteral */); for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { var targetProp = properties_3[_i]; - var sourceProp = getPropertyOfType(source, targetProp.escapedName); - if (sourceProp !== targetProp) { - if (!sourceProp) { - if (!(targetProp.flags & 16777216 /* Optional */) || requireOptionalProperties) { - if (reportErrors) { - reportError(ts.Diagnostics.Property_0_is_missing_in_type_1, symbolToString(targetProp), typeToString(source)); - } - return 0 /* False */; - } - } - else if (!(targetProp.flags & 4194304 /* Prototype */)) { + if (!(targetProp.flags & 4194304 /* Prototype */)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); + if (sourceProp && sourceProp !== targetProp) { var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { @@ -31737,13 +31994,14 @@ var ts; return type.flags & 16384 /* TypeParameter */ && !getConstraintFromTypeParameter(type); } function isTypeReferenceWithGenericArguments(type) { - return getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, isUnconstrainedTypeParameter); + return getObjectFlags(type) & 4 /* Reference */ && ts.some(type.typeArguments, function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); }); } /** * getTypeReferenceId(A) returns "111=0-12=1" * where A.id=111 and number.id=12 */ - function getTypeReferenceId(type, typeParameters) { + function getTypeReferenceId(type, typeParameters, depth) { + if (depth === void 0) { depth = 0; } var result = "" + type.target.id; for (var _i = 0, _a = type.typeArguments; _i < _a.length; _i++) { var t = _a[_i]; @@ -31755,6 +32013,9 @@ var ts; } result += "=" + index; } + else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) { + result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">"; + } else { result += "-" + t.id; } @@ -31958,8 +32219,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -32000,7 +32261,7 @@ var ts; return !!getPropertyOfType(type, "0"); } function isUnitType(type) { - return (type.flags & (224 /* Literal */ | 2048 /* Undefined */ | 4096 /* Null */)) !== 0; + return !!(type.flags & 6368 /* Unit */); } function isLiteralType(type) { return type.flags & 8 /* Boolean */ ? true : @@ -32032,8 +32293,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; result |= getFalsyFlags(t); } return result; @@ -32276,7 +32537,6 @@ var ts; function createInferenceContext(signature, flags, compareTypes, baseInferences) { var inferences = baseInferences ? ts.map(baseInferences, cloneInferenceInfo) : ts.map(signature.typeParameters, createInferenceInfo); var context = mapper; - context.mappedTypes = signature.typeParameters; context.signature = signature; context.inferences = inferences; context.flags = flags; @@ -32317,7 +32577,7 @@ var ts; // results for union and intersection types for performance reasons. function couldContainTypeVariables(type) { var objectFlags = getObjectFlags(type); - return !!(type.flags & 540672 /* TypeVariable */ || + return !!(type.flags & (540672 /* TypeVariable */ | 262144 /* Index */) || objectFlags & 4 /* Reference */ && ts.forEach(type.typeArguments, couldContainTypeVariables) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 2048 /* TypeLiteral */ | 32 /* Class */) || objectFlags & 32 /* Mapped */ || @@ -32375,18 +32635,18 @@ var ts; return inference.candidates && getUnionType(inference.candidates, /*subtypeReduction*/ true); } } - function isPossiblyAssignableTo(source, target) { + function getUnmatchedProperty(source, target, requireOptionalProperties) { var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { var targetProp = properties_5[_i]; - if (!(targetProp.flags & (16777216 /* Optional */ | 4194304 /* Prototype */))) { - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + if (requireOptionalProperties || !(targetProp.flags & 16777216 /* Optional */)) { + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (!sourceProp) { - return false; + return targetProp; } } } - return true; + return undefined; } function inferTypes(inferences, originalSource, originalTarget, priority) { if (priority === void 0) { priority = 0; } @@ -32483,6 +32743,13 @@ var ts; inferFromTypes(sourceTypes[i], targetTypes[i]); } } + else if (source.flags & 262144 /* Index */ && target.flags & 262144 /* Index */) { + inferFromTypes(source.type, target.type); + } + else if (source.flags & 524288 /* IndexedAccess */ && target.flags & 524288 /* IndexedAccess */) { + inferFromTypes(source.objectType, target.objectType); + inferFromTypes(source.indexType, target.indexType); + } else if (target.flags & 196608 /* UnionOrIntersection */) { var targetTypes = target.types; var typeVariableCount = 0; @@ -32508,7 +32775,7 @@ var ts; priority = savePriority; } } - else if (source.flags & 196608 /* UnionOrIntersection */) { + else if (source.flags & 65536 /* Union */) { // Source is a union or intersection type, infer from each constituent type var sourceTypes = source.types; for (var _e = 0, sourceTypes_3 = sourceTypes; _e < sourceTypes_3.length; _e++) { @@ -32518,7 +32785,7 @@ var ts; } else { source = getApparentType(source); - if (source.flags & 32768 /* Object */) { + if (source.flags & (32768 /* Object */ | 131072 /* Intersection */)) { var key = source.id + "," + target.id; if (visited && visited.get(key)) { return; @@ -32557,6 +32824,12 @@ var ts; return undefined; } function inferFromObjectTypes(source, target) { + if (isGenericMappedType(source) && isGenericMappedType(target)) { + // The source and target types are generic types { [P in S]: X } and { [P in T]: Y }, so we infer + // from S to T and from X to Y. + inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target)); + inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target)); + } if (getObjectFlags(target) & 32 /* Mapped */) { var constraintType = getConstraintTypeFromMappedType(target); if (constraintType.flags & 262144 /* Index */) { @@ -32586,7 +32859,7 @@ var ts; } // Infer from the members of source and target only if the two types are possibly related. We check // in both directions because we may be inferring for a co-variant or a contra-variant position. - if (isPossiblyAssignableTo(source, target) || isPossiblyAssignableTo(target, source)) { + if (!getUnmatchedProperty(source, target, /*requireOptionalProperties*/ false) || !getUnmatchedProperty(target, source, /*requireOptionalProperties*/ false)) { inferFromProperties(source, target); inferFromSignatures(source, target, 0 /* Call */); inferFromSignatures(source, target, 1 /* Construct */); @@ -32597,7 +32870,7 @@ var ts; var properties = getPropertiesOfObjectType(target); for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { var targetProp = properties_6[_i]; - var sourceProp = getPropertyOfObjectType(source, targetProp.escapedName); + var sourceProp = getPropertyOfType(source, targetProp.escapedName); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); } @@ -32643,8 +32916,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -32734,7 +33007,8 @@ var ts; function getResolvedSymbol(node) { var links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = !ts.nodeIsMissing(node) && resolveName(node, node.escapedText, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; + links.resolvedSymbol = !ts.nodeIsMissing(node) && + resolveName(node, node.escapedText, 107455 /* Value */ | 1048576 /* ExportValue */, ts.Diagnostics.Cannot_find_name_0, node, !ts.isWriteOnlyAccess(node), ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } @@ -32915,8 +33189,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; result |= getTypeFacts(t); } return result; @@ -33183,8 +33457,8 @@ var ts; var types = type.types; var mappedType; var mappedTypes; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var current = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var current = types_14[_i]; var t = mapper(current); if (t) { if (!mappedType) { @@ -33264,8 +33538,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var t = types_15[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33319,15 +33593,25 @@ var ts; } return false; } + function reportFlowControlError(node) { + var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock); + var sourceFile = ts.getSourceFileOfNode(node); + var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos); + diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis)); + } function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { if (initialType === void 0) { initialType = declaredType; } var key; + var flowDepth = 0; + if (flowAnalysisDisabled) { + return unknownType; + } if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810175 /* Narrowable */)) { return declaredType; } - var visitedFlowStart = visitedFlowCount; + var sharedFlowStart = sharedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); - visitedFlowCount = visitedFlowStart; + sharedFlowCount = sharedFlowStart; // When the reference is 'x' in an 'x.length', 'x.push(value)', 'x.unshift(value)' or x[n] = value' operation, // we give type 'any[]' to 'x' instead of using the type determined by control flow analysis such that operations // on empty arrays are possible without implicit any errors and new element types can be inferred without @@ -33338,60 +33622,70 @@ var ts; } return resultType; function getTypeAtFlowNode(flow) { + if (flowDepth === 2500) { + // We have made 2500 recursive invocations. To avoid overflowing the call stack we report an error + // and disable further control flow analysis in the containing function or module body. + flowAnalysisDisabled = true; + reportFlowControlError(reference); + return unknownType; + } + flowDepth++; while (true) { - if (flow.flags & 1024 /* Shared */) { + var flags = flow.flags; + if (flags & 1024 /* Shared */) { // We cache results of flow type resolution for shared nodes that were previously visited in // the same getFlowTypeOfReference invocation. A node is considered shared when it is the // antecedent of more than one node. - for (var i = visitedFlowStart; i < visitedFlowCount; i++) { - if (visitedFlowNodes[i] === flow) { - return visitedFlowTypes[i]; + for (var i = sharedFlowStart; i < sharedFlowCount; i++) { + if (sharedFlowNodes[i] === flow) { + flowDepth--; + return sharedFlowTypes[i]; } } } var type = void 0; - if (flow.flags & 4096 /* AfterFinally */) { + if (flags & 4096 /* AfterFinally */) { // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; } - else if (flow.flags & 2048 /* PreFinally */) { + else if (flags & 2048 /* PreFinally */) { // locked pre-finally flows are filtered out in getTypeAtFlowBranchLabel // so here just redirect to antecedent flow = flow.antecedent; continue; } - else if (flow.flags & 16 /* Assignment */) { + else if (flags & 16 /* Assignment */) { type = getTypeAtFlowAssignment(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 96 /* Condition */) { + else if (flags & 96 /* Condition */) { type = getTypeAtFlowCondition(flow); } - else if (flow.flags & 128 /* SwitchClause */) { + else if (flags & 128 /* SwitchClause */) { type = getTypeAtSwitchClause(flow); } - else if (flow.flags & 12 /* Label */) { + else if (flags & 12 /* Label */) { if (flow.antecedents.length === 1) { flow = flow.antecedents[0]; continue; } - type = flow.flags & 4 /* BranchLabel */ ? + type = flags & 4 /* BranchLabel */ ? getTypeAtFlowBranchLabel(flow) : getTypeAtFlowLoopLabel(flow); } - else if (flow.flags & 256 /* ArrayMutation */) { + else if (flags & 256 /* ArrayMutation */) { type = getTypeAtFlowArrayMutation(flow); if (!type) { flow = flow.antecedent; continue; } } - else if (flow.flags & 2 /* Start */) { + else if (flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; if (container && container !== flowContainer && reference.kind !== 179 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { @@ -33406,12 +33700,13 @@ var ts; // simply return the non-auto declared type to reduce follow-on errors. type = convertAutoToAny(declaredType); } - if (flow.flags & 1024 /* Shared */) { + if (flags & 1024 /* Shared */) { // Record visited node and the associated type in the cache. - visitedFlowNodes[visitedFlowCount] = flow; - visitedFlowTypes[visitedFlowCount] = type; - visitedFlowCount++; + sharedFlowNodes[sharedFlowCount] = flow; + sharedFlowTypes[sharedFlowCount] = type; + sharedFlowCount++; } + flowDepth--; return type; } } @@ -33447,30 +33742,32 @@ var ts; return undefined; } function getTypeAtFlowArrayMutation(flow) { - var node = flow.node; - var expr = node.kind === 181 /* CallExpression */ ? - node.expression.expression : - node.left.expression; - if (isMatchingReference(reference, getReferenceCandidate(expr))) { - var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); - if (getObjectFlags(type) & 256 /* EvolvingArray */) { - var evolvedType_1 = type; - if (node.kind === 181 /* CallExpression */) { - for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { - var arg = _a[_i]; - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + if (declaredType === autoType || declaredType === autoArrayType) { + var node = flow.node; + var expr = node.kind === 181 /* CallExpression */ ? + node.expression.expression : + node.left.expression; + if (isMatchingReference(reference, getReferenceCandidate(expr))) { + var flowType = getTypeAtFlowNode(flow.antecedent); + var type = getTypeFromFlowType(flowType); + if (getObjectFlags(type) & 256 /* EvolvingArray */) { + var evolvedType_1 = type; + if (node.kind === 181 /* CallExpression */) { + for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { + var arg = _a[_i]; + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); + } } - } - else { - var indexType = getTypeOfExpression(node.left.argumentExpression); - if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { - evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + else { + var indexType = getTypeOfExpression(node.left.argumentExpression); + if (isTypeAssignableToKind(indexType, 84 /* NumberLike */)) { + evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right); + } } + return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); } - return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType)); + return flowType; } - return flowType; } return undefined; } @@ -33530,9 +33827,7 @@ var ts; if (type === declaredType && declaredType === initialType) { return type; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control // flow using the instanceof operator or a user defined type predicate. @@ -33598,9 +33893,7 @@ var ts; if (cached_1) { return cached_1; } - if (!ts.contains(antecedentTypes, type)) { - antecedentTypes.push(type); - } + ts.pushIfUnique(antecedentTypes, type); // If an antecedent type is not a subset of the declared type, we need to perform // subtype reduction. This happens when a "foreign" type is injected into the control // flow using the instanceof operator or a user defined type predicate. @@ -34571,7 +34864,8 @@ var ts; } } } - if (noImplicitThis || ts.isInJavaScriptFile(func)) { + var inJs = ts.isInJavaScriptFile(func); + if (noImplicitThis || inJs) { var containingLiteral = getContainingObjectLiteral(func); if (containingLiteral) { // We have an object literal method. Check if the containing object literal has a contextual type @@ -34598,10 +34892,19 @@ var ts; } // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the // contextual type for 'this' is 'obj'. - if (func.parent.kind === 194 /* BinaryExpression */ && func.parent.operatorToken.kind === 58 /* EqualsToken */) { - var target = func.parent.left; + var parent = func.parent; + if (parent.kind === 194 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */) { + var target = parent.left; if (target.kind === 179 /* PropertyAccessExpression */ || target.kind === 180 /* ElementAccessExpression */) { - return checkExpressionCached(target.expression); + var expression = target.expression; + // Don't contextually type `this` as `exports` in `exports.Point = function(x, y) { this.x = x; this.y = y; }` + if (inJs && ts.isIdentifier(expression)) { + var sourceFile = ts.getSourceFileOfNode(parent); + if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) { + return undefined; + } + } + return checkExpressionCached(expression); } } } @@ -34776,7 +35079,7 @@ var ts; // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { - type = getTypeOfExpression(binaryExpression.left); + type = getTypeOfExpression(binaryExpression.left, /*cache*/ true); } return type; } @@ -34834,16 +35137,10 @@ var ts; // the type of the property with the numeric name N in T, if one exists. Otherwise, if T has a numeric index signature, // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated // type of T. - function getContextualTypeForElementExpression(node) { - var arrayLiteral = node.parent; - var type = getApparentTypeOfContextualType(arrayLiteral); - if (type) { - var index = ts.indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index) - || getIndexTypeOfContextualType(type, 1 /* Number */) - || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false); - } - return undefined; + function getContextualTypeForElementExpression(arrayContextualType, index) { + return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index) + || getIndexTypeOfContextualType(arrayContextualType, 1 /* Number */) + || getIteratedTypeOrElementType(arrayContextualType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. function getContextualTypeForConditionalOperand(node) { @@ -34948,15 +35245,21 @@ var ts; return getContextualTypeForObjectLiteralElement(parent); case 263 /* SpreadAssignment */: return getApparentTypeOfContextualType(parent.parent); - case 177 /* ArrayLiteralExpression */: - return getContextualTypeForElementExpression(node); + case 177 /* ArrayLiteralExpression */: { + var arrayLiteral = parent; + var type = getApparentTypeOfContextualType(arrayLiteral); + return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node)); + } case 195 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); case 205 /* TemplateSpan */: ts.Debug.assert(parent.parent.kind === 196 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 185 /* ParenthesizedExpression */: - return getContextualType(parent); + case 185 /* ParenthesizedExpression */: { + // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. + var tag = ts.isInJavaScriptFile(parent) ? ts.getJSDocTypeTag(parent) : undefined; + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); + } case 256 /* JsxExpression */: return getContextualTypeForJsxExpression(parent); case 253 /* JsxAttribute */: @@ -35028,8 +35331,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var current = types_16[_i]; var signature = getContextualCallSignature(current, node); if (signature) { if (!signatureList) { @@ -35072,8 +35375,9 @@ var ts; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); - for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { - var e = elements_1[_i]; + var contextualType = getApparentTypeOfContextualType(node); + for (var index = 0; index < elements.length; index++) { + var e = elements[index]; if (inDestructuringPattern && e.kind === 198 /* SpreadElement */) { // Given the following situation: // var c: {}; @@ -35095,7 +35399,8 @@ var ts; } } else { - var type = checkExpressionForMutableLocation(e, checkMode); + var elementContextualType = getContextualTypeForElementExpression(contextualType, index); + var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === 198 /* SpreadElement */; @@ -35108,9 +35413,9 @@ var ts; type.pattern = node; return type; } - var contextualType = getApparentTypeOfContextualType(node); - if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { - var pattern = contextualType.pattern; + var contextualType_1 = getApparentTypeOfContextualType(node); + if (contextualType_1 && contextualTypeIsTupleLikeType(contextualType_1)) { + var pattern = contextualType_1.pattern; // If array literal is contextually typed by a binding pattern or an assignment pattern, pad the resulting // tuple type with the corresponding binding or assignment element types to make the lengths equal. if (pattern && (pattern.kind === 175 /* ArrayBindingPattern */ || pattern.kind === 177 /* ArrayLiteralExpression */)) { @@ -35118,7 +35423,7 @@ var ts; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; if (hasDefaultValue(patternElement)) { - elementTypes.push(contextualType.typeArguments[i]); + elementTypes.push(contextualType_1.typeArguments[i]); } else { if (patternElement.kind !== 200 /* OmittedExpression */) { @@ -35230,6 +35535,7 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; + var literalName = void 0; if (memberDecl.kind === 261 /* PropertyAssignment */ || memberDecl.kind === 262 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { @@ -35239,6 +35545,12 @@ var ts; } var type = void 0; if (memberDecl.kind === 261 /* PropertyAssignment */) { + if (memberDecl.name.kind === 144 /* ComputedPropertyName */) { + var t = checkComputedPropertyName(memberDecl.name); + if (t.flags & 224 /* Literal */) { + literalName = ts.escapeLeadingUnderscores("" + t.value); + } + } type = checkPropertyAssignment(memberDecl, checkMode); } else if (memberDecl.kind === 151 /* MethodDeclaration */) { @@ -35253,7 +35565,7 @@ var ts; type = jsdocType; } typeFlags |= type.flags; - var prop = createSymbol(4 /* Property */ | member.flags, member.escapedName); + var prop = createSymbol(4 /* Property */ | member.flags, literalName || member.escapedName); if (inDestructuringPattern) { // If object literal is an assignment pattern and if the assignment pattern specifies a default value // for the property, make the property optional. @@ -35262,7 +35574,7 @@ var ts; if (isOptional) { prop.flags |= 16777216 /* Optional */; } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { patternWithComputedProperties = true; } } @@ -35316,7 +35628,7 @@ var ts; ts.Debug.assert(memberDecl.kind === 153 /* GetAccessor */ || memberDecl.kind === 154 /* SetAccessor */); checkNodeDeferred(memberDecl); } - if (ts.hasDynamicName(memberDecl)) { + if (!literalName && ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { hasComputedNumberProperty = true; } @@ -35377,7 +35689,8 @@ var ts; } } function isValidSpreadType(type) { - return !!(type.flags & (1 /* Any */ | 4096 /* Null */ | 2048 /* Undefined */ | 16777216 /* NonPrimitive */) || + return !!(type.flags & (1 /* Any */ | 16777216 /* NonPrimitive */) || + getFalsyFlags(type) & 7392 /* DefinitelyFalsy */ && isValidSpreadType(removeDefinitelyFalsyTypes(type)) || type.flags & 32768 /* Object */ && !isGenericMappedType(type) || type.flags & 196608 /* UnionOrIntersection */ && !ts.forEach(type.types, function (t) { return !isValidSpreadType(t); })); } @@ -35622,8 +35935,9 @@ var ts; for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { var signature = signatures_3[_i]; if (signature.typeParameters) { - var typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + var isJavascript = ts.isInJavaScriptFile(node); + var typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0, isJavascript); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); } else { instantiatedSignatures.push(signature); @@ -36016,7 +36330,7 @@ var ts; // And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error. var reactRefErr = diagnostics && compilerOptions.jsx === 2 /* React */ ? ts.Diagnostics.Cannot_find_name_0 : undefined; var reactNamespace = getJsxNamespace(); - var reactSym = resolveName(node.tagName, reactNamespace, 107455 /* Value */, reactRefErr, reactNamespace); + var reactSym = resolveName(node.tagName, reactNamespace, 107455 /* Value */, reactRefErr, reactNamespace, /*isUse*/ true); if (reactSym) { // Mark local symbol as referenced here because it might not have been marked // if jsx emit was not react as there wont be error being emitted @@ -36264,19 +36578,8 @@ var ts; } return unknownType; } - if (prop.valueDeclaration) { - if (isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - if (prop.valueDeclaration.kind === 229 /* ClassDeclaration */ && - node.parent && node.parent.kind !== 159 /* TypeReference */ && - !ts.isInAmbientContext(prop.valueDeclaration) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); - } - } - markPropertyAsReferenced(prop); + checkPropertyNotUsedBeforeDeclaration(prop, node, right); + markPropertyAsReferenced(prop, node); getNodeLinks(node).resolvedSymbol = prop; checkPropertyAccessibility(node, left, apparentType, prop); var propType = getDeclaredOrApparentType(prop, node); @@ -36298,6 +36601,61 @@ var ts; var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function checkPropertyNotUsedBeforeDeclaration(prop, node, right) { + var valueDeclaration = prop.valueDeclaration; + if (!valueDeclaration) { + return; + } + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) + && !isPropertyDeclaredInAncestorClass(prop)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + else if (valueDeclaration.kind === 229 /* ClassDeclaration */ && + node.parent.kind !== 159 /* TypeReference */ && + !ts.isInAmbientContext(valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, ts.unescapeLeadingUnderscores(right.escapedText)); + } + } + function isInPropertyInitializer(node) { + return !!ts.findAncestor(node, function (node) { + switch (node.kind) { + case 149 /* PropertyDeclaration */: + return true; + case 261 /* PropertyAssignment */: + // We might be in `a = { b: this.b }`, so keep looking. See `tests/cases/compiler/useBeforeDeclaration_propertyAssignment.ts`. + return false; + default: + return ts.isPartOfExpression(node) ? false : "quit"; + } + }); + } + /** + * It's possible that "prop.valueDeclaration" is a local declaration, but the property was also declared in a superclass. + * In that case we won't consider it used before its declaration, because it gets its value from the superclass' declaration. + */ + function isPropertyDeclaredInAncestorClass(prop) { + var classType = getTypeOfSymbol(prop.parent); + while (true) { + classType = getSuperClass(classType); + if (!classType) { + return false; + } + var superProperty = getPropertyOfObjectType(classType, prop.escapedName); + if (superProperty && superProperty.valueDeclaration) { + return true; + } + } + } + function getSuperClass(classType) { + var x = getBaseTypes(classType); + if (x.length === 0) { + return undefined; + } + ts.Debug.assert(x.length === 1); + return x[0]; + } function reportNonexistentProperty(propNode, containingType) { var errorInfo; if (containingType.flags & 65536 /* Union */ && !(containingType.flags & 8190 /* Primitive */)) { @@ -36310,8 +36668,8 @@ var ts; } } var suggestion = getSuggestionForNonexistentProperty(propNode, containingType); - if (suggestion) { - errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), suggestion); + if (suggestion !== undefined) { + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, ts.declarationNameToString(propNode), typeToString(containingType), ts.unescapeLeadingUnderscores(suggestion)); } else { errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType)); @@ -36323,7 +36681,7 @@ var ts; return suggestion && suggestion.escapedName; } function getSuggestionForNonexistentSymbol(location, name, meaning) { - var result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, function (symbols, name, meaning) { + var result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, /*isUse*/ false, function (symbols, name, meaning) { var symbol = getSymbol(symbols, name, meaning); if (symbol) { // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function @@ -36402,11 +36760,12 @@ var ts; } return bestCandidate; } - function markPropertyAsReferenced(prop) { + function markPropertyAsReferenced(prop, nodeForCheckWriteOnly) { if (prop && noUnusedIdentifiers && (prop.flags & 106500 /* ClassMember */) && - prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8 /* Private */)) { + prop.valueDeclaration && ts.hasModifier(prop.valueDeclaration, 8 /* Private */) + && !(nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly))) { if (ts.getCheckFlags(prop) & 1 /* Instantiated */) { getSymbolLinks(prop).target.isReferenced = true; } @@ -36415,15 +36774,6 @@ var ts; } } } - function isInPropertyInitializer(node) { - while (node) { - if (node.parent && node.parent.kind === 149 /* PropertyDeclaration */ && node.parent.initializer === node) { - return true; - } - node = node.parent; - } - return false; - } function isValidPropertyAccess(node, propertyName) { var left = node.kind === 179 /* PropertyAccessExpression */ ? node.expression @@ -36648,7 +36998,6 @@ var ts; var argCount; // Apparent number of arguments we will have in this call var typeArguments; // Type arguments (undefined if none) var callIsIncomplete; // In incomplete call we want to be lenient when we have too few arguments - var isDecorator; var spreadArgIndex = -1; if (ts.isJsxOpeningLikeElement(node)) { // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". @@ -36678,7 +37027,6 @@ var ts; } } else if (node.kind === 147 /* Decorator */) { - isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); } @@ -36738,7 +37086,7 @@ var ts; if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), 4 /* ReturnType */); } - return getSignatureInstantiation(signature, getInferredTypes(context)); + return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJavaScriptFile(contextualSignature.declaration)); } function inferTypeArguments(node, signature, args, excludeArgument, context) { // Clear out all the inference results from the last time inferTypeArguments was called on this context @@ -36756,7 +37104,7 @@ var ts; // example, given a 'function wrap(cb: (x: T) => U): (x: T) => U' and a call expression // 'let f: (x: string) => number = wrap(s => s.length)', we infer from the declared type of 'f' to the // return type of 'wrap'. - if (ts.isExpression(node)) { + if (node.kind !== 147 /* Decorator */) { var contextualType = getContextualType(node); if (contextualType) { // We clone the contextual mapper to avoid disturbing a resolution in progress for an @@ -36772,7 +37120,7 @@ var ts; // Above, the type of the 'value' parameter is inferred to be 'A'. var contextualSignature = getSingleCallSignature(instantiatedType); var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, ts.isInJavaScriptFile(node))) : instantiatedType; var inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -37415,8 +37763,9 @@ var ts; candidate = originalCandidate; if (candidate.typeParameters) { var typeArgumentTypes = void 0; + var isJavascript = ts.isInJavaScriptFile(candidate.declaration); if (typeArguments) { - typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); + typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript); if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) { candidateForTypeArgumentError = originalCandidate; break; @@ -37425,7 +37774,7 @@ var ts; else { typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); } if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { candidateForArgumentError = candidate; @@ -37559,15 +37908,6 @@ var ts; // Another error has already been reported return resolveErrorCall(node); } - // If the expression is a class of abstract type, then it cannot be instantiated. - // Note, only class declarations can be declared abstract. - // In the case of a merged class-module or class-interface declaration, - // only the class declaration node will have the Abstract flag set. - var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); - if (valueDecl && ts.hasModifier(valueDecl, 128 /* Abstract */)) { - error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); - return resolveErrorCall(node); - } // TS 1.0 spec: 4.11 // If expressionType is of type Any, Args can be any argument // list and the result of the operation is of type Any. @@ -37586,6 +37926,15 @@ var ts; if (!isConstructorAccessible(node, constructSignatures[0])) { return resolveErrorCall(node); } + // If the expression is a class of abstract type, then it cannot be instantiated. + // Note, only class declarations can be declared abstract. + // In the case of a merged class-module or class-interface declaration, + // only the class declaration node will have the Abstract flag set. + var valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); + if (valueDecl && ts.hasModifier(valueDecl, 128 /* Abstract */)) { + error(node, ts.Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, ts.declarationNameToString(ts.getNameOfDeclaration(valueDecl))); + return resolveErrorCall(node); + } return resolveCall(node, constructSignatures, candidatesOutArray); } // If expressionType's apparent type is an object type with no construct signatures but @@ -37732,8 +38081,8 @@ var ts; if (elementType.flags & 65536 /* Union */) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var type = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var type = types_17[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -37759,7 +38108,7 @@ var ts; // This code-path is called by language service return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } - ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); + ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable."); } /** * Resolve a signature of a given call-like expression. @@ -37791,18 +38140,32 @@ var ts; * file. */ function isJavaScriptConstructor(node) { - if (ts.isInJavaScriptFile(node)) { + if (node && ts.isInJavaScriptFile(node)) { // If the node has a @class tag, treat it like a constructor. if (ts.getJSDocClassTag(node)) return true; // If the symbol of the node has members, treat it like a constructor. var symbol = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? getSymbolOfNode(node) : - ts.isVariableDeclaration(node) && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : + ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; return symbol && symbol.members !== undefined; } return false; } + function getJavaScriptClassType(symbol) { + if (ts.isDeclarationOfFunctionOrClassExpression(symbol)) { + symbol = getSymbolOfNode(symbol.valueDeclaration.initializer); + } + if (isJavaScriptConstructor(symbol.valueDeclaration)) { + return getInferredClassType(symbol); + } + if (symbol.flags & 3 /* Variable */) { + var valueType = getTypeOfSymbol(symbol); + if (valueType.symbol && !isInferredClassType(valueType) && isJavaScriptConstructor(valueType.symbol.valueDeclaration)) { + return getInferredClassType(valueType.symbol); + } + } + } function getInferredClassType(symbol) { var links = getSymbolLinks(symbol); if (!links.inferredClassType) { @@ -37842,13 +38205,11 @@ var ts; var funcSymbol = node.expression.kind === 71 /* Identifier */ ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { - funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + var type = funcSymbol && getJavaScriptClassType(funcSymbol); + if (type) { + return type; } - if (funcSymbol && funcSymbol.flags & 16 /* Function */ && (funcSymbol.members || ts.getJSDocClassTag(funcSymbol.valueDeclaration))) { - return getInferredClassType(funcSymbol); - } - else if (noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -37914,7 +38275,7 @@ var ts; // Make sure require is not a local function if (!ts.isIdentifier(node.expression)) throw ts.Debug.fail(); - var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (!resolvedRequire) { // project does not contain symbol named 'require' - assume commonjs require return true; @@ -38022,8 +38383,9 @@ var ts; } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { + // parameter might be a transient symbol generated by use of `arguments` in the function body. var parameter = ts.lastOrUndefined(signature.parameters); - if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { + if (isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType); } @@ -38169,9 +38531,7 @@ var ts; ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } - if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } }); return aggregatedTypes; @@ -38219,9 +38579,7 @@ var ts; if (type.flags & 8192 /* Never */) { hasReturnOfTypeNever = true; } - else if (!ts.contains(aggregatedTypes, type)) { - aggregatedTypes.push(type); - } + ts.pushIfUnique(aggregatedTypes, type); } else { hasReturnWithNoExpression = true; @@ -38232,9 +38590,7 @@ var ts; return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { - if (!ts.contains(aggregatedTypes, undefinedType)) { - aggregatedTypes.push(undefinedType); - } + ts.pushIfUnique(aggregatedTypes, undefinedType); } return aggregatedTypes; } @@ -38539,8 +38895,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var t = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var t = types_18[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -39097,20 +39453,6 @@ var ts; var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } - function checkLiteralExpression(node) { - switch (node.kind) { - case 13 /* NoSubstitutionTemplateLiteral */: - case 9 /* StringLiteral */: - return getFreshTypeOfLiteralType(getLiteralType(node.text)); - case 8 /* NumericLiteral */: - checkGrammarNumericLiteral(node); - return getFreshTypeOfLiteralType(getLiteralType(+node.text)); - case 101 /* TrueKeyword */: - return trueType; - case 86 /* FalseKeyword */: - return falseType; - } - } function checkTemplateExpression(node) { // We just want to check each expressions, but we are unconcerned with // the type of each expression, as any value may be coerced into a string. @@ -39173,9 +39515,13 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, checkMode) { + function checkExpressionForMutableLocation(node, checkMode, contextualType) { + if (arguments.length === 2) { + contextualType = getContextualType(node); + } var type = checkExpression(node, checkMode); - return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); + var shouldWiden = isTypeAssertion(node) || isLiteralContextualType(contextualType); + return shouldWiden ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node, checkMode) { // Do not use hasDynamicName here, because that returns false for well known symbols. @@ -39279,13 +39625,9 @@ var ts; return type; } function checkParenthesizedExpression(node, checkMode) { - if (ts.isInJavaScriptFile(node) && node.jsDoc) { - var typecasts = ts.flatMap(node.jsDoc, function (doc) { return ts.filter(doc.tags, function (tag) { return tag.kind === 281 /* JSDocTypeTag */; }); }); - if (typecasts && typecasts.length) { - // We should have already issued an error if there were multiple type jsdocs - var cast_1 = typecasts[0]; - return checkAssertionWorker(cast_1, cast_1.typeExpression.type, node.expression, checkMode); - } + var tag = ts.isInJavaScriptFile(node) ? ts.getJSDocTypeTag(node) : undefined; + if (tag) { + return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -39301,10 +39643,14 @@ var ts; return nullWideningType; case 13 /* NoSubstitutionTemplateLiteral */: case 9 /* StringLiteral */: + return getFreshTypeOfLiteralType(getLiteralType(node.text)); case 8 /* NumericLiteral */: + checkGrammarNumericLiteral(node); + return getFreshTypeOfLiteralType(getLiteralType(+node.text)); case 101 /* TrueKeyword */: + return trueType; case 86 /* FalseKeyword */: - return checkLiteralExpression(node); + return falseType; case 196 /* TemplateExpression */: return checkTemplateExpression(node); case 12 /* RegularExpressionLiteral */: @@ -39920,7 +40266,7 @@ var ts; var constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); + typeArguments = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, ts.isInJavaScriptFile(typeArgumentNodes[i])); mapper = createTypeMapper(typeParameters, typeArguments); } var typeArgument = typeArguments[i]; @@ -39994,6 +40340,10 @@ var ts; var objectType = type.objectType; var indexType = type.indexType; if (isTypeAssignableTo(indexType, getIndexType(objectType))) { + if (accessNode.kind === 180 /* ElementAccessExpression */ && ts.isAssignmentTarget(accessNode) && + getObjectFlags(objectType) & 32 /* Mapped */ && objectType.declaration.readonlyToken) { + error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType)); + } return type; } // Check if we're indexing with a numeric type and if either object or index types @@ -40296,6 +40646,8 @@ var ts; switch (d.kind) { case 230 /* InterfaceDeclaration */: case 231 /* TypeAliasDeclaration */: + // A jsdoc typedef is, by definition, a type alias + case 283 /* JSDocTypedefTag */: return 2 /* ExportType */; case 233 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ @@ -40304,7 +40656,10 @@ var ts; case 229 /* ClassDeclaration */: case 232 /* EnumDeclaration */: return 2 /* ExportType */ | 1 /* ExportValue */; + // The below options all declare an Alias, which is allowed to merge with other values within the importing module case 237 /* ImportEqualsDeclaration */: + case 240 /* NamespaceImport */: + case 239 /* ImportClause */: var result_3 = 0 /* None */; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -40613,8 +40968,11 @@ var ts; markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node)); } function markEntityNameOrEntityExpressionAsReference(typeName) { - var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.escapedText, (typeName.kind === 71 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + if (!typeName) + return; + var rootName = getFirstIdentifier(typeName); + var meaning = (typeName.kind === 71 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 2097152 /* Alias */; + var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isRefernce*/ true); if (rootSymbol && rootSymbol.flags & 2097152 /* Alias */ && symbolIsValue(rootSymbol) @@ -40738,22 +41096,13 @@ var ts; checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name); } } - function checkJSDoc(node) { - if (!ts.isInJavaScriptFile(node)) { - return; - } - ts.forEach(node.jsDoc, checkSourceElement); - } - function checkJSDocComment(node) { - if (node.tags) { - for (var _i = 0, _a = node.tags; _i < _a.length; _i++) { - var tag = _a[_i]; - checkSourceElement(tag); - } + function checkJSDocTypedefTag(node) { + if (!node.typeExpression) { + // If the node had `@property` tags, `typeExpression` would have been set to the first property tag. + error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags); } } function checkFunctionOrMethodDeclaration(node) { - checkJSDoc(node); checkDecorators(node); checkSignatureDeclaration(node); var functionFlags = ts.getFunctionFlags(node); @@ -40879,11 +41228,11 @@ var ts; !ts.isParameterPropertyDeclaration(parameter) && !ts.parameterIsThisKeyword(parameter) && !parameterNameStartsWithUnderscore(name)) { - error(name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(local.escapedName)); + error(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(local.escapedName)); } } else if (compilerOptions.noUnusedLocals) { - ts.forEach(local.declarations, function (d) { return errorUnusedLocal(ts.getNameOfDeclaration(d) || d, ts.unescapeLeadingUnderscores(local.escapedName)); }); + ts.forEach(local.declarations, function (d) { return errorUnusedLocal(d, ts.unescapeLeadingUnderscores(local.escapedName)); }); } } }); @@ -40896,15 +41245,17 @@ var ts; } return false; } - function errorUnusedLocal(node, name) { + function errorUnusedLocal(declaration, name) { + var node = ts.getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { - var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 226 /* VariableDeclaration */ && ts.isForInOrOfStatement(declaration.parent.parent)) { + var declaration_2 = ts.getRootDeclaration(node.parent); + if ((declaration_2.kind === 226 /* VariableDeclaration */ && ts.isForInOrOfStatement(declaration_2.parent.parent)) || + declaration_2.kind === 145 /* TypeParameter */) { return; } } if (!isRemovedPropertyFromObjectSpread(node.kind === 71 /* Identifier */ ? node.parent : node)) { - error(node, ts.Diagnostics._0_is_declared_but_never_used, name); + error(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name); } } function parameterNameStartsWithUnderscore(parameterName) { @@ -40920,14 +41271,14 @@ var ts; var member = _a[_i]; if (member.kind === 151 /* MethodDeclaration */ || member.kind === 149 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.hasModifier(member, 8 /* Private */)) { - error(member.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); + error(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(member.symbol.escapedName)); } } else if (member.kind === 152 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.hasModifier(parameter, 8 /* Private */)) { - error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); + error(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(parameter.symbol.escapedName)); } } } @@ -40947,8 +41298,8 @@ var ts; } for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) { var typeParameter = _a[_i]; - if (!getMergedSymbol(typeParameter.symbol).isReferenced) { - error(typeParameter.name, ts.Diagnostics._0_is_declared_but_never_used, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); + if (!getMergedSymbol(typeParameter.symbol).isReferenced && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { + error(typeParameter.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } } @@ -40961,7 +41312,7 @@ var ts; for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; if (!ts.isAmbientModule(declaration)) { - errorUnusedLocal(ts.getNameOfDeclaration(declaration), ts.unescapeLeadingUnderscores(local.escapedName)); + errorUnusedLocal(declaration, ts.unescapeLeadingUnderscores(local.escapedName)); } } } @@ -40973,7 +41324,14 @@ var ts; if (node.kind === 207 /* Block */) { checkGrammarStatementInAmbientContext(node); } - ts.forEach(node.statements, checkSourceElement); + if (ts.isFunctionOrModuleBlock(node)) { + var saveFlowAnalysisDisabled = flowAnalysisDisabled; + ts.forEach(node.statements, checkSourceElement); + flowAnalysisDisabled = saveFlowAnalysisDisabled; + } + else { + ts.forEach(node.statements, checkSourceElement); + } if (node.locals) { registerForUnusedIdentifiersCheck(node); } @@ -41143,7 +41501,7 @@ var ts; if (symbol.flags & 1 /* FunctionScopedVariable */) { if (!ts.isIdentifier(node.name)) throw ts.Debug.fail(); - var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined); + var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3 /* Variable */, /*nodeNotFoundErrorMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (localDeclarationSymbol && localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { @@ -41191,7 +41549,7 @@ var ts; else if (n.kind === 71 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name - var symbol = resolveName(n, n.escapedText, 107455 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + var symbol = resolveName(n, n.escapedText, 107455 /* Value */ | 2097152 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; } @@ -41268,7 +41626,7 @@ var ts; var parentType = getTypeForBindingElementParent(parent); var name = node.propertyName || node.name; var property = getPropertyOfType(parentType, ts.getTextOfPropertyName(name)); - markPropertyAsReferenced(property); + markPropertyAsReferenced(property, /*nodeForCheckWriteOnly*/ undefined); // A destructuring is never a write-only reference. if (parent.initializer && property) { checkPropertyAccessibility(parent, parent.initializer, parentType, property); } @@ -42955,9 +43313,9 @@ var ts; } } else { - if (modulekind === ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { + if (modulekind >= ts.ModuleKind.ES2015 && !ts.isInAmbientContext(node)) { // Import equals declaration is deprecated in es6 or above - grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); + grammarErrorOnNode(node, ts.Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead); } } } @@ -42988,7 +43346,7 @@ var ts; if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) { error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol)); } - if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015) { + if (modulekind !== ts.ModuleKind.System && modulekind !== ts.ModuleKind.ES2015 && modulekind !== ts.ModuleKind.ESNext) { checkExternalEmitHelpers(node, 32768 /* ExportStar */); } } @@ -43007,7 +43365,7 @@ var ts; var exportedName = node.propertyName || node.name; // find immediate value referenced by exported name (SymbolFlags.Alias is set so we don't chase down aliases) var symbol = resolveName(exportedName, exportedName.escapedText, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */, - /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); if (symbol && (symbol === undefinedSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) { error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.unescapeLeadingUnderscores(exportedName.escapedText)); } @@ -43042,10 +43400,13 @@ var ts; checkExpressionCached(node.expression); } checkExternalModuleExports(container); + if (ts.isInAmbientContext(node) && !ts.isEntityNameExpression(node.expression)) { + grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context); + } if (node.isExportEquals && !ts.isInAmbientContext(node)) { - if (modulekind === ts.ModuleKind.ES2015) { + if (modulekind >= ts.ModuleKind.ES2015) { // export assignment is not supported in es6 modules - grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead); + grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead); } else if (modulekind === ts.ModuleKind.System) { // system modules does not support export assignment @@ -43079,7 +43440,7 @@ var ts; if (flags & (1920 /* Namespace */ | 64 /* Interface */ | 384 /* Enum */)) { return; } - var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverload); + var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor); if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) { // it is legal to merge type alias with other values // so count should be either 1 (just type alias) or 2 (type alias + merged value) @@ -43096,15 +43457,25 @@ var ts; }); links.exportsChecked = true; } - function isNotOverload(declaration) { - return (declaration.kind !== 228 /* FunctionDeclaration */ && declaration.kind !== 151 /* MethodDeclaration */) || - !!declaration.body; - } + } + function isNotAccessor(declaration) { + // Accessors check for their own matching duplicates, and in contexts where they are valid, there are already duplicate identifier checks + return !ts.isAccessor(declaration); + } + function isNotOverload(declaration) { + return (declaration.kind !== 228 /* FunctionDeclaration */ && declaration.kind !== 151 /* MethodDeclaration */) || + !!declaration.body; } function checkSourceElement(node) { if (!node) { return; } + if (ts.isInJavaScriptFile(node) && node.jsDoc) { + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var tags = _a[_i].tags; + ts.forEach(tags, checkSourceElement); + } + } var kind = node.kind; if (cancellationToken) { // Only bother checking on a few construct kinds. We don't want to be excessively @@ -43158,8 +43529,8 @@ var ts; case 168 /* ParenthesizedType */: case 170 /* TypeOperator */: return checkSourceElement(node.type); - case 275 /* JSDocComment */: - return checkJSDocComment(node); + case 283 /* JSDocTypedefTag */: + return checkJSDocTypedefTag(node); case 279 /* JSDocParameterTag */: return checkSourceElement(node.typeExpression); case 273 /* JSDocFunctionType */: @@ -43304,6 +43675,7 @@ var ts; ts.clear(potentialNewTargetCollisions); deferredNodes = []; deferredUnusedIdentifierNodes = produceDiagnostics && noUnusedIdentifiers ? [] : undefined; + flowAnalysisDisabled = false; ts.forEach(node.statements, checkSourceElement); checkDeferredNodes(); if (ts.isExternalModule(node)) { @@ -43674,12 +44046,14 @@ var ts; return sig.thisParameter; } } + if (ts.isInExpressionContext(node)) { + return checkExpression(node).symbol; + } // falls through - case 97 /* SuperKeyword */: - var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); - return type.symbol; case 169 /* ThisType */: - return getTypeFromTypeNode(node).symbol; + return getTypeFromThisTypeNode(node).symbol; + case 97 /* SuperKeyword */: + return checkExpression(node).symbol; case 123 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; @@ -43699,13 +44073,17 @@ var ts; // falls through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { - var objectType = getTypeOfExpression(node.parent.expression); - return getPropertyOfType(objectType, node.text); - } - break; + var objectType = ts.isElementAccessExpression(node.parent) + ? node.parent.argumentExpression === node ? getTypeOfExpression(node.parent.expression) : undefined + : ts.isLiteralTypeNode(node.parent) && ts.isIndexedAccessTypeNode(node.parent.parent) + ? getTypeFromTypeNode(node.parent.parent.objectType) + : undefined; + return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text)); + case 79 /* DefaultKeyword */: + return getSymbolOfNode(node.parent); + default: + return undefined; } - return undefined; } function getShorthandAssignmentValueSymbol(location) { // The function returns a value symbol of an identifier in the short-hand property assignment. @@ -43853,9 +44231,9 @@ var ts; function getRootSymbols(symbol) { if (ts.getCheckFlags(symbol) & 6 /* Synthetic */) { var symbols_4 = []; - var name_2 = symbol.escapedName; + var name_3 = symbol.escapedName; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { - var symbol = getPropertyOfType(t, name_2); + var symbol = getPropertyOfType(t, name_3); if (symbol) { symbols_4.push(symbol); } @@ -43976,7 +44354,7 @@ var ts; var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (ts.isStatementWithLocals(container)) { var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration); - if (!!resolveName(container.parent, symbol.escapedName, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)) { + if (resolveName(container.parent, symbol.escapedName, 107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ false)) { // redeclaration - always should be renamed links.isDeclarationWithCollidingName = true; } @@ -44155,6 +44533,15 @@ var ts; return type.flags & 32768 /* Object */ && getSignaturesOfType(type, 0 /* Call */).length > 0; } function getTypeReferenceSerializationKind(typeName, location) { + // ensure both `typeName` and `location` are parse tree nodes. + typeName = ts.getParseTreeNode(typeName, ts.isEntityName); + if (!typeName) + return ts.TypeReferenceSerializationKind.Unknown; + if (location) { + location = ts.getParseTreeNode(location); + if (!location) + return ts.TypeReferenceSerializationKind.Unknown; + } // Resolve the symbol as a value to ensure the type can be reached at runtime during emit. var valueSymbol = resolveEntityName(typeName, 107455 /* Value */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. @@ -44244,7 +44631,7 @@ var ts; location = getDeclarationContainer(parent); } } - return resolveName(location, reference.escapedText, 107455 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined); + return resolveName(location, reference.escapedText, 107455 /* Value */ | 1048576 /* ExportValue */ | 2097152 /* Alias */, /*nodeNotFoundMessage*/ undefined, /*nameArg*/ undefined, /*isUse*/ true); } function getReferencedValueDeclaration(reference) { if (!ts.isGeneratedIdentifier(reference)) { @@ -44547,7 +44934,7 @@ var ts; if (quickResult !== undefined) { return quickResult; } - var lastStatic, lastPrivate, lastProtected, lastDeclare, lastAsync, lastReadonly; + var lastStatic, lastDeclare, lastAsync, lastReadonly; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; @@ -44569,12 +44956,6 @@ var ts; case 113 /* ProtectedKeyword */: case 112 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 113 /* ProtectedKeyword */) { - lastProtected = modifier; - } - else if (modifier.kind === 112 /* PrivateKeyword */) { - lastPrivate = modifier; - } if (flags & 28 /* AccessibilityModifier */) { return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen); } @@ -45089,7 +45470,7 @@ var ts; currentKind = SetAccessor; } else { - ts.Debug.fail("Unexpected syntax kind:" + prop.kind); + ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind); } var effectiveName = ts.getPropertyNameForPropertyNameNode(name); if (effectiveName === undefined) { @@ -45372,7 +45753,7 @@ var ts; } } } - if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && + if (compilerOptions.module !== ts.ModuleKind.ES2015 && compilerOptions.module !== ts.ModuleKind.ESNext && compilerOptions.module !== ts.ModuleKind.System && !compilerOptions.noEmit && !ts.isInAmbientContext(node.parent.parent) && ts.hasModifier(node.parent.parent, 1 /* Export */)) { checkESModuleMarker(node.name); } @@ -45393,8 +45774,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { - var element = elements_2[_i]; + for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { + var element = elements_1[_i]; if (!ts.isOmittedExpression(element)) { return checkESModuleMarker(element.name); } @@ -45409,8 +45790,8 @@ var ts; } else { var elements = name.elements; - for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { - var element = elements_3[_i]; + for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) { + var element = elements_2[_i]; if (!ts.isOmittedExpression(element)) { checkGrammarNameInLetOrConstDeclarations(element.name); } @@ -45908,7 +46289,7 @@ var ts; || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer - ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) + ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node) : node; } ts.updateParameter = updateParameter; @@ -46531,13 +46912,26 @@ var ts; return node; } ts.createArrowFunction = createArrowFunction; - function updateArrowFunction(node, modifiers, typeParameters, parameters, type, body) { + function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody, bodyOrUndefined) { + var equalsGreaterThanToken; + var body; + if (bodyOrUndefined === undefined) { + equalsGreaterThanToken = node.equalsGreaterThanToken; + body = ts.cast(equalsGreaterThanTokenOrBody, ts.isConciseBody); + } + else { + equalsGreaterThanToken = ts.cast(equalsGreaterThanTokenOrBody, function (n) { + return n.kind === 36 /* EqualsGreaterThanToken */; + }); + body = bodyOrUndefined; + } return node.modifiers !== modifiers || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type + || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, body), node) + ? updateNode(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } ts.updateArrowFunction = updateArrowFunction; @@ -46642,11 +47036,23 @@ var ts; return node; } ts.createConditional = createConditional; - function updateConditional(node, condition, whenTrue, whenFalse) { + function updateConditional(node, condition) { + var args = []; + for (var _i = 2; _i < arguments.length; _i++) { + args[_i - 2] = arguments[_i]; + } + if (args.length === 2) { + var whenTrue_1 = args[0], whenFalse_1 = args[1]; + return updateConditional(node, condition, node.questionToken, whenTrue_1, node.colonToken, whenFalse_1); + } + ts.Debug.assert(args.length === 4); + var questionToken = args[0], whenTrue = args[1], colonToken = args[2], whenFalse = args[3]; return node.condition !== condition + || node.questionToken !== questionToken || node.whenTrue !== whenTrue + || node.colonToken !== colonToken || node.whenFalse !== whenFalse - ? updateNode(createConditional(condition, node.questionToken, whenTrue, node.colonToken, whenFalse), node) + ? updateNode(createConditional(condition, questionToken, whenTrue, colonToken, whenFalse), node) : node; } ts.updateConditional = updateConditional; @@ -46664,6 +47070,30 @@ var ts; : node; } ts.updateTemplateExpression = updateTemplateExpression; + function createTemplateHead(text) { + var node = createSynthesizedNode(14 /* TemplateHead */); + node.text = text; + return node; + } + ts.createTemplateHead = createTemplateHead; + function createTemplateMiddle(text) { + var node = createSynthesizedNode(15 /* TemplateMiddle */); + node.text = text; + return node; + } + ts.createTemplateMiddle = createTemplateMiddle; + function createTemplateTail(text) { + var node = createSynthesizedNode(16 /* TemplateTail */); + node.text = text; + return node; + } + ts.createTemplateTail = createTemplateTail; + function createNoSubstitutionTemplateLiteral(text) { + var node = createSynthesizedNode(13 /* NoSubstitutionTemplateLiteral */); + node.text = text; + return node; + } + ts.createNoSubstitutionTemplateLiteral = createNoSubstitutionTemplateLiteral; function createYield(asteriskTokenOrExpression, expression) { var node = createSynthesizedNode(197 /* YieldExpression */); node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; @@ -47795,6 +48225,17 @@ var ts; /*argumentsArray*/ paramValue ? [paramValue] : []); } ts.createImmediatelyInvokedFunctionExpression = createImmediatelyInvokedFunctionExpression; + function createImmediatelyInvokedArrowFunction(statements, param, paramValue) { + return createCall(createArrowFunction( + /*modifiers*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ param ? [param] : [], + /*type*/ undefined, + /*equalsGreaterThanToken*/ undefined, createBlock(statements, /*multiLine*/ true)), + /*typeArguments*/ undefined, + /*argumentsArray*/ paramValue ? [paramValue] : []); + } + ts.createImmediatelyInvokedArrowFunction = createImmediatelyInvokedArrowFunction; function createComma(left, right) { return createBinary(left, 26 /* CommaToken */, right); } @@ -48044,9 +48485,7 @@ var ts; var emitNode = getOrCreateEmitNode(node); for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) { var helper = helpers_1[_i]; - if (!ts.contains(emitNode.helpers, helper)) { - emitNode.helpers = ts.append(emitNode.helpers, helper); - } + emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper); } } return node; @@ -48088,9 +48527,7 @@ var ts; var helper = sourceEmitHelpers[i]; if (predicate(helper)) { helpersRemoved++; - if (!ts.contains(targetEmitNode.helpers, helper)) { - targetEmitNode.helpers = ts.append(targetEmitNode.helpers, helper); - } + targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper); } else if (helpersRemoved > 0) { sourceEmitHelpers[i - helpersRemoved] = helper; @@ -49055,11 +49492,9 @@ var ts; return recreateOuterExpressions(expression, mutableCall, 4 /* PartiallyEmittedExpressions */); } } - else { - var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 178 /* ObjectLiteralExpression */ || leftmostExpressionKind === 186 /* FunctionExpression */) { - return ts.setTextRange(ts.createParen(expression), expression); - } + var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === 178 /* ObjectLiteralExpression */ || leftmostExpressionKind === 186 /* FunctionExpression */) { + return ts.setTextRange(ts.createParen(expression), expression); } return expression; } @@ -49195,9 +49630,31 @@ var ts; case 288 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(outerExpression, expression); } } + /** + * Determines whether a node is a parenthesized expression that can be ignored when recreating outer expressions. + * + * A parenthesized expression can be ignored when all of the following are true: + * + * - It's `pos` and `end` are not -1 + * - It does not have a custom source map range + * - It does not have a custom comment range + * - It does not have synthetic leading or trailing comments + * + * If an outermost parenthesized expression is ignored, but the containing expression requires a parentheses around + * the expression to maintain precedence, a new parenthesized expression should be created automatically when + * the containing expression is created/updated. + */ + function isIgnorableParen(node) { + return node.kind === 185 /* ParenthesizedExpression */ + && ts.nodeIsSynthesized(node) + && ts.nodeIsSynthesized(ts.getSourceMapRange(node)) + && ts.nodeIsSynthesized(ts.getCommentRange(node)) + && !ts.some(ts.getSyntheticLeadingComments(node)) + && !ts.some(ts.getSyntheticTrailingComments(node)); + } function recreateOuterExpressions(outerExpression, innerExpression, kinds) { if (kinds === void 0) { kinds = 7 /* All */; } - if (outerExpression && isOuterExpression(outerExpression, kinds)) { + if (outerExpression && isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) { return updateOuterExpression(outerExpression, recreateOuterExpressions(outerExpression.expression, innerExpression)); } return innerExpression; @@ -49223,7 +49680,8 @@ var ts; var moduleKind = ts.getEmitModuleKind(compilerOptions); var create = hasExportStarsToExportValues && moduleKind !== ts.ModuleKind.System - && moduleKind !== ts.ModuleKind.ES2015; + && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext; if (!create) { var helpers = ts.getEmitHelpers(node); if (helpers) { @@ -49793,7 +50251,7 @@ var ts; case 186 /* FunctionExpression */: return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); case 187 /* ArrowFunction */: - return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.equalsGreaterThanToken, visitor, ts.isToken), visitFunctionBody(node.body, visitor, context)); case 188 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); case 189 /* TypeOfExpression */: @@ -49809,7 +50267,7 @@ var ts; case 194 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression), visitNode(node.operatorToken, visitor, ts.isToken)); case 195 /* ConditionalExpression */: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.questionToken, visitor, ts.isToken), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.colonToken, visitor, ts.isToken), visitNode(node.whenFalse, visitor, ts.isExpression)); case 196 /* TemplateExpression */: return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); case 197 /* YieldExpression */: @@ -50649,7 +51107,7 @@ var ts; else { // export class x { } var name = node.name; - if (!uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { + if (name && !uniqueExports.get(ts.unescapeLeadingUnderscores(name.escapedText))) { multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name); uniqueExports.set(ts.unescapeLeadingUnderscores(name.escapedText), true); exportedNames = ts.append(exportedNames, name); @@ -51047,7 +51505,7 @@ var ts; */ function createDestructuringPropertyAccess(flattenContext, value, propertyName) { if (ts.isComputedPropertyName(propertyName)) { - var argumentExpression = ensureIdentifier(flattenContext, propertyName.expression, /*reuseIdentifierExpressions*/ false, /*location*/ propertyName); + var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), /*reuseIdentifierExpressions*/ false, /*location*/ propertyName); return ts.createElementAccess(value, argumentExpression); } else if (ts.isStringOrNumericLiteral(propertyName)) { @@ -51316,6 +51774,23 @@ var ts; * @param node The node to visit. */ function sourceElementVisitorWorker(node) { + switch (node.kind) { + case 238 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 243 /* ExportAssignment */: + case 244 /* ExportDeclaration */: + return visitEllidableStatement(node); + default: + return visitorWorker(node); + } + } + function visitEllidableStatement(node) { + var parsed = ts.getParseTreeNode(node); + if (parsed !== node) { + // If the node has been transformed by a `before` transformer, perform no ellision on it + // As the type information we would attempt to lookup to perform ellision is potentially unavailable for the synthesized nodes + return node; + } switch (node.kind) { case 238 /* ImportDeclaration */: return visitImportDeclaration(node); @@ -51326,7 +51801,7 @@ var ts; case 244 /* ExportDeclaration */: return visitExportDeclaration(node); default: - return visitorWorker(node); + ts.Debug.fail("Unhandled ellided statement"); } } /** @@ -51567,7 +52042,7 @@ var ts; } function visitSourceFile(node) { var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && - !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } /** @@ -51667,10 +52142,12 @@ var ts; ts.setEmitFlags(statement, 1536 /* NoComments */ | 384 /* NoTokenSourceMaps */); statements.push(statement); ts.addRange(statements, context.endLexicalEnvironment()); + var iife = ts.createImmediatelyInvokedArrowFunction(statements); + ts.setEmitFlags(iife, 33554432 /* TypeScriptClassWrapper */); var varStatement = ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(ts.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), - /*type*/ undefined, ts.createImmediatelyInvokedFunctionExpression(statements)) + /*type*/ undefined, iife) ])); ts.setOriginalNode(varStatement, node); ts.setCommentRange(varStatement, node); @@ -52773,7 +53250,7 @@ var ts; var name = ts.getMutableClone(node); name.flags &= ~8 /* Synthesized */; name.original = undefined; - name.parent = currentScope; + name.parent = ts.getParseTreeNode(currentScope); // ensure the parent is set to a parse tree node. if (useFallback) { return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } @@ -53028,7 +53505,7 @@ var ts; function visitArrowFunction(node) { var updated = ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context)); + /*type*/ undefined, node.equalsGreaterThanToken, ts.visitFunctionBody(node.body, visitor, context)); return updated; } /** @@ -53278,6 +53755,7 @@ var ts; return isExportOfNamespace(node) || (isExternalModuleExport(node) && moduleKind !== ts.ModuleKind.ES2015 + && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System); } /** @@ -53983,8 +54461,6 @@ var ts; var resolver = context.getEmitResolver(); var compilerOptions = context.getCompilerOptions(); var languageVersion = ts.getEmitScriptTarget(compilerOptions); - // These variables contain state that changes as we descend into the tree. - var currentSourceFile; /** * Keeps track of whether expression substitution has been enabled for specific edge cases. * They are persisted between each SourceFile transformation and should not be reset. @@ -54006,10 +54482,8 @@ var ts; if (node.isDeclarationFile) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -54104,7 +54578,7 @@ var ts; function visitArrowFunction(node) { return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + /*type*/ undefined, node.equalsGreaterThanToken, ts.getFunctionFlags(node) & 2 /* Async */ ? transformAsyncFunctionBody(node) : ts.visitFunctionBody(node.body, visitor, context)); } @@ -54435,8 +54909,8 @@ var ts; function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; - for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { - var e = elements_4[_i]; + for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) { + var e = elements_3[_i]; if (e.kind === 263 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); @@ -54454,7 +54928,7 @@ var ts; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } else { - chunkObject.push(e); + chunkObject.push(ts.visitNode(e, visitor, ts.isObjectLiteralElementLike)); } } } @@ -54693,7 +55167,7 @@ var ts; enclosingFunctionFlags = ts.getFunctionFlags(node); var updated = ts.updateArrowFunction(node, node.modifiers, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node)); + /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node)); enclosingFunctionFlags = savedEnclosingFunctionFlags; return updated; } @@ -55689,58 +56163,12 @@ var ts; && node.kind === 219 /* ReturnStatement */ && !node.expression; } - function isClassLikeVariableStatement(node) { - if (!ts.isVariableStatement(node)) - return false; - var variable = ts.singleOrUndefined(node.declarationList.declarations); - return variable - && variable.initializer - && ts.isIdentifier(variable.name) - && (ts.isClassLike(variable.initializer) - || (ts.isAssignmentExpression(variable.initializer) - && ts.isIdentifier(variable.initializer.left) - && ts.isClassLike(variable.initializer.right))); - } - function isTypeScriptClassWrapper(node) { - var call = ts.tryCast(node, ts.isCallExpression); - if (!call || ts.isParseTreeNode(call) || - ts.some(call.typeArguments) || - ts.some(call.arguments)) { - return false; - } - var func = ts.tryCast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression); - if (!func || ts.isParseTreeNode(func) || - ts.some(func.typeParameters) || - ts.some(func.parameters) || - func.type || - !func.body) { - return false; - } - var statements = func.body.statements; - if (statements.length < 2) { - return false; - } - var firstStatement = statements[0]; - if (ts.isParseTreeNode(firstStatement) || - !ts.isClassLike(firstStatement) && - !isClassLikeVariableStatement(firstStatement)) { - return false; - } - var lastStatement = ts.elementAt(statements, -1); - var returnStatement = ts.tryCast(ts.isVariableStatement(lastStatement) ? ts.elementAt(statements, -2) : lastStatement, ts.isReturnStatement); - if (!returnStatement || - !returnStatement.expression || - !ts.isIdentifier(ts.skipOuterExpressions(returnStatement.expression))) { - return false; - } - return true; - } function shouldVisitNode(node) { return (node.transformFlags & 128 /* ContainsES2015 */) !== 0 || convertedLoopState !== undefined || (hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ && (ts.isStatement(node) || (node.kind === 207 /* Block */))) || (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(node)) - || isTypeScriptClassWrapper(node); + || (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) !== 0; } function visitor(node) { if (shouldVisitNode(node)) { @@ -57875,7 +58303,7 @@ var ts; * @param node a CallExpression. */ function visitCallExpression(node) { - if (isTypeScriptClassWrapper(node)) { + if (ts.getEmitFlags(node) & 33554432 /* TypeScriptClassWrapper */) { return visitTypeScriptClassWrapper(node); } if (node.transformFlags & 64 /* ES2015 */) { @@ -57917,7 +58345,7 @@ var ts; // }()) // We skip any outer expressions in a number of places to get to the innermost // expression, but we will restore them later to preserve comments and source maps. - var body = ts.cast(ts.skipOuterExpressions(node.expression), ts.isFunctionExpression).body; + var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock); // The class statements are the statements generated by visiting the first statement of the // body (1), while all other statements are added to remainingStatements (2) var classStatements = ts.visitNodes(body.statements, visitor, ts.isStatement, 0, 1); @@ -58820,7 +59248,6 @@ var ts; var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - var currentSourceFile; var renamedCatchVariables; var renamedCatchVariableDeclarations; var inGeneratorFunctionBody; @@ -58867,10 +59294,8 @@ var ts; if (node.isDeclarationFile || (node.transformFlags & 512 /* ContainsGenerator */) === 0) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } /** @@ -61437,6 +61862,7 @@ var ts; */ function transformUMDModule(node) { var _a = collectAsynchronousDependencies(node, /*includeNonAmdDependencies*/ false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames; + var moduleName = ts.tryGetModuleNameFromFile(node, host, compilerOptions); var umdHeader = ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, @@ -61456,13 +61882,13 @@ var ts; ts.setEmitFlags(ts.createIf(ts.createStrictInequality(ts.createIdentifier("v"), ts.createIdentifier("undefined")), ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), ts.createIdentifier("v")))), 1 /* SingleLine */) ]), ts.createIf(ts.createLogicalAnd(ts.createTypeCheck(ts.createIdentifier("define"), "function"), ts.createPropertyAccess(ts.createIdentifier("define"), "amd")), ts.createBlock([ ts.createStatement(ts.createCall(ts.createIdentifier("define"), - /*typeArguments*/ undefined, [ + /*typeArguments*/ undefined, (moduleName ? [moduleName] : []).concat([ ts.createArrayLiteral([ ts.createLiteral("require"), ts.createLiteral("exports") ].concat(aliasedModuleNames, unaliasedModuleNames)), ts.createIdentifier("factory") - ])) + ]))) ]))) ], /*multiLine*/ true), @@ -61588,17 +62014,20 @@ var ts; */ function addExportEqualsIfNeeded(statements, emitAsReturn) { if (currentModuleInfo.exportEquals) { - if (emitAsReturn) { - var statement = ts.createReturn(currentModuleInfo.exportEquals.expression); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); - statements.push(statement); - } - else { - var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), currentModuleInfo.exportEquals.expression)); - ts.setTextRange(statement, currentModuleInfo.exportEquals); - ts.setEmitFlags(statement, 1536 /* NoComments */); - statements.push(statement); + var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, importCallExpressionVisitor); + if (expressionResult) { + if (emitAsReturn) { + var statement = ts.createReturn(expressionResult); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */); + statements.push(statement); + } + else { + var statement = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier("module"), "exports"), expressionResult)); + ts.setTextRange(statement, currentModuleInfo.exportEquals); + ts.setEmitFlags(statement, 1536 /* NoComments */); + statements.push(statement); + } } } } @@ -62143,7 +62572,7 @@ var ts; return statements; } if (ts.hasModifier(decl, 1 /* Export */)) { - var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : decl.name; + var exportName = ts.hasModifier(decl, 512 /* Default */) ? ts.createIdentifier("default") : ts.getDeclarationName(decl); statements = appendExportStatement(statements, exportName, ts.getLocalName(decl), /*location*/ decl); } if (decl.name) { @@ -63352,7 +63781,8 @@ var ts; */ function createExportExpression(name, value) { var exportName = ts.isIdentifier(name) ? ts.createLiteral(name) : name; - return ts.createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]); + ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536 /* NoComments */); + return ts.setCommentRange(ts.createCall(exportFunction, /*typeArguments*/ undefined, [exportName, value]), value); } // // Top-Level or Nested Source Element Visitors @@ -67105,8 +67535,15 @@ var ts; comments.reset(); setWriter(/*output*/ undefined); } + // TODO: Should this just be `emit`? + // See https://github.com/Microsoft/TypeScript/pull/18284#discussion_r137611034 + function emitIfPresent(node) { + if (node) { + emit(node); + } + } function emit(node) { - pipelineEmitWithNotification(3 /* Unspecified */, node); + pipelineEmitWithNotification(4 /* Unspecified */, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2 /* IdentifierName */, node); @@ -67144,7 +67581,8 @@ var ts; case 0 /* SourceFile */: return pipelineEmitSourceFile(node); case 2 /* IdentifierName */: return pipelineEmitIdentifierName(node); case 1 /* Expression */: return pipelineEmitExpression(node); - case 3 /* Unspecified */: return pipelineEmitUnspecified(node); + case 3 /* MappedTypeParameter */: return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration)); + case 4 /* Unspecified */: return pipelineEmitUnspecified(node); } } function pipelineEmitSourceFile(node) { @@ -67155,6 +67593,11 @@ var ts; ts.Debug.assertNode(node, ts.isIdentifier); emitIdentifier(node); } + function emitMappedTypeParameter(node) { + emit(node.name); + write(" in "); + emit(node.constraint); + } function pipelineEmitUnspecified(node) { var kind = node.kind; // Reserved words @@ -67544,9 +67987,9 @@ var ts; function emitParameter(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); } @@ -67561,7 +68004,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); write(";"); } @@ -67569,7 +68012,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitWithPrefix(": ", node.type); emitExpressionWithPrefix(" = ", node.initializer); write(";"); @@ -67578,7 +68021,7 @@ var ts; emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitWithPrefix(": ", node.type); @@ -67587,9 +68030,9 @@ var ts; function emitMethodDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - writeIfPresent(node.asteriskToken, "*"); + emitIfPresent(node.asteriskToken); emit(node.name); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); emitSignatureAndBody(node, emitSignatureHead); } function emitConstructor(node) { @@ -67662,10 +68105,8 @@ var ts; } function emitTypeLiteral(node) { write("{"); - // If the literal is empty, do not add spaces between braces. - if (node.members.length > 0) { - emitList(node, node.members, ts.getEmitFlags(node) & 1 /* SingleLine */ ? 448 /* SingleLineTypeLiteralMembers */ : 65 /* MultiLineTypeLiteralMembers */); - } + var flags = ts.getEmitFlags(node) & 1 /* SingleLine */ ? 448 /* SingleLineTypeLiteralMembers */ : 65 /* MultiLineTypeLiteralMembers */; + emitList(node, node.members, flags | 262144 /* NoSpaceIfEmpty */); write("}"); } function emitArrayType(node) { @@ -67712,13 +68153,14 @@ var ts; writeLine(); increaseIndent(); } - writeIfPresent(node.readonlyToken, "readonly "); + if (node.readonlyToken) { + emit(node.readonlyToken); + write(" "); + } write("["); - emit(node.typeParameter.name); - write(" in "); - emit(node.typeParameter.constraint); + pipelineEmitWithNotification(3 /* MappedTypeParameter */, node.typeParameter); write("]"); - writeIfPresent(node.questionToken, "?"); + emitIfPresent(node.questionToken); write(": "); emit(node.type); write(";"); @@ -67761,7 +68203,7 @@ var ts; } function emitBindingElement(node) { emitWithSuffix(node.propertyName, ": "); - writeIfPresent(node.dotDotDotToken, "..."); + emitIfPresent(node.dotDotDotToken); emit(node.name); emitExpressionWithPrefix(" = ", node.initializer); } @@ -67770,30 +68212,19 @@ var ts; // function emitArrayLiteralExpression(node) { var elements = node.elements; - if (elements.length === 0) { - write("[]"); - } - else { - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); - } + var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; + emitExpressionList(node, elements, 4466 /* ArrayLiteralExpressionElements */ | preferNewLine); } function emitObjectLiteralExpression(node) { - var properties = node.properties; - if (properties.length === 0) { - write("{}"); + var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; + if (indentedFlag) { + increaseIndent(); } - else { - var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; - if (indentedFlag) { - increaseIndent(); - } - var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; - emitList(node, properties, 978 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); - if (indentedFlag) { - decreaseIndent(); - } + var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; + emitList(node, node.properties, 263122 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); + if (indentedFlag) { + decreaseIndent(); } } function emitPropertyAccessExpression(node) { @@ -67880,7 +68311,8 @@ var ts; emitTypeParameters(node, node.typeParameters); emitParametersForArrow(node, node.parameters); emitWithPrefix(": ", node.type); - write(" =>"); + write(" "); + emit(node.equalsGreaterThanToken); } function emitDeleteExpression(node) { write("delete "); @@ -67947,12 +68379,12 @@ var ts; var indentAfterColon = needsIndentation(node, node.colonToken, node.whenFalse); emitExpression(node.condition); increaseIndentIf(indentBeforeQuestion, " "); - write("?"); + emit(node.questionToken); increaseIndentIf(indentAfterQuestion, " "); emitExpression(node.whenTrue); decreaseIndentIf(indentBeforeQuestion, indentAfterQuestion); increaseIndentIf(indentBeforeColon, " "); - write(":"); + emit(node.colonToken); increaseIndentIf(indentAfterColon, " "); emitExpression(node.whenFalse); decreaseIndentIf(indentBeforeColon, indentAfterColon); @@ -67962,7 +68394,8 @@ var ts; emitList(node, node.templateSpans, 131072 /* TemplateExpressionSpans */); } function emitYieldExpression(node) { - write(node.asteriskToken ? "yield*" : "yield"); + write("yield"); + emit(node.asteriskToken); emitExpressionWithPrefix(" ", node.expression); } function emitSpreadExpression(node) { @@ -68003,28 +68436,17 @@ var ts; // Statements // function emitBlock(node) { - if (isSingleLineEmptyBlock(node)) { - writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); - write(" "); - writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); - } - else { - writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); - emitBlockStatements(node); - // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted - increaseIndent(); - emitLeadingCommentsOfPosition(node.statements.end); - decreaseIndent(); - writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); - } + writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); + writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } - function emitBlockStatements(node) { - if (ts.getEmitFlags(node) & 1 /* SingleLine */) { - emitList(node, node.statements, 384 /* SingleLineBlockStatements */); - } - else { - emitList(node, node.statements, 65 /* MultiLineBlockStatements */); - } + function emitBlockStatements(node, forceSingleLine) { + var format = forceSingleLine || ts.getEmitFlags(node) & 1 /* SingleLine */ ? 384 /* SingleLineBlockStatements */ : 65 /* MultiLineBlockStatements */; + emitList(node, node.statements, format); } function emitVariableStatement(node) { emitModifiers(node, node.modifiers); @@ -68205,7 +68627,9 @@ var ts; function emitFunctionDeclarationOrExpression(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.asteriskToken ? "function* " : "function "); + write("function"); + emitIfPresent(node.asteriskToken); + write(" "); emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -68223,7 +68647,7 @@ var ts; if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3 /* Unspecified */, body, emitBlockCallback); + onEmitNode(4 /* Unspecified */, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -68233,7 +68657,7 @@ var ts; pushNameGenerationScope(); emitSignatureHead(node); if (onEmitNode) { - onEmitNode(3 /* Unspecified */, body, emitBlockCallback); + onEmitNode(4 /* Unspecified */, body, emitBlockCallback); } else { emitBlockFunctionBody(body); @@ -68378,7 +68802,9 @@ var ts; } function emitModuleDeclaration(node) { emitModifiers(node, node.modifiers); - write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); + if (~node.flags & 512 /* GlobalAugmentation */) { + write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); + } emit(node.name); var body = node.body; while (body.kind === 233 /* ModuleDeclaration */) { @@ -68390,16 +68816,11 @@ var ts; emit(body); } function emitModuleBlock(node) { - if (isEmptyBlock(node)) { - write("{ }"); - } - else { - pushNameGenerationScope(); - write("{"); - emitBlockStatements(node); - write("}"); - popNameGenerationScope(); - } + pushNameGenerationScope(); + write("{"); + emitBlockStatements(node, /*forceSingleLine*/ isEmptyBlock(node)); + write("}"); + popNameGenerationScope(); } function emitCaseBlock(node) { writeToken(17 /* OpenBraceToken */, node.pos); @@ -68550,9 +68971,7 @@ var ts; function emitJsxExpression(node) { if (node.expression) { write("{"); - if (node.dotDotDotToken) { - write("..."); - } + emitIfPresent(node.dotDotDotToken); emitExpression(node.expression); write("}"); } @@ -68600,13 +69019,12 @@ var ts; // Note: we can't use parentNode.end as such position includes statements. emitTrailingCommentsOfPosition(statements.pos); } + var format = 81985 /* CaseOrDefaultClauseStatements */; if (emitAsSingleStatement) { write(" "); - emit(statements[0]); - } - else { - emitList(parentNode, statements, 81985 /* CaseOrDefaultClauseStatements */); + format &= ~(1 /* MultiLine */ | 64 /* Indented */); } + emitList(parentNode, statements, format); } function emitHeritageClause(node) { write(" "); @@ -68827,7 +69245,7 @@ var ts; } function emitParametersForArrow(parentNode, parameters) { if (canEmitSimpleArrowHead(parentNode, parameters)) { - emit(parameters[0]); + emitList(parentNode, parameters, 1360 /* Parameters */ & ~1024 /* Parenthesis */); } else { emitParameters(parentNode, parameters); @@ -68849,8 +69267,14 @@ var ts; if (isUndefined && format & 8192 /* OptionalIfUndefined */) { return; } - var isEmpty = isUndefined || children.length === 0 || start >= children.length || count === 0; + var isEmpty = isUndefined || start >= children.length || count === 0; if (isEmpty && format & 16384 /* OptionalIfEmpty */) { + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } return; } if (format & 7680 /* BracketsMask */) { @@ -68864,7 +69288,7 @@ var ts; if (format & 1 /* MultiLine */) { writeLine(); } - else if (format & 128 /* SpaceBetweenBraces */) { + else if (format & 128 /* SpaceBetweenBraces */ && !(format & 262144 /* NoSpaceIfEmpty */)) { write(" "); } } @@ -68944,7 +69368,7 @@ var ts; // 2 // /* end of element 2 */ // ]; - if (previousSibling && delimiter && previousSibling.end !== parentNode.end) { + if (previousSibling && delimiter && previousSibling.end !== parentNode.end && !(ts.getEmitFlags(previousSibling) & 1024 /* NoTrailingComments */)) { emitLeadingCommentsOfPosition(previousSibling.end); } // Decrease the indent, if requested. @@ -68983,11 +69407,6 @@ var ts; write(text); } } - function writeIfPresent(node, text) { - if (node) { - write(text); - } - } function writeToken(token, pos, contextNode) { return onEmitSourceMapOfToken ? onEmitSourceMapOfToken(contextNode, token, pos, writeTokenText) @@ -68997,7 +69416,7 @@ var ts; if (onBeforeEmitToken) { onBeforeEmitToken(node); } - writeTokenText(node.kind); + write(ts.tokenToString(node.kind)); if (onAfterEmitToken) { onAfterEmitToken(node); } @@ -69151,10 +69570,6 @@ var ts; && !ts.nodeIsSynthesized(node2) && !ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } - function isSingleLineEmptyBlock(block) { - return !block.multiLine - && isEmptyBlock(block); - } function isEmptyBlock(block) { return block.statements.length === 0 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); @@ -69463,6 +69878,8 @@ var ts; ListFormat[ListFormat["PreferNewLine"] = 32768] = "PreferNewLine"; ListFormat[ListFormat["NoTrailingNewLine"] = 65536] = "NoTrailingNewLine"; ListFormat[ListFormat["NoInterveningComments"] = 131072] = "NoInterveningComments"; + ListFormat[ListFormat["NoSpaceIfEmpty"] = 262144] = "NoSpaceIfEmpty"; + ListFormat[ListFormat["SingleElement"] = 524288] = "SingleElement"; // Precomputed Formats ListFormat[ListFormat["Modifiers"] = 131328] = "Modifiers"; ListFormat[ListFormat["HeritageClauses"] = 256] = "HeritageClauses"; @@ -69473,7 +69890,7 @@ var ts; ListFormat[ListFormat["IntersectionTypeConstituents"] = 264] = "IntersectionTypeConstituents"; ListFormat[ListFormat["ObjectBindingPatternElements"] = 432] = "ObjectBindingPatternElements"; ListFormat[ListFormat["ArrayBindingPatternElements"] = 304] = "ArrayBindingPatternElements"; - ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 978] = "ObjectLiteralExpressionProperties"; + ListFormat[ListFormat["ObjectLiteralExpressionProperties"] = 263122] = "ObjectLiteralExpressionProperties"; ListFormat[ListFormat["ArrayLiteralExpressionElements"] = 4466] = "ArrayLiteralExpressionElements"; ListFormat[ListFormat["CommaListElements"] = 272] = "CommaListElements"; ListFormat[ListFormat["CallExpressionArguments"] = 1296] = "CallExpressionArguments"; @@ -69680,7 +70097,7 @@ var ts; function getPreEmitDiagnostics(program, sourceFile, cancellationToken) { var diagnostics = program.getOptionsDiagnostics(cancellationToken).concat(program.getSyntacticDiagnostics(sourceFile, cancellationToken), program.getGlobalDiagnostics(cancellationToken), program.getSemanticDiagnostics(sourceFile, cancellationToken)); if (program.getCompilerOptions().declaration) { - diagnostics = diagnostics.concat(program.getDeclarationDiagnostics(sourceFile, cancellationToken)); + ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken)); } return ts.sortAndDeduplicateDiagnostics(diagnostics); } @@ -69704,7 +70121,7 @@ var ts; var redForegroundEscapeSequence = "\u001b[91m"; var yellowForegroundEscapeSequence = "\u001b[93m"; var blueForegroundEscapeSequence = "\u001b[93m"; - var gutterStyleSequence = "\u001b[100;30m"; + var gutterStyleSequence = "\u001b[30;47m"; var gutterSeparator = " "; var resetEscapeSequence = "\u001b[0m"; var ellipsis = "..."; @@ -69729,9 +70146,9 @@ var ts; for (var _i = 0, diagnostics_2 = diagnostics; _i < diagnostics_2.length; _i++) { var diagnostic = diagnostics_2[_i]; if (diagnostic.file) { - var start = diagnostic.start, length_6 = diagnostic.length, file = diagnostic.file; + var start = diagnostic.start, length_5 = diagnostic.length, file = diagnostic.file; var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; - var _b = ts.getLineAndCharacterOfPosition(file, start + length_6), lastLine = _b.line, lastLineChar = _b.character; + var _b = ts.getLineAndCharacterOfPosition(file, start + length_5), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; @@ -69739,12 +70156,12 @@ var ts; if (hasMoreThanFiveLines) { gutterWidth = Math.max(ellipsis.length, gutterWidth); } - output += ts.sys.newLine; + output += host.getNewLine(); for (var i = firstLine; i <= lastLine; i++) { // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + ts.sys.newLine; + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0); @@ -69754,7 +70171,7 @@ var ts; lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + ts.sys.newLine; + output += lineContent + host.getNewLine(); // Output the gutter and the error span for the line using tildes. output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; output += redForegroundEscapeSequence; @@ -69773,15 +70190,15 @@ var ts; output += lineContent.replace(/./g, "~"); } output += resetEscapeSequence; - output += ts.sys.newLine; + output += host.getNewLine(); } - output += ts.sys.newLine; + output += host.getNewLine(); output += relativeFileName + "(" + (firstLine + 1) + "," + (firstLineChar + 1) + "): "; } var categoryColor = getCategoryFormat(diagnostic.category); var category = ts.DiagnosticCategory[diagnostic.category].toLowerCase(); - output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine); - output += ts.sys.newLine; + output += formatAndReset(category, categoryColor) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()); + output += host.getNewLine(); } return output; } @@ -69870,6 +70287,8 @@ var ts; ts.performance.mark("beforeProgram"); host = host || createCompilerHost(options); var skipDefaultLib = options.noLib; + var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); }); + var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName()); var programDiagnostics = ts.createDiagnosticCollection(); var currentDirectory = host.getCurrentDirectory(); var supportedExtensions = ts.getSupportedExtensions(options); @@ -69936,12 +70355,11 @@ var ts; // If '--lib' is not specified, include default library file according to '--target' // otherwise, using options specified in '--lib' instead of '--target' default library file if (!options.lib) { - processRootFile(host.getDefaultLibFileName(options), /*isDefaultLib*/ true); + processRootFile(getDefaultLibraryFileName(), /*isDefaultLib*/ true); } else { - var libDirectory_1 = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(host.getDefaultLibFileName(options)); ts.forEach(options.lib, function (libFileName) { - processRootFile(ts.combinePaths(libDirectory_1, libFileName), /*isDefaultLib*/ true); + processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), /*isDefaultLib*/ true); }); } } @@ -69976,6 +70394,7 @@ var ts; getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; }, getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; }, isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary, + isSourceFileDefaultLibrary: isSourceFileDefaultLibrary, dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker, getSourceFileFromReference: getSourceFileFromReference, sourceFileToPackageName: sourceFileToPackageName, @@ -70267,7 +70686,7 @@ var ts; var _b = modifiedSourceFiles_1[_a], oldSourceFile = _b.oldFile, newSourceFile = _b.newFile; var newSourceFilePath = ts.getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { - var moduleNames = ts.map(ts.concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); + var moduleNames = getModuleNames(newSourceFile); var oldProgramState = { program: oldProgram, file: oldSourceFile, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); // ensure that module resolution results are still correct @@ -70344,6 +70763,15 @@ var ts; function isSourceFileFromExternalLibrary(file) { return sourceFilesFoundSearchingNodeModules.get(file.path); } + function isSourceFileDefaultLibrary(file) { + if (file.hasNoDefaultLib) { + return true; + } + if (defaultLibraryPath && defaultLibraryPath.length !== 0) { + return ts.containsPath(defaultLibraryPath, file.path, currentDirectory, /*ignoreCase*/ !host.useCaseSensitiveFileNames()); + } + return ts.compareStrings(file.fileName, getDefaultLibraryFileName(), /*ignoreCase*/ !host.useCaseSensitiveFileNames()) === 0 /* EqualTo */; + } function getDiagnosticsProducingTypeChecker() { return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ true)); } @@ -70485,9 +70913,7 @@ var ts; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - return ts.isSourceFileJavaScript(sourceFile) - ? ts.filter(diagnostics, shouldReportDiagnostic) - : diagnostics; + return ts.filter(diagnostics, shouldReportDiagnostic); }); } /** @@ -70724,16 +71150,15 @@ var ts; return ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()); } function processRootFile(fileName, isDefaultLib) { - processSourceFile(ts.normalizePath(fileName), isDefaultLib); + processSourceFile(ts.normalizePath(fileName), isDefaultLib, /*packageId*/ undefined); } function fileReferenceIsEqualTo(a, b) { return a.fileName === b.fileName; } function moduleNameIsEqualTo(a, b) { - return a.text === b.text; - } - function getTextOfLiteral(literal) { - return literal.text; + return a.kind === 9 /* StringLiteral */ + ? b.kind === 9 /* StringLiteral */ && a.text === b.text + : b.kind === 71 /* Identifier */ && a.escapedText === b.escapedText; } function collectExternalModuleReferences(file) { if (file.imports) { @@ -70789,7 +71214,7 @@ var ts; break; case 233 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || file.isDeclarationFile)) { - var moduleName = node.name; // TODO: GH#17347 + var moduleName = node.name; var nameText = ts.getTextOfIdentifierOrLiteral(moduleName); // Ambient module declarations can be interpreted as augmentations for some existing external modules. // This will happen in two cases: @@ -70869,8 +71294,8 @@ var ts; } } /** This has side effects through `findSourceFile`. */ - function processSourceFile(fileName, isDefaultLib, refFile, refPos, refEnd) { - getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, /*packageId*/ undefined); }, function (diagnostic) { + function processSourceFile(fileName, isDefaultLib, packageId, refFile, refPos, refEnd) { + getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, refFile, refPos, refEnd, packageId); }, function (diagnostic) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; @@ -70942,7 +71367,7 @@ var ts; } }); if (packageId) { - var packageIdKey = packageId.name + "@" + packageId.version; + var packageIdKey = packageId.name + "/" + packageId.subModuleName + "@" + packageId.version; var fileFromPackageId = packageIdToSourceFile.get(packageIdKey); if (fileFromPackageId) { // Some other SourceFile already exists with this package name and version. @@ -70994,7 +71419,7 @@ var ts; function processReferencedFiles(file, isDefaultLib) { ts.forEach(file.referencedFiles, function (ref) { var referencedFileName = resolveTripleslashReference(ref.fileName, file.fileName); - processSourceFile(referencedFileName, isDefaultLib, file, ref.pos, ref.end); + processSourceFile(referencedFileName, isDefaultLib, /*packageId*/ undefined, file, ref.pos, ref.end); }); } function processTypeReferenceDirectives(file) { @@ -71020,7 +71445,7 @@ var ts; if (resolvedTypeReferenceDirective) { if (resolvedTypeReferenceDirective.primary) { // resolved from the primary path - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } else { // If we already resolved to this file, it must have been a secondary reference. Check file contents @@ -71038,7 +71463,7 @@ var ts; } else { // First resolution of this library - processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, refFile, refPos, refEnd); + processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, /*isDefaultLib*/ false, resolvedTypeReferenceDirective.packageId, refFile, refPos, refEnd); } } } @@ -71068,8 +71493,7 @@ var ts; collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. - var nonGlobalAugmentation = ts.filter(file.moduleAugmentations, function (moduleAugmentation) { return moduleAugmentation.kind === 9 /* StringLiteral */; }); - var moduleNames = ts.map(ts.concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); + var moduleNames = getModuleNames(file); var oldProgramState = { program: oldProgram, file: file, modifiedFilePaths: modifiedFilePaths }; var resolutions = resolveModuleNamesReusingOldState(moduleNames, ts.getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState); ts.Debug.assert(resolutions.length === moduleNames.length); @@ -71080,7 +71504,8 @@ var ts; continue; } var isFromNodeModulesSearch = resolution.isExternalLibraryImport; - var isJsFileFromNodeModules = isFromNodeModulesSearch && !ts.extensionIsTypeScript(resolution.extension); + var isJsFile = !ts.extensionIsTypeScript(resolution.extension); + var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; var resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { currentNodeModulesDepth++; @@ -71093,7 +71518,12 @@ var ts; var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. - var shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; + var shouldAddFile = resolvedFileName + && !getResolutionDiagnostic(options, resolution) + && !options.noResolve + && i < file.imports.length + && !elideImport + && !(isJsFile && !options.allowJs); if (elideImport) { modulesWithElidedImports.set(file.path, true); } @@ -71429,7 +71859,7 @@ var ts; return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + return options.allowJs || !options.noImplicitAny ? undefined : ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } } ts.getResolutionDiagnostic = getResolutionDiagnostic; @@ -71437,6 +71867,18 @@ var ts; ts.Debug.assert(names.every(function (name) { return name !== undefined; }), "A name is undefined.", function () { return JSON.stringify(names); }); return names; } + function getModuleNames(_a) { + var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations; + var res = imports.map(function (i) { return i.text; }); + for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) { + var aug = moduleAugmentations_1[_i]; + if (aug.kind === 9 /* StringLiteral */) { + res.push(aug.text); + } + // Do nothing if it's an Identifier; we don't need to do module resolution for `declare global`. + } + return res; + } })(ts || (ts = {})); /// /// @@ -72431,7 +72873,7 @@ var ts; errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } var value = convertPropertyValueToJson(element.initializer, option); - if (typeof keyText !== "undefined" && typeof value !== "undefined") { + if (typeof keyText !== "undefined") { result[keyText] = value; // Notify key value set, if user asked for it if (jsonConversionNotifier && @@ -72471,7 +72913,7 @@ var ts; reportInvalidOptionValue(option && option.type !== "boolean"); return false; case 95 /* NullKeyword */: - reportInvalidOptionValue(!!option); + reportInvalidOptionValue(option && option.name === "extends"); // "extends" is the only option we don't allow null/undefined for return null; // tslint:disable-line:no-null-keyword case 9 /* StringLiteral */: if (!isDoubleQuotedString(valueExpression)) { @@ -72536,6 +72978,8 @@ var ts; } function isCompilerOptionsValue(option, value) { if (option) { + if (isNullOrUndefined(value)) + return true; // All options are undefinable/nullable if (option.type === "list") { return ts.isArray(value); } @@ -72720,6 +73164,15 @@ var ts; } } ts.setConfigFileInOptions = setConfigFileInOptions; + function isNullOrUndefined(x) { + // tslint:disable-next-line:no-null-keyword + return x === undefined || x === null; + } + function directoryOfCombinedPath(fileName, basePath) { + // Use the `identity` function to avoid canonicalizing the path, as it must remain noncanonical + // until consistient casing errors are reported + return ts.getDirectoryPath(ts.toPath(fileName, basePath, ts.identity)); + } /** * Parse the contents of a config file from json or json source file (tsconfig.json). * @param json The contents of the config file to parse @@ -72752,7 +73205,7 @@ var ts; }; function getFileNames() { var fileNames; - if (ts.hasProperty(raw, "files")) { + if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw["files"])) { if (ts.isArray(raw["files"])) { fileNames = raw["files"]; if (fileNames.length === 0) { @@ -72764,7 +73217,7 @@ var ts; } } var includeSpecs; - if (ts.hasProperty(raw, "include")) { + if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw["include"])) { if (ts.isArray(raw["include"])) { includeSpecs = raw["include"]; } @@ -72773,7 +73226,7 @@ var ts; } } var excludeSpecs; - if (ts.hasProperty(raw, "exclude")) { + if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw["exclude"])) { if (ts.isArray(raw["exclude"])) { excludeSpecs = raw["exclude"]; } @@ -72790,7 +73243,7 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !ts.hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); } @@ -72860,7 +73313,8 @@ var ts; errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, ts.createCompilerDiagnostic); + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, ts.createCompilerDiagnostic); } } return { raw: json, options: options, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath }; @@ -72882,7 +73336,8 @@ var ts; onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) { switch (key) { case "extends": - extendedConfigPath = getExtendsConfigPath(value, host, basePath, getCanonicalFileName, errors, function (message, arg0) { + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(value, host, newBase, getCanonicalFileName, errors, function (message, arg0) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0); }); return; @@ -73038,6 +73493,8 @@ var ts; } } function normalizeOptionValue(option, basePath, value) { + if (isNullOrUndefined(value)) + return undefined; if (option.type === "list") { var listOption_1 = option; if (listOption_1.element.isFilePath || typeof listOption_1.element.type !== "string") { @@ -73060,6 +73517,8 @@ var ts; return value; } function convertJsonOptionOfCustomType(opt, value, errors) { + if (isNullOrUndefined(value)) + return undefined; var key = value.toLowerCase(); var val = opt.type.get(key); if (val !== undefined) { @@ -73186,7 +73645,7 @@ var ts; if (fileNames) { for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); + var file = ts.getNormalizedAbsolutePath(fileName, basePath); literalFileMap.set(keyMapper(file), file); } } @@ -73871,25 +74330,24 @@ var ts; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { - if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { - switch (node.parent.kind) { - case 149 /* PropertyDeclaration */: - case 148 /* PropertySignature */: - case 261 /* PropertyAssignment */: - case 264 /* EnumMember */: - case 151 /* MethodDeclaration */: - case 150 /* MethodSignature */: - case 153 /* GetAccessor */: - case 154 /* SetAccessor */: - case 233 /* ModuleDeclaration */: - return ts.getNameOfDeclaration(node.parent) === node; - case 180 /* ElementAccessExpression */: - return node.parent.argumentExpression === node; - case 144 /* ComputedPropertyName */: - return true; - } + switch (node.parent.kind) { + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 261 /* PropertyAssignment */: + case 264 /* EnumMember */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 233 /* ModuleDeclaration */: + return ts.getNameOfDeclaration(node.parent) === node; + case 180 /* ElementAccessExpression */: + return node.parent.argumentExpression === node; + case 144 /* ComputedPropertyName */: + return true; + case 173 /* LiteralType */: + return node.parent.parent.kind === 171 /* IndexedAccessType */; } - return false; } ts.isLiteralNameOfPropertyDeclarationOrIndexAccess = isLiteralNameOfPropertyDeclarationOrIndexAccess; function isExpressionOfExternalModuleImportEqualsDeclaration(node) { @@ -73969,6 +74427,28 @@ var ts; return "alias" /* alias */; case 283 /* JSDocTypedefTag */: return "type" /* typeElement */; + case 194 /* BinaryExpression */: + var kind = ts.getSpecialPropertyAssignmentKind(node); + var right = node.right; + switch (kind) { + case 0 /* None */: + return "" /* unknown */; + case 1 /* ExportsProperty */: + case 2 /* ModuleExports */: + var rightKind = getNodeKind(right); + return rightKind === "" /* unknown */ ? "const" /* constElement */ : rightKind; + case 3 /* PrototypeProperty */: + return "method" /* memberFunctionElement */; // instance method + case 4 /* ThisProperty */: + return "property" /* memberVariableElement */; // property + case 5 /* Property */: + // static method / property + return ts.isFunctionExpression(right) ? "method" /* memberFunctionElement */ : "property" /* memberVariableElement */; + default: { + ts.assertTypeIsNever(kind); + return "" /* unknown */; + } + } default: return "" /* unknown */; } @@ -74172,7 +74652,7 @@ var ts; return undefined; } var children = list.getChildren(); - var listItemIndex = ts.indexOf(children, node); + var listItemIndex = ts.indexOfNode(children, node); return { listItemIndex: listItemIndex, list: list @@ -74954,7 +75434,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_7 = dense[i + 1]; + var length_6 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -74963,8 +75443,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_7, classification: convertClassification(type) }); - lastEnd = start + length_7; + entries.push({ length: length_6, classification: convertClassification(type) }); + lastEnd = start + length_6; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -75517,6 +75997,7 @@ var ts; // specially. var docCommentAndDiagnostics = ts.parseIsolatedJSDocComment(sourceFile.text, start, width); if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) { + // TODO: This should be predicated on `token["kind"]` being compatible with `HasJSDoc["kind"]` docCommentAndDiagnostics.jsDoc.parent = token; classifyJSDocComment(docCommentAndDiagnostics.jsDoc); return; @@ -75968,8 +76449,8 @@ var ts; continue; } var start = completePrefix.length; - var length_8 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_8))); + var length_7 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_7))); } return result; } @@ -76263,7 +76744,7 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, request = completionData.request, keywordFilters = completionData.keywordFilters; + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, allowStringLiteral = completionData.allowStringLiteral, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, request = completionData.request, keywordFilters = completionData.keywordFilters; if (sourceFile.languageVariant === 1 /* JSX */ && location && location.parent && location.parent.kind === 252 /* JsxClosingElement */) { // In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag, @@ -76289,14 +76770,14 @@ var ts; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { - var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log, allowStringLiteral); getJavaScriptCompletionEntries(sourceFile, location.pos, uniqueNames, compilerOptions.target, entries); } else { if ((!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) { return undefined; } - getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); + getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log, allowStringLiteral); } // TODO add filter for keyword based on type/value/namespace and also location // Add all keywords if @@ -76319,7 +76800,7 @@ var ts; return; } uniqueNames.set(realName, true); - var displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true); + var displayName = getCompletionEntryDisplayName(realName, target, /*performCharacterChecks*/ true, /*allowStringLiteral*/ false); if (displayName) { entries.push({ name: displayName, @@ -76330,11 +76811,11 @@ var ts; } }); } - function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target) { + function createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral) { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks); + var displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral); if (!displayName) { return undefined; } @@ -76352,13 +76833,13 @@ var ts; sortText: "0", }; } - function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log) { + function getCompletionEntriesFromSymbols(symbols, entries, location, performCharacterChecks, typeChecker, target, log, allowStringLiteral) { var start = ts.timestamp(); var uniqueNames = ts.createMap(); if (symbols) { for (var _i = 0, symbols_5 = symbols; _i < symbols_5.length; _i++) { var symbol = symbols_5[_i]; - var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target); + var entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral); if (entry) { var id = entry.name; if (!uniqueNames.has(id)) { @@ -76438,7 +76919,7 @@ var ts; var type = typeChecker.getContextualType(element.parent); var entries = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, element, /*performCharacterChecks*/ false, typeChecker, target, log, /*allowStringLiteral*/ true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } @@ -76462,7 +76943,7 @@ var ts; var type = typeChecker.getTypeAtLocation(node.expression); var entries = []; if (type) { - getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log); + getCompletionEntriesFromSymbols(type.getApparentProperties(), entries, node, /*performCharacterChecks*/ false, typeChecker, target, log, /*allowStringLiteral*/ true); if (entries.length) { return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: true, entries: entries }; } @@ -76493,7 +76974,7 @@ var ts; addStringLiteralCompletionsFromType(t, result, typeChecker, uniques); } } - else if (type.flags & 32 /* StringLiteral */) { + else if (type.flags & 32 /* StringLiteral */ && !(type.flags & 256 /* EnumLiteral */)) { var name = type.value; if (!uniques.has(name)) { uniques.set(name, true); @@ -76510,12 +76991,12 @@ var ts; // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { - var symbols = completionData.symbols, location = completionData.location; + var symbols = completionData.symbols, location = completionData.location, allowStringLiteral_1 = completionData.allowStringLiteral; // Find the symbol with the matching entry name. // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false) === entryName ? s : undefined; }); + var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral_1) === entryName ? s : undefined; }); if (symbol) { var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { @@ -76546,11 +77027,15 @@ var ts; function getCompletionEntrySymbol(typeChecker, log, compilerOptions, sourceFile, position, entryName) { // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); + if (!completionData) { + return undefined; + } + var symbols = completionData.symbols, allowStringLiteral = completionData.allowStringLiteral; // Find the symbol with the matching entry name. // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - return completionData && ts.forEach(completionData.symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false) === entryName ? s : undefined; }); + return ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral) === entryName ? s : undefined; }); } Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; function getCompletionData(typeChecker, log, sourceFile, position) { @@ -76618,7 +77103,7 @@ var ts; } } if (request) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request: request, keywordFilters: 0 /* None */ }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, allowStringLiteral: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, request: request, keywordFilters: 0 /* None */ }; } if (!insideJsDocTagTypeExpression) { // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal @@ -76705,6 +77190,7 @@ var ts; var semanticStart = ts.timestamp(); var isGlobalCompletion = false; var isMemberCompletion; + var allowStringLiteral = false; var isNewIdentifierLocation; var keywordFilters = 0 /* None */; var symbols = []; @@ -76740,7 +77226,7 @@ var ts; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request: request, keywordFilters: keywordFilters }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, allowStringLiteral: allowStringLiteral, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request: request, keywordFilters: keywordFilters }; function isTagWithTypeExpression(tag) { switch (tag.kind) { case 277 /* JSDocAugmentsTag */: @@ -77073,6 +77559,7 @@ var ts; function tryGetObjectLikeCompletionSymbols(objectLikeContainer) { // We're looking up possible property names from contextual/inferred/declared type. isMemberCompletion = true; + allowStringLiteral = true; var typeMembers; var existingMembers; if (objectLikeContainer.kind === 178 /* ObjectLiteralExpression */) { @@ -77082,7 +77569,7 @@ var ts; var typeForObject = typeChecker.getContextualType(objectLikeContainer); if (!typeForObject) return false; - typeMembers = typeChecker.getAllPossiblePropertiesOfType(typeForObject); + typeMembers = getPropertiesForCompletion(typeForObject, typeChecker); existingMembers = objectLikeContainer.properties; } else { @@ -77641,7 +78128,7 @@ var ts; * * @return undefined if the name is of external module */ - function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks) { + function getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral) { var name = symbol.name; if (!name) return undefined; @@ -77654,19 +78141,20 @@ var ts; return undefined; } } - return getCompletionEntryDisplayName(name, target, performCharacterChecks); + return getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral); } /** * Get a displayName from a given for completion list, performing any necessary quotes stripping * and checking whether the name is valid identifier name. */ - function getCompletionEntryDisplayName(name, target, performCharacterChecks) { + function getCompletionEntryDisplayName(name, target, performCharacterChecks, allowStringLiteral) { // If the user entered name for the symbol was quoted, removing the quotes is not enough, as the name could be an // invalid identifier name. We need to check if whatever was inside the quotes is actually a valid identifier name. // e.g "b a" is valid quoted name but when we strip off the quotes, it is invalid. // We, thus, need to check if whatever was inside the quotes is actually a valid identifier name. if (performCharacterChecks && !ts.isIdentifierText(name, target)) { - return undefined; + // TODO: GH#18169 + return allowStringLiteral ? JSON.stringify(name) : undefined; } return name; } @@ -77773,6 +78261,20 @@ var ts; return node.parent; } } + /** + * Gets all properties on a type, but if that type is a union of several types, + * tries to only include those types which declare properties, not methods. + * This ensures that we don't try providing completions for all the methods on e.g. Array. + */ + function getPropertiesForCompletion(type, checker) { + if (!(type.flags & 65536 /* Union */)) { + return checker.getPropertiesOfType(type); + } + var types = type.types; + var filteredTypes = types.filter(function (memberType) { return !(memberType.flags & 8190 /* Primitive */ || checker.isArrayLikeType(memberType)); }); + // If there are no property-only types, just provide completions for every type as usual. + return checker.getAllPossiblePropertiesOfTypes(filteredTypes); + } })(Completions = ts.Completions || (ts.Completions = {})); })(ts || (ts = {})); /* @internal */ @@ -78365,12 +78867,11 @@ var ts; var bucket = getBucketForCompilationSettings(key, /*createIfMissing*/ true); var entry = bucket.get(path); if (!entry) { - ts.Debug.assert(acquiring, "How could we be trying to update a document that the registry doesn't have?"); // Have never seen this file with these settings. Create a new source file for it. var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, compilationSettings.target, version, /*setNodeParents*/ false, scriptKind); entry = { sourceFile: sourceFile, - languageServiceRefCount: 0, + languageServiceRefCount: 1, owners: [] }; bucket.set(path, entry); @@ -78382,14 +78883,14 @@ var ts; if (entry.sourceFile.version !== version) { entry.sourceFile = ts.updateLanguageServiceSourceFile(entry.sourceFile, scriptSnapshot, version, scriptSnapshot.getChangeRange(entry.sourceFile.scriptSnapshot)); } - } - // If we're acquiring, then this is the first time this LS is asking for this document. - // Increase our ref count so we know there's another LS using the document. If we're - // not acquiring, then that means the LS is 'updating' the file instead, and that means - // it has already acquired the document previously. As such, we do not need to increase - // the ref count. - if (acquiring) { - entry.languageServiceRefCount++; + // If we're acquiring, then this is the first time this LS is asking for this document. + // Increase our ref count so we know there's another LS using the document. If we're + // not acquiring, then that means the LS is 'updating' the file instead, and that means + // it has already acquired the document previously. As such, we do not need to increase + // the ref count. + if (acquiring) { + entry.languageServiceRefCount++; + } } return entry.sourceFile; } @@ -78571,7 +79072,6 @@ var ts; * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. */ function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, checker, isForRename) { - var exportName = exportSymbol.escapedName; var importSearches = []; var singleReferences = []; function addSearch(location, symbol) { @@ -78603,10 +79103,10 @@ var ts; searchForNamedImport(decl.exportClause); return; } - if (!decl.importClause) { + var importClause = decl.importClause; + if (!importClause) { return; } - var importClause = decl.importClause; var namedBindings = importClause.namedBindings; if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { handleNamespaceImportLike(namedBindings.name); @@ -78626,7 +79126,6 @@ var ts; } // 'default' might be accessed as a named import `{ default as foo }`. if (!isForRename && exportKind === 1 /* Default */) { - ts.Debug.assert(exportName === "default"); searchForNamedImport(namedBindings); } } @@ -78638,35 +79137,40 @@ var ts; */ function handleNamespaceImportLike(importName) { // Don't rename an import that already has a different name than the export. - if (exportKind === 2 /* ExportEquals */ && (!isForRename || importName.escapedText === exportName)) { + if (exportKind === 2 /* ExportEquals */ && (!isForRename || isNameMatch(importName.escapedText))) { addSearch(importName, checker.getSymbolAtLocation(importName)); } } function searchForNamedImport(namedBindings) { - if (namedBindings) { - for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { - var element = _a[_i]; - var name = element.name, propertyName = element.propertyName; - if ((propertyName || name).escapedText !== exportName) { - continue; - } - if (propertyName) { - // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. - singleReferences.push(propertyName); - if (!isForRename) { - // Search locally for `bar`. - addSearch(name, checker.getSymbolAtLocation(name)); - } - } - else { - var localSymbol = element.kind === 246 /* ExportSpecifier */ && element.propertyName - ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. - : checker.getSymbolAtLocation(name); - addSearch(name, localSymbol); + if (!namedBindings) { + return; + } + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name = element.name, propertyName = element.propertyName; + if (!isNameMatch((propertyName || name).escapedText)) { + continue; + } + if (propertyName) { + // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. + singleReferences.push(propertyName); + if (!isForRename) { + // Search locally for `bar`. + addSearch(name, checker.getSymbolAtLocation(name)); } } + else { + var localSymbol = element.kind === 246 /* ExportSpecifier */ && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } } } + function isNameMatch(name) { + // Use name of "default" even in `export =` case because we may have allowSyntheticDefaultImports + return name === exportSymbol.escapedName || exportKind !== 0 /* Named */ && name === "default"; + } } /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ function findNamespaceReExports(sourceFileLike, name, checker) { @@ -78842,7 +79346,8 @@ var ts; // Get the symbol for the `export =` node; its parent is the module it's the export of. var exportingModuleSymbol = ex.symbol.parent; ts.Debug.assert(!!exportingModuleSymbol); - return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: 2 /* ExportEquals */ } }; + var exportKind = ex.isExportEquals ? 2 /* ExportEquals */ : 1 /* Default */; + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } }; } function getSpecialPropertyExport(node, useLhsSymbol) { var kind; @@ -78874,7 +79379,11 @@ var ts; if (importedSymbol.escapedName === "export=") { importedSymbol = getExportEqualsLocalSymbol(importedSymbol, checker); } - if (symbolName(importedSymbol) === symbol.escapedName) { + // If the import has a different name than the export, do not continue searching. + // If `importedName` is undefined, do continue searching as the export is anonymous. + // (All imports returned from this function will be ignored anyway if we are in rename and this is a not a named export.) + var importedName = symbolName(importedSymbol); + if (importedName === undefined || importedName === "default" || importedName === symbol.escapedName) { return __assign({ kind: 0 /* Import */, symbol: importedSymbol }, isImport); } } @@ -79066,8 +79575,8 @@ var ts; case "symbol": { var symbol = def.symbol, node_2 = def.node; var _a = getDefinitionKindAndDisplayParts(symbol, node_2, checker), displayParts_1 = _a.displayParts, kind_1 = _a.kind; - var name_3 = displayParts_1.map(function (p) { return p.text; }).join(""); - return { node: node_2, name: name_3, kind: kind_1, displayParts: displayParts_1 }; + var name_4 = displayParts_1.map(function (p) { return p.text; }).join(""); + return { node: node_2, name: name_4, kind: kind_1, displayParts: displayParts_1 }; } case "label": { var node_3 = def.node; @@ -79075,8 +79584,8 @@ var ts; } case "keyword": { var node_4 = def.node; - var name_4 = ts.tokenToString(node_4.kind); - return { node: node_4, name: name_4, kind: "keyword" /* keyword */, displayParts: [{ text: name_4, kind: "keyword" /* keyword */ }] }; + var name_5 = ts.tokenToString(node_4.kind); + return { node: node_4, name: name_5, kind: "keyword" /* keyword */, displayParts: [{ text: name_5, kind: "keyword" /* keyword */ }] }; } case "this": { var node_5 = def.node; @@ -79117,8 +79626,10 @@ var ts; return { fileName: node.getSourceFile().fileName, textSpan: getTextSpan(node), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isAnyDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node), + isWriteAccess: isWriteAccessForReference(node), + isDefinition: node.kind === 79 /* DefaultKeyword */ + || ts.isAnyDeclarationName(node) + || ts.isLiteralComputedPropertyDeclarationName(node), isInString: isInString }; } @@ -79160,7 +79671,7 @@ var ts; } var node = entry.node, isInString = entry.isInString; var fileName = entry.node.getSourceFile().fileName; - var writeAccess = isWriteAccess(node); + var writeAccess = isWriteAccessForReference(node); var span = { textSpan: getTextSpan(node), kind: writeAccess ? "writtenReference" /* writtenReference */ : "reference" /* reference */, @@ -79179,20 +79690,8 @@ var ts; return ts.createTextSpanFromBounds(start, end); } /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ - function isWriteAccess(node) { - if (ts.isAnyDeclarationName(node)) { - return true; - } - var parent = node.parent; - switch (parent && parent.kind) { - case 193 /* PostfixUnaryExpression */: - case 192 /* PrefixUnaryExpression */: - return true; - case 194 /* BinaryExpression */: - return parent.left === node && ts.isAssignmentOperator(parent.operatorToken.kind); - default: - return false; - } + function isWriteAccessForReference(node) { + return node.kind === 79 /* DefaultKeyword */ || ts.isAnyDeclarationName(node) || ts.isWriteAccess(node); } })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); @@ -79617,7 +80116,7 @@ var ts; } function isValidReferencePosition(node, searchSymbolName) { // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node && node.kind) { + switch (node.kind) { case 71 /* Identifier */: return node.text.length === searchSymbolName.length; case 9 /* StringLiteral */: @@ -79625,6 +80124,8 @@ var ts; node.text.length === searchSymbolName.length; case 8 /* NumericLiteral */: return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.text.length === searchSymbolName.length; + case 79 /* DefaultKeyword */: + return "default".length === searchSymbolName.length; default: return false; } @@ -80237,20 +80738,24 @@ var ts; var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); if (bindingElementPropertySymbol) { result.push(bindingElementPropertySymbol); + addRootSymbols(bindingElementPropertySymbol); } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - for (var _i = 0, _a = checker.getRootSymbols(symbol); _i < _a.length; _i++) { - var rootSymbol = _a[_i]; - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ ts.createSymbolTable(), checker); - } - } + addRootSymbols(symbol); return result; + function addRootSymbols(sym) { + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + for (var _i = 0, _a = checker.getRootSymbols(sym); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== sym) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ ts.createSymbolTable(), checker); + } + } + } } /** * Find symbol of the given property-name and add the symbol to the given result array @@ -80333,30 +80838,35 @@ var ts; // then include the binding element in the related symbols // let { a } : { a }; var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); - if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; + if (bindingElementPropertySymbol) { + var fromBindingElement = findRootSymbol(bindingElementPropertySymbol); + if (fromBindingElement) + return fromBindingElement; } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return ts.forEach(state.checker.getRootSymbols(referenceSymbol), function (rootSymbol) { - // if it is in the list, then we are done - if (search.includes(rootSymbol)) { - return rootSymbol; - } - // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - // Parents will only be defined if implementations is true - if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { - return undefined; + return findRootSymbol(referenceSymbol); + function findRootSymbol(sym) { + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return ts.forEach(state.checker.getRootSymbols(sym), function (rootSymbol) { + // if it is in the list, then we are done + if (search.includes(rootSymbol)) { + return rootSymbol; } - var result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ ts.createSymbolTable(), state.checker); - return ts.find(result, search.includes); - } - return undefined; - }); + // Finally, try all properties with the same name in any type the containing type extended or implemented, and + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + // Parents will only be defined if implementations is true + if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { + return undefined; + } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.name, result, /*previousIterationSymbolsCache*/ ts.createSymbolTable(), state.checker); + return ts.find(result, search.includes); + } + return undefined; + }); + } } function getNameFromObjectLiteralElement(node) { if (node.name.kind === 144 /* ComputedPropertyName */) { @@ -80979,52 +81489,32 @@ var ts; if (!tokenAtPos || tokenStart < position) { return undefined; } - // TODO: add support for: - // - enums/enum members - // - interfaces - // - property declarations - // - potentially property assignments - var commentOwner; - findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { - switch (commentOwner.kind) { - case 228 /* FunctionDeclaration */: - case 151 /* MethodDeclaration */: - case 152 /* Constructor */: - case 229 /* ClassDeclaration */: - case 208 /* VariableStatement */: - break findOwner; - case 265 /* SourceFile */: - return undefined; - case 233 /* ModuleDeclaration */: - // If in walking up the tree, we hit a a nested namespace declaration, - // then we must be somewhere within a dotted namespace name; however we don't - // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. - if (commentOwner.parent.kind === 233 /* ModuleDeclaration */) { - return undefined; - } - break findOwner; - } + var commentOwnerInfo = getCommentOwnerInfo(tokenAtPos); + if (!commentOwnerInfo) { + return undefined; } - if (!commentOwner || commentOwner.getStart() < position) { + var commentOwner = commentOwnerInfo.commentOwner, parameters = commentOwnerInfo.parameters; + if (commentOwner.getStart() < position) { return undefined; } - var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; // replace non-whitespace characters in prefix with spaces. var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; - for (var i = 0; i < parameters.length; i++) { - var currentName = parameters[i].name; - var paramName = currentName.kind === 71 /* Identifier */ ? - currentName.escapedText : - "param" + i; - if (isJavaScriptFile) { - docParams += indentationStr + " * @param {any} " + paramName + newLine; - } - else { - docParams += indentationStr + " * @param " + paramName + newLine; + if (parameters) { + for (var i = 0; i < parameters.length; i++) { + var currentName = parameters[i].name; + var paramName = currentName.kind === 71 /* Identifier */ ? + currentName.escapedText : + "param" + i; + if (isJavaScriptFile) { + docParams += indentationStr + " * @param {any} " + paramName + newLine; + } + else { + docParams += indentationStr + " * @param " + paramName + newLine; + } } } // A doc comment consists of the following @@ -81043,18 +81533,46 @@ var ts; return { newText: result, caretOffset: preamble.length }; } JsDoc.getDocCommentTemplateAtPosition = getDocCommentTemplateAtPosition; - function getParametersForJsDocOwningNode(commentOwner) { - if (ts.isFunctionLike(commentOwner)) { - return commentOwner.parameters; - } - if (commentOwner.kind === 208 /* VariableStatement */) { - var varStatement = commentOwner; - var varDeclarations = varStatement.declarationList.declarations; - if (varDeclarations.length === 1 && varDeclarations[0].initializer) { - return getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer); + function getCommentOwnerInfo(tokenAtPos) { + // TODO: add support for: + // - enums/enum members + // - interfaces + // - property declarations + // - potentially property assignments + for (var commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { + switch (commentOwner.kind) { + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 152 /* Constructor */: + var parameters = commentOwner.parameters; + return { commentOwner: commentOwner, parameters: parameters }; + case 229 /* ClassDeclaration */: + return { commentOwner: commentOwner }; + case 208 /* VariableStatement */: { + var varStatement = commentOwner; + var varDeclarations = varStatement.declarationList.declarations; + var parameters_1 = varDeclarations.length === 1 && varDeclarations[0].initializer + ? getParametersFromRightHandSideOfAssignment(varDeclarations[0].initializer) + : undefined; + return { commentOwner: commentOwner, parameters: parameters_1 }; + } + case 265 /* SourceFile */: + return undefined; + case 233 /* ModuleDeclaration */: + // If in walking up the tree, we hit a a nested namespace declaration, + // then we must be somewhere within a dotted namespace name; however we don't + // want to give back a JSDoc template for the 'b' or 'c' in 'namespace a.b.c { }'. + return commentOwner.parent.kind === 233 /* ModuleDeclaration */ ? undefined : { commentOwner: commentOwner }; + case 194 /* BinaryExpression */: { + var be = commentOwner; + if (ts.getSpecialPropertyAssignmentKind(be) === 0 /* None */) { + return undefined; + } + var parameters_2 = ts.isFunctionLike(be.right) ? be.right.parameters : ts.emptyArray; + return { commentOwner: commentOwner, parameters: parameters_2 }; + } } } - return ts.emptyArray; } /** * Digs into an an initializer or RHS operand of an assignment operation @@ -81303,32 +81821,7 @@ var ts; return "continue"; } ts.forEachEntry(sourceFile.getNamedDeclarations(), function (declarations, name) { - if (declarations) { - // First do a quick check to see if the name of the declaration matches the - // last portion of the (possibly) dotted name they're searching for. - var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); - if (!matches) { - return; // continue to next named declarations - } - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - // It was a match! If the pattern has dots in it, then also see if the - // declaration container matches as well. - if (patternMatcher.patternContainsDots) { - var containers = getContainers(declaration); - if (!containers) { - return true; // Break out of named declarations and go to the next source file. - } - matches = patternMatcher.getMatches(containers, name); - if (!matches) { - return; // continue to next named declarations - } - } - var fileName = sourceFile.fileName; - var matchKind = bestMatchKind(matches); - rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: allMatchesAreCaseSensitive(matches), declaration: declaration }); - } - } + getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, sourceFile.fileName, rawItems); }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] @@ -81336,134 +81829,159 @@ var ts; var sourceFile = sourceFiles_8[_i]; _loop_6(sourceFile); } - // Remove imports when the imported declaration is already in the list and has the same name. - rawItems = ts.filter(rawItems, function (item) { - var decl = item.declaration; - if (decl.kind === 239 /* ImportClause */ || decl.kind === 242 /* ImportSpecifier */ || decl.kind === 237 /* ImportEqualsDeclaration */) { - var importer = checker.getSymbolAtLocation(decl.name); - var imported = checker.getAliasedSymbol(importer); - return importer.escapedName !== imported.escapedName; - } - else { - return true; - } - }); rawItems.sort(compareNavigateToItems); if (maxResultCount !== undefined) { rawItems = rawItems.slice(0, maxResultCount); } - var items = ts.map(rawItems, createNavigateToItem); - return items; - function allMatchesAreCaseSensitive(matches) { - ts.Debug.assert(matches.length > 0); - // This is a case sensitive match, only if all the submatches were case sensitive. - for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { - var match = matches_2[_i]; - if (!match.isCaseSensitive) { + return rawItems.map(createNavigateToItem); + } + NavigateTo.getNavigateToItems = getNavigateToItems; + function getItemsFromNamedDeclaration(patternMatcher, name, declarations, checker, fileName, rawItems) { + // First do a quick check to see if the name of the declaration matches the + // last portion of the (possibly) dotted name they're searching for. + var matches = patternMatcher.getMatchesForLastSegmentOfPattern(name); + if (!matches) { + return; // continue to next named declarations + } + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + if (!shouldKeepItem(declaration, checker)) { + continue; + } + // It was a match! If the pattern has dots in it, then also see if the + // declaration container matches as well. + var containerMatches = matches; + if (patternMatcher.patternContainsDots) { + containerMatches = patternMatcher.getMatches(getContainers(declaration), name); + if (!containerMatches) { + continue; + } + } + var matchKind = bestMatchKind(containerMatches); + var isCaseSensitive = allMatchesAreCaseSensitive(containerMatches); + rawItems.push({ name: name, fileName: fileName, matchKind: matchKind, isCaseSensitive: isCaseSensitive, declaration: declaration }); + } + } + function shouldKeepItem(declaration, checker) { + switch (declaration.kind) { + case 239 /* ImportClause */: + case 242 /* ImportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + var importer = checker.getSymbolAtLocation(declaration.name); + var imported = checker.getAliasedSymbol(importer); + return importer.escapedName !== imported.escapedName; + default: + return true; + } + } + function allMatchesAreCaseSensitive(matches) { + ts.Debug.assert(matches.length > 0); + // This is a case sensitive match, only if all the submatches were case sensitive. + for (var _i = 0, matches_2 = matches; _i < matches_2.length; _i++) { + var match = matches_2[_i]; + if (!match.isCaseSensitive) { + return false; + } + } + return true; + } + function tryAddSingleDeclarationName(declaration, containers) { + if (declaration) { + var name = ts.getNameOfDeclaration(declaration); + if (name) { + var text = ts.getTextOfIdentifierOrLiteral(name); + if (text !== undefined) { + containers.unshift(text); + } + else if (name.kind === 144 /* ComputedPropertyName */) { + return tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ true); + } + else { + // Don't know how to add this. return false; } } - return true; - } - function tryAddSingleDeclarationName(declaration, containers) { - if (declaration) { - var name = ts.getNameOfDeclaration(declaration); - if (name) { - var text = ts.getTextOfIdentifierOrLiteral(name); - if (text !== undefined) { - containers.unshift(text); - } - else if (name.kind === 144 /* ComputedPropertyName */) { - return tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ true); - } - else { - // Don't know how to add this. - return false; - } - } - } - return true; - } - // Only added the names of computed properties if they're simple dotted expressions, like: - // - // [X.Y.Z]() { } - function tryAddComputedPropertyName(expression, containers, includeLastPortion) { - var text = ts.getTextOfIdentifierOrLiteral(expression); - if (text !== undefined) { - if (includeLastPortion) { - containers.unshift(text); - } - return true; - } - if (expression.kind === 179 /* PropertyAccessExpression */) { - var propertyAccess = expression; - if (includeLastPortion) { - containers.unshift(propertyAccess.name.text); - } - return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true); - } - return false; - } - function getContainers(declaration) { - var containers = []; - // First, if we started with a computed property name, then add all but the last - // portion into the container array. - var name = ts.getNameOfDeclaration(declaration); - if (name.kind === 144 /* ComputedPropertyName */) { - if (!tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { - return undefined; - } - } - // Now, walk up our containers, adding all their names to the container array. - declaration = ts.getContainerNode(declaration); - while (declaration) { - if (!tryAddSingleDeclarationName(declaration, containers)) { - return undefined; - } - declaration = ts.getContainerNode(declaration); - } - return containers; - } - function bestMatchKind(matches) { - ts.Debug.assert(matches.length > 0); - var bestMatchKind = ts.PatternMatchKind.camelCase; - for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { - var match = matches_3[_i]; - var kind = match.kind; - if (kind < bestMatchKind) { - bestMatchKind = kind; - } - } - return bestMatchKind; - } - function compareNavigateToItems(i1, i2) { - // TODO(cyrusn): get the gamut of comparisons that VS already uses here. - // Right now we just sort by kind first, and then by name of the item. - // We first sort case insensitively. So "Aaa" will come before "bar". - // Then we sort case sensitively, so "aaa" will come before "Aaa". - return i1.matchKind - i2.matchKind || - ts.compareStringsCaseInsensitive(i1.name, i2.name) || - ts.compareStrings(i1.name, i2.name); - } - function createNavigateToItem(rawItem) { - var declaration = rawItem.declaration; - var container = ts.getContainerNode(declaration); - var containerName = container && ts.getNameOfDeclaration(container); - return { - name: rawItem.name, - kind: ts.getNodeKind(declaration), - kindModifiers: ts.getNodeModifiers(declaration), - matchKind: ts.PatternMatchKind[rawItem.matchKind], - isCaseSensitive: rawItem.isCaseSensitive, - fileName: rawItem.fileName, - textSpan: ts.createTextSpanFromNode(declaration), - // TODO(jfreeman): What should be the containerName when the container has a computed name? - containerName: containerName ? containerName.text : "", - containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ - }; } + return true; + } + // Only added the names of computed properties if they're simple dotted expressions, like: + // + // [X.Y.Z]() { } + function tryAddComputedPropertyName(expression, containers, includeLastPortion) { + var text = ts.getTextOfIdentifierOrLiteral(expression); + if (text !== undefined) { + if (includeLastPortion) { + containers.unshift(text); + } + return true; + } + if (expression.kind === 179 /* PropertyAccessExpression */) { + var propertyAccess = expression; + if (includeLastPortion) { + containers.unshift(propertyAccess.name.text); + } + return tryAddComputedPropertyName(propertyAccess.expression, containers, /*includeLastPortion*/ true); + } + return false; + } + function getContainers(declaration) { + var containers = []; + // First, if we started with a computed property name, then add all but the last + // portion into the container array. + var name = ts.getNameOfDeclaration(declaration); + if (name.kind === 144 /* ComputedPropertyName */) { + if (!tryAddComputedPropertyName(name.expression, containers, /*includeLastPortion*/ false)) { + return undefined; + } + } + // Now, walk up our containers, adding all their names to the container array. + declaration = ts.getContainerNode(declaration); + while (declaration) { + if (!tryAddSingleDeclarationName(declaration, containers)) { + return undefined; + } + declaration = ts.getContainerNode(declaration); + } + return containers; + } + function bestMatchKind(matches) { + ts.Debug.assert(matches.length > 0); + var bestMatchKind = ts.PatternMatchKind.camelCase; + for (var _i = 0, matches_3 = matches; _i < matches_3.length; _i++) { + var match = matches_3[_i]; + var kind = match.kind; + if (kind < bestMatchKind) { + bestMatchKind = kind; + } + } + return bestMatchKind; + } + function compareNavigateToItems(i1, i2) { + // TODO(cyrusn): get the gamut of comparisons that VS already uses here. + // Right now we just sort by kind first, and then by name of the item. + // We first sort case insensitively. So "Aaa" will come before "bar". + // Then we sort case sensitively, so "aaa" will come before "Aaa". + return i1.matchKind - i2.matchKind || + ts.compareStringsCaseInsensitive(i1.name, i2.name) || + ts.compareStrings(i1.name, i2.name); + } + function createNavigateToItem(rawItem) { + var declaration = rawItem.declaration; + var container = ts.getContainerNode(declaration); + var containerName = container && ts.getNameOfDeclaration(container); + return { + name: rawItem.name, + kind: ts.getNodeKind(declaration), + kindModifiers: ts.getNodeModifiers(declaration), + matchKind: ts.PatternMatchKind[rawItem.matchKind], + isCaseSensitive: rawItem.isCaseSensitive, + fileName: rawItem.fileName, + textSpan: ts.createTextSpanFromNode(declaration), + // TODO(jfreeman): What should be the containerName when the container has a computed name? + containerName: containerName ? containerName.text : "", + containerKind: containerName ? ts.getNodeKind(container) : "" /* unknown */ + }; } - NavigateTo.getNavigateToItems = getNavigateToItems; })(NavigateTo = ts.NavigateTo || (ts.NavigateTo = {})); })(ts || (ts = {})); /// @@ -81647,17 +82165,24 @@ var ts; break; case 176 /* BindingElement */: case 226 /* VariableDeclaration */: - var decl = node; - var name = decl.name; + var _d = node, name = _d.name, initializer = _d.initializer; if (ts.isBindingPattern(name)) { addChildrenRecursively(name); } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - // For `const x = function() {}`, just use the function node, not the const. - addChildrenRecursively(decl.initializer); + else if (initializer && isFunctionOrClassExpression(initializer)) { + if (initializer.name) { + // Don't add a node for the VariableDeclaration, just for the initializer. + addChildrenRecursively(initializer); + } + else { + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + ts.forEachChild(initializer, addChildrenRecursively); + endNode(); + } } else { - addNodeWithRecursiveChild(decl, decl.initializer); + addNodeWithRecursiveChild(node, initializer); } break; case 187 /* ArrowFunction */: @@ -81667,8 +82192,8 @@ var ts; break; case 232 /* EnumDeclaration */: startNode(node); - for (var _d = 0, _e = node.members; _d < _e.length; _d++) { - var member = _e[_d]; + for (var _e = 0, _f = node.members; _e < _f.length; _e++) { + var member = _f[_e]; if (!isComputedProperty(member)) { addLeafNode(member); } @@ -81679,8 +82204,8 @@ var ts; case 199 /* ClassExpression */: case 230 /* InterfaceDeclaration */: startNode(node); - for (var _f = 0, _g = node.members; _f < _g.length; _f++) { - var member = _g[_f]; + for (var _g = 0, _h = node.members; _g < _h.length; _g++) { + var member = _h[_g]; addChildrenRecursively(member); } endNode(); @@ -81697,13 +82222,15 @@ var ts; addLeafNode(node); break; default: - ts.forEach(node.jsDoc, function (jsDoc) { - ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 283 /* JSDocTypedefTag */) { - addLeafNode(tag); - } + if (ts.hasJSDocNodes(node)) { + ts.forEach(node.jsDoc, function (jsDoc) { + ts.forEach(jsDoc.tags, function (tag) { + if (tag.kind === 283 /* JSDocTypedefTag */) { + addLeafNode(tag); + } + }); }); - }); + } ts.forEachChild(node, addChildrenRecursively); } } @@ -82038,7 +82565,14 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 186 /* FunctionExpression */ || node.kind === 187 /* ArrowFunction */ || node.kind === 199 /* ClassExpression */; + switch (node.kind) { + case 187 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 199 /* ClassExpression */: + return true; + default: + return false; + } } })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); @@ -82049,11 +82583,15 @@ var ts; (function (OutliningElementsCollector) { var collapseText = "..."; var maxDepth = 20; + var defaultLabel = "#region"; + var regionMatch = new RegExp("^\\s*//\\s*#(end)?region(?:\\s+(.*))?$"); function collectElements(sourceFile, cancellationToken) { var elements = []; var depth = 0; + var regions = []; walk(sourceFile); - return elements; + gatherRegions(); + return elements.sort(function (span1, span2) { return span1.textSpan.start - span2.textSpan.start; }); /** If useFullStart is true, then the collapsing span includes leading whitespace, including linebreaks. */ function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse, useFullStart) { if (hintSpanNode && startElement && endElement) { @@ -82122,6 +82660,36 @@ var ts; function autoCollapse(node) { return ts.isFunctionBlock(node) && node.parent.kind !== 187 /* ArrowFunction */; } + function gatherRegions() { + var lineStarts = sourceFile.getLineStarts(); + for (var i = 0; i < lineStarts.length; i++) { + var currentLineStart = lineStarts[i]; + var lineEnd = lineStarts[i + 1] - 1 || sourceFile.getEnd(); + var comment = sourceFile.text.substring(currentLineStart, lineEnd); + var result = comment.match(regionMatch); + if (result && !ts.isInComment(sourceFile, currentLineStart)) { + if (!result[1]) { + var start = sourceFile.getFullText().indexOf("//", currentLineStart); + var textSpan = ts.createTextSpanFromBounds(start, lineEnd); + var region = { + textSpan: textSpan, + hintSpan: textSpan, + bannerText: result[2] || defaultLabel, + autoCollapse: false + }; + regions.push(region); + } + else { + var region = regions.pop(); + if (region) { + region.textSpan.length = lineEnd - region.textSpan.start; + region.hintSpan.length = lineEnd - region.textSpan.start; + elements.push(region); + } + } + } + } + } function walk(n) { cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { @@ -83030,13 +83598,11 @@ var ts; } // skip open bracket token = nextToken(); - var i = 0; // scan until ']' or EOF while (token !== 22 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names if (token === 9 /* StringLiteral */) { recordModuleName(); - i++; } token = nextToken(); } @@ -83197,10 +83763,16 @@ var ts; return ts.createTextSpan(start, width); } function nodeIsEligibleForRename(node) { - return node.kind === 71 /* Identifier */ || - node.kind === 9 /* StringLiteral */ || - ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || - ts.isThis(node); + switch (node.kind) { + case 71 /* Identifier */: + case 9 /* StringLiteral */: + case 99 /* ThisKeyword */: + return true; + case 8 /* NumericLiteral */: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node); + default: + return false; + } } })(Rename = ts.Rename || (ts.Rename = {})); })(ts || (ts = {})); @@ -83537,8 +84109,7 @@ var ts; if (isTypeParameterList) { isVariadic = false; // type parameter lists are not variadic prefixDisplayParts.push(ts.punctuationPart(27 /* LessThanToken */)); - // Use `.mapper` to ensure we get the generic type arguments even if this is an instantiated version of the signature. - var typeParameters = candidateSignature.mapper ? candidateSignature.mapper.mappedTypes : candidateSignature.typeParameters; + var typeParameters = (candidateSignature.target || candidateSignature).typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : ts.emptyArray; suffixDisplayParts.push(ts.punctuationPart(29 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { @@ -83676,7 +84247,8 @@ var ts; if (rootSymbolFlags & (98308 /* PropertyOrAccessor */ | 3 /* Variable */)) { return "property" /* memberVariableElement */; } - ts.Debug.assert(!!(rootSymbolFlags & 8192 /* Method */)); + // May be a Function if this was from `typeof N` with `namespace N { function f();. }`. + ts.Debug.assert(!!(rootSymbolFlags & (8192 /* Method */ | 16 /* Function */))); }); if (!unionPropertyKind) { // If this was union of all methods, @@ -84270,10 +84842,6 @@ var ts; (function (formatting) { var standardScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, 0 /* Standard */); var jsxScanner = ts.createScanner(5 /* Latest */, /*skipTrivia*/ false, 1 /* JSX */); - /** - * Scanner that is currently used for formatting - */ - var scanner; var ScanAction; (function (ScanAction) { ScanAction[ScanAction["Scan"] = 0] = "Scan"; @@ -84283,9 +84851,8 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); - function getFormattingScanner(text, languageVariant, startPos, endPos) { - ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + function getFormattingScanner(text, languageVariant, startPos, endPos, cb) { + var scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; @@ -84294,38 +84861,28 @@ var ts; var savedPos; var lastScanAction; var lastTokenInfo; - return { + var res = cb({ advance: advance, readTokenInfo: readTokenInfo, isOnToken: isOnToken, getCurrentLeadingTrivia: function () { return leadingTrivia; }, lastTrailingTriviaWasNewLine: function () { return wasNewLine; }, skipToEndOf: skipToEndOf, - close: function () { - ts.Debug.assert(scanner !== undefined); - lastTokenInfo = undefined; - scanner.setText(undefined); - scanner = undefined; - } - }; + }); + lastTokenInfo = undefined; + scanner.setText(undefined); + return res; function advance() { - ts.Debug.assert(scanner !== undefined, "Scanner should be present"); lastTokenInfo = undefined; var isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - if (trailingTrivia) { - ts.Debug.assert(trailingTrivia.length !== 0); - wasNewLine = ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; - } - else { - wasNewLine = false; - } + wasNewLine = trailingTrivia && ts.lastOrUndefined(trailingTrivia).kind === 4 /* NewLineTrivia */; + } + else { + scanner.scan(); } leadingTrivia = undefined; trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } var pos = scanner.getStartPos(); // Read leading trivia and token while (pos < endPos) { @@ -84341,23 +84898,18 @@ var ts; kind: t }; pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; - } - leadingTrivia.push(item); + leadingTrivia = ts.append(leadingTrivia, item); } savedPos = scanner.getStartPos(); } function shouldRescanGreaterThanToken(node) { - if (node) { - switch (node.kind) { - case 31 /* GreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanEqualsToken */: - case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 47 /* GreaterThanGreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanToken */: - return true; - } + switch (node.kind) { + case 31 /* GreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanToken */: + return true; } return false; } @@ -84368,13 +84920,14 @@ var ts; case 251 /* JsxOpeningElement */: case 252 /* JsxClosingElement */: case 250 /* JsxSelfClosingElement */: - return node.kind === 71 /* Identifier */; + // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. + return ts.isKeyword(node.kind) || node.kind === 71 /* Identifier */; } } return false; } function shouldRescanJsxText(node) { - return node && node.kind === 10 /* JsxText */; + return node.kind === 10 /* JsxText */; } function shouldRescanSlashToken(container) { return container.kind === 12 /* RegularExpressionLiteral */; @@ -84387,15 +84940,7 @@ var ts; return t === 41 /* SlashToken */ || t === 63 /* SlashEqualsToken */; } function readTokenInfo(n) { - ts.Debug.assert(scanner !== undefined); - if (!isOnToken()) { - // scanner is not on the token (either advance was not called yet or scanner is already past the end position) - return { - leadingTrivia: leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } + ts.Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. var expectedScanAction = shouldRescanGreaterThanToken(n) @@ -84424,32 +84969,7 @@ var ts; scanner.setTextPos(savedPos); scanner.scan(); } - var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 29 /* GreaterThanToken */) { - currentToken = scanner.reScanGreaterToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 1 /* RescanGreaterThanToken */; - } - else if (expectedScanAction === 2 /* RescanSlashToken */ && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - ts.Debug.assert(n.kind === currentToken); - lastScanAction = 2 /* RescanSlashToken */; - } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 18 /* CloseBraceToken */) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = 3 /* RescanTemplateToken */; - } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 71 /* Identifier */) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = 4 /* RescanJsxIdentifier */; - } - else if (expectedScanAction === 5 /* RescanJsxText */) { - currentToken = scanner.reScanJsxToken(); - lastScanAction = 5 /* RescanJsxText */; - } - else { - lastScanAction = 0 /* Scan */; - } + var currentToken = getNextToken(n, expectedScanAction); var token = { pos: scanner.getStartPos(), end: scanner.getTextPos(), @@ -84482,8 +85002,46 @@ var ts; lastTokenInfo = { leadingTrivia: leadingTrivia, trailingTrivia: trailingTrivia, token: token }; return fixTokenKind(lastTokenInfo, n); } + function getNextToken(n, expectedScanAction) { + var token = scanner.getToken(); + lastScanAction = 0 /* Scan */; + switch (expectedScanAction) { + case 1 /* RescanGreaterThanToken */: + if (token === 29 /* GreaterThanToken */) { + lastScanAction = 1 /* RescanGreaterThanToken */; + var newToken = scanner.reScanGreaterToken(); + ts.Debug.assert(n.kind === newToken); + return newToken; + } + break; + case 2 /* RescanSlashToken */: + if (startsWithSlashToken(token)) { + lastScanAction = 2 /* RescanSlashToken */; + var newToken = scanner.reScanSlashToken(); + ts.Debug.assert(n.kind === newToken); + return newToken; + } + break; + case 3 /* RescanTemplateToken */: + if (token === 18 /* CloseBraceToken */) { + lastScanAction = 3 /* RescanTemplateToken */; + return scanner.reScanTemplateToken(); + } + break; + case 4 /* RescanJsxIdentifier */: + lastScanAction = 4 /* RescanJsxIdentifier */; + return scanner.scanJsxIdentifier(); + case 5 /* RescanJsxText */: + lastScanAction = 5 /* RescanJsxText */; + return scanner.reScanJsxToken(); + case 0 /* Scan */: + break; + default: + ts.Debug.assertNever(expectedScanAction); + } + return token; + } function isOnToken() { - ts.Debug.assert(scanner !== undefined); var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); @@ -84623,11 +85181,6 @@ var ts; this.Operation = Operation; this.Flag = Flag; } - Rule.prototype.toString = function () { - return "[desc=" + this.Descriptor + "," + - "operation=" + this.Operation + "," + - "flag=" + this.Flag + "]"; - }; return Rule; }()); formatting.Rule = Rule; @@ -85021,16 +85574,16 @@ var ts; this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - } - Rules.prototype.getRuleName = function (rule) { - var o = this; - for (var name in o) { - if (o[name] === rule) { - return name; + if (ts.Debug.isDebugging) { + var o = this; + for (var name in o) { + var rule = o[name]; + if (rule instanceof formatting.Rule) { + rule.debugName = name; + } } } - throw new Error("Unknown rule"); - }; + } /// /// Contexts /// @@ -85188,8 +85741,8 @@ var ts; return true; case 207 /* Block */: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 187 /* ArrowFunction */ && - blockParent.kind !== 186 /* FunctionExpression */) { + // In a codefix scenario, we can't rely on parents being set. So just always return true. + if (!blockParent || blockParent.kind !== 187 /* ArrowFunction */ && blockParent.kind !== 186 /* FunctionExpression */) { return true; } } @@ -85635,15 +86188,9 @@ var ts; var RulesProvider = /** @class */ (function () { function RulesProvider() { this.globalRules = new formatting.Rules(); - var activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); + var activeRules = this.globalRules.HighPriorityCommonRules.concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); this.rulesMap = formatting.RulesMap.create(activeRules); } - RulesProvider.prototype.getRuleName = function (rule) { - return this.globalRules.getRuleName(rule); - }; - RulesProvider.prototype.getRuleByName = function (name) { - return this.globalRules[name]; - }; RulesProvider.prototype.getRulesMap = function () { return this.rulesMap; }; @@ -85918,8 +86465,8 @@ var ts; /* @internal */ function formatNodeGivenIndentation(node, sourceFileLike, languageVariant, initialIndentation, delta, rulesProvider) { var range = { pos: 0, end: sourceFileLike.text.length }; - return formatSpanWorker(range, node, initialIndentation, delta, formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), rulesProvider.getFormatOptions(), rulesProvider, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors - sourceFileLike); + return formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end, function (scanner) { return formatSpanWorker(range, node, initialIndentation, delta, scanner, rulesProvider.getFormatOptions(), rulesProvider, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + sourceFileLike); }); } formatting.formatNodeGivenIndentation = formatNodeGivenIndentation; function formatNodeLines(node, sourceFile, options, rulesProvider, requestKind) { @@ -85935,7 +86482,7 @@ var ts; function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { // find the smallest node that fully wraps the range and compute the initial indentation for the node var enclosingNode = findEnclosingNode(originalRange, sourceFile); - return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); + return formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end, function (scanner) { return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), scanner, options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); }); } function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { // formatting context is used by rules provider @@ -85962,7 +86509,6 @@ var ts; trimTrailingWhitespacesForRemainingRange(); } } - formattingScanner.close(); return edits; // local functions /** Tries to compute the indentation for a list element. @@ -86201,6 +86747,7 @@ var ts; return inheritedIndentation; } function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) { + ts.Debug.assert(ts.isNodeArray(nodes)); var listStartToken = getOpenTokenForList(parent, nodes); var listEndToken = getCloseTokenForOpenToken(listStartToken); var listDynamicIndentation = parentDynamicIndentation; @@ -87120,6 +87667,8 @@ var ts; case 241 /* NamedImports */: case 246 /* ExportSpecifier */: case 242 /* ImportSpecifier */: + case 261 /* PropertyAssignment */: + case 149 /* PropertyDeclaration */: return true; } return false; @@ -87174,15 +87723,21 @@ var ts; * It can be changed to side-table later if we decide that current design is too invasive. */ function getPos(n) { - return n["__pos"]; + var result = n["__pos"]; + ts.Debug.assert(typeof result === "number"); + return result; } function setPos(n, pos) { + ts.Debug.assert(typeof pos === "number"); n["__pos"] = pos; } function getEnd(n) { - return n["__end"]; + var result = n["__end"]; + ts.Debug.assert(typeof result === "number"); + return result; } function setEnd(n, end) { + ts.Debug.assert(typeof end === "number"); n["__end"] = end; } var Position; @@ -87237,7 +87792,9 @@ var ts; return position === Position.Start ? start : fullStart; } // get start position of the line following the line that contains fullstart position - var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + // (but only if the fullstart isn't the very beginning of the file) + var nextLineStart = fullStart > 0 ? 1 : 0; + var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + nextLineStart, sourceFile); // skip whitespaces/newlines adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); @@ -87267,9 +87824,6 @@ var ts; } return s; } - function getNewlineKind(context) { - return context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */; - } var ChangeTracker = /** @class */ (function () { function ChangeTracker(newLine, rulesProvider, validator) { this.newLine = newLine; @@ -87278,8 +87832,8 @@ var ts; this.changes = []; this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); } - ChangeTracker.fromCodeFixContext = function (context) { - return new ChangeTracker(getNewlineKind(context), context.rulesProvider); + ChangeTracker.fromContext = function (context) { + return new ChangeTracker(context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */, context.rulesProvider); }; ChangeTracker.prototype.deleteRange = function (sourceFile, range) { this.changes.push({ kind: ChangeKind.Remove, sourceFile: sourceFile, range: range }); @@ -87305,7 +87859,7 @@ var ts; ts.Debug.fail("node is not a list element"); return this; } - var index = containingList.indexOf(node); + var index = ts.indexOfNode(containingList, node); if (index < 0) { return this; } @@ -87430,7 +87984,7 @@ var ts; ts.Debug.fail("node is not a list element"); return this; } - var index = containingList.indexOf(after); + var index = ts.indexOfNode(containingList, after); if (index < 0) { return this; } @@ -87646,10 +88200,9 @@ var ts; var options = { newLine: newLine, target: sourceFile && sourceFile.languageVersion }; var writer = new Writer(ts.getNewLineCharacter(options)); var printer = ts.createPrinter(options, writer); - printer.writeNode(3 /* Unspecified */, node, sourceFile, writer); + printer.writeNode(4 /* Unspecified */, node, sourceFile, writer); return { text: writer.getText(), node: assignPositionsToNode(node) }; } - textChanges.getNonformattedText = getNonformattedText; function applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, rulesProvider) { var lineMap = ts.computeLineStarts(nonFormattedText.text); var file = { @@ -87660,7 +88213,6 @@ var ts; var changes = ts.formatting.formatNodeGivenIndentation(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); return applyChanges(nonFormattedText.text, changes); } - textChanges.applyFormatting = applyFormatting; function applyChanges(text, changes) { for (var i = changes.length - 1; i >= 0; i--) { var change = changes[i]; @@ -87675,13 +88227,10 @@ var ts; function assignPositionsToNode(node) { var visited = ts.visitEachChild(node, assignPositionsToNode, ts.nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes - var newNode = ts.nodeIsSynthesized(visited) - ? visited - : (Proxy.prototype = visited, new Proxy()); + var newNode = ts.nodeIsSynthesized(visited) ? visited : Object.create(visited); newNode.pos = getPos(node); newNode.end = getEnd(node); return newNode; - function Proxy() { } } function assignPositionsToNodeArray(nodes, visitor, test, start, count) { var visited = ts.visitNodes(nodes, visitor, test, start, count); @@ -87817,7 +88366,15 @@ var ts; ts.forEach(fixes, function (f) { var actions = f.getCodeActions(context); if (actions && actions.length > 0) { - allActions = allActions.concat(actions); + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + if (action === undefined) { + context.host.log("Action for error code " + context.errorCode + " added an invalid action entry; please log a bug"); + } + else { + allActions.push(action); + } + } } }); return allActions; @@ -87849,6 +88406,10 @@ var ts; } refactor_1.getEditsForRefactor = getEditsForRefactor; })(refactor = ts.refactor || (ts.refactor = {})); + function getRefactorContextLength(context) { + return context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + } + ts.getRefactorContextLength = getRefactorContextLength; })(ts || (ts = {})); /* @internal */ var ts; @@ -87868,7 +88429,7 @@ var ts; var leftText = qualifiedName.left.getText(sourceFile); var rightText = qualifiedName.right.getText(sourceFile); var replacement = ts.createIndexedAccessTypeNode(ts.createTypeReferenceNode(qualifiedName.left, /*typeArguments*/ undefined), ts.createLiteralTypeNode(ts.createLiteral(rightText))); - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, qualifiedName, replacement); return [{ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Rewrite_as_the_indexed_access_type_0), [leftText + "[\"" + rightText + "\"]"]), @@ -88006,7 +88567,7 @@ var ts; } var className = classDeclaration.name.getText(); var staticInitialization = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createIdentifier(className), tokenName), ts.createIdentifier("undefined"))); - var staticInitializationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var staticInitializationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); staticInitializationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classDeclaration, staticInitialization, { suffix: context.newLineCharacter }); var initializeStaticAction = { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_static_property_0), [tokenName]), @@ -88021,7 +88582,7 @@ var ts; return actions; } var propertyInitialization = ts.createStatement(ts.createAssignment(ts.createPropertyAccess(ts.createThis(), tokenName), ts.createIdentifier("undefined"))); - var propertyInitializationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var propertyInitializationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); propertyInitializationChangeTracker.insertNodeAt(classDeclarationSourceFile, classConstructor.body.getEnd() - 1, propertyInitialization, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); var initializeAction = { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]), @@ -88051,7 +88612,7 @@ var ts; /*modifiers*/ makeStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined); - var propertyChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var propertyChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter }); (actions || (actions = [])).push({ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Declare_property_0), [tokenName]), @@ -88069,7 +88630,7 @@ var ts; var indexSignature = ts.createIndexSignature( /*decorators*/ undefined, /*modifiers*/ undefined, [indexingParameter], typeNode); - var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); indexSignatureChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, indexSignature, { suffix: context.newLineCharacter }); actions.push({ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_property_0), [tokenName]), @@ -88082,7 +88643,7 @@ var ts; if (token.parent.parent.kind === 181 /* CallExpression */) { var callExpression = token.parent.parent; var methodDeclaration = codefix.createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic); - var methodDeclarationChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var methodDeclarationChangeTracker = ts.textChanges.ChangeTracker.fromContext(context); methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); return { description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(makeStatic ? @@ -88225,7 +88786,7 @@ var ts; } } } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); changeTracker.deleteNode(sourceFile, superCall); return [{ @@ -88258,7 +88819,7 @@ var ts; if (token.kind !== 123 /* ConstructorKeyword */) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var superCall = ts.createStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ ts.emptyArray)); changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ @@ -88292,7 +88853,7 @@ var ts; if (!(extendsToken && extendsToken.kind === 85 /* ExtendsKeyword */)) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, extendsToken, ts.createToken(108 /* ImplementsKeyword */)); // We replace existing keywords with commas. for (var i = 1; i < heritageClauses.length; i++) { @@ -88323,7 +88884,7 @@ var ts; if (token.kind !== 71 /* Identifier */) { return undefined; } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); changeTracker.replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createThis(), token)); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), @@ -88340,8 +88901,8 @@ var ts; (function (codefix) { codefix.registerCodeFix({ errorCodes: [ - ts.Diagnostics._0_is_declared_but_never_used.code, - ts.Diagnostics.Property_0_is_declared_but_never_used.code + ts.Diagnostics._0_is_declared_but_its_value_is_never_read.code, + ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read.code ], getCodeActions: function (context) { var sourceFile = context.sourceFile; @@ -88491,19 +89052,19 @@ var ts; } } function deleteNode(n) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNode(sourceFile, n)); } function deleteRange(range) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteRange(sourceFile, range)); } function deleteNodeInList(n) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNodeInList(sourceFile, n)); } function deleteNodeRange(start, end) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).deleteNodeRange(sourceFile, start, end)); } function replaceNode(n, newNode) { - return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + return makeChange(ts.textChanges.ChangeTracker.fromContext(context).replaceNode(sourceFile, n, newNode)); } function makeChange(changeTracker) { return { @@ -88527,11 +89088,32 @@ var ts; function getActionsForJSDocTypes(context) { var sourceFile = context.sourceFile; var node = ts.getTokenAtPosition(sourceFile, context.span.start, /*includeJsDocComment*/ false); - var decl = ts.findAncestor(node, function (n) { return n.kind === 226 /* VariableDeclaration */; }); + // NOTE: Some locations are not handled yet: + // MappedTypeNode.typeParameters and SignatureDeclaration.typeParameters, as well as CallExpression.typeArguments + var decl = ts.findAncestor(node, function (n) { + return n.kind === 202 /* AsExpression */ || + n.kind === 155 /* CallSignature */ || + n.kind === 156 /* ConstructSignature */ || + n.kind === 228 /* FunctionDeclaration */ || + n.kind === 153 /* GetAccessor */ || + n.kind === 157 /* IndexSignature */ || + n.kind === 172 /* MappedType */ || + n.kind === 151 /* MethodDeclaration */ || + n.kind === 150 /* MethodSignature */ || + n.kind === 146 /* Parameter */ || + n.kind === 149 /* PropertyDeclaration */ || + n.kind === 148 /* PropertySignature */ || + n.kind === 154 /* SetAccessor */ || + n.kind === 231 /* TypeAliasDeclaration */ || + n.kind === 184 /* TypeAssertionExpression */ || + n.kind === 226 /* VariableDeclaration */; + }); if (!decl) return; var checker = context.program.getTypeChecker(); var jsdocType = decl.type; + if (!jsdocType) + return; var original = ts.getTextOfNode(jsdocType); var type = checker.getTypeFromTypeNode(jsdocType); var actions = [createAction(jsdocType, sourceFile.fileName, original, checker.typeToString(type, /*enclosingDeclaration*/ undefined, 8 /* NoTruncation */))]; @@ -88734,28 +89316,21 @@ var ts; if (cached) { return cached; } - var existingDeclarations = []; - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importModuleSpecifier = _a[_i]; - var importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); - if (importSymbol === moduleSymbol) { - existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); - } - } + var existingDeclarations = ts.mapDefined(sourceFile.imports, function (importModuleSpecifier) { + return checker.getSymbolAtLocation(importModuleSpecifier) === moduleSymbol ? getImportDeclaration(importModuleSpecifier) : undefined; + }); cachedImportDeclarations[moduleSymbolId] = existingDeclarations; return existingDeclarations; - function getImportDeclaration(moduleSpecifier) { - var node = moduleSpecifier; - while (node) { - if (node.kind === 238 /* ImportDeclaration */) { - return node; - } - if (node.kind === 237 /* ImportEqualsDeclaration */) { - return node; - } - node = node.parent; + function getImportDeclaration(_a) { + var parent = _a.parent; + switch (parent.kind) { + case 238 /* ImportDeclaration */: + return parent; + case 248 /* ExternalModuleReference */: + return parent.parent; + default: + return undefined; } - return undefined; } } function getUniqueSymbolId(symbol) { @@ -89164,7 +89739,7 @@ var ts; } } function createChangeTracker() { - return ts.textChanges.ChangeTracker.fromCodeFixContext(context); + return ts.textChanges.ChangeTracker.fromContext(context); } function createCodeAction(description, diagnosticArgs, changes, kind, moduleSpecifier) { return { @@ -89251,7 +89826,7 @@ var ts; (function (codefix) { function newNodesToChanges(newNodes, insertAfter, context) { var sourceFile = context.sourceFile; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) { var newNode = newNodes_1[_i]; changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); @@ -89538,7 +90113,7 @@ var ts; return undefined; } var ctorDeclaration = ctorSymbol.valueDeclaration; - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); var precedingNode; var newClassDeclaration; switch (ctorDeclaration.kind) { @@ -89568,7 +90143,9 @@ var ts; deleteCallback(); } return { - edits: changeTracker.getChanges() + edits: changeTracker.getChanges(), + renameFilename: undefined, + renameLocation: undefined, }; function deleteNode(node, inList) { if (inList === void 0) { inList = false; } @@ -89730,7 +90307,7 @@ var ts; refactor.registerRefactor(extractMethod); /** Compute the associated code actions */ function getAvailableActions(context) { - var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: ts.getRefactorContextLength(context) }); var targetRange = rangeToExtract.targetRange; if (targetRange === undefined) { return undefined; @@ -89744,15 +90321,15 @@ var ts; var usedNames = ts.createMap(); var i = 0; for (var _i = 0, extractions_1 = extractions; _i < extractions_1.length; _i++) { - var extr = extractions_1[_i]; + var _a = extractions_1[_i], scopeDescription = _a.scopeDescription, errors = _a.errors; // Skip these since we don't have a way to report errors yet - if (extr.errors && extr.errors.length) { + if (errors.length) { continue; } // Don't issue refactorings with duplicated names. // Scopes come back in "innermost first" order, so extractions will // preferentially go into nearer scopes - var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_function_into_0.message, [extr.scopeDescription]); + var description = ts.formatStringFromArgs(ts.Diagnostics.Extract_to_0.message, [scopeDescription]); if (!usedNames.has(description)) { usedNames.set(description, true); actions.push({ @@ -89775,17 +90352,13 @@ var ts; }]; } function getEditsForAction(context, actionName) { - var length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; - var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: length }); + var rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: ts.getRefactorContextLength(context) }); var targetRange = rangeToExtract.targetRange; var parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); ts.Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); var index = +parsedIndexMatch[1]; ts.Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); - var extractions = getPossibleExtractions(targetRange, context, index); - // Scope is no longer valid from when the user issued the refactor (??) - ts.Debug.assert(extractions !== undefined, "The extraction went missing? How?"); - return ({ edits: extractions[0].changes }); + return getExtractionAtIndex(targetRange, context, index); } // Move these into diagnostic messages if they become user-facing var Messages; @@ -89818,15 +90391,19 @@ var ts; * The range is in a function which needs the 'static' modifier in a class */ RangeFacts[RangeFacts["InStaticRegion"] = 16] = "InStaticRegion"; - })(RangeFacts = extractMethod_1.RangeFacts || (extractMethod_1.RangeFacts = {})); + })(RangeFacts || (RangeFacts = {})); /** * getRangeToExtract takes a span inside a text file and returns either an expression or an array * of statements representing the minimum set of nodes needed to extract the entire span. This * process may fail, in which case a set of errors is returned instead (these are currently * not shown to the user, but can be used by us diagnostically) */ + // exported only for tests function getRangeToExtract(sourceFile, span) { - var length = span.length || 0; + var length = span.length; + if (length === 0) { + return { errors: [ts.createFileDiagnostic(sourceFile, span.start, length, Messages.StatementOrExpressionExpected)] }; + } // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) var start = getParentNodeInSpan(ts.getTokenAtPosition(sourceFile, span.start, /*includeJsDocComment*/ false), sourceFile, span); @@ -89893,22 +90470,13 @@ var ts; if (errors) { return { errors: errors }; } - // If our selection is the expression in an ExpressionStatement, expand - // the selection to include the enclosing Statement (this stops us - // from trying to care about the return value of the extracted function - // and eliminates double semicolon insertion in certain scenarios) - var range = ts.isStatement(start) - ? [start] - : start.parent && start.parent.kind === 210 /* ExpressionStatement */ - ? [start.parent] - : start; - return { targetRange: { range: range, facts: rangeFacts, declarations: declarations } }; + return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations: declarations } }; } function createErrorResult(sourceFile, start, length, message) { return { errors: [ts.createFileDiagnostic(sourceFile, start, length, message)] }; } function checkRootNode(node) { - if (ts.isIdentifier(node)) { + if (ts.isIdentifier(ts.isExpressionStatement(node) ? node.expression : node)) { return [ts.createDiagnosticForNode(node, Messages.InsufficientSelection)]; } return undefined; @@ -89946,7 +90514,7 @@ var ts; PermittedJumps[PermittedJumps["Continue"] = 2] = "Continue"; PermittedJumps[PermittedJumps["Return"] = 4] = "Return"; })(PermittedJumps || (PermittedJumps = {})); - if (!ts.isStatement(nodeToCheck) && !(ts.isExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { + if (!ts.isStatement(nodeToCheck) && !(ts.isPartOfExpression(nodeToCheck) && isExtractableExpression(nodeToCheck))) { return [ts.createDiagnosticForNode(nodeToCheck, Messages.StatementOrExpressionExpected)]; } if (ts.isInAmbientContext(nodeToCheck)) { @@ -90010,45 +90578,30 @@ var ts; return false; } var savedPermittedJumps = permittedJumps; - if (node.parent) { - switch (node.parent.kind) { - case 211 /* IfStatement */: - if (node.parent.thenStatement === node || node.parent.elseStatement === node) { - // forbid all jumps inside thenStatement or elseStatement - permittedJumps = 0 /* None */; - } - break; - case 224 /* TryStatement */: - if (node.parent.tryBlock === node) { - // forbid all jumps inside try blocks - permittedJumps = 0 /* None */; - } - else if (node.parent.finallyBlock === node) { - // allow unconditional returns from finally blocks - permittedJumps = 4 /* Return */; - } - break; - case 260 /* CatchClause */: - if (node.parent.block === node) { - // forbid all jumps inside the block of catch clause - permittedJumps = 0 /* None */; - } - break; - case 257 /* CaseClause */: - if (node.expression !== node) { - // allow unlabeled break inside case clauses - permittedJumps |= 1 /* Break */; - } - break; - default: - if (ts.isIterationStatement(node.parent, /*lookInLabeledStatements*/ false)) { - if (node.parent.statement === node) { - // allow unlabeled break/continue inside loops - permittedJumps |= 1 /* Break */ | 2 /* Continue */; - } - } - break; - } + switch (node.kind) { + case 211 /* IfStatement */: + permittedJumps = 0 /* None */; + break; + case 224 /* TryStatement */: + // forbid all jumps inside try blocks + permittedJumps = 0 /* None */; + break; + case 207 /* Block */: + if (node.parent && node.parent.kind === 224 /* TryStatement */ && node.finallyBlock === node) { + // allow unconditional returns from finally blocks + permittedJumps = 4 /* Return */; + } + break; + case 257 /* CaseClause */: + // allow unlabeled break inside case clauses + permittedJumps |= 1 /* Break */; + break; + default: + if (ts.isIterationStatement(node, /*lookInLabeledStatements*/ false)) { + // allow unlabeled break/continue inside loops + permittedJumps |= 1 /* Break */ | 2 /* Continue */; + } + break; } switch (node.kind) { case 169 /* ThisType */: @@ -90074,7 +90627,7 @@ var ts; } } else { - if (!(permittedJumps & (218 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { + if (!(permittedJumps & (node.kind === 218 /* BreakStatement */ ? 1 /* Break */ : 2 /* Continue */))) { // attempt to break or continue in a forbidden context (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements)); } @@ -90104,6 +90657,19 @@ var ts; } } extractMethod_1.getRangeToExtract = getRangeToExtract; + function getStatementOrExpressionRange(node) { + if (ts.isStatement(node)) { + return [node]; + } + else if (ts.isPartOfExpression(node)) { + // If our selection is the expression in an ExpressionStatement, expand + // the selection to include the enclosing Statement (this stops us + // from trying to care about the return value of the extracted function + // and eliminates double semicolon insertion in certain scenarios) + return ts.isExpressionStatement(node.parent) ? [node.parent] : node; + } + return undefined; + } function isValidExtractionTarget(node) { // Note that we don't use isFunctionLike because we don't want to put the extracted closure *inside* a method return (node.kind === 228 /* FunctionDeclaration */) || ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isClassLike(node); @@ -90144,14 +90710,29 @@ var ts; } return scopes; } - extractMethod_1.collectEnclosingScopes = collectEnclosingScopes; + // exported only for tests + function getExtractionAtIndex(targetRange, context, requestedChangesIndex) { + var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, _b = _a.readsAndWrites, target = _b.target, usagesPerScope = _b.usagesPerScope, errorsPerScope = _b.errorsPerScope; + ts.Debug.assert(!errorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); + context.cancellationToken.throwIfCancellationRequested(); + return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context); + } + extractMethod_1.getExtractionAtIndex = getExtractionAtIndex; /** * Given a piece of text to extract ('targetRange'), computes a list of possible extractions. * Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes * or an error explaining why we can't extract into that scope. */ - function getPossibleExtractions(targetRange, context, requestedChangesIndex) { - if (requestedChangesIndex === void 0) { requestedChangesIndex = undefined; } + // exported only for tests + function getPossibleExtractions(targetRange, context) { + var _a = getPossibleExtractionsWorker(targetRange, context), scopes = _a.scopes, errorsPerScope = _a.readsAndWrites.errorsPerScope; + // Need the inner type annotation to avoid https://github.com/Microsoft/TypeScript/issues/7547 + return scopes.map(function (scope, i) { + return ({ scopeDescription: getDescriptionForScope(scope), errors: errorsPerScope[i] }); + }); + } + extractMethod_1.getPossibleExtractions = getPossibleExtractions; + function getPossibleExtractionsWorker(targetRange, context) { var sourceFile = context.file; if (targetRange === undefined) { return undefined; @@ -90161,87 +90742,67 @@ var ts; return undefined; } var enclosingTextRange = getEnclosingTextRange(targetRange, sourceFile); - var _a = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker()), target = _a.target, usagesPerScope = _a.usagesPerScope, errorsPerScope = _a.errorsPerScope; - context.cancellationToken.throwIfCancellationRequested(); - if (requestedChangesIndex !== undefined) { - if (errorsPerScope[requestedChangesIndex].length) { - return undefined; - } - return [extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context)]; - } - else { - return scopes.map(function (scope, i) { - var errors = errorsPerScope[i]; - if (errors.length) { - return { - scope: scope, - scopeDescription: getDescriptionForScope(scope), - errors: errors - }; - } - return { scope: scope, scopeDescription: getDescriptionForScope(scope) }; - }); - } + var readsAndWrites = collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, context.program.getTypeChecker(), context.cancellationToken); + return { scopes: scopes, readsAndWrites: readsAndWrites }; } - extractMethod_1.getPossibleExtractions = getPossibleExtractions; function getDescriptionForScope(scope) { - if (ts.isFunctionLike(scope)) { - switch (scope.kind) { - case 152 /* Constructor */: - return "constructor"; - case 186 /* FunctionExpression */: - return scope.name - ? "function expression " + scope.name.getText() - : "anonymous function expression"; - case 228 /* FunctionDeclaration */: - return "function " + scope.name.getText(); - case 187 /* ArrowFunction */: - return "arrow function"; - case 151 /* MethodDeclaration */: - return "method " + scope.name.getText(); - case 153 /* GetAccessor */: - return "get " + scope.name.getText(); - case 154 /* SetAccessor */: - return "set " + scope.name.getText(); - } - } - else if (ts.isModuleBlock(scope)) { - return "namespace " + scope.parent.name.getText(); - } - else if (ts.isClassLike(scope)) { - return scope.kind === 229 /* ClassDeclaration */ - ? "class " + scope.name.text - : scope.name.text - ? "class expression " + scope.name.text - : "anonymous class expression"; - } - else if (ts.isSourceFile(scope)) { - return "file '" + scope.fileName + "'"; - } - else { - return "unknown"; + return ts.isFunctionLikeDeclaration(scope) + ? "inner function in " + getDescriptionForFunctionLikeDeclaration(scope) + : ts.isClassLike(scope) + ? "method in " + getDescriptionForClassLikeDeclaration(scope) + : "function in " + getDescriptionForModuleLikeDeclaration(scope); + } + function getDescriptionForFunctionLikeDeclaration(scope) { + switch (scope.kind) { + case 152 /* Constructor */: + return "constructor"; + case 186 /* FunctionExpression */: + return scope.name + ? "function expression '" + scope.name.text + "'" + : "anonymous function expression"; + case 228 /* FunctionDeclaration */: + return "function '" + scope.name.text + "'"; + case 187 /* ArrowFunction */: + return "arrow function"; + case 151 /* MethodDeclaration */: + return "method '" + scope.name.getText(); + case 153 /* GetAccessor */: + return "'get " + scope.name.getText() + "'"; + case 154 /* SetAccessor */: + return "'set " + scope.name.getText() + "'"; + default: + ts.Debug.assertNever(scope); } } - function getUniqueName(isNameOkay) { + function getDescriptionForClassLikeDeclaration(scope) { + return scope.kind === 229 /* ClassDeclaration */ + ? "class '" + scope.name.text + "'" + : scope.name ? "class expression '" + scope.name.text + "'" : "anonymous class expression"; + } + function getDescriptionForModuleLikeDeclaration(scope) { + return scope.kind === 234 /* ModuleBlock */ + ? "namespace '" + scope.parent.name.getText() + "'" + : scope.externalModuleIndicator ? "module scope" : "global scope"; + } + function getUniqueName(fileText) { var functionNameText = "newFunction"; - if (isNameOkay(functionNameText)) { - return functionNameText; - } - var i = 1; - while (!isNameOkay(functionNameText = "newFunction_" + i)) { - i++; + for (var i = 1; fileText.indexOf(functionNameText) !== -1; i++) { + functionNameText = "newFunction_" + i; } return functionNameText; } + /** + * Result of 'extractRange' operation for a specific scope. + * Stores either a list of changes that should be applied to extract a range or a list of errors + */ function extractFunctionInScope(node, scope, _a, range, context) { - var usagesInScope = _a.usages, substitutions = _a.substitutions; + var usagesInScope = _a.usages, typeParameterUsages = _a.typeParameterUsages, substitutions = _a.substitutions; var checker = context.program.getTypeChecker(); // Make a unique name for the extracted function var file = scope.getSourceFile(); - var functionNameText = getUniqueName(function (n) { return !file.identifiers.has(n); }); + var functionNameText = getUniqueName(file.text); var isJS = ts.isInJavaScriptFile(scope); var functionName = ts.createIdentifier(functionNameText); - var functionReference = ts.createIdentifier(functionNameText); var returnType = undefined; var parameters = []; var callArguments = []; @@ -90266,13 +90827,23 @@ var ts; } callArguments.push(ts.createIdentifier(name)); }); - // Provide explicit return types for contexutally-typed functions + var typeParametersAndDeclarations = ts.arrayFrom(typeParameterUsages.values()).map(function (type) { return ({ type: type, declaration: getFirstDeclaration(type) }); }); + var sortedTypeParametersAndDeclarations = typeParametersAndDeclarations.sort(compareTypesByDeclarationOrder); + var typeParameters = sortedTypeParametersAndDeclarations.length === 0 + ? undefined + : sortedTypeParametersAndDeclarations.map(function (t) { return t.declaration; }); + // Strictly speaking, we should check whether each name actually binds to the appropriate type + // parameter. In cases of shadowing, they may not. + var callTypeArguments = typeParameters !== undefined + ? typeParameters.map(function (decl) { return ts.createTypeReferenceNode(decl.name, /*typeArguments*/ undefined); }) + : undefined; + // Provide explicit return types for contextually-typed functions // to avoid problems when there are literal types present if (ts.isExpression(node) && !isJS) { var contextualType = checker.getContextualType(node); returnType = checker.typeToTypeNode(contextualType); } - var _b = transformFunctionBody(node), body = _b.body, returnValueProperty = _b.returnValueProperty; + var _b = transformFunctionBody(node, writes, substitutions, !!(range.facts & RangeFacts.HasReturn)), body = _b.body, returnValueProperty = _b.returnValueProperty; var newFunction; if (ts.isClassLike(scope)) { // always create private method in TypeScript files @@ -90284,22 +90855,27 @@ var ts; modifiers.push(ts.createToken(120 /* AsyncKeyword */)); } newFunction = ts.createMethod( - /*decorators*/ undefined, modifiers, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, - /*questionToken*/ undefined, - /*typeParameters*/ [], parameters, returnType, body); + /*decorators*/ undefined, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, + /*questionToken*/ undefined, typeParameters, parameters, returnType, body); } else { newFunction = ts.createFunctionDeclaration( - /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, - /*typeParameters*/ [], parameters, returnType, body); + /*decorators*/ undefined, range.facts & RangeFacts.IsAsyncFunction ? [ts.createToken(120 /* AsyncKeyword */)] : undefined, range.facts & RangeFacts.IsGenerator ? ts.createToken(39 /* AsteriskToken */) : undefined, functionName, typeParameters, parameters, returnType, body); + } + var changeTracker = ts.textChanges.ChangeTracker.fromContext(context); + var minInsertionPos = (isReadonlyArray(range.range) ? ts.lastOrUndefined(range.range) : range.range).end; + var nodeToInsertBefore = getNodeToInsertBefore(minInsertionPos, scope); + if (nodeToInsertBefore) { + changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); } - var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); - // insert function at the end of the scope - changeTracker.insertNodeBefore(context.file, scope.getLastToken(), newFunction, { prefix: context.newLineCharacter, suffix: context.newLineCharacter }); var newNodes = []; // replace range with function call - var call = ts.createCall(ts.isClassLike(scope) ? ts.createPropertyAccess(range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.getText()) : ts.createThis(), functionReference) : functionReference, - /*typeArguments*/ undefined, callArguments); + var called = getCalledExpression(scope, range, functionNameText); + var call = ts.createCall(called, callTypeArguments, // Note that no attempt is made to take advantage of type argument inference + callArguments); if (range.facts & RangeFacts.IsGenerator) { call = ts.createYield(ts.createToken(39 /* AsteriskToken */), call); } @@ -90323,6 +90899,9 @@ var ts; } else { newNodes.push(ts.createStatement(ts.createBinary(assignments[0].name, 58 /* EqualsToken */, call))); + if (range.facts & RangeFacts.HasReturn) { + newNodes.push(ts.createReturn()); + } } } else { @@ -90355,67 +90934,164 @@ var ts; else { changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter }); } - return { - scope: scope, - scopeDescription: getDescriptionForScope(scope), - changes: changeTracker.getChanges() - }; - function getPropertyAssignmentsForWrites(writes) { - return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + var edits = changeTracker.getChanges(); + var renameRange = isReadonlyArray(range.range) ? range.range[0] : range.range; + var renameFilename = renameRange.getSourceFile().fileName; + var renameLocation = getRenameLocation(edits, renameFilename, functionNameText); + return { renameFilename: renameFilename, renameLocation: renameLocation, edits: edits }; + } + function getRenameLocation(edits, renameFilename, functionNameText) { + var delta = 0; + for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) { + var _a = edits_1[_i], fileName = _a.fileName, textChanges_1 = _a.textChanges; + ts.Debug.assert(fileName === renameFilename); + for (var _b = 0, textChanges_2 = textChanges_1; _b < textChanges_2.length; _b++) { + var change = textChanges_2[_b]; + var span_17 = change.span, newText = change.newText; + // TODO(acasey): We are assuming that the call expression comes before the function declaration, + // because we want the new cursor to be on the call expression, + // which is closer to where the user was before extracting the function. + var index = newText.indexOf(functionNameText); + if (index !== -1) { + return span_17.start + delta + index; + } + delta += newText.length - span_17.length; + } } - function generateReturnValueProperty() { - return "__return"; + throw new Error(); // Didn't find the text we inserted? + } + function getFirstDeclaration(type) { + var firstDeclaration = undefined; + var symbol = type.symbol; + if (symbol && symbol.declarations) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (firstDeclaration === undefined || declaration.pos < firstDeclaration.pos) { + firstDeclaration = declaration; + } + } } - function transformFunctionBody(body) { - if (ts.isBlock(body) && !writes && substitutions.size === 0) { - // already block, no writes to propagate back, no substitutions - can use node as is - return { body: ts.createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; - } - var returnValueProperty; - var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); - // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions - if (writes || substitutions.size) { - var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); - if (writes && !(range.facts & RangeFacts.HasReturn) && ts.isStatement(body)) { - // add return at the end to propagate writes back in case if control flow falls out of the function body - // it is ok to know that range has at least one return since it we only allow unconditional returns - var assignments = getPropertyAssignmentsForWrites(writes); - if (assignments.length === 1) { - rewrittenStatements.push(ts.createReturn(assignments[0].name)); - } - else { - rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); - } + return firstDeclaration; + } + function compareTypesByDeclarationOrder(_a, _b) { + var type1 = _a.type, declaration1 = _a.declaration; + var type2 = _b.type, declaration2 = _b.declaration; + if (declaration1) { + if (declaration2) { + var positionDiff = declaration1.pos - declaration2.pos; + if (positionDiff !== 0) { + return positionDiff; } - return { body: ts.createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty: returnValueProperty }; } else { - return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; + return 1; // Sort undeclared type parameters to the front. } - function visitor(node) { - if (node.kind === 219 /* ReturnStatement */ && writes) { - var assignments = getPropertyAssignmentsForWrites(writes); - if (node.expression) { - if (!returnValueProperty) { - returnValueProperty = generateReturnValueProperty(); - } - assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); - } - if (assignments.length === 1) { - return ts.createReturn(assignments[0].name); - } - else { - return ts.createReturn(ts.createObjectLiteral(assignments)); - } + } + else if (declaration2) { + return -1; // Sort undeclared type parameters to the front. + } + var name1 = type1.symbol ? type1.symbol.getName() : ""; + var name2 = type2.symbol ? type2.symbol.getName() : ""; + var nameDiff = ts.compareStrings(name1, name2); + if (nameDiff !== 0) { + return nameDiff; + } + // IDs are guaranteed to be unique, so this ensures a total ordering. + return type1.id - type2.id; + } + function getCalledExpression(scope, range, functionNameText) { + var functionReference = ts.createIdentifier(functionNameText); + if (ts.isClassLike(scope)) { + var lhs = range.facts & RangeFacts.InStaticRegion ? ts.createIdentifier(scope.name.text) : ts.createThis(); + return ts.createPropertyAccess(lhs, functionReference); + } + else { + return functionReference; + } + } + function transformFunctionBody(body, writes, substitutions, hasReturn) { + if (ts.isBlock(body) && !writes && substitutions.size === 0) { + // already block, no writes to propagate back, no substitutions - can use node as is + return { body: ts.createBlock(body.statements, /*multLine*/ true), returnValueProperty: undefined }; + } + var returnValueProperty; + var ignoreReturns = false; + var statements = ts.createNodeArray(ts.isBlock(body) ? body.statements.slice(0) : [ts.isStatement(body) ? body : ts.createReturn(body)]); + // rewrite body if either there are writes that should be propagated back via return statements or there are substitutions + if (writes || substitutions.size) { + var rewrittenStatements = ts.visitNodes(statements, visitor).slice(); + if (writes && !hasReturn && ts.isStatement(body)) { + // add return at the end to propagate writes back in case if control flow falls out of the function body + // it is ok to know that range has at least one return since it we only allow unconditional returns + var assignments = getPropertyAssignmentsForWrites(writes); + if (assignments.length === 1) { + rewrittenStatements.push(ts.createReturn(assignments[0].name)); } else { - var substitution = substitutions.get(ts.getNodeId(node).toString()); - return substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + rewrittenStatements.push(ts.createReturn(ts.createObjectLiteral(assignments))); } } + return { body: ts.createBlock(rewrittenStatements, /*multiLine*/ true), returnValueProperty: returnValueProperty }; + } + else { + return { body: ts.createBlock(statements, /*multiLine*/ true), returnValueProperty: undefined }; + } + function visitor(node) { + if (!ignoreReturns && node.kind === 219 /* ReturnStatement */ && writes) { + var assignments = getPropertyAssignmentsForWrites(writes); + if (node.expression) { + if (!returnValueProperty) { + returnValueProperty = "__return"; + } + assignments.unshift(ts.createPropertyAssignment(returnValueProperty, ts.visitNode(node.expression, visitor))); + } + if (assignments.length === 1) { + return ts.createReturn(assignments[0].name); + } + else { + return ts.createReturn(ts.createObjectLiteral(assignments)); + } + } + else { + var oldIgnoreReturns = ignoreReturns; + ignoreReturns = ignoreReturns || ts.isFunctionLike(node) || ts.isClassLike(node); + var substitution = substitutions.get(ts.getNodeId(node).toString()); + var result = substitution || ts.visitEachChild(node, visitor, ts.nullTransformationContext); + ignoreReturns = oldIgnoreReturns; + return result; + } } } - extractMethod_1.extractFunctionInScope = extractFunctionInScope; + function getStatementsOrClassElements(scope) { + if (ts.isFunctionLike(scope)) { + var body = scope.body; + if (ts.isBlock(body)) { + return body.statements; + } + } + else if (ts.isModuleBlock(scope) || ts.isSourceFile(scope)) { + return scope.statements; + } + else if (ts.isClassLike(scope)) { + return scope.members; + } + else { + ts.assertTypeIsNever(scope); + } + return ts.emptyArray; + } + /** + * If `scope` contains a function after `minPos`, then return the first such function. + * Otherwise, return `undefined`. + */ + function getNodeToInsertBefore(minPos, scope) { + return ts.find(getStatementsOrClassElements(scope), function (child) { + return child.pos >= minPos && ts.isFunctionLike(child) && !ts.isConstructorDeclaration(child); + }); + } + function getPropertyAssignmentsForWrites(writes) { + return writes.map(function (w) { return ts.createShorthandPropertyAssignment(w.symbol.name); }); + } function isReadonlyArray(v) { return ts.isArray(v); } @@ -90440,7 +91116,8 @@ var ts; // value should be passed to extracted method and propagated back Usage[Usage["Write"] = 2] = "Write"; })(Usage || (Usage = {})); - function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker) { + function collectReadsAndWrites(targetRange, scopes, enclosingTextRange, sourceFile, checker, cancellationToken) { + var allTypeParameterUsages = ts.createMap(); // Key is type ID var usagesPerScope = []; var substitutionsPerScope = []; var errorsPerScope = []; @@ -90448,14 +91125,50 @@ var ts; // initialize results for (var _i = 0, scopes_1 = scopes; _i < scopes_1.length; _i++) { var _ = scopes_1[_i]; - usagesPerScope.push({ usages: ts.createMap(), substitutions: ts.createMap() }); + usagesPerScope.push({ usages: ts.createMap(), typeParameterUsages: ts.createMap(), substitutions: ts.createMap() }); substitutionsPerScope.push(ts.createMap()); errorsPerScope.push([]); } var seenUsages = ts.createMap(); var target = isReadonlyArray(targetRange.range) ? ts.createBlock(targetRange.range) : targetRange.range; var containingLexicalScopeOfExtraction = ts.isBlockScope(scopes[0], scopes[0].parent) ? scopes[0] : ts.getEnclosingBlockScopeContainer(scopes[0]); + var unmodifiedNode = isReadonlyArray(targetRange.range) ? targetRange.range[0] : targetRange.range; + var inGenericContext = isInGenericContext(unmodifiedNode); collectUsages(target); + // Unfortunately, this code takes advantage of the knowledge that the generated method + // will use the contextual type of an expression as the return type of the extracted + // method (and will therefore "use" all the types involved). + if (inGenericContext && !isReadonlyArray(targetRange.range)) { + var contextualType = checker.getContextualType(targetRange.range); + recordTypeParameterUsages(contextualType); + } + if (allTypeParameterUsages.size > 0) { + var seenTypeParameterUsages = ts.createMap(); // Key is type ID + var i_1 = 0; + for (var curr = unmodifiedNode; curr !== undefined && i_1 < scopes.length; curr = curr.parent) { + if (curr === scopes[i_1]) { + // Copy current contents of seenTypeParameterUsages into scope. + seenTypeParameterUsages.forEach(function (typeParameter, id) { + usagesPerScope[i_1].typeParameterUsages.set(id, typeParameter); + }); + i_1++; + } + // Note that we add the current node's type parameters *after* updating the corresponding scope. + if (ts.isDeclarationWithTypeParameters(curr) && curr.typeParameters) { + for (var _a = 0, _b = curr.typeParameters; _a < _b.length; _a++) { + var typeParameterDecl = _b[_a]; + var typeParameter = checker.getTypeAtLocation(typeParameterDecl); + if (allTypeParameterUsages.has(typeParameter.id.toString())) { + seenTypeParameterUsages.set(typeParameter.id.toString(), typeParameter); + } + } + } + } + // If we didn't get through all the scopes, then there were some that weren't in our + // parent chain (impossible at time of writing). A conservative solution would be to + // copy allTypeParameterUsages into all remaining scopes. + ts.Debug.assert(i_1 === scopes.length); + } var _loop_8 = function (i) { var hasWrite = false; var readonlyClassPropertyWrite = undefined; @@ -90473,7 +91186,7 @@ var ts; errorsPerScope[i].push(ts.createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); } else if (readonlyClassPropertyWrite && i > 0) { - errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotCombineWritesAndReturns)); + errorsPerScope[i].push(ts.createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor)); } }; for (var i = 0; i < scopes.length; i++) { @@ -90485,8 +91198,38 @@ var ts; ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } return { target: target, usagesPerScope: usagesPerScope, errorsPerScope: errorsPerScope }; + function hasTypeParameters(node) { + return ts.isDeclarationWithTypeParameters(node) && + node.typeParameters !== undefined && + node.typeParameters.length > 0; + } + function isInGenericContext(node) { + for (; node; node = node.parent) { + if (hasTypeParameters(node)) { + return true; + } + } + return false; + } + function recordTypeParameterUsages(type) { + // PERF: This is potentially very expensive. `type` could be a library type with + // a lot of properties, each of which the walker will visit. Unfortunately, the + // solution isn't as trivial as filtering to user types because of (e.g.) Array. + var symbolWalker = checker.getSymbolWalker(function () { return (cancellationToken.throwIfCancellationRequested(), true); }); + var visitedTypes = symbolWalker.walkType(type).visitedTypes; + for (var _i = 0, visitedTypes_1 = visitedTypes; _i < visitedTypes_1.length; _i++) { + var visitedType = visitedTypes_1[_i]; + if (visitedType.flags & 16384 /* TypeParameter */) { + allTypeParameterUsages.set(visitedType.id.toString(), visitedType); + } + } + } function collectUsages(node, valueUsage) { if (valueUsage === void 0) { valueUsage = 1 /* Read */; } + if (inGenericContext) { + var type = checker.getTypeAtLocation(node); + recordTypeParameterUsages(type); + } if (ts.isDeclaration(node) && node.symbol) { visibleDeclarationsInExtractedRange.push(node.symbol); } @@ -90531,7 +91274,11 @@ var ts; } } function recordUsagebySymbol(identifier, usage, isTypeName) { - var symbol = checker.getSymbolAtLocation(identifier); + // If the identifier is both a property name and its value, we're only interested in its value + // (since the name is a declaration and will be included in the extracted range). + var symbol = identifier.parent && ts.isShorthandPropertyAssignment(identifier.parent) && identifier.parent.name === identifier + ? checker.getShorthandAssignmentValueSymbol(identifier.parent) + : checker.getSymbolAtLocation(identifier); if (!symbol) { // cannot find symbol - do nothing return undefined; @@ -90565,7 +91312,7 @@ var ts; if (!declInFile) { return undefined; } - if (ts.rangeContainsRange(enclosingTextRange, declInFile)) { + if (ts.rangeContainsStartEnd(enclosingTextRange, declInFile.getStart(), declInFile.end)) { // declaration is located in range to be extracted - do nothing return undefined; } @@ -90589,7 +91336,11 @@ var ts; substitutionsPerScope[i].set(symbolId, substitution); } else if (isTypeName) { - errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument + // so there's no problem. + if (!(symbol.flags & 262144 /* TypeParameter */)) { + errorsPerScope[i].push(ts.createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + } } else { usagesPerScope[i].usages.set(identifier.text, { usage: usage, symbol: symbol, node: identifier }); @@ -91237,6 +91988,11 @@ var ts; } } break; + case 194 /* BinaryExpression */: + if (ts.getSpecialPropertyAssignmentKind(node) !== 0 /* None */) { + addDeclaration(node); + } + // falls through default: ts.forEachChild(node, visit); } @@ -91582,7 +92338,7 @@ var ts; oldSettings.noResolve !== newSettings.noResolve || oldSettings.jsx !== newSettings.jsx || oldSettings.allowJs !== newSettings.allowJs || - oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || + oldSettings.disableSizeLimit !== newSettings.disableSizeLimit || oldSettings.baseUrl !== newSettings.baseUrl || !ts.equalOwnProperties(oldSettings.paths, newSettings.paths)); // Now create a new compiler @@ -91760,7 +92516,7 @@ var ts; /// Diagnostics function getSyntacticDiagnostics(fileName) { synchronizeHostData(); - return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken); + return program.getSyntacticDiagnostics(getValidSourceFile(fileName), cancellationToken).slice(); } /** * getSemanticDiagnostics return array of Diagnostics. If '-d' is not enabled, only report semantic errors @@ -91773,11 +92529,11 @@ var ts; // Therefore only get diagnostics for given file. var semanticDiagnostics = program.getSemanticDiagnostics(targetSourceFile, cancellationToken); if (!program.getCompilerOptions().declaration) { - return semanticDiagnostics; + return semanticDiagnostics.slice(); } // If '-d' is enabled, check for emitter error. One example of emitter error is export class implements non-export interface var declarationDiagnostics = program.getDeclarationDiagnostics(targetSourceFile, cancellationToken); - return ts.concatenate(semanticDiagnostics, declarationDiagnostics); + return semanticDiagnostics.concat(declarationDiagnostics); } function getCompilerOptionsDiagnostics() { synchronizeHostData(); @@ -91806,7 +92562,7 @@ var ts; return undefined; } var typeChecker = program.getTypeChecker(); - var symbol = typeChecker.getSymbolAtLocation(node); + var symbol = getSymbolAtLocationForQuickInfo(node, typeChecker); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { @@ -91841,6 +92597,20 @@ var ts; tags: displayPartsDocumentationsAndKind.tags }; } + function getSymbolAtLocationForQuickInfo(node, checker) { + if ((ts.isIdentifier(node) || ts.isStringLiteral(node)) + && ts.isPropertyAssignment(node.parent) + && node.parent.name === node) { + var type = checker.getContextualType(node.parent.parent); + if (type) { + var property = checker.getPropertyOfType(type, ts.getTextOfIdentifierOrLiteral(node)); + if (property) { + return property; + } + } + } + return checker.getSymbolAtLocation(node); + } /// Goto definition function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); @@ -91903,7 +92673,20 @@ var ts; } function getReferences(fileName, position, options) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); + // Exclude default library when renaming as commonly user don't want to change that file. + var sourceFiles = []; + if (options && options.isForRename) { + for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) { + var sourceFile = _a[_i]; + if (!program.isSourceFileDefaultLibrary(sourceFile)) { + sourceFiles.push(sourceFile); + } + } + } + else { + sourceFiles = program.getSourceFiles().slice(); + } + return ts.FindAllReferences.findReferencedEntries(program, cancellationToken, sourceFiles, getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { synchronizeHostData(); @@ -92304,7 +93087,7 @@ var ts; startPosition: startPosition, endPosition: endPosition, program: getProgram(), - newLineCharacter: host.getNewLine(), + newLineCharacter: formatOptions ? formatOptions.newLineCharacter : host.getNewLine(), rulesProvider: getRuleProvider(formatOptions), cancellationToken: cancellationToken }; @@ -92385,7 +93168,7 @@ var ts; nameTable.set(text, nameTable.get(text) === undefined ? node.pos : -1); } ts.forEachChild(node, walk); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; ts.forEachChild(jsDoc, walk); diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 5f69ba3ddcd..af4a4c801b2 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -705,6 +705,7 @@ var ts; TypeFlags[TypeFlags["JsxAttributes"] = 33554432] = "JsxAttributes"; TypeFlags[TypeFlags["Nullable"] = 6144] = "Nullable"; TypeFlags[TypeFlags["Literal"] = 224] = "Literal"; + TypeFlags[TypeFlags["Unit"] = 6368] = "Unit"; TypeFlags[TypeFlags["StringOrNumberLiteral"] = 96] = "StringOrNumberLiteral"; TypeFlags[TypeFlags["DefinitelyFalsy"] = 7392] = "DefinitelyFalsy"; TypeFlags[TypeFlags["PossiblyFalsy"] = 7406] = "PossiblyFalsy"; @@ -1065,6 +1066,7 @@ var ts; EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; EmitFlags[EmitFlags["NoAsciiEscaping"] = 16777216] = "NoAsciiEscaping"; + EmitFlags[EmitFlags["TypeScriptClassWrapper"] = 33554432] = "TypeScriptClassWrapper"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); var ExternalEmitHelpers; (function (ExternalEmitHelpers) { @@ -1097,7 +1099,8 @@ var ts; EmitHint[EmitHint["SourceFile"] = 0] = "SourceFile"; EmitHint[EmitHint["Expression"] = 1] = "Expression"; EmitHint[EmitHint["IdentifierName"] = 2] = "IdentifierName"; - EmitHint[EmitHint["Unspecified"] = 3] = "Unspecified"; + EmitHint[EmitHint["MappedTypeParameter"] = 3] = "MappedTypeParameter"; + EmitHint[EmitHint["Unspecified"] = 4] = "Unspecified"; })(EmitHint = ts.EmitHint || (ts.EmitHint = {})); })(ts || (ts = {})); var ts; @@ -1164,6 +1167,12 @@ var ts; ts.versionMajorMinor = "2.6"; ts.version = ts.versionMajorMinor + ".0"; })(ts || (ts = {})); +(function (ts) { + function isExternalModuleNameRelative(moduleName) { + return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName); + } + ts.isExternalModuleNameRelative = isExternalModuleNameRelative; +})(ts || (ts = {})); (function (ts) { ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; @@ -1795,6 +1804,26 @@ var ts; return to; } ts.addRange = addRange; + function pushIfUnique(array, toAdd) { + if (contains(array, toAdd)) { + return false; + } + else { + array.push(toAdd); + return true; + } + } + ts.pushIfUnique = pushIfUnique; + function appendIfUnique(array, toAdd) { + if (array) { + pushIfUnique(array, toAdd); + return array; + } + else { + return [toAdd]; + } + } + ts.appendIfUnique = appendIfUnique; function stableSort(array, comparer) { if (comparer === void 0) { comparer = compareValues; } return array @@ -1941,6 +1970,16 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; + function getOwnValues(sparseArray) { + var values = []; + for (var key in sparseArray) { + if (hasOwnProperty.call(sparseArray, key)) { + values.push(sparseArray[key]); + } + } + return values; + } + ts.getOwnValues = getOwnValues; function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { @@ -2105,6 +2144,8 @@ var ts; ts.cast = cast; function noop() { } ts.noop = noop; + function identity(x) { return x; } + ts.identity = identity; function notImplemented() { throw new Error("Not implemented"); } @@ -2181,12 +2222,11 @@ var ts; } ts.getLocaleSpecificMessage = getLocaleSpecificMessage; function createFileDiagnostic(file, start, length, message) { - var end = start + length; Debug.assertGreaterThanOrEqual(start, 0); Debug.assertGreaterThanOrEqual(length, 0); if (file) { Debug.assertLessThanOrEqual(start, file.text.length); - Debug.assertLessThanOrEqual(end, file.text.length); + Debug.assertLessThanOrEqual(start + length, file.text.length); } var text = getLocaleSpecificMessage(message); if (arguments.length > 4) { @@ -2428,12 +2468,8 @@ var ts; return /^\.\.?($|[\\/])/.test(path); } ts.pathIsRelative = pathIsRelative; - function isExternalModuleNameRelative(moduleName) { - return pathIsRelative(moduleName) || isRootedDiskPath(moduleName); - } - ts.isExternalModuleNameRelative = isExternalModuleNameRelative; function moduleHasNonRelativeName(moduleName) { - return !isExternalModuleNameRelative(moduleName); + return !ts.isExternalModuleNameRelative(moduleName); } ts.moduleHasNonRelativeName = moduleHasNonRelativeName; function getEmitScriptTarget(compilerOptions) { @@ -2470,7 +2506,7 @@ var ts; } ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter; function isRootedDiskPath(path) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } ts.isRootedDiskPath = isRootedDiskPath; function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) { @@ -3096,6 +3132,10 @@ var ts; throw e; } Debug.fail = fail; + function assertNever(member, message, stackCrawlMark) { + return fail(message || "Illegal value: " + member, stackCrawlMark || assertNever); + } + Debug.assertNever = assertNever; function getFunctionName(func) { if (typeof func !== "function") { return ""; @@ -3233,6 +3273,12 @@ var ts; return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; } ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; + function and(f, g) { + return function (arg) { return f(arg) && g(arg); }; + } + ts.and = and; + function assertTypeIsNever(_) { } + ts.assertTypeIsNever = assertTypeIsNever; })(ts || (ts = {})); var ts; (function (ts) { @@ -3797,8 +3843,8 @@ var ts; An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: diag(1198, ts.DiagnosticCategory.Error, "An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive_1198", "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive."), Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."), Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."), - Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asteri_1202", "Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), - Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_defaul_1203", "Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead."), + Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead: diag(1202, ts.DiagnosticCategory.Error, "Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_1202", "Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead."), + Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead: diag(1203, ts.DiagnosticCategory.Error, "Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or__1203", "Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead."), Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided: diag(1205, ts.DiagnosticCategory.Error, "Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided_1205", "Cannot re-export a type when the '--isolatedModules' flag is provided."), Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."), Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name: diag(1207, ts.DiagnosticCategory.Error, "Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name_1207", "Decorators cannot be applied to multiple get/set accessors of the same name."), @@ -4118,7 +4164,9 @@ var ts; Expected_0_type_arguments_but_got_1: diag(2558, ts.DiagnosticCategory.Error, "Expected_0_type_arguments_but_got_1_2558", "Expected {0} type arguments, but got {1}."), Type_0_has_no_properties_in_common_with_type_1: diag(2559, ts.DiagnosticCategory.Error, "Type_0_has_no_properties_in_common_with_type_1_2559", "Type '{0}' has no properties in common with type '{1}'."), Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it: diag(2560, ts.DiagnosticCategory.Error, "Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it_2560", "Value of type '{0}' has no properties in common with type '{1}'. Did you mean to call it?"), - Base_class_expressions_cannot_reference_class_type_parameters: diag(2561, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2561", "Base class expressions cannot reference class type parameters."), + Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_write_2: diag(2561, ts.DiagnosticCategory.Error, "Object_literal_may_only_specify_known_properties_but_0_does_not_exist_in_type_1_Did_you_mean_to_writ_2561", "Object literal may only specify known properties, but '{0}' does not exist in type '{1}'. Did you mean to write '{2}'?"), + Base_class_expressions_cannot_reference_class_type_parameters: diag(2562, ts.DiagnosticCategory.Error, "Base_class_expressions_cannot_reference_class_type_parameters_2562", "Base class expressions cannot reference class type parameters."), + The_containing_function_or_module_body_is_too_large_for_control_flow_analysis: diag(2563, ts.DiagnosticCategory.Error, "The_containing_function_or_module_body_is_too_large_for_control_flow_analysis_2563", "The containing function or module body is too large for control flow analysis."), JSX_element_attributes_type_0_may_not_be_a_union_type: diag(2600, ts.DiagnosticCategory.Error, "JSX_element_attributes_type_0_may_not_be_a_union_type_2600", "JSX element attributes type '{0}' may not be a union type."), The_return_type_of_a_JSX_element_constructor_must_return_an_object_type: diag(2601, ts.DiagnosticCategory.Error, "The_return_type_of_a_JSX_element_constructor_must_return_an_object_type_2601", "The return type of a JSX element constructor must return an object type."), JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist: diag(2602, ts.DiagnosticCategory.Error, "JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist_2602", "JSX element implicitly has type 'any' because the global type 'JSX.Element' does not exist."), @@ -4191,6 +4239,7 @@ var ts; A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option: diag(2711, ts.DiagnosticCategory.Error, "A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES20_2711", "A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option."), A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: diag(2712, ts.DiagnosticCategory.Error, "A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declarat_2712", "A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option."), Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1: diag(2713, ts.DiagnosticCategory.Error, "Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_p_2713", "Cannot access '{0}.{1}' because '{0}' is a type, but not a namespace. Did you mean to retrieve the type of the property '{1}' in '{0}' with '{0}[\"{1}\"]'?"), + The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context: diag(2714, ts.DiagnosticCategory.Error, "The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context_2714", "The expression of an export assignment must be an identifier or qualified name in an ambient context."), Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."), Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."), Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."), @@ -4308,7 +4357,7 @@ var ts; Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."), Do_not_resolve_the_real_path_of_symlinks: diag(6013, ts.DiagnosticCategory.Message, "Do_not_resolve_the_real_path_of_symlinks_6013", "Do not resolve the real path of symlinks."), Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: diag(6015, ts.DiagnosticCategory.Message, "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'."), - Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), + Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext: diag(6016, ts.DiagnosticCategory.Message, "Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_or_ESNext_6016", "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'."), Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."), Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."), Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: diag(6020, ts.DiagnosticCategory.Message, "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'."), @@ -4413,17 +4462,16 @@ var ts; Resolving_real_path_for_0_result_1: diag(6130, ts.DiagnosticCategory.Message, "Resolving_real_path_for_0_result_1_6130", "Resolving real path for '{0}', result '{1}'."), Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: diag(6131, ts.DiagnosticCategory.Error, "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'."), File_name_0_has_a_1_extension_stripping_it: diag(6132, ts.DiagnosticCategory.Message, "File_name_0_has_a_1_extension_stripping_it_6132", "File name '{0}' has a '{1}' extension - stripping it."), - _0_is_declared_but_never_used: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_never_used_6133", "'{0}' is declared but never used."), + _0_is_declared_but_its_value_is_never_read: diag(6133, ts.DiagnosticCategory.Error, "_0_is_declared_but_its_value_is_never_read_6133", "'{0}' is declared but its value is never read."), Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."), Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."), The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: diag(6136, ts.DiagnosticCategory.Message, "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", "The maximum dependency depth to search under node_modules and load JavaScript files."), Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1: diag(6137, ts.DiagnosticCategory.Error, "Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1_6137", "Cannot import type declaration files. Consider importing '{0}' instead of '{1}'."), - Property_0_is_declared_but_never_used: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_never_used_6138", "Property '{0}' is declared but never used."), + Property_0_is_declared_but_its_value_is_never_read: diag(6138, ts.DiagnosticCategory.Error, "Property_0_is_declared_but_its_value_is_never_read_6138", "Property '{0}' is declared but its value is never read."), Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."), Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: diag(6140, ts.DiagnosticCategory.Error, "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'."), Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: diag(6141, ts.DiagnosticCategory.Message, "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", "Parse in strict mode and emit \"use strict\" for each source file."), Module_0_was_resolved_to_1_but_jsx_is_not_set: diag(6142, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", "Module '{0}' was resolved to '{1}', but '--jsx' is not set."), - Module_0_was_resolved_to_1_but_allowJs_is_not_set: diag(6143, ts.DiagnosticCategory.Error, "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", "Module '{0}' was resolved to '{1}', but '--allowJs' is not set."), Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: diag(6144, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", "Module '{0}' was resolved as locally declared ambient module in file '{1}'."), Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified: diag(6145, ts.DiagnosticCategory.Message, "Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified_6145", "Module '{0}' was resolved as ambient module declared in '{1}' since this file was not modified."), Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: diag(6146, ts.DiagnosticCategory.Message, "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'."), @@ -4514,6 +4562,7 @@ var ts; Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: diag(8018, ts.DiagnosticCategory.Error, "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'."), Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."), JSDoc_types_can_only_be_used_inside_documentation_comments: diag(8020, ts.DiagnosticCategory.Error, "JSDoc_types_can_only_be_used_inside_documentation_comments_8020", "JSDoc types can only be used inside documentation comments."), + JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags: diag(8021, ts.DiagnosticCategory.Error, "JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags_8021", "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags."), Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_class_extends_clause: diag(9002, ts.DiagnosticCategory.Error, "Only_identifiers_Slashqualified_names_with_optional_type_arguments_are_currently_supported_in_a_clas_9002", "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause."), class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."), Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."), @@ -4561,7 +4610,7 @@ var ts; Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"), Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"), Extract_function: diag(95003, ts.DiagnosticCategory.Message, "Extract_function_95003", "Extract function"), - Extract_function_into_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_function_into_0_95004", "Extract function into '{0}'"), + Extract_to_0: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_95004", "Extract to {0}"), }; })(ts || (ts = {})); var ts; @@ -4583,7 +4632,6 @@ var ts; } ts.getDeclarationOfKind = getDeclarationOfKind; var stringWriter = createSingleLineStringWriter(); - var stringWriterAcquired = false; function createSingleLineStringWriter() { var str = ""; var writeText = function (text) { return str += text; }; @@ -4607,15 +4655,14 @@ var ts; }; } function usingSingleLineStringWriter(action) { + var oldString = stringWriter.string(); try { - ts.Debug.assert(!stringWriterAcquired); - stringWriterAcquired = true; action(stringWriter); return stringWriter.string(); } finally { stringWriter.clear(); - stringWriterAcquired = false; + stringWriter.writeKeyword(oldString); } } ts.usingSingleLineStringWriter = usingSingleLineStringWriter; @@ -4649,7 +4696,7 @@ var ts; } ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo; function packageIdIsEqual(a, b) { - return a === b || a && b && a.name === b.name && a.version === b.version; + return a === b || a && b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version; } function typeDirectiveIsEqualTo(oldResolution, newResolution) { return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary; @@ -4771,7 +4818,7 @@ var ts; if (ts.isJSDocNode(node)) { return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true); } - if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { + if (includeJsDoc && ts.hasJSDocNodes(node)) { return getTokenPosOfNode(node.jsDoc[0]); } if (node.kind === 286 && node._children.length > 0) { @@ -4808,6 +4855,15 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; + function indexOfNode(nodeArray, node) { + return ts.binarySearch(nodeArray, node, compareNodePos); + } + ts.indexOfNode = indexOfNode; + function compareNodePos(_a, _b) { + var aPos = _a.pos; + var bPos = _b.pos; + return aPos < bPos ? -1 : bPos < aPos ? 1 : 0; + } function getEmitFlags(node) { var emitNode = node.emitNode; return emitNode && emitNode.flags; @@ -4835,6 +4891,7 @@ var ts; case 16: return "}" + escapeText(node.text, 96) + "`"; case 8: + case 12: return node.text; } ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); @@ -4932,6 +4989,34 @@ var ts; return false; } ts.isBlockScope = isBlockScope; + function isDeclarationWithTypeParameters(node) { + switch (node.kind) { + case 155: + case 156: + case 150: + case 157: + case 160: + case 161: + case 273: + case 229: + case 199: + case 230: + case 231: + case 282: + case 228: + case 151: + case 152: + case 153: + case 154: + case 186: + case 187: + return true; + default: + ts.assertTypeIsNever(node); + return false; + } + } + ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters; function getEnclosingBlockScopeContainer(node) { var current = node.parent; while (current) { @@ -5579,59 +5664,62 @@ var ts; case 8: case 9: case 99: - var parent = node.parent; - switch (parent.kind) { - case 226: - case 146: - case 149: - case 148: - case 264: - case 261: - case 176: - return parent.initializer === node; - case 210: - case 211: - case 212: - case 213: - case 219: - case 220: - case 221: - case 257: - case 223: - return parent.expression === node; - case 214: - var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || - forStatement.condition === node || - forStatement.incrementor === node; - case 215: - case 216: - var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || - forInStatement.expression === node; - case 184: - case 202: - return node === parent.expression; - case 205: - return node === parent.expression; - case 144: - return node === parent.expression; - case 147: - case 256: - case 255: - case 263: - return true; - case 201: - return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); - default: - if (isPartOfExpression(parent)) { - return true; - } - } + return isInExpressionContext(node); + default: + return false; } - return false; } ts.isPartOfExpression = isPartOfExpression; + function isInExpressionContext(node) { + var parent = node.parent; + switch (parent.kind) { + case 226: + case 146: + case 149: + case 148: + case 264: + case 261: + case 176: + return parent.initializer === node; + case 210: + case 211: + case 212: + case 213: + case 219: + case 220: + case 221: + case 257: + case 223: + return parent.expression === node; + case 214: + var forStatement = parent; + return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || + forStatement.condition === node || + forStatement.incrementor === node; + case 215: + case 216: + var forInStatement = parent; + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || + forInStatement.expression === node; + case 184: + case 202: + return node === parent.expression; + case 205: + return node === parent.expression; + case 144: + return node === parent.expression; + case 147: + case 256: + case 255: + case 263: + return true; + case 201: + return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); + default: + return isPartOfExpression(parent); + } + } + ts.isInExpressionContext = isInExpressionContext; function isExternalModuleImportEqualsDeclaration(node) { return node.kind === 237 && node.moduleReference.kind === 248; } @@ -5795,14 +5883,6 @@ var ts; node.parameters[0].name.escapedText === "new"; } ts.isJSDocConstructSignature = isJSDocConstructSignature; - function hasJSDocParameterTags(node) { - return !!getFirstJSDocTag(node, 279); - } - ts.hasJSDocParameterTags = hasJSDocParameterTags; - function getFirstJSDocTag(node, kind) { - var tags = getJSDocTags(node); - return ts.find(tags, function (doc) { return doc.kind === kind; }); - } function getAllJSDocs(node) { if (ts.isJSDocTypedefTag(node)) { return [node.parent]; @@ -5810,14 +5890,6 @@ var ts; return getJSDocCommentsAndTags(node); } ts.getAllJSDocs = getAllJSDocs; - function getJSDocTags(node) { - var tags = node.jsDocCache; - if (tags === undefined) { - node.jsDocCache = tags = ts.flatMap(getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); - } - return tags; - } - ts.getJSDocTags = getJSDocTags; function getJSDocCommentsAndTags(node) { var result; getJSDocCommentsAndTagsWorker(node); @@ -5849,22 +5921,17 @@ var ts; getJSDocCommentsAndTagsWorker(parent); } if (node.kind === 146) { - result = ts.addRange(result, getJSDocParameterTags(node)); + result = ts.addRange(result, ts.getJSDocParameterTags(node)); } - if (isVariableLike(node) && node.initializer) { + if (isVariableLike(node) && node.initializer && ts.hasJSDocNodes(node.initializer)) { result = ts.addRange(result, node.initializer.jsDoc); } - result = ts.addRange(result, node.jsDoc); + if (ts.hasJSDocNodes(node)) { + result = ts.addRange(result, node.jsDoc); + } } } - function getJSDocParameterTags(param) { - if (param.name && ts.isIdentifier(param.name)) { - var name_1 = param.name.escapedText; - return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); - } - return undefined; - } - ts.getJSDocParameterTags = getJSDocParameterTags; + ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags; function getParameterSymbolFromJSDoc(node) { if (node.symbol) { return node.symbol; @@ -5890,38 +5957,6 @@ var ts; return ts.find(typeParameters, function (p) { return p.name.escapedText === name; }); } ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc; - function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 281); - if (!tag && node.kind === 146) { - var paramTags = getJSDocParameterTags(node); - if (paramTags) { - tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); - } - } - return tag && tag.typeExpression && tag.typeExpression.type; - } - ts.getJSDocType = getJSDocType; - function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 277); - } - ts.getJSDocAugmentsTag = getJSDocAugmentsTag; - function getJSDocClassTag(node) { - return getFirstJSDocTag(node, 278); - } - ts.getJSDocClassTag = getJSDocClassTag; - function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 280); - } - ts.getJSDocReturnTag = getJSDocReturnTag; - function getJSDocReturnType(node) { - var returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - ts.getJSDocReturnType = getJSDocReturnType; - function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 282); - } - ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { return isRestParameter(ts.lastOrUndefined(s.parameters)); } @@ -5933,7 +5968,7 @@ var ts; function isRestParameter(node) { if (isInJavaScriptFile(node)) { if (node.type && node.type.kind === 274 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274; })) { + ts.forEach(ts.getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 274; })) { return true; } } @@ -6334,9 +6369,9 @@ var ts; || kind === 265; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; - function nodeIsSynthesized(node) { - return ts.positionIsSynthesized(node.pos) - || ts.positionIsSynthesized(node.end); + function nodeIsSynthesized(range) { + return ts.positionIsSynthesized(range.pos) + || ts.positionIsSynthesized(range.end); } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFile(sourceFile) { @@ -6600,13 +6635,17 @@ var ts; "\u2029": "\\u2029", "\u0085": "\\u0085" }); + var escapedNullRegExp = /\\0[0-9]/g; function escapeString(s, quoteChar) { var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp : quoteChar === 39 ? singleQuoteEscapedCharsRegExp : doubleQuoteEscapedCharsRegExp; - return s.replace(escapedCharsRegExp, getReplacement); + return s.replace(escapedCharsRegExp, getReplacement).replace(escapedNullRegExp, nullReplacement); } ts.escapeString = escapeString; + function nullReplacement(c) { + return "\\x00" + c.charAt(c.length - 1); + } function getReplacement(c) { return escapedCharsMap.get(c) || get16BitUnicodeEscapeSequence(c.charCodeAt(0)); } @@ -6886,7 +6925,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocType(node); + return ts.getJSDocType(node); } } ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode; @@ -6895,7 +6934,7 @@ var ts; return node.type; } if (isInJavaScriptFile(node)) { - return getJSDocReturnType(node); + return ts.getJSDocReturnType(node); } } ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode; @@ -6904,7 +6943,7 @@ var ts; return node.typeParameters; } if (isInJavaScriptFile(node)) { - var templateTag = getJSDocTemplateTag(node); + var templateTag = ts.getJSDocTemplateTag(node); return templateTag && templateTag.typeParameters; } } @@ -7463,6 +7502,41 @@ var ts; return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags; } ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags; + function isWriteOnlyAccess(node) { + return accessKind(node) === 1; + } + ts.isWriteOnlyAccess = isWriteOnlyAccess; + function isWriteAccess(node) { + return accessKind(node) !== 0; + } + ts.isWriteAccess = isWriteAccess; + var AccessKind; + (function (AccessKind) { + AccessKind[AccessKind["Read"] = 0] = "Read"; + AccessKind[AccessKind["Write"] = 1] = "Write"; + AccessKind[AccessKind["ReadWrite"] = 2] = "ReadWrite"; + })(AccessKind || (AccessKind = {})); + function accessKind(node) { + var parent = node.parent; + if (!parent) + return 0; + switch (parent.kind) { + case 193: + case 192: + var operator = parent.operator; + return operator === 43 || operator === 44 ? writeOrReadWrite() : 0; + case 194: + var _a = parent, left = _a.left, operatorToken = _a.operatorToken; + return left === node && isAssignmentOperator(operatorToken.kind) ? writeOrReadWrite() : 0; + case 179: + return parent.name !== node ? 0 : accessKind(parent); + default: + return 0; + } + function writeOrReadWrite() { + return parent.parent && parent.parent.kind === 210 ? 1 : 2; + } + } })(ts || (ts = {})); (function (ts) { function getDefaultLibFileName(options) { @@ -7741,6 +7815,56 @@ var ts; return id; } ts.unescapeIdentifier = unescapeIdentifier; + function nameForNamelessJSDocTypedef(declaration) { + var hostNode = declaration.parent.parent; + if (!hostNode) { + return undefined; + } + if (ts.isDeclaration(hostNode)) { + return getDeclarationIdentifier(hostNode); + } + switch (hostNode.kind) { + case 208: + if (hostNode.declarationList && + hostNode.declarationList.declarations[0]) { + return getDeclarationIdentifier(hostNode.declarationList.declarations[0]); + } + return undefined; + case 210: + var expr = hostNode.expression; + switch (expr.kind) { + case 179: + return expr.name; + case 180: + var arg = expr.argumentExpression; + if (ts.isIdentifier(arg)) { + return arg; + } + } + return undefined; + case 1: + return undefined; + case 185: { + return getDeclarationIdentifier(hostNode.expression); + } + case 222: { + if (ts.isDeclaration(hostNode.statement) || ts.isExpression(hostNode.statement)) { + return getDeclarationIdentifier(hostNode.statement); + } + return undefined; + } + default: + ts.Debug.assertNever(hostNode, "Found typedef tag attached to node which it should not be!"); + } + } + function getDeclarationIdentifier(node) { + var name = getNameOfDeclaration(node); + return ts.isIdentifier(name) ? name : undefined; + } + function getNameOfJSDocTypedef(declaration) { + return declaration.name || nameForNamelessJSDocTypedef(declaration); + } + ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef; function getNameOfDeclaration(declaration) { if (!declaration) { return undefined; @@ -7760,11 +7884,78 @@ var ts; return undefined; } } + else if (declaration.kind === 283) { + return getNameOfJSDocTypedef(declaration); + } else { return declaration.name; } } ts.getNameOfDeclaration = getNameOfDeclaration; + function getJSDocParameterTags(param) { + if (param.name && ts.isIdentifier(param.name)) { + var name_1 = param.name.escapedText; + return getJSDocTags(param.parent).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; }); + } + return undefined; + } + ts.getJSDocParameterTags = getJSDocParameterTags; + function hasJSDocParameterTags(node) { + return !!getFirstJSDocTag(node, 279); + } + ts.hasJSDocParameterTags = hasJSDocParameterTags; + function getJSDocAugmentsTag(node) { + return getFirstJSDocTag(node, 277); + } + ts.getJSDocAugmentsTag = getJSDocAugmentsTag; + function getJSDocClassTag(node) { + return getFirstJSDocTag(node, 278); + } + ts.getJSDocClassTag = getJSDocClassTag; + function getJSDocReturnTag(node) { + return getFirstJSDocTag(node, 280); + } + ts.getJSDocReturnTag = getJSDocReturnTag; + function getJSDocTemplateTag(node) { + return getFirstJSDocTag(node, 282); + } + ts.getJSDocTemplateTag = getJSDocTemplateTag; + function getJSDocTypeTag(node) { + var tag = getFirstJSDocTag(node, 281); + if (tag && tag.typeExpression && tag.typeExpression.type) { + return tag; + } + return undefined; + } + ts.getJSDocTypeTag = getJSDocTypeTag; + function getJSDocType(node) { + var tag = getFirstJSDocTag(node, 281); + if (!tag && node.kind === 146) { + var paramTags = getJSDocParameterTags(node); + if (paramTags) { + tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); + } + } + return tag && tag.typeExpression && tag.typeExpression.type; + } + ts.getJSDocType = getJSDocType; + function getJSDocReturnType(node) { + var returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + ts.getJSDocReturnType = getJSDocReturnType; + function getJSDocTags(node) { + var tags = node.jsDocCache; + if (tags === undefined) { + node.jsDocCache = tags = ts.flatMap(ts.getJSDocCommentsAndTags(node), function (j) { return ts.isJSDoc(j) ? j.tags : j; }); + } + return tags; + } + ts.getJSDocTags = getJSDocTags; + function getFirstJSDocTag(node, kind) { + var tags = getJSDocTags(node); + return ts.find(tags, function (doc) { return doc.kind === kind; }); + } })(ts || (ts = {})); (function (ts) { function isNumericLiteral(node) { @@ -8397,8 +8588,7 @@ var ts; } ts.isToken = isToken; function isNodeArray(array) { - return array.hasOwnProperty("pos") - && array.hasOwnProperty("end"); + return array.hasOwnProperty("pos") && array.hasOwnProperty("end"); } ts.isNodeArray = isNodeArray; function isLiteralKind(kind) { @@ -8483,16 +8673,27 @@ var ts; return node && isFunctionLikeKind(node.kind); } ts.isFunctionLike = isFunctionLike; - function isFunctionLikeKind(kind) { + function isFunctionLikeDeclaration(node) { + return node && isFunctionLikeDeclarationKind(node.kind); + } + ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration; + function isFunctionLikeDeclarationKind(kind) { switch (kind) { - case 152: - case 186: case 228: - case 187: case 151: - case 150: + case 152: case 153: case 154: + case 186: + case 187: + return true; + default: + return false; + } + } + function isFunctionLikeKind(kind) { + switch (kind) { + case 150: case 155: case 156: case 157: @@ -8500,10 +8701,15 @@ var ts; case 273: case 161: return true; + default: + return isFunctionLikeDeclarationKind(kind); } - return false; } ts.isFunctionLikeKind = isFunctionLikeKind; + function isFunctionOrModuleBlock(node) { + return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent); + } + ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock; function isClassElement(node) { var kind = node.kind; return kind === 152 @@ -8657,52 +8863,61 @@ var ts; || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; - function isLeftHandSideExpressionKind(kind) { - return kind === 179 - || kind === 180 - || kind === 182 - || kind === 181 - || kind === 249 - || kind === 250 - || kind === 183 - || kind === 177 - || kind === 185 - || kind === 178 - || kind === 199 - || kind === 186 - || kind === 71 - || kind === 12 - || kind === 8 - || kind === 9 - || kind === 13 - || kind === 196 - || kind === 86 - || kind === 95 - || kind === 99 - || kind === 101 - || kind === 97 - || kind === 91 - || kind === 203 - || kind === 204; - } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; - function isUnaryExpressionKind(kind) { - return kind === 192 - || kind === 193 - || kind === 188 - || kind === 189 - || kind === 190 - || kind === 191 - || kind === 184 - || isLeftHandSideExpressionKind(kind); + function isLeftHandSideExpressionKind(kind) { + switch (kind) { + case 179: + case 180: + case 182: + case 181: + case 249: + case 250: + case 183: + case 177: + case 185: + case 178: + case 199: + case 186: + case 71: + case 12: + case 8: + case 9: + case 13: + case 196: + case 86: + case 95: + case 99: + case 101: + case 97: + case 203: + case 204: + case 91: + return true; + default: + return false; + } } function isUnaryExpression(node) { return isUnaryExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isUnaryExpression = isUnaryExpression; + function isUnaryExpressionKind(kind) { + switch (kind) { + case 192: + case 193: + case 188: + case 189: + case 190: + case 191: + case 184: + return true; + default: + return isLeftHandSideExpressionKind(kind); + } + } function isUnaryExpressionWithWrite(expr) { switch (expr.kind) { case 193: @@ -8715,21 +8930,26 @@ var ts; } } ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite; - function isExpressionKind(kind) { - return kind === 195 - || kind === 197 - || kind === 187 - || kind === 194 - || kind === 198 - || kind === 202 - || kind === 200 - || kind === 289 - || isUnaryExpressionKind(kind); - } function isExpression(node) { return isExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isExpression = isExpression; + function isExpressionKind(kind) { + switch (kind) { + case 195: + case 197: + case 187: + case 194: + case 198: + case 202: + case 200: + case 289: + case 288: + return true; + default: + return isUnaryExpressionKind(kind); + } + } function isAssertionExpression(node) { var kind = node.kind; return kind === 184 @@ -8970,6 +9190,10 @@ var ts; return node.kind >= 276 && node.kind <= 285; } ts.isJSDocTag = isJSDocTag; + function hasJSDocNodes(node) { + return !!node.jsDoc && node.jsDoc.length > 0; + } + ts.hasJSDocNodes = hasJSDocNodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -9196,7 +9420,7 @@ var ts; ts.Debug.assert(res < lineStarts[line + 1]); } else if (debugText !== undefined) { - ts.Debug.assert(res < debugText.length); + ts.Debug.assert(res <= debugText.length); } return res; } @@ -10987,9 +11211,11 @@ var ts; visitNode(cbNode, node.typeExpression); } case 285: - for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { - var tag = _a[_i]; - visitNode(cbNode, tag); + if (node.jsDocPropertyTags) { + for (var _i = 0, _a = node.jsDocPropertyTags; _i < _a.length; _i++) { + var tag = _a[_i]; + visitNode(cbNode, tag); + } } return; case 288: @@ -11169,7 +11395,7 @@ var ts; var saveParent = parent; parent = n; forEachChild(n, visitNode); - if (n.jsDoc) { + if (ts.hasJSDocNodes(n)) { for (var _i = 0, _a = n.jsDoc; _i < _a.length; _i++) { var jsDoc = _a[_i]; jsDoc.parent = n; @@ -11289,9 +11515,6 @@ var ts; function getNodePos() { return scanner.getStartPos(); } - function getNodeEnd() { - return scanner.getStartPos(); - } function token() { return currentToken; } @@ -11414,13 +11637,11 @@ var ts; kind === 71 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } - function createNodeArray(elements, pos) { - var array = (elements || []); - if (!(pos >= 0)) { - pos = getNodePos(); - } + function createNodeArray(elements, pos, end) { + var length = elements.length; + var array = (length >= 1 && length <= 4 ? elements.slice() : elements); array.pos = pos; - array.end = pos; + array.end = end === undefined ? scanner.getStartPos() : end; return array; } function finishNode(node, end) { @@ -11468,7 +11689,8 @@ var ts; nextToken(); return finishNode(node); } - return createMissingNode(71, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + var reportAtCurrentPosition = token() === 1; + return createMissingNode(71, reportAtCurrentPosition, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -11701,20 +11923,20 @@ var ts; function parseList(kind, parseElement) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); while (!isListTerminator(kind)) { if (isListElement(kind, false)) { var element = parseListElement(kind, parseElement); - result.push(element); + list.push(element); continue; } if (abortParsingListOrMoveToNextToken(kind)) { break; } } - result.end = getNodeEnd(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseListElement(parsingContext, parseElement) { var node = currentNode(parsingContext); @@ -11920,12 +12142,13 @@ var ts; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var commaStart = -1; while (true) { if (isListElement(kind, false)) { var startPos = scanner.getStartPos(); - result.push(parseListElement(kind, parseElement)); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(26)) { continue; @@ -11950,15 +12173,15 @@ var ts; break; } } + parsingContext = saveParsingContext; + var result = createNodeArray(list, listPos); if (commaStart >= 0) { result.hasTrailingComma = true; } - result.end = getNodeEnd(); - parsingContext = saveParsingContext; return result; } function createMissingList() { - return createNodeArray(); + return createNodeArray([], getNodePos()); } function parseBracketedList(kind, parseElement, open, close) { if (parseExpected(open)) { @@ -12000,12 +12223,12 @@ var ts; var template = createNode(196); template.head = parseTemplateHead(); ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); - var templateSpans = createNodeArray(); + var list = []; + var listPos = getNodePos(); do { - templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 15); - templateSpans.end = getNodeEnd(); - template.templateSpans = templateSpans; + list.push(parseTemplateSpan()); + } while (ts.lastOrUndefined(list).literal.kind === 15); + template.templateSpans = createNodeArray(list, listPos); return finishNode(template); } function parseTemplateSpan() { @@ -12100,7 +12323,7 @@ var ts; var result = createNode(273); nextToken(); fillSignature(56, 4 | 32, result); - return finishNode(result); + return addJSDocComment(finishNode(result)); } var node = createNode(159); node.typeName = parseIdentifierName(); @@ -12158,9 +12381,10 @@ var ts; return token() === 24 || isIdentifierOrPattern() || ts.isModifierKind(token()) || - token() === 57 || isStartOfType(); + token() === 57 || + isStartOfType(true); } - function parseParameter() { + function parseParameter(requireEqualsToken) { var node = createNode(146); if (token() === 99) { node.name = createIdentifier(true); @@ -12176,37 +12400,33 @@ var ts; } node.questionToken = parseOptionalToken(55); node.type = parseParameterType(); - node.initializer = parseBindingElementInitializer(true); + node.initializer = parseInitializer(true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - function parseBindingElementInitializer(inParameter) { - return inParameter ? parseParameterInitializer() : parseNonParameterInitializer(); - } - function parseParameterInitializer() { - return parseInitializer(true); - } function fillSignature(returnToken, flags, signature) { if (!(flags & 32)) { signature.typeParameters = parseTypeParameters(); } signature.parameters = parseParameterList(flags); - var returnTokenRequired = returnToken === 36; - if (returnTokenRequired) { + signature.type = parseReturnType(returnToken, !!(flags & 4)); + } + function parseReturnType(returnToken, isType) { + return shouldParseReturnType(returnToken, isType) ? parseTypeOrTypePredicate() : undefined; + } + function shouldParseReturnType(returnToken, isType) { + if (returnToken === 36) { parseExpected(returnToken); - signature.type = parseTypeOrTypePredicate(); + return true; } - else if (parseOptional(returnToken)) { - signature.type = parseTypeOrTypePredicate(); + else if (parseOptional(56)) { + return true; } - else if (flags & 4) { - var start = scanner.getTokenPos(); - var length_1 = scanner.getTextPos() - start; - var backwardToken = parseOptional(returnToken === 56 ? 36 : 56); - if (backwardToken) { - signature.type = parseTypeOrTypePredicate(); - parseErrorAtPosition(start, length_1, ts.Diagnostics._0_expected, ts.tokenToString(returnToken)); - } + else if (isType && token() === 36) { + parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(56)); + nextToken(); + return true; } + return false; } function parseParameterList(flags) { if (parseExpected(19)) { @@ -12214,7 +12434,7 @@ var ts; var savedAwaitContext = inAwaitContext(); setYieldContext(!!(flags & 1)); setAwaitContext(!!(flags & 2)); - var result = parseDelimitedList(16, flags & 32 ? parseJSDocParameter : parseParameter); + var result = parseDelimitedList(16, flags & 32 ? parseJSDocParameter : function () { return parseParameter(!!(flags & 8)); }); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); if (!parseExpected(20) && (flags & 8)) { @@ -12278,7 +12498,7 @@ var ts; node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); @@ -12410,7 +12630,7 @@ var ts; parseExpected(94); } fillSignature(36, 4, node); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseKeywordAndNoDot() { var node = parseTokenNode(); @@ -12424,16 +12644,9 @@ var ts; unaryMinusExpression.operator = 38; nextToken(); } - var expression; - switch (token()) { - case 9: - case 8: - expression = parseLiteralLikeNode(token()); - break; - case 101: - case 86: - expression = parseTokenNode(); - } + var expression = token() === 101 || token() === 86 + ? parseTokenNode() + : parseLiteralLikeNode(token()); if (negative) { unaryMinusExpression.operand = expression; finishNode(unaryMinusExpression); @@ -12466,6 +12679,7 @@ var ts; return parseJSDocNodeWithType(274); case 51: return parseJSDocNodeWithType(271); + case 13: case 9: case 8: case 101: @@ -12497,7 +12711,7 @@ var ts; return parseTypeReference(); } } - function isStartOfType() { + function isStartOfType(inStartOfParameter) { switch (token()) { case 119: case 136: @@ -12522,11 +12736,14 @@ var ts; case 86: case 134: case 39: + case 55: + case 51: + case 24: return true; case 38: - return lookAhead(nextTokenIsNumericLiteral); + return !inStartOfParameter && lookAhead(nextTokenIsNumericLiteral); case 19: - return lookAhead(isStartOfParenthesizedOrFunctionType); + return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); } @@ -12592,13 +12809,12 @@ var ts; parseOptional(operator); var type = parseConstituentType(); if (token() === operator) { - var types = createNodeArray([type], type.pos); + var types = [type]; while (parseOptional(operator)) { types.push(parseConstituentType()); } - types.end = getNodeEnd(); var node = createNode(kind, type.pos); - node.types = types; + node.types = createNodeArray(types, type.pos); type = finishNode(node); } return type; @@ -12758,11 +12974,16 @@ var ts; } return expr; } - function parseInitializer(inParameter) { + function parseInitializer(inParameter, requireEqualsToken) { if (token() !== 58) { if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17) || !isStartOfExpression()) { return undefined; } + if (inParameter && requireEqualsToken) { + var result = createMissingNode(71, true, ts.Diagnostics._0_expected, "="); + result.escapedText = "= not found"; + return result; + } } parseExpected(58); return parseAssignmentExpressionOrHigher(); @@ -12823,8 +13044,7 @@ var ts; var parameter = createNode(146, identifier.pos); parameter.name = identifier; finishNode(parameter); - node.parameters = createNodeArray([parameter], parameter.pos); - node.parameters.end = parameter.end; + node.parameters = createNodeArray([parameter], parameter.pos, parameter.end); node.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); @@ -12931,8 +13151,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { if (token() === 120) { - var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); - if (isUnParenthesizedAsyncArrowFunction === 1) { + if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) { var asyncModifier = parseModifiersForArrowFunction(); var expr = parseBinaryExpressionOrHigher(0); return parseSimpleArrowFunctionExpression(expr, asyncModifier); @@ -12961,7 +13180,8 @@ var ts; if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 36 && token() !== 17) { + if (!allowAmbiguity && ((token() !== 36 && token() !== 17) || + ts.find(node.parameters, function (p) { return p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"; }))) { return undefined; } return node; @@ -13303,7 +13523,8 @@ var ts; ts.Debug.fail("Unknown JSX child kind " + token()); } function parseJsxChildren(openingTagName) { - var result = createNodeArray(); + var list = []; + var listPos = getNodePos(); var saveParsingContext = parsingContext; parsingContext |= 1 << 14; while (true) { @@ -13320,12 +13541,11 @@ var ts; } var child = parseJsxChild(); if (child) { - result.push(child); + list.push(child); } } - result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; - return result; + return createNodeArray(list, listPos); } function parseJsxAttributes() { var jsxAttributes = createNode(254); @@ -14204,7 +14424,7 @@ var ts; var node = createNode(176); node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingElement() { @@ -14220,7 +14440,7 @@ var ts; node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseBindingElementInitializer(false); + node.initializer = parseInitializer(false); return finishNode(node); } function parseObjectBindingPattern() { @@ -14254,7 +14474,7 @@ var ts; node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseInitializer(false); + node.initializer = parseNonParameterInitializer(); } return finishNode(node); } @@ -14418,7 +14638,8 @@ var ts; return false; } function parseDecorators() { - var decorators; + var list; + var listPos = getNodePos(); while (true) { var decoratorStart = getNodePos(); if (!parseOptional(57)) { @@ -14427,20 +14648,13 @@ var ts; var decorator = createNode(147, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); - if (!decorators) { - decorators = createNodeArray([decorator], decoratorStart); - } - else { - decorators.push(decorator); - } + (list || (list = [])).push(decorator); } - if (decorators) { - decorators.end = getNodeEnd(); - } - return decorators; + return list && createNodeArray(list, listPos); } function parseModifiers(permitInvalidConstAsModifier) { - var modifiers; + var list; + var listPos = getNodePos(); while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); @@ -14455,17 +14669,9 @@ var ts; } } var modifier = finishNode(createNode(modifierKind, modifierStart)); - if (!modifiers) { - modifiers = createNodeArray([modifier], modifierStart); - } - else { - modifiers.push(modifier); - } + (list || (list = [])).push(modifier); } - if (modifiers) { - modifiers.end = scanner.getStartPos(); - } - return modifiers; + return list && createNodeArray(list, listPos); } function parseModifiersForArrowFunction() { var modifiers; @@ -14475,7 +14681,6 @@ var ts; nextToken(); var modifier = finishNode(createNode(modifierKind, modifierStart)); modifiers = createNodeArray([modifier], modifierStart); - modifiers.end = scanner.getStartPos(); } return modifiers; } @@ -14970,9 +15175,11 @@ var ts; return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; - function parseJSDocTypeExpression() { + function parseJSDocTypeExpression(requireBraces) { var result = createNode(267, scanner.getTokenPos()); - parseExpected(17); + if (!parseExpected(17) && requireBraces) { + return undefined; + } result.type = doInsideOfContext(1048576, parseType); parseExpected(18); fixupParentReferences(result); @@ -15029,6 +15236,8 @@ var ts; ts.Debug.assert(start <= end); ts.Debug.assert(end <= content.length); var tags; + var tagsPos; + var tagsEnd; var comments = []; var result; if (!isJsDocStart(content, start)) { @@ -15137,7 +15346,7 @@ var ts; } function createJSDocComment() { var result = createNode(275, start); - result.tags = tags; + result.tags = tags && createNodeArray(tags, tagsPos, tagsEnd); result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -15260,21 +15469,17 @@ var ts; function addTag(tag, comments) { tag.comment = comments.join(""); if (!tags) { - tags = createNodeArray([tag], tag.pos); + tags = [tag]; + tagsPos = tag.pos; } else { tags.push(tag); } - tags.end = tag.end; + tagsEnd = tag.end; } function tryParseTypeExpression() { - return tryParse(function () { - skipWhitespace(); - if (token() !== 17) { - return undefined; - } - return parseJSDocTypeExpression(); - }); + skipWhitespace(); + return token() === 17 ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag() { var isBracketed = parseOptional(21); @@ -15364,11 +15569,11 @@ var ts; var result = createNode(281, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); + result.typeExpression = parseJSDocTypeExpression(true); return finishNode(result); } function parseAugmentsTag(atToken, tagName) { - var typeExpression = tryParseTypeExpression(); + var typeExpression = parseJSDocTypeExpression(true); var result = createNode(277, atToken.pos); result.atToken = atToken; result.tagName = tagName; @@ -15403,19 +15608,18 @@ var ts; if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) { var child = void 0; var jsdocTypeLiteral = void 0; - var alreadyHasTypeTag = false; + var childTypeTag = void 0; var start_3 = scanner.getStartPos(); while (child = tryParse(function () { return parseChildParameterOrPropertyTag(0); })) { if (!jsdocTypeLiteral) { jsdocTypeLiteral = createNode(285, start_3); } if (child.kind === 281) { - if (alreadyHasTypeTag) { + if (childTypeTag) { break; } else { - jsdocTypeLiteral.jsDocTypeTag = child; - alreadyHasTypeTag = true; + childTypeTag = child; } } else { @@ -15429,7 +15633,9 @@ var ts; if (typeExpression && typeExpression.type.kind === 164) { jsdocTypeLiteral.isArrayType = true; } - typedefTag.typeExpression = finishNode(jsdocTypeLiteral); + typedefTag.typeExpression = childTypeTag && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ? + childTypeTag.typeExpression : + finishNode(jsdocTypeLiteral); } } return finishNode(typedefTag); @@ -15523,7 +15729,8 @@ var ts; if (ts.forEach(tags, function (t) { return t.kind === 282; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.escapedText); } - var typeParameters = createNodeArray(); + var typeParameters = []; + var typeParametersPos = getNodePos(); while (true) { var name = parseJSDocIdentifierName(); skipWhitespace(); @@ -15546,9 +15753,8 @@ var ts; var result = createNode(282, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeParameters = typeParameters; + result.typeParameters = createNodeArray(typeParameters, typeParametersPos); finishNode(result); - typeParameters.end = result.end; return result; } function nextJSDocToken() { @@ -15640,7 +15846,7 @@ var ts; ts.Debug.assert(text === newText.substring(node.pos, node.end)); } forEachChild(node, visitNode, visitArray); - if (node.jsDoc) { + if (ts.hasJSDocNodes(node)) { for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { var jsDocComment = _a[_i]; forEachChild(jsDocComment, visitNode, visitArray); @@ -16814,7 +17020,7 @@ var ts; errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnosticMessage, keyText)); } var value = convertPropertyValueToJson(element.initializer, option); - if (typeof keyText !== "undefined" && typeof value !== "undefined") { + if (typeof keyText !== "undefined") { result[keyText] = value; if (jsonConversionNotifier && (parentOption || knownOptions === knownRootOptions)) { @@ -16849,7 +17055,7 @@ var ts; reportInvalidOptionValue(option && option.type !== "boolean"); return false; case 95: - reportInvalidOptionValue(!!option); + reportInvalidOptionValue(option && option.name === "extends"); return null; case 9: if (!isDoubleQuotedString(valueExpression)) { @@ -16905,6 +17111,8 @@ var ts; } function isCompilerOptionsValue(option, value) { if (option) { + if (isNullOrUndefined(value)) + return true; if (option.type === "list") { return ts.isArray(value); } @@ -17057,6 +17265,12 @@ var ts; } } ts.setConfigFileInOptions = setConfigFileInOptions; + function isNullOrUndefined(x) { + return x === undefined || x === null; + } + function directoryOfCombinedPath(fileName, basePath) { + return ts.getDirectoryPath(ts.toPath(fileName, basePath, ts.identity)); + } function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { if (existingOptions === void 0) { existingOptions = {}; } if (resolutionStack === void 0) { resolutionStack = []; } @@ -17080,7 +17294,7 @@ var ts; }; function getFileNames() { var fileNames; - if (ts.hasProperty(raw, "files")) { + if (ts.hasProperty(raw, "files") && !isNullOrUndefined(raw["files"])) { if (ts.isArray(raw["files"])) { fileNames = raw["files"]; if (fileNames.length === 0) { @@ -17092,7 +17306,7 @@ var ts; } } var includeSpecs; - if (ts.hasProperty(raw, "include")) { + if (ts.hasProperty(raw, "include") && !isNullOrUndefined(raw["include"])) { if (ts.isArray(raw["include"])) { includeSpecs = raw["include"]; } @@ -17101,7 +17315,7 @@ var ts; } } var excludeSpecs; - if (ts.hasProperty(raw, "exclude")) { + if (ts.hasProperty(raw, "exclude") && !isNullOrUndefined(raw["exclude"])) { if (ts.isArray(raw["exclude"])) { excludeSpecs = raw["exclude"]; } @@ -17118,7 +17332,7 @@ var ts; if (fileNames === undefined && includeSpecs === undefined) { includeSpecs = ["**/*"]; } - var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, basePath, options, host, errors, extraFileExtensions, sourceFile); + var result = matchFileNames(fileNames, includeSpecs, excludeSpecs, configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath, options, host, errors, extraFileExtensions, sourceFile); if (result.fileNames.length === 0 && !ts.hasProperty(raw, "files") && resolutionStack.length === 0) { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2, configFileName || "tsconfig.json", JSON.stringify(includeSpecs || []), JSON.stringify(excludeSpecs || []))); } @@ -17180,7 +17394,8 @@ var ts; errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } else { - extendedConfigPath = getExtendsConfigPath(json.extends, host, basePath, getCanonicalFileName, errors, ts.createCompilerDiagnostic); + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, getCanonicalFileName, errors, ts.createCompilerDiagnostic); } } return { raw: json, options: options, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath }; @@ -17202,7 +17417,8 @@ var ts; onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) { switch (key) { case "extends": - extendedConfigPath = getExtendsConfigPath(value, host, basePath, getCanonicalFileName, errors, function (message, arg0) { + var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath; + extendedConfigPath = getExtendsConfigPath(value, host, newBase, getCanonicalFileName, errors, function (message, arg0) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0); }); return; @@ -17356,6 +17572,8 @@ var ts; } } function normalizeOptionValue(option, basePath, value) { + if (isNullOrUndefined(value)) + return undefined; if (option.type === "list") { var listOption_1 = option; if (listOption_1.element.isFilePath || typeof listOption_1.element.type !== "string") { @@ -17378,6 +17596,8 @@ var ts; return value; } function convertJsonOptionOfCustomType(opt, value, errors) { + if (isNullOrUndefined(value)) + return undefined; var key = value.toLowerCase(); var val = opt.type.get(key); if (val !== undefined) { @@ -17414,7 +17634,7 @@ var ts; if (fileNames) { for (var _i = 0, fileNames_1 = fileNames; _i < fileNames_1.length; _i++) { var fileName = fileNames_1[_i]; - var file = ts.combinePaths(basePath, fileName); + var file = ts.getNormalizedAbsolutePath(fileName, basePath); literalFileMap.set(keyMapper(file), file); } } @@ -17806,7 +18026,7 @@ var ts; return undefined; } ts.Debug.assert(ts.extensionIsTypeScript(resolved.extension)); - return resolved.path; + return { fileName: resolved.path, packageId: resolved.packageId }; } function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations) { return { @@ -17909,12 +18129,12 @@ var ts; var resolvedTypeReferenceDirective; if (resolved) { if (!options.preserveSymlinks) { - resolved = realPath(resolved, host, traceEnabled); + resolved = __assign({}, resolved, { fileName: realPath(resolved.fileName, host, traceEnabled) }); } if (traceEnabled) { - trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved, primary); + trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolved.fileName, primary); } - resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved }; + resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolved.fileName, packageId: resolved.packageId }; } return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations }; function primaryLookup() { @@ -18211,7 +18431,7 @@ var ts; if (extension !== undefined) { var path_1 = tryFile(candidate, failedLookupLocations, false, state); if (path_1 !== undefined) { - return { path: path_1, extension: extension, packageId: undefined }; + return noPackageId({ path: path_1, ext: extension }); } } return loader(extensions, candidate, failedLookupLocations, !directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state); @@ -18373,31 +18593,40 @@ var ts; } function loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, considerPackageJson) { if (considerPackageJson === void 0) { considerPackageJson = true; } + var _a = considerPackageJson + ? getPackageJsonInfo(candidate, "", failedLookupLocations, onlyRecordFailures, state) + : { packageJsonContent: undefined, packageId: undefined }, packageJsonContent = _a.packageJsonContent, packageId = _a.packageId; + return withPackageId(packageId, loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent)); + } + function loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, packageJsonContent) { + var fromPackageJson = packageJsonContent && loadModuleFromPackageJson(packageJsonContent, extensions, candidate, failedLookupLocations, state); + if (fromPackageJson) { + return fromPackageJson; + } var directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); - var packageId; - if (considerPackageJson) { - var packageJsonPath = pathToPackageJson(candidate); - if (directoryExists && state.host.fileExists(packageJsonPath)) { - if (state.traceEnabled) { - trace(state.host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); - } - var jsonContent = readJson(packageJsonPath, state.host); - if (typeof jsonContent.name === "string" && typeof jsonContent.version === "string") { - packageId = { name: jsonContent.name, version: jsonContent.version }; - } - var fromPackageJson = loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state); - if (fromPackageJson) { - return withPackageId(packageId, fromPackageJson); - } + return loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state); + } + function getPackageJsonInfo(nodeModuleDirectory, subModuleName, failedLookupLocations, onlyRecordFailures, _a) { + var host = _a.host, traceEnabled = _a.traceEnabled; + var directoryExists = !onlyRecordFailures && directoryProbablyExists(nodeModuleDirectory, host); + var packageJsonPath = pathToPackageJson(nodeModuleDirectory); + if (directoryExists && host.fileExists(packageJsonPath)) { + if (traceEnabled) { + trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath); } - else { - if (directoryExists && state.traceEnabled) { - trace(state.host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); - } - failedLookupLocations.push(packageJsonPath); + var packageJsonContent = readJson(packageJsonPath, host); + var packageId = typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string" + ? { name: packageJsonContent.name, subModuleName: subModuleName, version: packageJsonContent.version } + : undefined; + return { packageJsonContent: packageJsonContent, packageId: packageId }; + } + else { + if (directoryExists && traceEnabled) { + trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath); } + failedLookupLocations.push(packageJsonPath); + return { packageJsonContent: undefined, packageId: undefined }; } - return withPackageId(packageId, loadModuleFromFile(extensions, ts.combinePaths(candidate, "index"), failedLookupLocations, !directoryExists, state)); } function loadModuleFromPackageJson(jsonContent, extensions, candidate, failedLookupLocations, state) { var file = tryReadPackageJsonFields(extensions !== Extensions.JavaScript, jsonContent, candidate, state); @@ -18440,9 +18669,20 @@ var ts; return ts.combinePaths(directory, "package.json"); } function loadModuleFromNodeModulesFolder(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, failedLookupLocations, state) { + var _a = getPackageName(moduleName), packageName = _a.packageName, rest = _a.rest; + var packageRootPath = ts.combinePaths(nodeModulesFolder, packageName); + var _b = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state), packageJsonContent = _b.packageJsonContent, packageId = _b.packageId; var candidate = ts.normalizePath(ts.combinePaths(nodeModulesFolder, moduleName)); - return loadModuleFromFileNoPackageId(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || - loadNodeModuleFromDirectory(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state); + var pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || + loadNodeModuleFromDirectoryWorker(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state, packageJsonContent); + return withPackageId(packageId, pathAndExtension); + } + function getPackageName(moduleName) { + var idx = moduleName.indexOf(ts.directorySeparator); + if (moduleName[0] === "@") { + idx = moduleName.indexOf(ts.directorySeparator, idx + 1); + } + return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions, moduleName, directory, failedLookupLocations, state, cache) { return loadModuleFromNodeModulesWorker(extensions, moduleName, directory, failedLookupLocations, state, false, cache); diff --git a/package.json b/package.json index 9e4b3234770..ca7d48c7774 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "devDependencies": { "@types/browserify": "latest", "@types/chai": "latest", + "@types/colors": "latest", "@types/convert-source-map": "latest", "@types/del": "latest", "@types/glob": "latest", @@ -48,8 +49,8 @@ "@types/q": "latest", "@types/run-sequence": "latest", "@types/through2": "latest", - "browserify": "latest", "browser-resolve": "^1.11.2", + "browserify": "latest", "chai": "latest", "convert-source-map": "latest", "del": "latest", @@ -75,6 +76,7 @@ "travis-fold": "latest", "ts-node": "latest", "tslint": "latest", + "colors": "latest", "typescript": "next" }, "scripts": { diff --git a/scripts/tslint/formatters/autolinkableStylishFormatter.ts b/scripts/tslint/formatters/autolinkableStylishFormatter.ts new file mode 100644 index 00000000000..6a02ec24f05 --- /dev/null +++ b/scripts/tslint/formatters/autolinkableStylishFormatter.ts @@ -0,0 +1,97 @@ +import * as Lint from "tslint"; +import * as colors from "colors"; +import { sep } from "path"; +function groupBy(array: ReadonlyArray | undefined, getGroupId: (elem: T, index: number) => number | string): T[][] { + if (!array) { + return []; + } + + const groupIdToGroup: { [index: string]: T[] } = {}; + let result: T[][] | undefined; // Compacted array for return value + for (let index = 0; index < array.length; index++) { + const value = array[index]; + const key = getGroupId(value, index); + if (groupIdToGroup[key]) { + groupIdToGroup[key].push(value); + } + else { + const newGroup = [value]; + groupIdToGroup[key] = newGroup; + if (!result) { + result = [newGroup]; + } + else { + result.push(newGroup); + } + } + } + + return result || []; +} + +function max(array: ReadonlyArray | undefined, selector: (elem: T) => number): number { + if (!array) { + return 0; + } + + let max = 0; + for (const item of array) { + const scalar = selector(item); + if (scalar > max) { + max = scalar; + } + } + return max; +} + +function getLink(failure: Lint.RuleFailure, color: boolean): string { + const lineAndCharacter = failure.getStartPosition().getLineAndCharacter(); + const sev = failure.getRuleSeverity().toUpperCase(); + let path = failure.getFileName(); + // Most autolinks only become clickable if they contain a slash in some way; so we make a top level file into a relative path here + if (path.indexOf("/") === -1 && path.indexOf("\\") === -1) { + path = `.${sep}${path}`; + } + return `${color ? (sev === "WARNING" ? colors.blue(sev) : colors.red(sev)) : sev}: ${path}:${lineAndCharacter.line + 1}:${lineAndCharacter.character + 1}`; +} + +function getLinkMaxSize(failures: Lint.RuleFailure[]): number { + return max(failures, f => getLink(f, /*color*/ false).length); +} + +function getNameMaxSize(failures: Lint.RuleFailure[]): number { + return max(failures, f => f.getRuleName().length); +} + +function pad(str: string, visiblelen: number, len: number) { + if (visiblelen >= len) return str; + const count = len - visiblelen; + for (let i = 0; i < count; i++) { + str += " "; + } + return str; +} + +export class Formatter extends Lint.Formatters.AbstractFormatter { + public static metadata: Lint.IFormatterMetadata = { + formatterName: "autolinkableStylish", + description: "Human-readable formatter which creates stylish messages with autolinkable filepaths.", + descriptionDetails: Lint.Utils.dedent` + Colorized output grouped by file, with autolinkable filepaths containing line and column information + `, + sample: Lint.Utils.dedent` + src/myFile.ts + ERROR: src/myFile.ts:1:14 semicolon Missing semicolon`, + consumer: "human" + }; + public format(failures: Lint.RuleFailure[]): string { + return groupBy(failures, f => f.getFileName()).map(group => { + const currentFile = group[0].getFileName(); + const linkMaxSize = getLinkMaxSize(group); + const nameMaxSize = getNameMaxSize(group); + return ` +${currentFile} +${group.map(f => `${pad(getLink(f, /*color*/ true), getLink(f, /*color*/ false).length, linkMaxSize)} ${colors.grey(pad(f.getRuleName(), f.getRuleName().length, nameMaxSize))} ${colors.yellow(f.getFailure())}`).join("\n")}`; + }).join("\n"); + } +} \ No newline at end of file diff --git a/scripts/tslint/booleanTriviaRule.ts b/scripts/tslint/rules/booleanTriviaRule.ts similarity index 100% rename from scripts/tslint/booleanTriviaRule.ts rename to scripts/tslint/rules/booleanTriviaRule.ts diff --git a/scripts/tslint/debugAssertRule.ts b/scripts/tslint/rules/debugAssertRule.ts similarity index 100% rename from scripts/tslint/debugAssertRule.ts rename to scripts/tslint/rules/debugAssertRule.ts diff --git a/scripts/tslint/nextLineRule.ts b/scripts/tslint/rules/nextLineRule.ts similarity index 100% rename from scripts/tslint/nextLineRule.ts rename to scripts/tslint/rules/nextLineRule.ts diff --git a/scripts/tslint/noBomRule.ts b/scripts/tslint/rules/noBomRule.ts similarity index 100% rename from scripts/tslint/noBomRule.ts rename to scripts/tslint/rules/noBomRule.ts diff --git a/scripts/tslint/noInOperatorRule.ts b/scripts/tslint/rules/noInOperatorRule.ts similarity index 100% rename from scripts/tslint/noInOperatorRule.ts rename to scripts/tslint/rules/noInOperatorRule.ts diff --git a/scripts/tslint/noIncrementDecrementRule.ts b/scripts/tslint/rules/noIncrementDecrementRule.ts similarity index 100% rename from scripts/tslint/noIncrementDecrementRule.ts rename to scripts/tslint/rules/noIncrementDecrementRule.ts diff --git a/scripts/tslint/noTypeAssertionWhitespaceRule.ts b/scripts/tslint/rules/noTypeAssertionWhitespaceRule.ts similarity index 100% rename from scripts/tslint/noTypeAssertionWhitespaceRule.ts rename to scripts/tslint/rules/noTypeAssertionWhitespaceRule.ts diff --git a/scripts/tslint/objectLiteralSurroundingSpaceRule.ts b/scripts/tslint/rules/objectLiteralSurroundingSpaceRule.ts similarity index 100% rename from scripts/tslint/objectLiteralSurroundingSpaceRule.ts rename to scripts/tslint/rules/objectLiteralSurroundingSpaceRule.ts diff --git a/scripts/tslint/typeOperatorSpacingRule.ts b/scripts/tslint/rules/typeOperatorSpacingRule.ts similarity index 100% rename from scripts/tslint/typeOperatorSpacingRule.ts rename to scripts/tslint/rules/typeOperatorSpacingRule.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 97e60777159..70141c853ca 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1456,11 +1456,6 @@ namespace ts { } function declareSymbolAndAddToSymbolTable(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { - // Just call this directly so that the return type of this function stays "void". - return declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes); - } - - function declareSymbolAndAddToSymbolTableWorker(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags): Symbol { switch (container.kind) { // Modules, source files, and classes need specialized handling for how their // members are declared (for example, a member of a class will go into a specific @@ -1683,6 +1678,9 @@ namespace ts { function bindAnonymousDeclaration(node: Declaration, symbolFlags: SymbolFlags, name: __String) { const symbol = createSymbol(symbolFlags, name); + if (symbolFlags & SymbolFlags.EnumMember) { + symbol.parent = container.symbol; + } addDeclarationToSymbol(symbol, node, symbolFlags); } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ceb9d70847f..de1b28f6a56 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1765,13 +1765,13 @@ namespace ts { } // May be an untyped module. If so, ignore resolutionDiagnostic. - if (resolvedModule && resolvedModule.isExternalLibraryImport && !extensionIsTypeScript(resolvedModule.extension)) { + if (resolvedModule && !extensionIsTypeScript(resolvedModule.extension) && resolutionDiagnostic === undefined || resolutionDiagnostic === Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type) { if (isForAugmentation) { const diag = Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } else if (noImplicitAny && moduleNotFoundError) { - let errorInfo = chainDiagnosticMessages(/*details*/ undefined, + let errorInfo = !resolvedModule.isExternalLibraryImport ? undefined : chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); errorInfo = chainDiagnosticMessages(errorInfo, @@ -2431,15 +2431,6 @@ namespace ts { } }; - interface NodeBuilderContext { - enclosingDeclaration: Node | undefined; - flags: NodeBuilderFlags | undefined; - - // State - encounteredError: boolean; - symbolStack: Symbol[] | undefined; - } - function createNodeBuilderContext(enclosingDeclaration: Node | undefined, flags: NodeBuilderFlags | undefined): NodeBuilderContext { return { enclosingDeclaration, @@ -3033,30 +3024,6 @@ namespace ts { } } } - - function getNameOfSymbol(symbol: Symbol, context: NodeBuilderContext): string { - const declaration = firstOrUndefined(symbol.declarations); - if (declaration) { - const name = getNameOfDeclaration(declaration); - if (name) { - return declarationNameToString(name); - } - if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { - return declarationNameToString((declaration.parent).name); - } - if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowAnonymousIdentifier)) { - context.encounteredError = true; - } - switch (declaration.kind) { - case SyntaxKind.ClassExpression: - return "(Anonymous class)"; - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - return "(Anonymous function)"; - } - } - return unescapeLeadingUnderscores(symbol.escapedName); - } } function typePredicateToString(typePredicate: TypePredicate, enclosingDeclaration?: Declaration, flags?: TypeFormatFlags): string { @@ -3121,7 +3088,16 @@ namespace ts { return type.flags & TypeFlags.StringLiteral ? '"' + escapeString((type).value) + '"' : "" + (type).value; } - function getNameOfSymbol(symbol: Symbol): string { + interface NodeBuilderContext { + enclosingDeclaration: Node | undefined; + flags: NodeBuilderFlags | undefined; + + // State + encounteredError: boolean; + symbolStack: Symbol[] | undefined; + } + + function getNameOfSymbol(symbol: Symbol, context?: NodeBuilderContext): string { if (symbol.declarations && symbol.declarations.length) { const declaration = symbol.declarations[0]; const name = getNameOfDeclaration(declaration); @@ -3131,6 +3107,9 @@ namespace ts { if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { return declarationNameToString((declaration.parent).name); } + if (context && !context.encounteredError && !(context.flags & NodeBuilderFlags.AllowAnonymousIdentifier)) { + context.encounteredError = true; + } switch (declaration.kind) { case SyntaxKind.ClassExpression: return "(Anonymous class)"; @@ -4909,7 +4888,16 @@ namespace ts { } function getBaseTypeNodeOfClass(type: InterfaceType): ExpressionWithTypeArguments { - return getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); + const decl = type.symbol.valueDeclaration; + if (isInJavaScriptFile(decl)) { + // Prefer an @augments tag because it may have type parameters. + const tag = getJSDocAugmentsTag(decl); + if (tag) { + return tag.class; + } + } + + return getClassExtendsHeritageClauseElement(decl); } function getConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray, location: Node): Signature[] { @@ -4922,7 +4910,7 @@ namespace ts { function getInstantiatedConstructorsForTypeArguments(type: Type, typeArgumentNodes: ReadonlyArray, location: Node): Signature[] { const signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); const typeArguments = map(typeArgumentNodes, getTypeFromTypeNode); - return sameMap(signatures, sig => some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments) : sig); + return sameMap(signatures, sig => some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, isInJavaScriptFile(location)) : sig); } /** @@ -5013,15 +5001,6 @@ namespace ts { baseType = getReturnTypeOfSignature(constructors[0]); } - // In a JS file, you can use the @augments jsdoc tag to specify a base type with type parameters - const valueDecl = type.symbol.valueDeclaration; - if (valueDecl && isInJavaScriptFile(valueDecl)) { - const augTag = getJSDocAugmentsTag(type.symbol.valueDeclaration); - if (augTag) { - baseType = getTypeFromTypeNode(augTag.typeExpression.type); - } - } - if (baseType === unknownType) { return; } @@ -5030,7 +5009,7 @@ namespace ts { return; } if (type === baseType || hasBaseType(baseType, type)) { - error(valueDecl, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, + error(type.symbol.valueDeclaration, Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, /*enclosingDeclaration*/ undefined, TypeFormatFlags.WriteArrayAsGenericType)); return; } @@ -5151,7 +5130,9 @@ namespace ts { const declaration = find(symbol.declarations, d => d.kind === SyntaxKind.JSDocTypedefTag || d.kind === SyntaxKind.TypeAliasDeclaration); - let type = getTypeFromTypeNode(declaration.kind === SyntaxKind.JSDocTypedefTag ? declaration.typeExpression : declaration.type); + const typeNode = declaration.kind === SyntaxKind.JSDocTypedefTag ? declaration.typeExpression : declaration.type; + // If typeNode is missing, we will error in checkJSDocTypedefTag. + let type = typeNode ? getTypeFromTypeNode(typeNode) : unknownType; if (popTypeResolution()) { const typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); @@ -5277,6 +5258,10 @@ namespace ts { } function getDeclaredTypeOfSymbol(symbol: Symbol): Type { + return tryGetDeclaredTypeOfSymbol(symbol) || unknownType; + } + + function tryGetDeclaredTypeOfSymbol(symbol: Symbol): Type | undefined { if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { return getDeclaredTypeOfClassOrInterface(symbol); } @@ -5295,7 +5280,7 @@ namespace ts { if (symbol.flags & SymbolFlags.Alias) { return getDeclaredTypeOfAlias(symbol); } - return unknownType; + return undefined; } // A type reference is considered independent if each type argument is considered independent. @@ -5518,7 +5503,7 @@ namespace ts { const minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); const typeParamCount = length(baseSig.typeParameters); if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { - const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); + const sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -6377,11 +6362,10 @@ namespace ts { * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, location?: Node) { + function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript: boolean) { const numTypeParameters = length(typeParameters); if (numTypeParameters) { const numTypeArguments = length(typeArguments); - const isJavaScript = isInJavaScriptFile(location); if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; @@ -6639,8 +6623,8 @@ namespace ts { return anyType; } - function getSignatureInstantiation(signature: Signature, typeArguments: Type[]): Signature { - typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters)); + function getSignatureInstantiation(signature: Signature, typeArguments: Type[], isJavascript: boolean): Signature { + typeArguments = fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript); const instantiations = signature.instantiations || (signature.instantiations = createMap()); const id = getTypeListId(typeArguments); let instantiation = instantiations.get(id); @@ -6678,7 +6662,10 @@ namespace ts { // where different generations of the same type parameter are in scope). This leads to a lot of new type // identities, and potentially a lot of work comparing those identities, so here we create an instantiation // that uses the original type identities for all unconstrained type parameters. - return getSignatureInstantiation(signature, map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp)); + return getSignatureInstantiation( + signature, + map(signature.typeParameters, tp => tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp), + isInJavaScriptFile(signature.declaration)); } function getOrCreateTypeFromSignature(signature: Signature): ObjectType { @@ -6829,7 +6816,8 @@ namespace ts { if (typeParameters) { const numTypeArguments = length(node.typeArguments); const minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (!isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { + const isJavascript = isInJavaScriptFile(node); + if (!isJavascript && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? Diagnostics.Generic_type_0_requires_1_type_argument_s @@ -6842,7 +6830,7 @@ namespace ts { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); + const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, isJavascript)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -6859,7 +6847,7 @@ namespace ts { const id = getTypeListId(typeArguments); let instantiation = links.instantiations.get(id); if (!instantiation) { - links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters))))); + links.instantiations.set(id, instantiation = instantiateType(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), isInJavaScriptFile(symbol.valueDeclaration))))); } return instantiation; } @@ -6894,17 +6882,6 @@ namespace ts { return type; } - /** - * Get type from reference to named type that cannot be generic (enum or type parameter) - */ - function getTypeFromNonGenericTypeReference(node: TypeReferenceType, symbol: Symbol): Type { - if (node.typeArguments) { - error(node, Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); - return unknownType; - } - return getDeclaredTypeOfSymbol(symbol); - } - function getTypeReferenceName(node: TypeReferenceType): EntityNameOrEntityNameExpression | undefined { switch (node.kind) { case SyntaxKind.TypeReference: @@ -6941,24 +6918,34 @@ namespace ts { return type; } - if (symbol.flags & SymbolFlags.Value && isJSDocTypeReference(node)) { - // A jsdoc TypeReference may have resolved to a value (as opposed to a type). If - // the symbol is a constructor function, return the inferred class type; otherwise, - // the type of this reference is just the type of the value we resolved to. - const valueType = getTypeOfSymbol(symbol); - if (valueType.symbol && !isInferredClassType(valueType)) { - const referenceType = getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments); - if (referenceType) { - return referenceType; - } + // Get type from reference to named type that cannot be generic (enum or type parameter) + const res = tryGetDeclaredTypeOfSymbol(symbol); + if (res !== undefined) { + if (typeArguments) { + error(node, Diagnostics.Type_0_is_not_generic, symbolToString(symbol)); + return unknownType; } - - // Resolve the type reference as a Type for the purpose of reporting errors. - resolveTypeReferenceName(getTypeReferenceName(node), SymbolFlags.Type); - return valueType; + return res; } - return getTypeFromNonGenericTypeReference(node, symbol); + if (!(symbol.flags & SymbolFlags.Value && isJSDocTypeReference(node))) { + return unknownType; + } + + // A jsdoc TypeReference may have resolved to a value (as opposed to a type). If + // the symbol is a constructor function, return the inferred class type; otherwise, + // the type of this reference is just the type of the value we resolved to. + const valueType = getTypeOfSymbol(symbol); + if (valueType.symbol && !isInferredClassType(valueType)) { + const referenceType = getTypeReferenceTypeWorker(node, valueType.symbol, typeArguments); + if (referenceType) { + return referenceType; + } + } + + // Resolve the type reference as a Type for the purpose of reporting errors. + resolveTypeReferenceName(getTypeReferenceName(node), SymbolFlags.Type); + return valueType; } function getTypeReferenceTypeWorker(node: TypeReferenceType, symbol: Symbol, typeArguments: Type[]): Type | undefined { @@ -13337,16 +13324,11 @@ namespace ts { // the type of the property with the numeric name N in T, if one exists. Otherwise, if T has a numeric index signature, // it is the type of the numeric index signature in T. Otherwise, in ES6 and higher, the contextual type is the iterated // type of T. - function getContextualTypeForElementExpression(node: Expression): Type { - const arrayLiteral = node.parent; - const type = getApparentTypeOfContextualType(arrayLiteral); - if (type) { - const index = indexOf(arrayLiteral.elements, node); - return getTypeOfPropertyOfContextualType(type, "" + index as __String) - || getIndexTypeOfContextualType(type, IndexKind.Number) - || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false); - } - return undefined; + function getContextualTypeForElementExpression(arrayContextualType: Type | undefined, index: number): Type | undefined { + return arrayContextualType && ( + getTypeOfPropertyOfContextualType(arrayContextualType, "" + index as __String) + || getIndexTypeOfContextualType(arrayContextualType, IndexKind.Number) + || getIteratedTypeOrElementType(arrayContextualType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterables*/ false, /*checkAssignability*/ false)); } // In a contextually typed conditional expression, the true/false expressions are contextually typed by the same type. @@ -13460,15 +13442,21 @@ namespace ts { return getContextualTypeForObjectLiteralElement(parent); case SyntaxKind.SpreadAssignment: return getApparentTypeOfContextualType(parent.parent as ObjectLiteralExpression); - case SyntaxKind.ArrayLiteralExpression: - return getContextualTypeForElementExpression(node); + case SyntaxKind.ArrayLiteralExpression: { + const arrayLiteral = parent; + const type = getApparentTypeOfContextualType(arrayLiteral); + return getContextualTypeForElementExpression(type, indexOfNode(arrayLiteral.elements, node)); + } case SyntaxKind.ConditionalExpression: return getContextualTypeForConditionalOperand(node); case SyntaxKind.TemplateSpan: Debug.assert(parent.parent.kind === SyntaxKind.TemplateExpression); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case SyntaxKind.ParenthesizedExpression: - return getContextualType(parent); + case SyntaxKind.ParenthesizedExpression: { + // Like in `checkParenthesizedExpression`, an `/** @type {xyz} */` comment before a parenthesized expression acts as a type cast. + const tag = isInJavaScriptFile(parent) ? getJSDocTypeTag(parent) : undefined; + return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent); + } case SyntaxKind.JsxExpression: return getContextualTypeForJsxExpression(parent); case SyntaxKind.JsxAttribute: @@ -13590,12 +13578,14 @@ namespace ts { (node.kind === SyntaxKind.BinaryExpression && (node).operatorToken.kind === SyntaxKind.EqualsToken); } - function checkArrayLiteral(node: ArrayLiteralExpression, checkMode?: CheckMode): Type { + function checkArrayLiteral(node: ArrayLiteralExpression, checkMode: CheckMode | undefined): Type { const elements = node.elements; let hasSpreadElement = false; const elementTypes: Type[] = []; const inDestructuringPattern = isAssignmentTarget(node); - for (const e of elements) { + const contextualType = getApparentTypeOfContextualType(node); + for (let index = 0; index < elements.length; index++) { + const e = elements[index]; if (inDestructuringPattern && e.kind === SyntaxKind.SpreadElement) { // Given the following situation: // var c: {}; @@ -13617,7 +13607,8 @@ namespace ts { } } else { - const type = checkExpressionForMutableLocation(e, checkMode); + const elementContextualType = getContextualTypeForElementExpression(contextualType, index); + const type = checkExpressionForMutableLocation(e, checkMode, elementContextualType); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElement; @@ -14196,8 +14187,9 @@ namespace ts { const instantiatedSignatures = []; for (const signature of signatures) { if (signature.typeParameters) { - const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0); - instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + const isJavascript = isInJavaScriptFile(node); + const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0, isJavascript); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments, isJavascript)); } else { instantiatedSignatures.push(signature); @@ -14726,7 +14718,7 @@ namespace ts { if (node.expression) { const type = checkExpression(node.expression, checkMode); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { - error(node, Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); + error(node, Diagnostics.JSX_spread_child_must_be_an_array_type); } return type; } @@ -15467,7 +15459,7 @@ namespace ts { if (!contextualMapper) { inferTypes(context.inferences, getReturnTypeOfSignature(contextualSignature), getReturnTypeOfSignature(signature), InferencePriority.ReturnType); } - return getSignatureInstantiation(signature, getInferredTypes(context)); + return getSignatureInstantiation(signature, getInferredTypes(context), isInJavaScriptFile(contextualSignature.declaration)); } function inferTypeArguments(node: CallLikeExpression, signature: Signature, args: ReadonlyArray, excludeArgument: boolean[], context: InferenceContext): Type[] { @@ -15502,7 +15494,7 @@ namespace ts { // Above, the type of the 'value' parameter is inferred to be 'A'. const contextualSignature = getSingleCallSignature(instantiatedType); const inferenceSourceType = contextualSignature && contextualSignature.typeParameters ? - getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters)) : + getOrCreateTypeFromSignature(getSignatureInstantiation(contextualSignature, contextualSignature.typeParameters, isInJavaScriptFile(node))) : instantiatedType; const inferenceTargetType = getReturnTypeOfSignature(signature); // Inferences made from return types have lower priority than all other inferences. @@ -16218,8 +16210,9 @@ namespace ts { candidate = originalCandidate; if (candidate.typeParameters) { let typeArgumentTypes: Type[]; + const isJavascript = isInJavaScriptFile(candidate.declaration); if (typeArguments) { - typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters)); + typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript); if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) { candidateForTypeArgumentError = originalCandidate; break; @@ -16228,7 +16221,7 @@ namespace ts { else { typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext); } - candidate = getSignatureInstantiation(candidate, typeArgumentTypes); + candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript); } if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { candidateForArgumentError = candidate; @@ -16645,7 +16638,7 @@ namespace ts { // If the symbol of the node has members, treat it like a constructor. const symbol = isFunctionDeclaration(node) || isFunctionExpression(node) ? getSymbolOfNode(node) : - isVariableDeclaration(node) && isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : + isVariableDeclaration(node) && node.initializer && isFunctionExpression(node.initializer) ? getSymbolOfNode(node.initializer) : undefined; return symbol && symbol.members !== undefined; @@ -18160,9 +18153,13 @@ namespace ts { return false; } - function checkExpressionForMutableLocation(node: Expression, checkMode?: CheckMode): Type { + function checkExpressionForMutableLocation(node: Expression, checkMode: CheckMode, contextualType?: Type): Type { + if (arguments.length === 2) { + contextualType = getContextualType(node); + } const type = checkExpression(node, checkMode); - return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); + const shouldWiden = isTypeAssertion(node) || isLiteralContextualType(contextualType); + return shouldWiden ? type : getWidenedLiteralType(type); } function checkPropertyAssignment(node: PropertyAssignment, checkMode?: CheckMode): Type { @@ -18280,13 +18277,9 @@ namespace ts { } function checkParenthesizedExpression(node: ParenthesizedExpression, checkMode?: CheckMode): Type { - if (isInJavaScriptFile(node) && node.jsDoc) { - const typecasts = flatMap(node.jsDoc, doc => filter(doc.tags, tag => tag.kind === SyntaxKind.JSDocTypeTag && !!(tag as JSDocTypeTag).typeExpression && !!(tag as JSDocTypeTag).typeExpression.type)); - if (typecasts && typecasts.length) { - // We should have already issued an error if there were multiple type jsdocs - const cast = typecasts[0] as JSDocTypeTag; - return checkAssertionWorker(cast, cast.typeExpression.type, node.expression, checkMode); - } + const tag = isInJavaScriptFile(node) ? getJSDocTypeTag(node) : undefined; + if (tag) { + return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode); } return checkExpression(node.expression, checkMode); } @@ -18992,7 +18985,7 @@ namespace ts { const constraint = getConstraintOfTypeParameter(typeParameters[i]); if (constraint) { if (!typeArguments) { - typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount); + typeArguments = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, isInJavaScriptFile(typeArgumentNodes[i])); mapper = createTypeMapper(typeParameters, typeArguments); } const typeArgument = typeArguments[i]; @@ -19426,10 +19419,11 @@ namespace ts { : DeclarationSpaces.ExportNamespace; case SyntaxKind.ClassDeclaration: case SyntaxKind.EnumDeclaration: - // A NamespaceImport declares an Alias, which is allowed to merge with other values within the module - case SyntaxKind.NamespaceImport: return DeclarationSpaces.ExportType | DeclarationSpaces.ExportValue; + // The below options all declare an Alias, which is allowed to merge with other values within the importing module case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.NamespaceImport: + case SyntaxKind.ImportClause: let result = DeclarationSpaces.None; const target = resolveAlias(getSymbolOfNode(d)); forEach(target.declarations, d => { result |= getDeclarationSpaces(d); }); @@ -19933,23 +19927,55 @@ namespace ts { } } - function checkJSDoc(node: FunctionDeclaration | MethodDeclaration) { - if (!isInJavaScriptFile(node)) { - return; + function checkJSDocTypedefTag(node: JSDocTypedefTag) { + if (!node.typeExpression) { + // If the node had `@property` tags, `typeExpression` would have been set to the first property tag. + error(node.name, Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags); } - forEach(node.jsDoc, checkSourceElement); } - function checkJSDocComment(node: JSDoc) { - if ((node as JSDoc).tags) { - for (const tag of (node as JSDoc).tags) { - checkSourceElement(tag); + function checkJSDocParameterTag(node: JSDocParameterTag) { + checkSourceElement(node.typeExpression); + if (!getParameterSymbolFromJSDoc(node)) { + error(node.name, + Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, + unescapeLeadingUnderscores((node.name.kind === SyntaxKind.QualifiedName ? node.name.right : node.name).escapedText)); + } + } + + function checkJSDocAugmentsTag(node: JSDocAugmentsTag): void { + const cls = getJSDocHost(node); + if (!isClassDeclaration(cls) && !isClassExpression(cls)) { + error(cls, Diagnostics.JSDoc_augments_is_not_attached_to_a_class_declaration); + return; + } + + const name = getIdentifierFromEntityNameExpression(node.class.expression); + const extend = getClassExtendsHeritageClauseElement(cls); + if (extend) { + const className = getIdentifierFromEntityNameExpression(extend.expression); + if (className && name.escapedText !== className.escapedText) { + error(name, Diagnostics.JSDoc_augments_0_does_not_match_the_extends_1_clause, + unescapeLeadingUnderscores(name.escapedText), + unescapeLeadingUnderscores(className.escapedText)); } } } + function getIdentifierFromEntityNameExpression(node: Identifier | PropertyAccessExpression): Identifier; + function getIdentifierFromEntityNameExpression(node: Expression): Identifier | undefined; + function getIdentifierFromEntityNameExpression(node: Expression): Identifier | undefined { + switch (node.kind) { + case SyntaxKind.Identifier: + return node as Identifier; + case SyntaxKind.PropertyAccessExpression: + return (node as PropertyAccessExpression).name; + default: + return undefined; + } + } + function checkFunctionOrMethodDeclaration(node: FunctionDeclaration | MethodDeclaration): void { - checkJSDoc(node); checkDecorators(node); checkSignatureDeclaration(node); const functionFlags = getFunctionFlags(node); @@ -20110,7 +20136,8 @@ namespace ts { const node = getNameOfDeclaration(declaration) || declaration; if (isIdentifierThatStartsWithUnderScore(node)) { const declaration = getRootDeclaration(node.parent); - if (declaration.kind === SyntaxKind.VariableDeclaration && isForInOrOfStatement(declaration.parent.parent)) { + if ((declaration.kind === SyntaxKind.VariableDeclaration && isForInOrOfStatement(declaration.parent.parent)) || + declaration.kind === SyntaxKind.TypeParameter) { return; } } @@ -20160,7 +20187,7 @@ namespace ts { return; } for (const typeParameter of node.typeParameters) { - if (!getMergedSymbol(typeParameter.symbol).isReferenced) { + if (!getMergedSymbol(typeParameter.symbol).isReferenced && !isIdentifierThatStartsWithUnderScore(typeParameter.name)) { error(typeParameter.name, Diagnostics._0_is_declared_but_its_value_is_never_read, unescapeLeadingUnderscores(typeParameter.symbol.escapedName)); } } @@ -22582,6 +22609,12 @@ namespace ts { return; } + if (isInJavaScriptFile(node) && (node as JSDocContainer).jsDoc) { + for (const { tags } of (node as JSDocContainer).jsDoc) { + forEach(tags, checkSourceElement); + } + } + const kind = node.kind; if (cancellationToken) { // Only bother checking on a few construct kinds. We don't want to be excessively @@ -22636,10 +22669,12 @@ namespace ts { case SyntaxKind.ParenthesizedType: case SyntaxKind.TypeOperator: return checkSourceElement((node).type); - case SyntaxKind.JSDocComment: - return checkJSDocComment(node as JSDoc); + case SyntaxKind.JSDocAugmentsTag: + return checkJSDocAugmentsTag(node as JSDocAugmentsTag); + case SyntaxKind.JSDocTypedefTag: + return checkJSDocTypedefTag(node as JSDocTypedefTag); case SyntaxKind.JSDocParameterTag: - return checkSourceElement((node as JSDocParameterTag).typeExpression); + return checkJSDocParameterTag(node as JSDocParameterTag); case SyntaxKind.JSDocFunctionType: checkSignatureDeclaration(node as JSDocFunctionType); // falls through diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f5e2a4069e4..ffa010c6551 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -994,11 +994,6 @@ namespace ts { /** * Gets the owned, enumerable property keys of a map-like. - * - * NOTE: This is intended for use with MapLike objects. For Map objects, use - * Object.keys instead as it offers better performance. - * - * @param map A map-like. */ export function getOwnKeys(map: MapLike): string[] { const keys: string[] = []; @@ -1011,6 +1006,17 @@ namespace ts { return keys; } + export function getOwnValues(sparseArray: T[]): T[] { + const values: T[] = []; + for (const key in sparseArray) { + if (hasOwnProperty.call(sparseArray, key)) { + values.push(sparseArray[key]); + } + } + + return values; + } + /** Shims `Array.from`. */ export function arrayFrom(iterator: Iterator, map: (t: T) => U): U[]; export function arrayFrom(iterator: Iterator): T[]; @@ -1659,7 +1665,7 @@ namespace ts { } export function isRootedDiskPath(path: string) { - return getRootLength(path) !== 0; + return path && getRootLength(path) !== 0; } export function convertToRelativePath(absoluteOrRelativePath: string, basePath: string, getCanonicalFileName: (path: string) => string): string { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 3a9857e09ea..854d09761cd 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2686,7 +2686,7 @@ "category": "Message", "code": 6015 }, - "Specify module code generation: 'none', commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.": { + "Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.": { "category": "Message", "code": 6016 }, @@ -3146,10 +3146,6 @@ "category": "Error", "code": 6142 }, - "Module '{0}' was resolved to '{1}', but '--allowJs' is not set.": { - "category": "Error", - "code": 6143 - }, "Module '{0}' was resolved as locally declared ambient module in file '{1}'.": { "category": "Message", "code": 6144 @@ -3515,6 +3511,22 @@ "category": "Error", "code": 8020 }, + "JSDoc '@typedef' tag should either have a type annotation or be followed by '@property' or '@member' tags.": { + "category": "Error", + "code": 8021 + }, + "JSDoc '@augments' is not attached to a class declaration.": { + "category": "Error", + "code": 8022 + }, + "JSDoc '@augments {0}' does not match the 'extends {1}' clause.": { + "category": "Error", + "code": 8023 + }, + "JSDoc '@param' tag has name '{0}', but there is no parameter with that name.": { + "category": "Error", + "code": 8024 + }, "Only identifiers/qualified-names with optional type arguments are currently supported in a class 'extends' clause.": { "category": "Error", "code": 9002 @@ -3693,6 +3705,10 @@ "category": "Message", "code": 90026 }, + "Declare static property '{0}'.": { + "category": "Message", + "code": 90027 + }, "Convert function to an ES2015 class": { "category": "Message", @@ -3703,7 +3719,7 @@ "code": 95002 }, - "Extract function": { + "Extract symbol": { "category": "Message", "code": 95003 }, @@ -3711,5 +3727,15 @@ "Extract to {0}": { "category": "Message", "code": 95004 + }, + + "Extract function": { + "category": "Message", + "code": 95005 + }, + + "Extract constant": { + "category": "Message", + "code": 95006 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts old mode 100644 new mode 100755 index 2c6eef3672f..d458e7e5ef5 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1440,29 +1440,18 @@ namespace ts { // function emitBlock(node: Block) { - if (isSingleLineEmptyBlock(node)) { - writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); - write(" "); - writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); - } - else { - writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); - emitBlockStatements(node); - // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted - increaseIndent(); - emitLeadingCommentsOfPosition(node.statements.end); - decreaseIndent(); - writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); - } + writeToken(SyntaxKind.OpenBraceToken, node.pos, /*contextNode*/ node); + emitBlockStatements(node, /*forceSingleLine*/ !node.multiLine && isEmptyBlock(node)); + // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted + increaseIndent(); + emitLeadingCommentsOfPosition(node.statements.end); + decreaseIndent(); + writeToken(SyntaxKind.CloseBraceToken, node.statements.end, /*contextNode*/ node); } - function emitBlockStatements(node: BlockLike) { - if (getEmitFlags(node) & EmitFlags.SingleLine) { - emitList(node, node.statements, ListFormat.SingleLineBlockStatements); - } - else { - emitList(node, node.statements, ListFormat.MultiLineBlockStatements); - } + function emitBlockStatements(node: BlockLike, forceSingleLine: boolean) { + const format = forceSingleLine || getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineBlockStatements : ListFormat.MultiLineBlockStatements; + emitList(node, node.statements, format); } function emitVariableStatement(node: VariableStatement) { @@ -1874,7 +1863,9 @@ namespace ts { function emitModuleDeclaration(node: ModuleDeclaration) { emitModifiers(node, node.modifiers); - write(node.flags & NodeFlags.Namespace ? "namespace " : "module "); + if (~node.flags & NodeFlags.GlobalAugmentation) { + write(node.flags & NodeFlags.Namespace ? "namespace " : "module "); + } emit(node.name); let body = node.body; @@ -1889,16 +1880,11 @@ namespace ts { } function emitModuleBlock(node: ModuleBlock) { - if (isEmptyBlock(node)) { - write("{ }"); - } - else { - pushNameGenerationScope(); - write("{"); - emitBlockStatements(node); - write("}"); - popNameGenerationScope(); - } + pushNameGenerationScope(); + write("{"); + emitBlockStatements(node, /*forceSingleLine*/ isEmptyBlock(node)); + write("}"); + popNameGenerationScope(); } function emitCaseBlock(node: CaseBlock) { @@ -2762,11 +2748,6 @@ namespace ts { && !rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile); } - function isSingleLineEmptyBlock(block: Block) { - return !block.multiLine - && isEmptyBlock(block); - } - function isEmptyBlock(block: BlockLike) { return block.statements.length === 0 && rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 7252a9f0c1d..2ba2408225e 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -1207,6 +1207,30 @@ namespace ts { : node; } + export function createTemplateHead(text: string) { + const node = createSynthesizedNode(SyntaxKind.TemplateHead); + node.text = text; + return node; + } + + export function createTemplateMiddle(text: string) { + const node = createSynthesizedNode(SyntaxKind.TemplateMiddle); + node.text = text; + return node; + } + + export function createTemplateTail(text: string) { + const node = createSynthesizedNode(SyntaxKind.TemplateTail); + node.text = text; + return node; + } + + export function createNoSubstitutionTemplateLiteral(text: string) { + const node = createSynthesizedNode(SyntaxKind.NoSubstitutionTemplateLiteral); + node.text = text; + return node; + } + export function createYield(expression?: Expression): YieldExpression; export function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; export function createYield(asteriskTokenOrExpression?: AsteriskToken | Expression, expression?: Expression) { @@ -3941,11 +3965,10 @@ namespace ts { return recreateOuterExpressions(expression, mutableCall, OuterExpressionKinds.PartiallyEmittedExpressions); } } - else { - const leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === SyntaxKind.ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind.FunctionExpression) { - return setTextRange(createParen(expression), expression); - } + + const leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; + if (leftmostExpressionKind === SyntaxKind.ObjectLiteralExpression || leftmostExpressionKind === SyntaxKind.FunctionExpression) { + return setTextRange(createParen(expression), expression); } return expression; diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index ddffe876d80..84256b3a1b1 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -976,8 +976,8 @@ namespace ts { } function loadModuleFromNodeModulesFolder(extensions: Extensions, moduleName: string, nodeModulesFolder: string, nodeModulesFolderExists: boolean, failedLookupLocations: Push, state: ModuleResolutionState): Resolved | undefined { - const { top, rest } = getNameOfTopDirectory(moduleName); - const packageRootPath = combinePaths(nodeModulesFolder, top); + const { packageName, rest } = getPackageName(moduleName); + const packageRootPath = combinePaths(nodeModulesFolder, packageName); const { packageJsonContent, packageId } = getPackageJsonInfo(packageRootPath, rest, failedLookupLocations, !nodeModulesFolderExists, state); const candidate = normalizePath(combinePaths(nodeModulesFolder, moduleName)); const pathAndExtension = loadModuleFromFile(extensions, candidate, failedLookupLocations, !nodeModulesFolderExists, state) || @@ -985,9 +985,12 @@ namespace ts { return withPackageId(packageId, pathAndExtension); } - function getNameOfTopDirectory(name: string): { top: string, rest: string } { - const idx = name.indexOf(directorySeparator); - return idx === -1 ? { top: name, rest: "" } : { top: name.slice(0, idx), rest: name.slice(idx + 1) }; + function getPackageName(moduleName: string): { packageName: string, rest: string } { + let idx = moduleName.indexOf(directorySeparator); + if (moduleName[0] === "@") { + idx = moduleName.indexOf(directorySeparator, idx + 1); + } + return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) }; } function loadModuleFromNodeModules(extensions: Extensions, moduleName: string, directory: string, failedLookupLocations: Push, state: ModuleResolutionState, cache: NonRelativeModuleNameResolutionCache): SearchResult { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f65f4c09f3f..baa89c61335 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -424,7 +424,7 @@ namespace ts { case SyntaxKind.JSDocTypeTag: return visitNode(cbNode, (node).typeExpression); case SyntaxKind.JSDocAugmentsTag: - return visitNode(cbNode, (node).typeExpression); + return visitNode(cbNode, (node).class); case SyntaxKind.JSDocTemplateTag: return visitNodes(cbNode, cbNodes, (node).typeParameters); case SyntaxKind.JSDocTypedefTag: @@ -1207,7 +1207,10 @@ namespace ts { return finishNode(node); } - return createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, diagnosticMessage || Diagnostics.Identifier_expected); + // Only for end of file because the error gets reported incorrectly on embedded script tags. + const reportAtCurrentPosition = token() === SyntaxKind.EndOfFileToken; + + return createMissingNode(SyntaxKind.Identifier, reportAtCurrentPosition, diagnosticMessage || Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage?: DiagnosticMessage): Identifier { @@ -5621,13 +5624,16 @@ namespace ts { function parseExpressionWithTypeArguments(): ExpressionWithTypeArguments { const node = createNode(SyntaxKind.ExpressionWithTypeArguments); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === SyntaxKind.LessThanToken) { - node.typeArguments = parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken); - } - + node.typeArguments = tryParseTypeArguments(); return finishNode(node); } + function tryParseTypeArguments(): NodeArray | undefined { + return token() === SyntaxKind.LessThanToken + ? parseBracketedList(ParsingContext.TypeArguments, parseType, SyntaxKind.LessThanToken, SyntaxKind.GreaterThanToken) + : undefined; + } + function isHeritageClause(): boolean { return token() === SyntaxKind.ExtendsKeyword || token() === SyntaxKind.ImplementsKeyword; } @@ -6132,11 +6138,14 @@ namespace ts { } // Parses out a JSDoc type expression. - /* @internal */ - export function parseJSDocTypeExpression(): JSDocTypeExpression { + export function parseJSDocTypeExpression(): JSDocTypeExpression; + export function parseJSDocTypeExpression(requireBraces: true): JSDocTypeExpression | undefined; + export function parseJSDocTypeExpression(requireBraces?: boolean): JSDocTypeExpression | undefined { const result = createNode(SyntaxKind.JSDocTypeExpression, scanner.getTokenPos()); - parseExpected(SyntaxKind.OpenBraceToken); + if (!parseExpected(SyntaxKind.OpenBraceToken) && requireBraces) { + return undefined; + } result.type = doInsideOfContext(NodeFlags.JSDoc, parseType); parseExpected(SyntaxKind.CloseBraceToken); @@ -6483,14 +6492,8 @@ namespace ts { } function tryParseTypeExpression(): JSDocTypeExpression | undefined { - return tryParse(() => { - skipWhitespace(); - if (token() !== SyntaxKind.OpenBraceToken) { - return undefined; - } - - return parseJSDocTypeExpression(); - }); + skipWhitespace(); + return token() === SyntaxKind.OpenBraceToken ? parseJSDocTypeExpression() : undefined; } function parseBracketNameInPropertyAndParamTag(): { name: EntityName, isBracketed: boolean } { @@ -6599,20 +6602,41 @@ namespace ts { const result = createNode(SyntaxKind.JSDocTypeTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeExpression = tryParseTypeExpression(); + result.typeExpression = parseJSDocTypeExpression(/*requireBraces*/ true); return finishNode(result); } function parseAugmentsTag(atToken: AtToken, tagName: Identifier): JSDocAugmentsTag { - const typeExpression = tryParseTypeExpression(); - const result = createNode(SyntaxKind.JSDocAugmentsTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; - result.typeExpression = typeExpression; + result.class = parseExpressionWithTypeArgumentsForAugments(); return finishNode(result); } + function parseExpressionWithTypeArgumentsForAugments(): ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression } { + const usedBrace = parseOptional(SyntaxKind.OpenBraceToken); + const node = createNode(SyntaxKind.ExpressionWithTypeArguments) as ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression }; + node.expression = parsePropertyAccessEntityNameExpression(); + node.typeArguments = tryParseTypeArguments(); + const res = finishNode(node); + if (usedBrace) { + parseExpected(SyntaxKind.CloseBraceToken); + } + return res; + } + + function parsePropertyAccessEntityNameExpression() { + let node: Identifier | PropertyAccessEntityNameExpression = parseJSDocIdentifierName(/*createIfMissing*/ true); + while (token() === SyntaxKind.DotToken) { + const prop: PropertyAccessEntityNameExpression = createNode(SyntaxKind.PropertyAccessExpression, node.pos) as PropertyAccessEntityNameExpression; + prop.expression = node; + prop.name = parseJSDocIdentifierName(); + node = finishNode(prop); + } + return node; + } + function parseClassTag(atToken: AtToken, tagName: Identifier): JSDocClassTag { const tag = createNode(SyntaxKind.JSDocClassTag, atToken.pos); tag.atToken = atToken; diff --git a/src/compiler/program.ts b/src/compiler/program.ts old mode 100644 new mode 100755 index f18d396e9dd..76a0b618a35 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -271,6 +271,7 @@ namespace ts { export function formatDiagnosticsWithColorAndContext(diagnostics: ReadonlyArray, host: FormatDiagnosticsHost): string { let output = ""; for (const diagnostic of diagnostics) { + let context = ""; if (diagnostic.file) { const { start, length, file } = diagnostic; const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); @@ -284,12 +285,12 @@ namespace ts { gutterWidth = Math.max(ellipsis.length, gutterWidth); } - output += host.getNewLine(); + context += host.getNewLine(); for (let i = firstLine; i <= lastLine; i++) { // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, // so we'll skip ahead to the second-to-last line. if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); + context += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine(); i = lastLine - 1; } @@ -300,30 +301,28 @@ namespace ts { lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces // Output the gutter and the actual contents of the line. - output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + host.getNewLine(); + context += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; + context += lineContent + host.getNewLine(); // Output the gutter and the error span for the line using tildes. - output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += redForegroundEscapeSequence; + context += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; + context += redForegroundEscapeSequence; if (i === firstLine) { // If we're on the last line, then limit it to the last character of the last line. // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position. const lastCharForLine = i === lastLine ? lastLineChar : undefined; - output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); - output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); + context += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); + context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); } else if (i === lastLine) { - output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); + context += lineContent.slice(0, lastLineChar).replace(/./g, "~"); } else { // Squiggle the entire line. - output += lineContent.replace(/./g, "~"); + context += lineContent.replace(/./g, "~"); } - output += resetEscapeSequence; - - output += host.getNewLine(); + context += resetEscapeSequence; } output += host.getNewLine(); @@ -333,6 +332,12 @@ namespace ts { const categoryColor = getCategoryFormat(diagnostic.category); const category = DiagnosticCategory[diagnostic.category].toLowerCase(); output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) }`; + + if (diagnostic.file) { + output += host.getNewLine(); + output += context; + } + output += host.getNewLine(); } return output; @@ -1172,9 +1177,7 @@ namespace ts { const programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); const diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); - return isSourceFileJavaScript(sourceFile) - ? filter(diagnostics, shouldReportDiagnostic) - : diagnostics; + return filter(diagnostics, shouldReportDiagnostic); }); } @@ -1464,7 +1467,7 @@ namespace ts { // file.imports may not be undefined if there exists dynamic import let imports: StringLiteral[]; - let moduleAugmentations: Array; + let moduleAugmentations: (StringLiteral | Identifier)[]; let ambientModules: string[]; // If we are importing helpers, we need to add a synthetic reference to resolve the @@ -1584,7 +1587,7 @@ namespace ts { fail(Diagnostics.File_0_not_found, fileName); } else if (refFile && host.getCanonicalFileName(fileName) === host.getCanonicalFileName(refFile.fileName)) { - fail(Diagnostics.A_file_cannot_have_a_reference_to_itself, fileName); + fail(Diagnostics.A_file_cannot_have_a_reference_to_itself); } } return sourceFile; @@ -1846,7 +1849,8 @@ namespace ts { } const isFromNodeModulesSearch = resolution.isExternalLibraryImport; - const isJsFileFromNodeModules = isFromNodeModulesSearch && !extensionIsTypeScript(resolution.extension); + const isJsFile = !extensionIsTypeScript(resolution.extension); + const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile; const resolvedFileName = resolution.resolvedFileName; if (isFromNodeModulesSearch) { @@ -1861,7 +1865,12 @@ namespace ts { const elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth; // Don't add the file if it has a bad extension (e.g. 'tsx' if we don't have '--allowJs') // This may still end up being an untyped module -- the file won't be included but imports will be allowed. - const shouldAddFile = resolvedFileName && !getResolutionDiagnostic(options, resolution) && !options.noResolve && i < file.imports.length && !elideImport; + const shouldAddFile = resolvedFileName + && !getResolutionDiagnostic(options, resolution) + && !options.noResolve + && i < file.imports.length + && !elideImport + && !(isJsFile && !options.allowJs); if (elideImport) { modulesWithElidedImports.set(file.path, true); @@ -2236,7 +2245,7 @@ namespace ts { return options.jsx ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set; } function needAllowJs() { - return options.allowJs ? undefined : Diagnostics.Module_0_was_resolved_to_1_but_allowJs_is_not_set; + return options.allowJs || !options.noImplicitAny ? undefined : Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type; } } diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index c9c14198279..b19a1466328 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -1856,6 +1856,12 @@ namespace ts { case CharacterCodes.closeBracket: pos++; return token = SyntaxKind.CloseBracketToken; + case CharacterCodes.lessThan: + pos++; + return token = SyntaxKind.LessThanToken; + case CharacterCodes.greaterThan: + pos++; + return token = SyntaxKind.GreaterThanToken; case CharacterCodes.equals: pos++; return token = SyntaxKind.EqualsToken; diff --git a/src/compiler/symbolWalker.ts b/src/compiler/symbolWalker.ts index e20ef9f9d98..ac6b60bdc3e 100644 --- a/src/compiler/symbolWalker.ts +++ b/src/compiler/symbolWalker.ts @@ -14,21 +14,29 @@ namespace ts { return getSymbolWalker; function getSymbolWalker(accept: (symbol: Symbol) => boolean = () => true): SymbolWalker { - const visitedTypes = createMap(); // Key is id as string - const visitedSymbols = createMap(); // Key is id as string + const visitedTypes: Type[] = []; // Sparse array from id to type + const visitedSymbols: Symbol[] = []; // Sparse array from id to symbol return { walkType: type => { - visitedTypes.clear(); - visitedSymbols.clear(); - visitType(type); - return { visitedTypes: arrayFrom(visitedTypes.values()), visitedSymbols: arrayFrom(visitedSymbols.values()) }; + try { + visitType(type); + return { visitedTypes: getOwnValues(visitedTypes), visitedSymbols: getOwnValues(visitedSymbols) }; + } + finally { + clear(visitedTypes); + clear(visitedSymbols); + } }, walkSymbol: symbol => { - visitedTypes.clear(); - visitedSymbols.clear(); - visitSymbol(symbol); - return { visitedTypes: arrayFrom(visitedTypes.values()), visitedSymbols: arrayFrom(visitedSymbols.values()) }; + try { + visitSymbol(symbol); + return { visitedTypes: getOwnValues(visitedTypes), visitedSymbols: getOwnValues(visitedSymbols) }; + } + finally { + clear(visitedTypes); + clear(visitedSymbols); + } }, }; @@ -37,11 +45,10 @@ namespace ts { return; } - const typeIdString = type.id.toString(); - if (visitedTypes.has(typeIdString)) { + if (visitedTypes[type.id]) { return; } - visitedTypes.set(typeIdString, type); + visitedTypes[type.id] = type; // Reuse visitSymbol to visit the type's symbol, // but be sure to bail on recuring into the type if accept declines the symbol. @@ -79,18 +86,9 @@ namespace ts { } } - function visitTypeList(types: Type[]): void { - if (!types) { - return; - } - for (let i = 0; i < types.length; i++) { - visitType(types[i]); - } - } - function visitTypeReference(type: TypeReference): void { visitType(type.target); - visitTypeList(type.typeArguments); + forEach(type.typeArguments, visitType); } function visitTypeParameter(type: TypeParameter): void { @@ -98,7 +96,7 @@ namespace ts { } function visitUnionOrIntersectionType(type: UnionOrIntersectionType): void { - visitTypeList(type.types); + forEach(type.types, visitType); } function visitIndexType(type: IndexType): void { @@ -122,7 +120,7 @@ namespace ts { if (signature.typePredicate) { visitType(signature.typePredicate.type); } - visitTypeList(signature.typeParameters); + forEach(signature.typeParameters, visitType); for (const parameter of signature.parameters){ visitSymbol(parameter); @@ -133,8 +131,8 @@ namespace ts { function visitInterfaceType(interfaceT: InterfaceType): void { visitObjectType(interfaceT); - visitTypeList(interfaceT.typeParameters); - visitTypeList(getBaseTypes(interfaceT)); + forEach(interfaceT.typeParameters, visitType); + forEach(getBaseTypes(interfaceT), visitType); visitType(interfaceT.thisType); } @@ -161,11 +159,11 @@ namespace ts { if (!symbol) { return; } - const symbolIdString = getSymbolId(symbol).toString(); - if (visitedSymbols.has(symbolIdString)) { + const symbolId = getSymbolId(symbol); + if (visitedSymbols[symbolId]) { return; } - visitedSymbols.set(symbolIdString, symbol); + visitedSymbols[symbolId] = symbol; if (!accept(symbol)) { return true; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a867d9ebe2a..c34f0ad5499 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2161,7 +2161,7 @@ namespace ts { export interface JSDocAugmentsTag extends JSDocTag { kind: SyntaxKind.JSDocAugmentsTag; - typeExpression: JSDocTypeExpression; + class: ExpressionWithTypeArguments & { expression: Identifier | PropertyAccessEntityNameExpression }; } export interface JSDocClassTag extends JSDocTag { @@ -2442,7 +2442,7 @@ namespace ts { } export interface WriteFileCallback { - (fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void, sourceFiles?: ReadonlyArray): void; + (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray): void; } export class OperationCanceledException { } @@ -4107,8 +4107,8 @@ namespace ts { } export interface CompilerHost extends ModuleResolutionHost { - getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; - getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile; + getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined; + getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile | undefined; getCancellationToken?(): CancellationToken; getDefaultLibFileName(options: CompilerOptions): string; getDefaultLibLocation?(): string; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 47cf2038f03..e7d973865fb 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -321,6 +321,18 @@ namespace ts { return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } + /** + * Note: it is expected that the `nodeArray` and the `node` are within the same file. + * For example, searching for a `SourceFile` in a `SourceFile[]` wouldn't work. + */ + export function indexOfNode(nodeArray: ReadonlyArray, node: Node) { + return binarySearch(nodeArray, node, compareNodePos); + } + + function compareNodePos({ pos: aPos }: Node, { pos: bPos}: Node) { + return aPos < bPos ? Comparison.LessThan : bPos < aPos ? Comparison.GreaterThan : Comparison.EqualTo; + } + /** * Gets flags that control emit behavior of a node. */ @@ -1326,11 +1338,11 @@ namespace ts { return isInJavaScriptFile(file); } - export function isInJavaScriptFile(node: Node): boolean { + export function isInJavaScriptFile(node: Node | undefined): boolean { return node && !!(node.flags & NodeFlags.JavaScriptFile); } - export function isInJSDoc(node: Node): boolean { + export function isInJSDoc(node: Node | undefined): boolean { return node && !!(node.flags & NodeFlags.JSDoc); } @@ -1389,11 +1401,10 @@ namespace ts { /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder - export function getSpecialPropertyAssignmentKind(expression: ts.BinaryExpression): SpecialPropertyAssignmentKind { - if (!isInJavaScriptFile(expression)) { + export function getSpecialPropertyAssignmentKind(expr: ts.BinaryExpression): SpecialPropertyAssignmentKind { + if (!isInJavaScriptFile(expr)) { return SpecialPropertyAssignmentKind.None; } - const expr = expression; if (expr.operatorToken.kind !== SyntaxKind.EqualsToken || expr.left.kind !== SyntaxKind.PropertyAccessExpression) { return SpecialPropertyAssignmentKind.None; } @@ -1494,15 +1505,6 @@ namespace ts { ((node as JSDocFunctionType).parameters[0].name as Identifier).escapedText === "new"; } - export function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean { - return !!getFirstJSDocTag(node, SyntaxKind.JSDocParameterTag); - } - - function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined { - const tags = getJSDocTags(node); - return find(tags, doc => doc.kind === kind); - } - export function getAllJSDocs(node: Node): (JSDoc | JSDocTag)[] { if (isJSDocTypedefTag(node)) { return [node.parent]; @@ -1510,17 +1512,8 @@ namespace ts { return getJSDocCommentsAndTags(node); } - export function getJSDocTags(node: Node): ReadonlyArray | undefined { - let tags = (node as JSDocContainer).jsDocCache; - // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. - if (tags === undefined) { - (node as JSDocContainer).jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); - } - return tags; - } - - function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] { - let result: Array | undefined; + export function getJSDocCommentsAndTags(node: Node): (JSDoc | JSDocTag)[] { + let result: (JSDoc | JSDocTag)[] | undefined; getJSDocCommentsAndTagsWorker(node); return result || emptyArray; @@ -1578,15 +1571,6 @@ namespace ts { } } - export function getJSDocParameterTags(param: ParameterDeclaration): JSDocParameterTag[] | undefined { - if (param.name && isIdentifier(param.name)) { - const name = param.name.escapedText; - return getJSDocTags(param.parent).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name) as JSDocParameterTag[]; - } - // a binding pattern doesn't have a name, so it's not possible to match it a jsdoc parameter, which is identified by name - return undefined; - } - /** Does the opposite of `getJSDocParameterTags`: given a JSDoc parameter, finds the parameter corresponding to it. */ export function getParameterSymbolFromJSDoc(node: JSDocParameterTag): Symbol | undefined { if (node.symbol) { @@ -1596,8 +1580,7 @@ namespace ts { return undefined; } const name = node.name.escapedText; - Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment); - const func = node.parent!.parent!; + const func = getJSDocHost(node); if (!isFunctionLike(func)) { return undefined; } @@ -1606,45 +1589,17 @@ namespace ts { return parameter && parameter.symbol; } + export function getJSDocHost(node: JSDocTag): HasJSDoc { + Debug.assert(node.parent!.kind === SyntaxKind.JSDocComment); + return node.parent!.parent!; + } + export function getTypeParameterFromJsDoc(node: TypeParameterDeclaration & { parent: JSDocTemplateTag }): TypeParameterDeclaration | undefined { const name = node.name.escapedText; const { typeParameters } = (node.parent.parent.parent as ts.SignatureDeclaration | ts.InterfaceDeclaration | ts.ClassDeclaration); return find(typeParameters, p => p.name.escapedText === name); } - export function getJSDocType(node: Node): TypeNode { - let tag: JSDocTypeTag | JSDocParameterTag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; - if (!tag && node.kind === SyntaxKind.Parameter) { - const paramTags = getJSDocParameterTags(node as ParameterDeclaration); - if (paramTags) { - tag = find(paramTags, tag => !!tag.typeExpression); - } - } - - return tag && tag.typeExpression && tag.typeExpression.type; - } - - export function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocAugmentsTag) as JSDocAugmentsTag; - } - - export function getJSDocClassTag(node: Node): JSDocClassTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; - } - - export function getJSDocReturnTag(node: Node): JSDocReturnTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; - } - - export function getJSDocReturnType(node: Node): TypeNode { - const returnTag = getJSDocReturnTag(node); - return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; - } - - export function getJSDocTemplateTag(node: Node): JSDocTemplateTag { - return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag; - } - export function hasRestParameter(s: SignatureDeclaration): boolean { return isRestParameter(lastOrUndefined(s.parameters)); } @@ -4086,6 +4041,119 @@ namespace ts { return (declaration as NamedDeclaration).name; } } + + /** + * Gets the JSDoc parameter tags for the node if present. + * + * @remarks Returns any JSDoc param tag that matches the provided + * parameter, whether a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are returned first, so in the previous example, the param + * tag on the containing function expression would be first. + * + * Does not return tags for binding patterns, because JSDoc matches + * parameters by name and binding patterns do not have a name. + */ + export function getJSDocParameterTags(param: ParameterDeclaration): ReadonlyArray | undefined { + if (param.name && isIdentifier(param.name)) { + const name = param.name.escapedText; + return getJSDocTags(param.parent).filter((tag): tag is JSDocParameterTag => isJSDocParameterTag(tag) && isIdentifier(tag.name) && tag.name.escapedText === name) as JSDocParameterTag[]; + } + // a binding pattern doesn't have a name, so it's not possible to match it a JSDoc parameter, which is identified by name + return undefined; + } + + /** + * Return true if the node has JSDoc parameter tags. + * + * @remarks Includes parameter tags that are not directly on the node, + * for example on a variable declaration whose initializer is a function expression. + */ + export function hasJSDocParameterTags(node: FunctionLikeDeclaration | SignatureDeclaration): boolean { + return !!getFirstJSDocTag(node, SyntaxKind.JSDocParameterTag); + } + + /** Gets the JSDoc augments tag for the node if present */ + export function getJSDocAugmentsTag(node: Node): JSDocAugmentsTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocAugmentsTag) as JSDocAugmentsTag; + } + + /** Gets the JSDoc class tag for the node if present */ + export function getJSDocClassTag(node: Node): JSDocClassTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocClassTag) as JSDocClassTag; + } + + /** Gets the JSDoc return tag for the node if present */ + export function getJSDocReturnTag(node: Node): JSDocReturnTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocReturnTag) as JSDocReturnTag; + } + + /** Gets the JSDoc template tag for the node if present */ + export function getJSDocTemplateTag(node: Node): JSDocTemplateTag | undefined { + return getFirstJSDocTag(node, SyntaxKind.JSDocTemplateTag) as JSDocTemplateTag; + } + + /** Gets the JSDoc type tag for the node if present and valid */ + export function getJSDocTypeTag(node: Node): JSDocTypeTag | undefined { + // We should have already issued an error if there were multiple type jsdocs, so just use the first one. + const tag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; + if (tag && tag.typeExpression && tag.typeExpression.type) { + return tag; + } + return undefined; + } + + /** + * Gets the type node for the node if provided via JSDoc. + * + * @remarks The search includes any JSDoc param tag that relates + * to the provided parameter, for example a type tag on the + * parameter itself, or a param tag on a containing function + * expression, or a param tag on a variable declaration whose + * initializer is the containing function. The tags closest to the + * node are examined first, so in the previous example, the type + * tag directly on the node would be returned. + */ + export function getJSDocType(node: Node): TypeNode | undefined { + let tag: JSDocTypeTag | JSDocParameterTag = getFirstJSDocTag(node, SyntaxKind.JSDocTypeTag) as JSDocTypeTag; + if (!tag && node.kind === SyntaxKind.Parameter) { + const paramTags = getJSDocParameterTags(node as ParameterDeclaration); + if (paramTags) { + tag = find(paramTags, tag => !!tag.typeExpression); + } + } + + return tag && tag.typeExpression && tag.typeExpression.type; + } + + /** + * Gets the return type node for the node if provided via JSDoc's return tag. + * + * @remarks `getJSDocReturnTag` just gets the whole JSDoc tag. This function + * gets the type from inside the braces. + */ + export function getJSDocReturnType(node: Node): TypeNode | undefined { + const returnTag = getJSDocReturnTag(node); + return returnTag && returnTag.typeExpression && returnTag.typeExpression.type; + } + + /** Get all JSDoc tags related to a node, including those on parent nodes. */ + export function getJSDocTags(node: Node): ReadonlyArray | undefined { + let tags = (node as JSDocContainer).jsDocCache; + // If cache is 'null', that means we did the work of searching for JSDoc tags and came up with nothing. + if (tags === undefined) { + (node as JSDocContainer).jsDocCache = tags = flatMap(getJSDocCommentsAndTags(node), j => isJSDoc(j) ? j.tags : j); + } + return tags; + } + + /** Get the first JSDoc tag of a specified kind, or undefined if not present. */ + function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag | undefined { + const tags = getJSDocTags(node); + return find(tags, doc => doc.kind === kind); + } + } // Simple node tests of the form `node.kind === SyntaxKind.Foo`. diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index dc3aa64c6ac..79695639fd8 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -177,7 +177,7 @@ class CompilerBaselineRunner extends RunnerBase { return; } - Harness.Compiler.doTypeAndSymbolBaseline(justName, result, toBeCompiled.concat(otherFiles).filter(file => !!result.program.getSourceFile(file.unitName))); + Harness.Compiler.doTypeAndSymbolBaseline(justName, result.program, toBeCompiled.concat(otherFiles).filter(file => !!result.program.getSourceFile(file.unitName))); }); }); } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 64e25e0eb9a..c2bab0a5a69 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1003,7 +1003,7 @@ namespace FourSlash { } } - public verifyReferenceGroups(startRanges: Range | Range[], parts: Array<{ definition: string, ranges: Range[] }>): void { + public verifyReferenceGroups(startRanges: Range | Range[], parts: FourSlashInterface.ReferenceGroup[]): void { const fullExpected = ts.map(parts, ({ definition, ranges }) => ({ definition, ranges: ranges.map(rangeToReferenceEntry) })); for (const startRange of toArray(startRanges)) { @@ -1037,8 +1037,7 @@ namespace FourSlash { const refs = this.getReferencesAtCaret(); if (refs && refs.length) { - console.log(refs); - this.raiseError("Expected getReferences to fail"); + this.raiseError(`Expected getReferences to fail, but saw references: ${stringify(refs)}`); } } @@ -1050,9 +1049,9 @@ namespace FourSlash { private assertObjectsEqual(fullActual: T, fullExpected: T, msgPrefix = ""): void { const recur = (actual: U, expected: U, path: string) => { const fail = (msg: string) => { - console.log("Expected:", stringify(fullExpected)); - console.log("Actual: ", stringify(fullActual)); - this.raiseError(`${msgPrefix}At ${path}: ${msg}`); + this.raiseError(`${msgPrefix} At ${path}: ${msg} +Expected: ${stringify(fullExpected)} +Actual: ${stringify(fullActual)}`); }; if ((actual === undefined) !== (expected === undefined)) { @@ -1084,9 +1083,9 @@ namespace FourSlash { if (fullActual === fullExpected) { return; } - console.log("Expected:", stringify(fullExpected)); - console.log("Actual: ", stringify(fullActual)); - this.raiseError(msgPrefix); + this.raiseError(`${msgPrefix} +Expected: ${stringify(fullExpected)} +Actual: ${stringify(fullActual)}`); } recur(fullActual, fullExpected, ""); @@ -2337,6 +2336,39 @@ namespace FourSlash { } } + public verifyCodeFix(options: FourSlashInterface.VerifyCodeFixOptions) { + const fileName = this.activeFile.fileName; + const actions = this.getCodeFixActions(fileName, options.errorCode); + let index = options.index; + if (index === undefined) { + if (!(actions && actions.length === 1)) { + this.raiseError(`Should find exactly one codefix, but ${actions ? actions.length : "none"} found. ${actions ? actions.map(a => `${Harness.IO.newLine()} "${a.description}"`) : ""}`); + } + index = 0; + } + else { + if (!(actions && actions.length >= index + 1)) { + this.raiseError(`Should find at least ${index + 1} codefix(es), but ${actions ? actions.length : "none"} found.`); + } + } + + const action = actions[index]; + + assert.equal(action.description, options.description); + + for (const change of action.changes) { + this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false); + } + + if (options.newFileContent) { + assert(!options.newRangeContent); + this.verifyCurrentFileContent(options.newFileContent); + } + else { + this.verifyRangeIs(options.newRangeContent, /*includeWhitespace*/ true); + } + } + /** * Rerieves a codefix satisfying the parameters, or undefined if no such codefix is found. * @param fileName Path to file where error should be retrieved from. @@ -2571,20 +2603,29 @@ namespace FourSlash { } } - public verifyNavigationBar(json: any) { - const items = this.languageService.getNavigationBarItems(this.activeFile.fileName); - if (JSON.stringify(items, replacer) !== JSON.stringify(json)) { - this.raiseError(`verifyNavigationBar failed - expected: ${stringify(json)}, got: ${stringify(items, replacer)}`); + public verifyNavigationBar(json: any, options: { checkSpans?: boolean } | undefined) { + this.verifyNavigationTreeOrBar(json, this.languageService.getNavigationBarItems(this.activeFile.fileName), "Bar", options); + } + + public verifyNavigationTree(json: any, options: { checkSpans?: boolean } | undefined) { + this.verifyNavigationTreeOrBar(json, this.languageService.getNavigationTree(this.activeFile.fileName), "Tree", options); + } + + private verifyNavigationTreeOrBar(json: any, tree: any, name: "Tree" | "Bar", options: { checkSpans?: boolean } | undefined) { + if (JSON.stringify(tree, replacer) !== JSON.stringify(json)) { + this.raiseError(`verifyNavigation${name} failed - expected: ${stringify(json)}, got: ${stringify(tree, replacer)}`); } - // Make the data easier to read. function replacer(key: string, value: any) { switch (key) { case "spans": - // We won't ever check this. - return undefined; + return options && options.checkSpans ? value : undefined; + case "start": + case "length": + // Never omit the values in a span, even if they are 0. + return value; case "childItems": - return value.length === 0 ? undefined : value; + return !value || value.length === 0 ? undefined : value; default: // Omit falsy values, those are presumed to be the default. return value || undefined; @@ -2592,18 +2633,6 @@ namespace FourSlash { } } - public verifyNavigationTree(json: any) { - const tree = this.languageService.getNavigationTree(this.activeFile.fileName); - if (JSON.stringify(tree, replacer) !== JSON.stringify(json)) { - this.raiseError(`verifyNavigationTree failed - expected: ${stringify(json)}, got: ${stringify(tree, replacer)}`); - } - - function replacer(key: string, value: any) { - // Don't check "spans", and omit falsy values. - return key === "spans" ? undefined : (value || undefined); - } - } - public printNavigationItems(searchValue: string) { const items = this.languageService.getNavigateToItems(searchValue); Harness.IO.log(`NavigationItems list (${items.length} items)`); @@ -3533,6 +3562,10 @@ namespace FourSlashInterface { return this.state.getRanges(); } + public spans(): ts.TextSpan[] { + return this.ranges().map(r => ts.createTextSpan(r.start, r.end - r.start)); + } + public rangesByText(): ts.Map { return this.state.rangesByText(); } @@ -3715,6 +3748,10 @@ namespace FourSlashInterface { this.state.verifySpanOfEnclosingComment(this.negative, onlyMultiLineDiverges); } + public codeFix(options: FourSlashInterface.VerifyCodeFixOptions) { + this.state.verifyCodeFix(options); + } + public codeFixAvailable() { this.state.verifyCodeFixAvailable(this.negative); } @@ -3832,7 +3869,7 @@ namespace FourSlashInterface { this.state.verifyReferencesOf(start, references); } - public referenceGroups(startRanges: FourSlash.Range[], parts: Array<{ definition: string, ranges: FourSlash.Range[] }>) { + public referenceGroups(startRanges: FourSlash.Range[], parts: ReferenceGroup[]) { this.state.verifyReferenceGroups(startRanges, parts); } @@ -3966,12 +4003,12 @@ namespace FourSlashInterface { this.state.verifyImportFixAtPosition(expectedTextArray, errorCode); } - public navigationBar(json: any) { - this.state.verifyNavigationBar(json); + public navigationBar(json: any, options?: { checkSpans?: boolean }) { + this.state.verifyNavigationBar(json, options); } - public navigationTree(json: any) { - this.state.verifyNavigationTree(json); + public navigationTree(json: any, options?: { checkSpans?: boolean }) { + this.state.verifyNavigationTree(json, options); } public navigationItemsListCount(count: number, searchValue: string, matchKind?: string, fileName?: string) { @@ -4343,6 +4380,11 @@ namespace FourSlashInterface { } } + export interface ReferenceGroup { + definition: string; + ranges: FourSlash.Range[]; + } + export interface ApplyRefactorOptions { refactorName: string; actionName: string; @@ -4353,4 +4395,13 @@ namespace FourSlashInterface { export interface CompletionsAtOptions { isNewIdentifierLocation?: boolean; } + + export interface VerifyCodeFixOptions { + description: string; + // One of these should be defined. + newFileContent?: string; + newRangeContent?: string; + errorCode?: number; + index?: number; + } } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 7a6c061c6d4..429362ab6cb 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -148,6 +148,8 @@ namespace Utils { }); } + export const canonicalizeForHarness = ts.createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux + export function assertInvariants(node: ts.Node, parent: ts.Node): void { if (node) { assert.isFalse(node.pos < 0, "node.pos < 0"); @@ -1446,10 +1448,7 @@ namespace Harness { }); } - export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[], opts?: Harness.Baseline.BaselineOptions, multifile?: boolean) { - if (result.errors.length !== 0) { - return; - } + export function doTypeAndSymbolBaseline(baselinePath: string, program: ts.Program, allFiles: {unitName: string, content: string}[], opts?: Harness.Baseline.BaselineOptions, multifile?: boolean, skipTypeAndSymbolbaselines?: boolean) { // The full walker simulates the types that you would get from doing a full // compile. The pull walker simulates the types you get when you just do // a type query for a random node (like how the LS would do it). Most of the @@ -1465,16 +1464,8 @@ namespace Harness { // These types are equivalent, but depend on what order the compiler observed // certain parts of the program. - const program = result.program; - const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true); - const fullResults = ts.createMap(); - - for (const sourceFile of allFiles) { - fullResults.set(sourceFile.unitName, fullWalker.getTypeAndSymbols(sourceFile.unitName)); - } - // Produce baselines. The first gives the types for all expressions. // The second gives symbols for all identifiers. let typesError: Error, symbolsError: Error; @@ -1515,76 +1506,77 @@ namespace Harness { baselinePath.replace(/\.tsx?/, "") : baselinePath; if (!multifile) { - const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); + const fullBaseLine = generateBaseLine(isSymbolBaseLine, skipTypeAndSymbolbaselines); Harness.Baseline.runBaseline(outputFileName + fullExtension, () => fullBaseLine, opts); } else { Harness.Baseline.runMultifileBaseline(outputFileName, fullExtension, () => { - return iterateBaseLine(fullResults, isSymbolBaseLine); + return iterateBaseLine(isSymbolBaseLine, skipTypeAndSymbolbaselines); }, opts); } } - function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { + function generateBaseLine(isSymbolBaseline: boolean, skipTypeAndSymbolbaselines?: boolean): string { let result = ""; - const gen = iterateBaseLine(typeWriterResults, isSymbolBaseline); + const gen = iterateBaseLine(isSymbolBaseline, skipTypeAndSymbolbaselines); for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { const [, content] = value; result += content; } - return result; + /* tslint:disable:no-null-keyword */ + return result || null; + /* tslint:enable:no-null-keyword */ } - function *iterateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): IterableIterator<[string, string]> { - let typeLines = ""; - const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; + function *iterateBaseLine(isSymbolBaseline: boolean, skipTypeAndSymbolbaselines?: boolean): IterableIterator<[string, string]> { + if (skipTypeAndSymbolbaselines) { + return; + } const dupeCase = ts.createMap(); for (const file of allFiles) { - const codeLines = file.content.split("\n"); - const key = file.unitName; - typeWriterResults.get(file.unitName).forEach(result => { + const { unitName } = file; + let typeLines = "=== " + unitName + " ===\r\n"; + const codeLines = ts.flatMap(file.content.split(/\r?\n/g), e => e.split(/[\r\u2028\u2029]/g)); + const gen: IterableIterator = isSymbolBaseline ? fullWalker.getSymbols(unitName) : fullWalker.getTypes(unitName); + let lastIndexWritten: number | undefined; + for (let {done, value: result} = gen.next(); !done; { done, value: result } = gen.next()) { if (isSymbolBaseline && !result.symbol) { return; } - + if (lastIndexWritten === undefined) { + typeLines += codeLines.slice(0, result.line + 1).join("\r\n") + "\r\n"; + } + else if (result.line !== lastIndexWritten) { + if (!((lastIndexWritten + 1 < codeLines.length) && (codeLines[lastIndexWritten + 1].match(/^\s*[{|}]\s*$/) || codeLines[lastIndexWritten + 1].trim() === ""))) { + typeLines += "\r\n"; + } + typeLines += codeLines.slice(lastIndexWritten + 1, result.line + 1).join("\r\n") + "\r\n"; + } + lastIndexWritten = result.line; const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; - if (!typeMap[key]) { - typeMap[key] = {}; - } + typeLines += ">" + formattedLine + "\r\n"; + } - let typeInfo = [formattedLine]; - const existingTypeInfo = typeMap[key][result.line]; - if (existingTypeInfo) { - typeInfo = existingTypeInfo.concat(typeInfo); - } - typeMap[key][result.line] = typeInfo; - }); - - typeLines += "=== " + file.unitName + " ===\r\n"; - for (let i = 0; i < codeLines.length; i++) { - const currentCodeLine = codeLines[i]; - typeLines += currentCodeLine + "\r\n"; - if (typeMap[key]) { - const typeInfo = typeMap[key][i]; - if (typeInfo) { - typeInfo.forEach(ty => { - typeLines += ">" + ty + "\r\n"; - }); - if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === "")) { - } - else { - typeLines += "\r\n"; - } - } - } - else { + // Preserve legacy behavior + if (lastIndexWritten === undefined) { + for (let i = 0; i < codeLines.length; i++) { + const currentCodeLine = codeLines[i]; + typeLines += currentCodeLine + "\r\n"; typeLines += "No type information for this code."; } } - yield [checkDuplicatedFileName(file.unitName, dupeCase), typeLines]; - typeLines = ""; + else { + if (lastIndexWritten + 1 < codeLines.length) { + if (!((lastIndexWritten + 1 < codeLines.length) && (codeLines[lastIndexWritten + 1].match(/^\s*[{|}]\s*$/) || codeLines[lastIndexWritten + 1].trim() === ""))) { + typeLines += "\r\n"; + } + typeLines += codeLines.slice(lastIndexWritten + 1).join("\r\n"); + } + typeLines += "\r\n"; + } + yield [checkDuplicatedFileName(unitName, dupeCase), typeLines]; } } } @@ -1725,8 +1717,12 @@ namespace Harness { return resultName; } - function sanitizeTestFilePath(name: string) { - return ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/").toLowerCase(); + export function sanitizeTestFilePath(name: string) { + const path = ts.toPath(ts.normalizeSlashes(name.replace(/[\^<>:"|?*%]/g, "_")).replace(/\.\.\//g, "__dotdot/"), "", Utils.canonicalizeForHarness); + if (ts.startsWith(path, "/")) { + return path.substring(1); + } + return path; } // This does not need to exist strictly speaking, but many tests will need to be updated if it's removed @@ -2070,25 +2066,22 @@ namespace Harness { export function runMultifileBaseline(relativeFileBase: string, extension: string, generateContent: () => IterableIterator<[string, string, number]> | IterableIterator<[string, string]>, opts?: BaselineOptions, referencedExtensions?: string[]): void { const gen = generateContent(); const writtenFiles = ts.createMap(); - const canonicalize = ts.createGetCanonicalFileName(/*caseSensitive*/ false); // This is done so tests work on windows _and_ linux - /* tslint:disable-next-line:no-null-keyword */ const errors: Error[] = []; + // tslint:disable-next-line:no-null-keyword if (gen !== null) { for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { const [name, content, count] = value as [string, string, number | undefined]; if (count === 0) continue; // Allow error reporter to skip writing files without errors - const relativeFileName = ts.combinePaths(relativeFileBase, name) + extension; + const relativeFileName = relativeFileBase + "/" + name + extension; const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); - const actual = content; - const comparison = compareToBaseline(actual, relativeFileName, opts); + const comparison = compareToBaseline(content, relativeFileName, opts); try { writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName); } catch (e) { errors.push(e); } - const path = ts.toPath(relativeFileName, "", canonicalize); - writtenFiles.set(path, true); + writtenFiles.set(relativeFileName, true); } } @@ -2101,8 +2094,7 @@ namespace Harness { const missing: string[] = []; for (const name of existing) { const localCopy = name.substring(referenceDir.length - relativeFileBase.length); - const path = ts.toPath(localCopy, "", canonicalize); - if (!writtenFiles.has(path)) { + if (!writtenFiles.has(localCopy)) { missing.push(localCopy); } } @@ -2115,13 +2107,14 @@ namespace Harness { if (errors.length || missing.length) { let errorMsg = ""; if (errors.length) { - errorMsg += `The baseline for ${relativeFileBase} has changed:${"\n " + errors.map(e => e.message).join("\n ")}`; + errorMsg += `The baseline for ${relativeFileBase} in ${errors.length} files has changed:${"\n " + errors.slice(0, 5).map(e => e.message).join("\n ") + (errors.length > 5 ? "\n" + ` and ${errors.length - 5} more` : "")}`; } if (errors.length && missing.length) { errorMsg += "\n"; } if (missing.length) { - errorMsg += `Baseline missing files:${"\n " + missing.join("\n ") + "\n"}Written:${"\n " + ts.arrayFrom(writtenFiles.keys()).join("\n ")}`; + const writtenFilesArray = ts.arrayFrom(writtenFiles.keys()); + errorMsg += `Baseline missing ${missing.length} files:${"\n " + missing.slice(0, 5).join("\n ") + (missing.length > 5 ? "\n" + ` and ${missing.length - 5} more` : "") + "\n"}Written ${writtenFiles.size} files:${"\n " + writtenFilesArray.slice(0, 5).join("\n ") + (writtenFilesArray.length > 5 ? "\n" + ` and ${writtenFilesArray.length - 5} more` : "")}`; } throw new Error(errorMsg); } diff --git a/src/harness/loggedIO.ts b/src/harness/loggedIO.ts index 125283dcb22..3123024f419 100644 --- a/src/harness/loggedIO.ts +++ b/src/harness/loggedIO.ts @@ -5,8 +5,10 @@ /// interface FileInformation { - contents: string; + contents?: string; + contentsPath?: string; codepage: number; + bom?: string; } interface FindFileResult { @@ -27,13 +29,15 @@ interface IOLog { filesRead: IOLogFile[]; filesWritten: { path: string; - contents: string; + contents?: string; + contentsPath?: string; bom: boolean; }[]; filesDeleted: string[]; filesAppended: { path: string; - contents: string; + contents?: string; + contentsPath?: string; }[]; fileExists: { path: string; @@ -129,6 +133,72 @@ namespace Playback { }; } + export function newStyleLogIntoOldStyleLog(log: IOLog, host: ts.System | Harness.IO, baseName: string) { + for (const file of log.filesAppended) { + if (file.contentsPath) { + file.contents = host.readFile(ts.combinePaths(baseName, file.contentsPath)); + delete file.contentsPath; + } + } + for (const file of log.filesWritten) { + if (file.contentsPath) { + file.contents = host.readFile(ts.combinePaths(baseName, file.contentsPath)); + delete file.contentsPath; + } + } + for (const file of log.filesRead) { + if (file.result.contentsPath) { + // `readFile` strips away a BOM (and actually reinerprets the file contents according to the correct encoding) + // - but this has the unfortunate sideeffect of removing the BOM from any outputs based on the file, so we readd it here. + file.result.contents = (file.result.bom || "") + host.readFile(ts.combinePaths(baseName, file.result.contentsPath)); + delete file.result.contentsPath; + } + } + return log; + } + + export function oldStyleLogIntoNewStyleLog(log: IOLog, writeFile: typeof Harness.IO.writeFile, baseTestName: string) { + if (log.filesAppended) { + for (const file of log.filesAppended) { + if (file.contents !== undefined) { + file.contentsPath = ts.combinePaths("appended", Harness.Compiler.sanitizeTestFilePath(file.path)); + writeFile(ts.combinePaths(baseTestName, file.contentsPath), file.contents); + delete file.contents; + } + } + } + if (log.filesWritten) { + for (const file of log.filesWritten) { + if (file.contents !== undefined) { + file.contentsPath = ts.combinePaths("written", Harness.Compiler.sanitizeTestFilePath(file.path)); + writeFile(ts.combinePaths(baseTestName, file.contentsPath), file.contents); + delete file.contents; + } + } + } + if (log.filesRead) { + for (const file of log.filesRead) { + const { contents } = file.result; + if (contents !== undefined) { + file.result.contentsPath = ts.combinePaths("read", Harness.Compiler.sanitizeTestFilePath(file.path)); + writeFile(ts.combinePaths(baseTestName, file.result.contentsPath), contents); + const len = contents.length; + if (len >= 2 && contents.charCodeAt(0) === 0xfeff) { + file.result.bom = "\ufeff"; + } + if (len >= 2 && contents.charCodeAt(0) === 0xfffe) { + file.result.bom = "\ufffe"; + } + if (len >= 3 && contents.charCodeAt(0) === 0xefbb && contents.charCodeAt(1) === 0xbf) { + file.result.bom = "\uefbb\xbf"; + } + delete file.result.contents; + } + } + } + return log; + } + function initWrapper(wrapper: PlaybackSystem, underlying: ts.System): void; function initWrapper(wrapper: PlaybackIO, underlying: Harness.IO): void; function initWrapper(wrapper: PlaybackSystem | PlaybackIO, underlying: ts.System | Harness.IO): void { @@ -164,9 +234,9 @@ namespace Playback { wrapper.endRecord = () => { if (recordLog !== undefined) { let i = 0; - const fn = () => recordLogFileNameBase + i + ".json"; - while (underlying.fileExists(fn())) i++; - underlying.writeFile(fn(), JSON.stringify(recordLog)); + const fn = () => recordLogFileNameBase + i; + while (underlying.fileExists(fn() + ".json")) i++; + underlying.writeFile(ts.combinePaths(fn(), "test.json"), JSON.stringify(oldStyleLogIntoNewStyleLog(recordLog, (path, string) => underlying.writeFile(ts.combinePaths(fn(), path), string), fn()), null, 4)); // tslint:disable-line:no-null-keyword recordLog = undefined; } }; diff --git a/src/harness/parallel/host.ts b/src/harness/parallel/host.ts index a3a1ec8082b..36fb3cd08d1 100644 --- a/src/harness/parallel/host.ts +++ b/src/harness/parallel/host.ts @@ -5,11 +5,10 @@ if (typeof describe === "undefined") { namespace Harness.Parallel.Host { interface ChildProcessPartial { - send(message: any, callback?: (error: Error) => void): boolean; + send(message: ParallelHostMessage, callback?: (error: Error) => void): boolean; on(event: "error", listener: (err: Error) => void): this; on(event: "exit", listener: (code: number, signal: string) => void): this; - on(event: "message", listener: (message: any) => void): this; - disconnect(): void; + on(event: "message", listener: (message: ParallelClientMessage) => void): this; } interface ProgressBarsOptions { @@ -27,22 +26,72 @@ namespace Harness.Parallel.Host { text?: string; } + const perfdataFileNameFragment = ".parallelperf"; + function perfdataFileName(target?: string) { + return `${perfdataFileNameFragment}${target ? `.${target}` : ""}.json`; + } + function readSavedPerfData(target?: string): {[testHash: string]: number} { + const perfDataContents = Harness.IO.readFile(perfdataFileName(target)); + if (perfDataContents) { + return JSON.parse(perfDataContents); + } + return undefined; + } + + function hashName(runner: TestRunnerKind, test: string) { + return `tsrunner-${runner}://${test}`; + } + export function start() { + initializeProgressBarsDependencies(); console.log("Discovering tests..."); const discoverStart = +(new Date()); const { statSync }: { statSync(path: string): { size: number }; } = require("fs"); - const tasks: { runner: TestRunnerKind, file: string, size: number }[] = []; - let totalSize = 0; + let tasks: { runner: TestRunnerKind, file: string, size: number }[] = []; + const newTasks: { runner: TestRunnerKind, file: string, size: number }[] = []; + const perfData = readSavedPerfData(configOption); + let totalCost = 0; + let unknownValue: string | undefined; for (const runner of runners) { const files = runner.enumerateTestFiles(); for (const file of files) { - const size = statSync(file).size; + let size: number; + if (!perfData) { + try { + size = statSync(file).size; + } + catch { + // May be a directory + try { + size = Harness.IO.listFiles(file, /.*/g, { recursive: true }).reduce((acc, elem) => acc + statSync(elem).size, 0); + } + catch { + // Unknown test kind, just return 0 and let the historical analysis take over after one run + size = 0; + } + } + } + else { + const hashedName = hashName(runner.kind(), file); + size = perfData[hashedName]; + if (size === undefined) { + size = 0; + unknownValue = hashedName; + newTasks.push({ runner: runner.kind(), file, size }); + continue; + } + } tasks.push({ runner: runner.kind(), file, size }); - totalSize += size; + totalCost += size; } } tasks.sort((a, b) => a.size - b.size); - const batchSize = (totalSize / workerCount) * 0.9; + tasks = tasks.concat(newTasks); + // 1 fewer batches than threads to account for unittests running on the final thread + const batchCount = runners.length === 1 ? workerCount : workerCount - 1; + const packfraction = 0.9; + const chunkSize = 1000; // ~1KB or 1s for sending batches near the end of a test + const batchSize = (totalCost / workerCount) * packfraction; // Keep spare tests for unittest thread in reserve console.log(`Discovered ${tasks.length} test files in ${+(new Date()) - discoverStart}ms.`); console.log(`Starting to run tests using ${workerCount} threads...`); const { fork }: { fork(modulePath: string, args?: string[], options?: {}): ChildProcessPartial; } = require("child_process"); @@ -58,7 +107,10 @@ namespace Harness.Parallel.Host { const progressUpdateInterval = 1 / progressBars._options.width; let nextProgress = progressUpdateInterval; + const newPerfData: {[testHash: string]: number} = {}; + const workers: ChildProcessPartial[] = []; + let closedWorkers = 0; for (let i = 0; i < workerCount; i++) { // TODO: Just send the config over the IPC channel or in the command line arguments const config: TestConfig = { light: Harness.lightMode, listenForWork: true, runUnitTests: runners.length === 1 ? false : i === workerCount - 1 }; @@ -66,7 +118,6 @@ namespace Harness.Parallel.Host { Harness.IO.writeFile(configPath, JSON.stringify(config)); const child = fork(__filename, [`--config="${configPath}"`]); child.on("error", err => { - child.disconnect(); console.error("Unexpected error in child process:"); console.error(err); return process.exit(2); @@ -80,8 +131,7 @@ namespace Harness.Parallel.Host { child.on("message", (data: ParallelClientMessage) => { switch (data.type) { case "error": { - child.disconnect(); - console.error(`Test worker encounted unexpected error and was forced to close: + console.error(`Test worker encounted unexpected error${data.payload.name ? ` during the execution of test ${data.payload.name}` : ""} and was forced to close: Message: ${data.payload.error} Stack: ${data.payload.stack}`); return process.exit(2); @@ -96,6 +146,7 @@ namespace Harness.Parallel.Host { else { passingFiles++; } + newPerfData[hashName(data.payload.runner, data.payload.file)] = data.payload.duration; const progress = (failingFiles + passingFiles) / totalFiles; if (progress >= nextProgress) { @@ -105,20 +156,27 @@ namespace Harness.Parallel.Host { updateProgress(progress, errorResults.length ? `${errorResults.length} failing` : `${totalPassing} passing`, errorResults.length ? "fail" : undefined); } - if (failingFiles + passingFiles === totalFiles) { - // Done. Finished every task and collected results. - child.send({ type: "close" }); - child.disconnect(); - return outputFinalResult(); - } - if (tasks.length === 0) { - // No more tasks to distribute - child.send({ type: "close" }); - child.disconnect(); - return; - } if (data.type === "result") { - child.send({ type: "test", payload: tasks.pop() }); + if (tasks.length === 0) { + // No more tasks to distribute + child.send({ type: "close" }); + closedWorkers++; + if (closedWorkers === workerCount) { + outputFinalResult(); + } + return; + } + // Send tasks in blocks if the tasks are small + const taskList = [tasks.pop()]; + while (tasks.length && taskList.reduce((p, c) => p + c.size, 0) < chunkSize) { + taskList.push(tasks.pop()); + } + if (taskList.length === 1) { + child.send({ type: "test", payload: taskList[0] }); + } + else { + child.send({ type: "batch", payload: taskList }); + } } } } @@ -129,12 +187,13 @@ namespace Harness.Parallel.Host { // It's only really worth doing an initial batching if there are a ton of files to go through if (totalFiles > 1000) { console.log("Batching initial test lists..."); - const batches: { runner: TestRunnerKind, file: string, size: number }[][] = new Array(workerCount); - const doneBatching = new Array(workerCount); + const batches: { runner: TestRunnerKind, file: string, size: number }[][] = new Array(batchCount); + const doneBatching = new Array(batchCount); + let scheduledTotal = 0; batcher: while (true) { - for (let i = 0; i < workerCount; i++) { - if (tasks.length === 0) { - // TODO: This indicates a particularly suboptimal packing + for (let i = 0; i < batchCount; i++) { + if (tasks.length <= workerCount) { // Keep a small reserve even in the suboptimally packed case + console.log(`Suboptimal packing detected: no tests remain to be stolen. Reduce packing fraction from ${packfraction} to fix.`); break batcher; } if (doneBatching[i]) { @@ -144,26 +203,38 @@ namespace Harness.Parallel.Host { batches[i] = []; } const total = batches[i].reduce((p, c) => p + c.size, 0); - if (total >= batchSize && !doneBatching[i]) { + if (total >= batchSize) { doneBatching[i] = true; continue; } - batches[i].push(tasks.pop()); + const task = tasks.pop(); + batches[i].push(task); + scheduledTotal += task.size; } - for (let j = 0; j < workerCount; j++) { + for (let j = 0; j < batchCount; j++) { if (!doneBatching[j]) { - continue; + continue batcher; } } break; } - console.log(`Batched into ${workerCount} groups with approximate total file sizes of ${Math.floor(batchSize)} bytes in each group.`); + const prefix = `Batched into ${batchCount} groups`; + if (unknownValue) { + console.log(`${prefix}. Unprofiled tests including ${unknownValue} will be run first.`); + } + else { + console.log(`${prefix} with approximate total ${perfData ? "time" : "file sizes"} of ${perfData ? ms(batchSize) : `${Math.floor(batchSize)} bytes`} in each group. (${(scheduledTotal / totalCost * 100).toFixed(1)}% of total tests batched)`); + } for (const worker of workers) { - const action: ParallelBatchMessage = { type: "batch", payload: batches.pop() }; - if (!action.payload[0]) { - throw new Error(`Tried to send invalid message ${action}`); + const payload = batches.pop(); + if (payload) { + worker.send({ type: "batch", payload }); + } + else { // Unittest thread - send off just one test + const payload = tasks.pop(); + ts.Debug.assert(!!payload); // The reserve kept above should ensure there is always an initial task available, even in suboptimal scenarios + worker.send({ type: "test", payload }); } - worker.send(action); } } else { @@ -176,7 +247,6 @@ namespace Harness.Parallel.Host { updateProgress(0); let duration: number; - const ms = require("mocha/lib/ms"); function completeBar() { const isPartitionFail = failingFiles !== 0; const summaryColor = isPartitionFail ? "fail" : "green"; @@ -234,6 +304,8 @@ namespace Harness.Parallel.Host { reporter.epilogue(); } + Harness.IO.writeFile(perfdataFileName(configOption), JSON.stringify(newPerfData, null, 4)); // tslint:disable-line:no-null-keyword + process.exit(errorResults.length); } @@ -254,14 +326,58 @@ namespace Harness.Parallel.Host { return; } - const Mocha = require("mocha"); - const Base = Mocha.reporters.Base; - const color = Base.color; - const cursor = Base.cursor; - const readline = require("readline"); - const os = require("os"); - const tty: { isatty(x: number): boolean } = require("tty"); - const isatty = tty.isatty(1) && tty.isatty(2); + let Mocha: any; + let Base: any; + let color: any; + let cursor: any; + let readline: any; + let os: any; + let tty: { isatty(x: number): boolean }; + let isatty: boolean; + + const s = 1000; + const m = s * 60; + const h = m * 60; + const d = h * 24; + function ms(ms: number) { + let result = ""; + if (ms >= d) { + const count = Math.floor(ms / d); + result += count + "d"; + ms -= count * d; + } + if (ms >= h) { + const count = Math.floor(ms / h); + result += count + "h"; + ms -= count * h; + } + if (ms >= m) { + const count = Math.floor(ms / m); + result += count + "m"; + ms -= count * m; + } + if (ms >= s) { + const count = Math.round(ms / s); + result += count + "s"; + return result; + } + if (ms > 0) { + result += Math.round(ms) + "ms"; + } + return result; + } + + function initializeProgressBarsDependencies() { + Mocha = require("mocha"); + Base = Mocha.reporters.Base; + color = Base.color; + cursor = Base.cursor; + readline = require("readline"); + os = require("os"); + tty = require("tty"); + isatty = tty.isatty(1) && tty.isatty(2); + } + class ProgressBars { public readonly _options: Readonly; private _enabled: boolean; @@ -273,7 +389,7 @@ namespace Harness.Parallel.Host { const close = options.close || "]"; const complete = options.complete || "▬"; const incomplete = options.incomplete || Base.symbols.dot; - const maxWidth = Base.window.width - open.length - close.length - 30; + const maxWidth = Base.window.width - open.length - close.length - 34; const width = minMax(options.width || maxWidth, 10, maxWidth); this._options = { open, @@ -373,4 +489,4 @@ namespace Harness.Parallel.Host { if (value > max) return max; return value; } -} \ No newline at end of file +} diff --git a/src/harness/parallel/shared.ts b/src/harness/parallel/shared.ts index ebfe3278849..280420dcdba 100644 --- a/src/harness/parallel/shared.ts +++ b/src/harness/parallel/shared.ts @@ -6,9 +6,9 @@ namespace Harness.Parallel { export type ParallelCloseMessage = { type: "close" } | never; export type ParallelHostMessage = ParallelTestMessage | ParallelCloseMessage | ParallelBatchMessage; - export type ParallelErrorMessage = { type: "error", payload: { error: string, stack: string } } | never; + export type ParallelErrorMessage = { type: "error", payload: { error: string, stack: string, name?: string } } | never; export type ErrorInfo = ParallelErrorMessage["payload"] & { name: string }; - export type ParallelResultMessage = { type: "result", payload: { passing: number, errors: ErrorInfo[] } } | never; + export type ParallelResultMessage = { type: "result", payload: { passing: number, errors: ErrorInfo[], duration: number, runner: TestRunnerKind, file: string } } | never; export type ParallelBatchProgressMessage = { type: "progress", payload: ParallelResultMessage["payload"] } | never; export type ParallelClientMessage = ParallelErrorMessage | ParallelResultMessage | ParallelBatchProgressMessage; } \ No newline at end of file diff --git a/src/harness/parallel/worker.ts b/src/harness/parallel/worker.ts index 34f89d37f13..1a3901b4fc4 100644 --- a/src/harness/parallel/worker.ts +++ b/src/harness/parallel/worker.ts @@ -1,60 +1,165 @@ namespace Harness.Parallel.Worker { let errors: ErrorInfo[] = []; let passing = 0; + let reportedUnitTests = false; + + type Executor = {name: string, callback: Function, kind: "suite" | "test"} | never; + function resetShimHarnessAndExecute(runner: RunnerBase) { - errors = []; - passing = 0; + if (reportedUnitTests) { + errors = []; + passing = 0; + testList.length = 0; + } + reportedUnitTests = true; + const start = +(new Date()); runner.initializeTests(); - return { errors, passing }; + testList.forEach(({ name, callback, kind }) => executeCallback(name, callback, kind)); + return { errors, passing, duration: +(new Date()) - start }; } + + let beforeEachFunc: Function; + const namestack: string[] = []; + let testList: Executor[] = []; function shimMochaHarness() { (global as any).before = undefined; (global as any).after = undefined; (global as any).beforeEach = undefined; - let beforeEachFunc: Function; - describe = ((_name, callback) => { - const fakeContext: Mocha.ISuiteCallbackContext = { - retries() { return this; }, - slow() { return this; }, - timeout() { return this; }, - }; - (before as any) = (cb: Function) => cb(); - let afterFunc: Function; - (after as any) = (cb: Function) => afterFunc = cb; - const savedBeforeEach = beforeEachFunc; - (beforeEach as any) = (cb: Function) => beforeEachFunc = cb; - callback.call(fakeContext); - afterFunc && afterFunc(); - afterFunc = undefined; - beforeEachFunc = savedBeforeEach; + describe = ((name, callback) => { + testList.push({ name, callback, kind: "suite" }); }) as Mocha.IContextDefinition; it = ((name, callback) => { - const fakeContext: Mocha.ITestCallbackContext = { - skip() { return this; }, - timeout() { return this; }, - retries() { return this; }, - slow() { return this; }, - }; - // TODO: If we ever start using async test completions, polyfill the `done` parameter/promise return handling - if (beforeEachFunc) { - try { - beforeEachFunc(); - } - catch (error) { - errors.push({ error: error.message, stack: error.stack, name }); - return; - } + if (!testList) { + throw new Error("Tests must occur within a describe block"); } + testList.push({ name, callback, kind: "test" }); + }) as Mocha.ITestDefinition; + } + + function executeSuiteCallback(name: string, callback: Function) { + const fakeContext: Mocha.ISuiteCallbackContext = { + retries() { return this; }, + slow() { return this; }, + timeout() { return this; }, + }; + namestack.push(name); + let beforeFunc: Function; + (before as any) = (cb: Function) => beforeFunc = cb; + let afterFunc: Function; + (after as any) = (cb: Function) => afterFunc = cb; + const savedBeforeEach = beforeEachFunc; + (beforeEach as any) = (cb: Function) => beforeEachFunc = cb; + const savedTestList = testList; + + testList = []; + try { + callback.call(fakeContext); + } + catch (e) { + errors.push({ error: `Error executing suite: ${e.message}`, stack: e.stack, name: namestack.join(" ") }); + return cleanup(); + } + try { + beforeFunc && beforeFunc(); + } + catch (e) { + errors.push({ error: `Error executing before function: ${e.message}`, stack: e.stack, name: namestack.join(" ") }); + return cleanup(); + } + finally { + beforeFunc = undefined; + } + testList.forEach(({ name, callback, kind }) => executeCallback(name, callback, kind)); + + try { + afterFunc && afterFunc(); + } + catch (e) { + errors.push({ error: `Error executing after function: ${e.message}`, stack: e.stack, name: namestack.join(" ") }); + } + finally { + afterFunc = undefined; + cleanup(); + } + function cleanup() { + testList.length = 0; + testList = savedTestList; + beforeEachFunc = savedBeforeEach; + namestack.pop(); + } + } + + function executeCallback(name: string, callback: Function, kind: "suite" | "test") { + if (kind === "suite") { + executeSuiteCallback(name, callback); + } + else { + executeTestCallback(name, callback); + } + } + + function executeTestCallback(name: string, callback: Function) { + const fakeContext: Mocha.ITestCallbackContext = { + skip() { return this; }, + timeout() { return this; }, + retries() { return this; }, + slow() { return this; }, + }; + namestack.push(name); + name = namestack.join(" "); + if (beforeEachFunc) { try { + beforeEachFunc(); + } + catch (error) { + errors.push({ error: error.message, stack: error.stack, name }); + namestack.pop(); + return; + } + } + if (callback.length === 0) { + try { + // TODO: If we ever start using async test completions, polyfill promise return handling callback.call(fakeContext); } catch (error) { errors.push({ error: error.message, stack: error.stack, name }); return; } + finally { + namestack.pop(); + } passing++; - }) as Mocha.ITestDefinition; + } + else { + // Uses `done` callback + let completed = false; + try { + callback.call(fakeContext, (err: any) => { + if (completed) { + throw new Error(`done() callback called multiple times; ensure it is only called once.`); + } + if (err) { + errors.push({ error: err.toString(), stack: "", name }); + } + else { + passing++; + } + completed = true; + }); + } + catch (error) { + errors.push({ error: error.message, stack: error.stack, name }); + return; + } + finally { + namestack.pop(); + } + if (!completed) { + errors.push({ error: "Test completes asynchronously, which is unsupported by the parallel harness", stack: "", name }); + } + } } export function start() { @@ -99,8 +204,14 @@ namespace Harness.Parallel.Worker { } }); process.on("uncaughtException", error => { - const message: ParallelErrorMessage = { type: "error", payload: { error: error.message, stack: error.stack } }; - process.send(message); + const message: ParallelErrorMessage = { type: "error", payload: { error: error.message, stack: error.stack, name: namestack.join(" ") } }; + try { + process.send(message); + } + catch (e) { + console.error(error); + throw error; + } }); if (!runUnitTests) { // ensure unit tests do not get run @@ -117,7 +228,7 @@ namespace Harness.Parallel.Worker { } const instance = runners.get(runner); instance.tests = [file]; - return resetShimHarnessAndExecute(instance); + return { ...resetShimHarnessAndExecute(instance), runner, file }; } } } \ No newline at end of file diff --git a/src/harness/runner.ts b/src/harness/runner.ts index 0b361e7fc9e..c1345f422c3 100644 --- a/src/harness/runner.ts +++ b/src/harness/runner.ts @@ -101,6 +101,7 @@ interface TaskSet { files: string[]; } +let configOption: string; function handleTestConfig() { if (testConfigContent !== "") { const testConfig = JSON.parse(testConfigContent); @@ -136,6 +137,13 @@ function handleTestConfig() { continue; } + if (!configOption) { + configOption = option; + } + else { + configOption += "+" + option; + } + switch (option) { case "compiler": runners.push(new CompilerBaselineRunner(CompilerTestType.Conformance)); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 1f398118c06..eba845d44ec 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -36,9 +36,11 @@ namespace RWC { Subfolder: "rwc", Baselinefolder: "internal/baselines" }; - const baseName = /(.*)\/(.*).json/.exec(ts.normalizeSlashes(jsonPath))[2]; + const baseName = ts.getBaseFileName(jsonPath); let currentDirectory: string; let useCustomLibraryFile: boolean; + let skipTypeAndSymbolbaselines = false; + const typeAndSymbolSizeLimit = 10000000; after(() => { // Mocha holds onto the closure environment of the describe callback even after the test is done. // Therefore we have to clean out large objects after the test is done. @@ -52,15 +54,17 @@ namespace RWC { // or to use lib.d.ts inside the json object. If the flag is true, use the lib.d.ts inside json file // otherwise use the lib.d.ts from built/local useCustomLibraryFile = undefined; + skipTypeAndSymbolbaselines = false; }); it("can compile", function(this: Mocha.ITestCallbackContext) { this.timeout(800000); // Allow long timeouts for RWC compilations let opts: ts.ParsedCommandLine; - const ioLog: IOLog = JSON.parse(Harness.IO.readFile(jsonPath)); + const ioLog: IOLog = Playback.newStyleLogIntoOldStyleLog(JSON.parse(Harness.IO.readFile(`internal/cases/rwc/${jsonPath}/test.json`)), Harness.IO, `internal/cases/rwc/${baseName}`); currentDirectory = ioLog.currentDirectory; useCustomLibraryFile = ioLog.useCustomLibraryFile; + skipTypeAndSymbolbaselines = ioLog.filesRead.reduce((acc, elem) => (elem && elem.result && elem.result.contents) ? acc + elem.result.contents.length : acc, 0) > typeAndSymbolSizeLimit; runWithIOLog(ioLog, () => { opts = ts.parseCommandLine(ioLog.arguments, fileName => Harness.IO.readFile(fileName)); assert.equal(opts.errors.length, 0); @@ -217,10 +221,10 @@ namespace RWC { it("has the expected types", () => { // We don't need to pass the extension here because "doTypeAndSymbolBaseline" will append appropriate extension of ".types" or ".symbols" - Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles + Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult.program, inputFiles .concat(otherFiles) .filter(file => !!compilerResult.program.getSourceFile(file.unitName)) - .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts, /*multifile*/ true); + .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts, /*multifile*/ true, skipTypeAndSymbolbaselines); }); // Ideally, a generated declaration file will have no errors. But we allow generated @@ -249,7 +253,7 @@ namespace RWC { class RWCRunner extends RunnerBase { public enumerateTestFiles() { - return Harness.IO.listFiles("internal/cases/rwc/", /.+\.json$/); + return Harness.IO.getDirectories("internal/cases/rwc/"); } public kind(): TestRunnerKind { diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index c6e78138638..88999b2d979 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -128,7 +128,10 @@ "./unittests/printer.ts", "./unittests/transform.ts", "./unittests/customTransforms.ts", - "./unittests/extractMethods.ts", + "./unittests/extractConstants.ts", + "./unittests/extractFunctions.ts", + "./unittests/extractRanges.ts", + "./unittests/extractTestHelpers.ts", "./unittests/textChanges.ts", "./unittests/telemetry.ts", "./unittests/languageService.ts", diff --git a/src/harness/typeWriter.ts b/src/harness/typeWriter.ts index 1e9316fa0ae..559d8ed332e 100644 --- a/src/harness/typeWriter.ts +++ b/src/harness/typeWriter.ts @@ -1,13 +1,26 @@ -interface TypeWriterResult { +interface TypeWriterTypeResult { line: number; syntaxKind: number; sourceText: string; type: string; +} + +interface TypeWriterSymbolResult { + line: number; + syntaxKind: number; + sourceText: string; symbol: string; } +interface TypeWriterResult { + line: number; + syntaxKind: number; + sourceText: string; + symbol?: string; + type?: string; +} + class TypeWriterWalker { - results: TypeWriterResult[]; currentSourceFile: ts.SourceFile; private checker: ts.TypeChecker; @@ -20,57 +33,93 @@ class TypeWriterWalker { : program.getTypeChecker(); } - public getTypeAndSymbols(fileName: string): TypeWriterResult[] { + public *getSymbols(fileName: string): IterableIterator { const sourceFile = this.program.getSourceFile(fileName); this.currentSourceFile = sourceFile; - this.results = []; - this.visitNode(sourceFile); - return this.results; + const gen = this.visitNode(sourceFile, /*isSymbolWalk*/ true); + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + yield value as TypeWriterSymbolResult; + } } - private visitNode(node: ts.Node): void { + public *getTypes(fileName: string): IterableIterator { + const sourceFile = this.program.getSourceFile(fileName); + this.currentSourceFile = sourceFile; + const gen = this.visitNode(sourceFile, /*isSymbolWalk*/ false); + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + yield value as TypeWriterTypeResult; + } + } + + private *visitNode(node: ts.Node, isSymbolWalk: boolean): IterableIterator { if (ts.isPartOfExpression(node) || node.kind === ts.SyntaxKind.Identifier) { - this.logTypeAndSymbol(node); + const result = this.writeTypeOrSymbol(node, isSymbolWalk); + if (result) { + yield result; + } } - ts.forEachChild(node, child => this.visitNode(child)); + const children: ts.Node[] = []; + ts.forEachChild(node, child => void children.push(child)); + for (const child of children) { + const gen = this.visitNode(child, isSymbolWalk); + for (let {done, value} = gen.next(); !done; { done, value } = gen.next()) { + yield value; + } + } } - private logTypeAndSymbol(node: ts.Node): void { + private writeTypeOrSymbol(node: ts.Node, isSymbolWalk: boolean): TypeWriterResult { const actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos); const lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos); const sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node); - // Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions - // let type = this.checker.getTypeAtLocation(node); - const type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node); - ts.Debug.assert(type !== undefined, "type doesn't exist"); - const symbol = this.checker.getSymbolAtLocation(node); - - const typeString = this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation); - let symbolString: string; - if (symbol) { - symbolString = "Symbol(" + this.checker.symbolToString(symbol, node.parent); - if (symbol.declarations) { - for (const declaration of symbol.declarations) { - symbolString += ", "; - const declSourceFile = declaration.getSourceFile(); - const declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos); - const fileName = ts.getBaseFileName(declSourceFile.fileName); - const isLibFile = /lib(.*)\.d\.ts/i.test(fileName); - symbolString += `Decl(${ fileName }, ${ isLibFile ? "--" : declLineAndCharacter.line }, ${ isLibFile ? "--" : declLineAndCharacter.character })`; - } - } - symbolString += ")"; + if (!isSymbolWalk) { + // Workaround to ensure we output 'C' instead of 'typeof C' for base class expressions + // let type = this.checker.getTypeAtLocation(node); + const type = node.parent && ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent) && this.checker.getTypeAtLocation(node.parent) || this.checker.getTypeAtLocation(node); + const typeString = type ? this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation) : "No type information available!"; + return { + line: lineAndCharacter.line, + syntaxKind: node.kind, + sourceText, + type: typeString + }; } - - this.results.push({ + const symbol = this.checker.getSymbolAtLocation(node); + if (!symbol) { + return; + } + let symbolString = "Symbol(" + this.checker.symbolToString(symbol, node.parent); + if (symbol.declarations) { + let count = 0; + for (const declaration of symbol.declarations) { + if (count >= 5) { + symbolString += ` ... and ${symbol.declarations.length - count} more`; + break; + } + count++; + symbolString += ", "; + if ((declaration as any)["__symbolTestOutputCache"]) { + symbolString += (declaration as any)["__symbolTestOutputCache"]; + continue; + } + const declSourceFile = declaration.getSourceFile(); + const declLineAndCharacter = declSourceFile.getLineAndCharacterOfPosition(declaration.pos); + const fileName = ts.getBaseFileName(declSourceFile.fileName); + const isLibFile = /lib(.*)\.d\.ts/i.test(fileName); + const declText = `Decl(${ fileName }, ${ isLibFile ? "--" : declLineAndCharacter.line }, ${ isLibFile ? "--" : declLineAndCharacter.character })`; + symbolString += declText; + (declaration as any)["__symbolTestOutputCache"] = declText; + } + } + symbolString += ")"; + return { line: lineAndCharacter.line, syntaxKind: node.kind, sourceText, - type: typeString, symbol: symbolString - }); + }; } } \ No newline at end of file diff --git a/src/harness/unittests/extractConstants.ts b/src/harness/unittests/extractConstants.ts new file mode 100644 index 00000000000..e2c64afb526 --- /dev/null +++ b/src/harness/unittests/extractConstants.ts @@ -0,0 +1,87 @@ +/// + +namespace ts { + describe("extractConstants", () => { + testExtractConstant("extractConstant_TopLevel", + `let x = [#|1|];`); + + testExtractConstant("extractConstant_Namespace", + `namespace N { + let x = [#|1|]; +}`); + + testExtractConstant("extractConstant_Class", + `class C { + x = [#|1|]; +}`); + + testExtractConstant("extractConstant_Method", + `class C { + M() { + let x = [#|1|]; + } +}`); + + testExtractConstant("extractConstant_Function", + `function F() { + let x = [#|1|]; +}`); + + testExtractConstant("extractConstant_ExpressionStatement", + `[#|"hello";|]`); + + testExtractConstant("extractConstant_ExpressionStatementExpression", + `[#|"hello"|];`); + + testExtractConstant("extractConstant_BlockScopes_NoDependencies", + `for (let i = 0; i < 10; i++) { + for (let j = 0; j < 10; j++) { + let x = [#|1|]; + } +}`); + + testExtractConstant("extractConstant_ClassInsertionPosition", + `class C { + a = 1; + b = 2; + M1() { } + M2() { } + M3() { + let x = [#|1|]; + } +}`); + + testExtractConstant("extractConstant_Parameters", + `function F() { + let w = 1; + let x = [#|w + 1|]; +}`); + + testExtractConstant("extractConstant_TypeParameters", + `function F(t: T) { + let x = [#|t + 1|]; +}`); + +// TODO (acasey): handle repeated substitution +// testExtractConstant("extractConstant_RepeatedSubstitution", +// `namespace X { +// export const j = 10; +// export const y = [#|j * j|]; +// }`); + + testExtractConstantFailed("extractConstant_BlockScopes_Dependencies", + `for (let i = 0; i < 10; i++) { + for (let j = 0; j < 10; j++) { + let x = [#|i + 1|]; + } +}`); + }); + + function testExtractConstant(caption: string, text: string) { + testExtractSymbol(caption, text, "extractConstant", Diagnostics.Extract_constant); + } + + function testExtractConstantFailed(caption: string, text: string) { + testExtractSymbolFailed(caption, text, Diagnostics.Extract_constant); + } +} diff --git a/src/harness/unittests/extractFunctions.ts b/src/harness/unittests/extractFunctions.ts new file mode 100644 index 00000000000..522ea7b1293 --- /dev/null +++ b/src/harness/unittests/extractFunctions.ts @@ -0,0 +1,379 @@ +/// + +namespace ts { + describe("extractFunctions", () => { + testExtractFunction("extractFunction1", + `namespace A { + let x = 1; + function foo() { + } + namespace B { + function a() { + let a = 1; + [#| + let y = 5; + let z = x; + a = y; + foo();|] + } + } +}`); + testExtractFunction("extractFunction2", + `namespace A { + let x = 1; + function foo() { + } + namespace B { + function a() { + [#| + let y = 5; + let z = x; + return foo();|] + } + } +}`); + testExtractFunction("extractFunction3", + `namespace A { + function foo() { + } + namespace B { + function* a(z: number) { + [#| + let y = 5; + yield z; + return foo();|] + } + } +}`); + testExtractFunction("extractFunction4", + `namespace A { + function foo() { + } + namespace B { + async function a(z: number, z1: any) { + [#| + let y = 5; + if (z) { + await z1; + } + return foo();|] + } + } +}`); + testExtractFunction("extractFunction5", + `namespace A { + let x = 1; + export function foo() { + } + namespace B { + function a() { + let a = 1; + [#| + let y = 5; + let z = x; + a = y; + foo();|] + } + } +}`); + testExtractFunction("extractFunction6", + `namespace A { + let x = 1; + export function foo() { + } + namespace B { + function a() { + let a = 1; + [#| + let y = 5; + let z = x; + a = y; + return foo();|] + } + } +}`); + testExtractFunction("extractFunction7", + `namespace A { + let x = 1; + export namespace C { + export function foo() { + } + } + namespace B { + function a() { + let a = 1; + [#| + let y = 5; + let z = x; + a = y; + return C.foo();|] + } + } +}`); + testExtractFunction("extractFunction8", + `namespace A { + let x = 1; + namespace B { + function a() { + let a1 = 1; + return 1 + [#|a1 + x|] + 100; + } + } +}`); + testExtractFunction("extractFunction9", + `namespace A { + export interface I { x: number }; + namespace B { + function a() { + [#|let a1: I = { x: 1 }; + return a1.x + 10;|] + } + } +}`); + testExtractFunction("extractFunction10", + `namespace A { + export interface I { x: number }; + class C { + a() { + let z = 1; + [#|let a1: I = { x: 1 }; + return a1.x + 10;|] + } + } +}`); + testExtractFunction("extractFunction11", + `namespace A { + let y = 1; + class C { + a() { + let z = 1; + [#|let a1 = { x: 1 }; + y = 10; + z = 42; + return a1.x + 10;|] + } + } +}`); + testExtractFunction("extractFunction12", + `namespace A { + let y = 1; + class C { + b() {} + a() { + let z = 1; + [#|let a1 = { x: 1 }; + y = 10; + z = 42; + this.b(); + return a1.x + 10;|] + } + } +}`); + // The "b" type parameters aren't used and shouldn't be passed to the extracted function. + // Type parameters should be in syntactic order (i.e. in order or character offset from BOF). + // In all cases, we could use type inference, rather than passing explicit type arguments. + // Note the inclusion of arrow functions to ensure that some type parameters are not from + // targetable scopes. + testExtractFunction("extractFunction13", + `(u1a: U1a, u1b: U1b) => { + function F1(t1a: T1a, t1b: T1b) { + (u2a: U2a, u2b: U2b) => { + function F2(t2a: T2a, t2b: T2b) { + (u3a: U3a, u3b: U3b) => { + [#|t1a.toString(); + t2a.toString(); + u1a.toString(); + u2a.toString(); + u3a.toString();|] + } + } + } + } +}`); + // This test is descriptive, rather than normative. The current implementation + // doesn't handle type parameter shadowing. + testExtractFunction("extractFunction14", + `function F(t1: T) { + function G(t2: T) { + [#|t1.toString(); + t2.toString();|] + } +}`); + // Confirm that the constraint is preserved. + testExtractFunction("extractFunction15", + `function F(t1: T) { + function G(t2: U) { + [#|t2.toString();|] + } +}`); + // Confirm that the contextual type of an extracted expression counts as a use. + testExtractFunction("extractFunction16", + `function F() { + const array: T[] = [#|[]|]; +}`); + // Class type parameter + testExtractFunction("extractFunction17", + `class C { + M(t1: T1, t2: T2) { + [#|t1.toString()|]; + } +}`); + // Function type parameter + testExtractFunction("extractFunction18", + `class C { + M(t1: T1, t2: T2) { + [#|t1.toString()|]; + } +}`); + // Coupled constraints + testExtractFunction("extractFunction19", + `function F(v: V) { + [#|v.toString()|]; +}`); + + testExtractFunction("extractFunction20", + `const _ = class { + a() { + [#|let a1 = { x: 1 }; + return a1.x + 10;|] + } +}`); + // Write + void return + testExtractFunction("extractFunction21", + `function foo() { + let x = 10; + [#|x++; + return;|] +}`); + // Return in finally block + testExtractFunction("extractFunction22", + `function test() { + try { + } + finally { + [#|return 1;|] + } +}`); + // Extraction position - namespace + testExtractFunction("extractFunction23", + `namespace NS { + function M1() { } + function M2() { + [#|return 1;|] + } + function M3() { } +}`); + // Extraction position - function + testExtractFunction("extractFunction24", + `function Outer() { + function M1() { } + function M2() { + [#|return 1;|] + } + function M3() { } +}`); + // Extraction position - file + testExtractFunction("extractFunction25", + `function M1() { } +function M2() { + [#|return 1;|] +} +function M3() { }`); + // Extraction position - class without ctor + testExtractFunction("extractFunction26", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + M3() { } +}`); + // Extraction position - class with ctor in middle + testExtractFunction("extractFunction27", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + constructor() { } + M3() { } +}`); + // Extraction position - class with ctor at end + testExtractFunction("extractFunction28", + `class C { + M1() { } + M2() { + [#|return 1;|] + } + M3() { } + constructor() { } +}`); + // Shorthand property names + testExtractFunction("extractFunction29", + `interface UnaryExpression { + kind: "Unary"; + operator: string; + operand: any; +} + +function parseUnaryExpression(operator: string): UnaryExpression { + [#|return { + kind: "Unary", + operator, + operand: parsePrimaryExpression(), + };|] +} + +function parsePrimaryExpression(): any { + throw "Not implemented"; +}`); + // Type parameter as declared type + testExtractFunction("extractFunction30", + `function F() { + [#|let t: T;|] +}`); + // Return in nested function + testExtractFunction("extractFunction31", + `namespace N { + + export const value = 1; + + () => { + var f: () => number; + [#|f = function (): number { + return value; + }|] + } +}`); + // Return in nested class + testExtractFunction("extractFunction32", + `namespace N { + + export const value = 1; + + () => { + [#|var c = class { + M() { + return value; + } + }|] + } +}`); + // Selection excludes leading trivia of declaration + testExtractFunction("extractFunction33", + `function F() { + [#|function G() { }|] +}`); + +// TODO (acasey): handle repeated substitution +// testExtractFunction("extractFunction_RepeatedSubstitution", +// `namespace X { +// export const j = 10; +// export const y = [#|j * j|]; +// }`); + }); + + function testExtractFunction(caption: string, text: string) { + testExtractSymbol(caption, text, "extractFunction", Diagnostics.Extract_function); + } +} diff --git a/src/harness/unittests/extractMethods.ts b/src/harness/unittests/extractMethods.ts deleted file mode 100644 index 6d8eed3b8b0..00000000000 --- a/src/harness/unittests/extractMethods.ts +++ /dev/null @@ -1,818 +0,0 @@ -/// -/// - -namespace ts { - interface Range { - start: number; - end: number; - name: string; - } - - interface Test { - source: string; - ranges: Map; - } - - function extractTest(source: string): Test { - const activeRanges: Range[] = []; - let text = ""; - let lastPos = 0; - let pos = 0; - const ranges = createMap(); - - while (pos < source.length) { - if (source.charCodeAt(pos) === CharacterCodes.openBracket && - (source.charCodeAt(pos + 1) === CharacterCodes.hash || source.charCodeAt(pos + 1) === CharacterCodes.$)) { - const saved = pos; - pos += 2; - const s = pos; - consumeIdentifier(); - const e = pos; - if (source.charCodeAt(pos) === CharacterCodes.bar) { - pos++; - text += source.substring(lastPos, saved); - const name = s === e - ? source.charCodeAt(saved + 1) === CharacterCodes.hash ? "selection" : "extracted" - : source.substring(s, e); - activeRanges.push({ name, start: text.length, end: undefined }); - lastPos = pos; - continue; - } - else { - pos = saved; - } - } - else if (source.charCodeAt(pos) === CharacterCodes.bar && source.charCodeAt(pos + 1) === CharacterCodes.closeBracket) { - text += source.substring(lastPos, pos); - activeRanges[activeRanges.length - 1].end = text.length; - const range = activeRanges.pop(); - if (range.name in ranges) { - throw new Error(`Duplicate name of range ${range.name}`); - } - ranges.set(range.name, range); - pos += 2; - lastPos = pos; - continue; - } - pos++; - } - text += source.substring(lastPos, pos); - - function consumeIdentifier() { - while (isIdentifierPart(source.charCodeAt(pos), ScriptTarget.Latest)) { - pos++; - } - } - return { source: text, ranges }; - } - - const newLineCharacter = "\n"; - function getRuleProvider(action?: (opts: FormatCodeSettings) => void) { - const options = { - indentSize: 4, - tabSize: 4, - newLineCharacter, - convertTabsToSpaces: true, - indentStyle: ts.IndentStyle.Smart, - insertSpaceAfterConstructor: false, - insertSpaceAfterCommaDelimiter: true, - insertSpaceAfterSemicolonInForStatements: true, - insertSpaceBeforeAndAfterBinaryOperators: true, - insertSpaceAfterKeywordsInControlFlowStatements: true, - insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, - insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, - insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, - insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, - insertSpaceBeforeFunctionParenthesis: false, - placeOpenBraceOnNewLineForFunctions: false, - placeOpenBraceOnNewLineForControlBlocks: false, - }; - if (action) { - action(options); - } - const rulesProvider = new formatting.RulesProvider(); - rulesProvider.ensureUpToDate(options); - return rulesProvider; - } - - function testExtractRangeFailed(caption: string, s: string, expectedErrors: string[]) { - return it(caption, () => { - const t = extractTest(s); - const file = createSourceFile("a.ts", t.source, ScriptTarget.Latest, /*setParentNodes*/ true); - const selectionRange = t.ranges.get("selection"); - if (!selectionRange) { - throw new Error(`Test ${s} does not specify selection range`); - } - const result = refactor.extractMethod.getRangeToExtract(file, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); - assert(result.targetRange === undefined, "failure expected"); - const sortedErrors = result.errors.map(e => e.messageText).sort(); - assert.deepEqual(sortedErrors, expectedErrors.sort(), "unexpected errors"); - }); - } - - function testExtractRange(s: string): void { - const t = extractTest(s); - const f = createSourceFile("a.ts", t.source, ScriptTarget.Latest, /*setParentNodes*/ true); - const selectionRange = t.ranges.get("selection"); - if (!selectionRange) { - throw new Error(`Test ${s} does not specify selection range`); - } - const result = refactor.extractMethod.getRangeToExtract(f, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); - const expectedRange = t.ranges.get("extracted"); - if (expectedRange) { - let start: number, end: number; - if (ts.isArray(result.targetRange.range)) { - start = result.targetRange.range[0].getStart(f); - end = ts.lastOrUndefined(result.targetRange.range).getEnd(); - } - else { - start = result.targetRange.range.getStart(f); - end = result.targetRange.range.getEnd(); - } - assert.equal(start, expectedRange.start, "incorrect start of range"); - assert.equal(end, expectedRange.end, "incorrect end of range"); - } - else { - assert.isTrue(!result.targetRange, `expected range to extract to be undefined`); - } - } - - describe("extractMethods", () => { - it("get extract range from selection", () => { - testExtractRange(` - [#| - [$|var x = 1; - var y = 2;|]|] - `); - testExtractRange(` - [#| - var x = 1; - var y = 2|]; - `); - testExtractRange(` - [#|var x = 1|]; - var y = 2; - `); - testExtractRange(` - if ([#|[#extracted|a && b && c && d|]|]) { - } - `); - testExtractRange(` - if [#|(a && b && c && d|]) { - } - `); - testExtractRange(` - if (a && b && c && d) { - [#| [$|var x = 1; - console.log(x);|] |] - } - `); - testExtractRange(` - [#| - if (a) { - return 100; - } |] - `); - testExtractRange(` - function foo() { - [#| [$|if (a) { - } - return 100|] |] - } - `); - testExtractRange(` - [#| - [$|l1: - if (x) { - break l1; - }|]|] - `); - testExtractRange(` - [#| - [$|l2: - { - if (x) { - } - break l2; - }|]|] - `); - testExtractRange(` - while (true) { - [#| if(x) { - } - break; |] - } - `); - testExtractRange(` - while (true) { - [#| if(x) { - } - continue; |] - } - `); - testExtractRange(` - l3: - { - [#| - if (x) { - } - break l3; |] - } - `); - testExtractRange(` - function f() { - while (true) { - [#| - if (x) { - return; - } |] - } - } - `); - testExtractRange(` - function f() { - while (true) { - [#| - [$|if (x) { - } - return;|] - |] - } - } - `); - testExtractRange(` - function f() { - return [#| [$|1 + 2|] |]+ 3; - } - } - `); - testExtractRange(` - function f() { - return [$|1 + [#|2 + 3|]|]; - } - } - `); - testExtractRange(` - function f() { - return [$|1 + 2 + [#|3 + 4|]|]; - } - } - `); - }); - - testExtractRangeFailed("extractRangeFailed1", - ` -namespace A { - function f() { - [#| - let x = 1 - if (x) { - return 10; - } - |] - } -} - `, - [ - "Cannot extract range containing conditional return statement." - ]); - - testExtractRangeFailed("extractRangeFailed2", - ` -namespace A { - function f() { - while (true) { - [#| - let x = 1 - if (x) { - break; - } - |] - } - } -} - `, - [ - "Cannot extract range containing conditional break or continue statements." - ]); - - testExtractRangeFailed("extractRangeFailed3", - ` -namespace A { - function f() { - while (true) { - [#| - let x = 1 - if (x) { - continue; - } - |] - } - } -} - `, - [ - "Cannot extract range containing conditional break or continue statements." - ]); - - testExtractRangeFailed("extractRangeFailed4", - ` -namespace A { - function f() { - l1: { - [#| - let x = 1 - if (x) { - break l1; - } - |] - } - } -} - `, - [ - "Cannot extract range containing labeled break or continue with target outside of the range." - ]); - - testExtractRangeFailed("extractRangeFailed5", - ` -namespace A { - function f() { - [#| - try { - f2() - return 10; - } - catch (e) { - } - |] - } - function f2() { - } -} - `, - [ - "Cannot extract range containing conditional return statement." - ]); - - testExtractRangeFailed("extractRangeFailed6", - ` -namespace A { - function f() { - [#| - try { - f2() - } - catch (e) { - return 10; - } - |] - } - function f2() { - } -} - `, - [ - "Cannot extract range containing conditional return statement." - ]); - - testExtractRangeFailed("extractRangeFailed7", - ` -function test(x: number) { - while (x) { - x--; - [#|break;|] - } -} - `, - [ - "Cannot extract range containing conditional break or continue statements." - ]); - - testExtractRangeFailed("extractRangeFailed8", - ` -function test(x: number) { - switch (x) { - case 1: - [#|break;|] - } -} - `, - [ - "Cannot extract range containing conditional break or continue statements." - ]); - - testExtractRangeFailed("extractRangeFailed9", - `var x = ([#||]1 + 2);`, - [ - "Statement or expression expected." - ]); - - testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, ["Select more than a single identifier."]); - - testExtractMethod("extractMethod1", - `namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - let a = 1; - [#| - let y = 5; - let z = x; - a = y; - foo();|] - } - } -}`); - testExtractMethod("extractMethod2", - `namespace A { - let x = 1; - function foo() { - } - namespace B { - function a() { - [#| - let y = 5; - let z = x; - return foo();|] - } - } -}`); - testExtractMethod("extractMethod3", - `namespace A { - function foo() { - } - namespace B { - function* a(z: number) { - [#| - let y = 5; - yield z; - return foo();|] - } - } -}`); - testExtractMethod("extractMethod4", - `namespace A { - function foo() { - } - namespace B { - async function a(z: number, z1: any) { - [#| - let y = 5; - if (z) { - await z1; - } - return foo();|] - } - } -}`); - testExtractMethod("extractMethod5", - `namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - [#| - let y = 5; - let z = x; - a = y; - foo();|] - } - } -}`); - testExtractMethod("extractMethod6", - `namespace A { - let x = 1; - export function foo() { - } - namespace B { - function a() { - let a = 1; - [#| - let y = 5; - let z = x; - a = y; - return foo();|] - } - } -}`); - testExtractMethod("extractMethod7", - `namespace A { - let x = 1; - export namespace C { - export function foo() { - } - } - namespace B { - function a() { - let a = 1; - [#| - let y = 5; - let z = x; - a = y; - return C.foo();|] - } - } -}`); - testExtractMethod("extractMethod8", - `namespace A { - let x = 1; - namespace B { - function a() { - let a1 = 1; - return 1 + [#|a1 + x|] + 100; - } - } -}`); - testExtractMethod("extractMethod9", - `namespace A { - export interface I { x: number }; - namespace B { - function a() { - [#|let a1: I = { x: 1 }; - return a1.x + 10;|] - } - } -}`); - testExtractMethod("extractMethod10", - `namespace A { - export interface I { x: number }; - class C { - a() { - let z = 1; - [#|let a1: I = { x: 1 }; - return a1.x + 10;|] - } - } -}`); - testExtractMethod("extractMethod11", - `namespace A { - let y = 1; - class C { - a() { - let z = 1; - [#|let a1 = { x: 1 }; - y = 10; - z = 42; - return a1.x + 10;|] - } - } -}`); - testExtractMethod("extractMethod12", - `namespace A { - let y = 1; - class C { - b() {} - a() { - let z = 1; - [#|let a1 = { x: 1 }; - y = 10; - z = 42; - this.b(); - return a1.x + 10;|] - } - } -}`); - // The "b" type parameters aren't used and shouldn't be passed to the extracted function. - // Type parameters should be in syntactic order (i.e. in order or character offset from BOF). - // In all cases, we could use type inference, rather than passing explicit type arguments. - // Note the inclusion of arrow functions to ensure that some type parameters are not from - // targetable scopes. - testExtractMethod("extractMethod13", - `(u1a: U1a, u1b: U1b) => { - function F1(t1a: T1a, t1b: T1b) { - (u2a: U2a, u2b: U2b) => { - function F2(t2a: T2a, t2b: T2b) { - (u3a: U3a, u3b: U3b) => { - [#|t1a.toString(); - t2a.toString(); - u1a.toString(); - u2a.toString(); - u3a.toString();|] - } - } - } - } -}`); - // This test is descriptive, rather than normative. The current implementation - // doesn't handle type parameter shadowing. - testExtractMethod("extractMethod14", - `function F(t1: T) { - function F(t2: T) { - [#|t1.toString(); - t2.toString();|] - } -}`); - // Confirm that the constraint is preserved. - testExtractMethod("extractMethod15", - `function F(t1: T) { - function F(t2: U) { - [#|t2.toString();|] - } -}`); - // Confirm that the contextual type of an extracted expression counts as a use. - testExtractMethod("extractMethod16", - `function F() { - const array: T[] = [#|[]|]; -}`); - // Class type parameter - testExtractMethod("extractMethod17", - `class C { - M(t1: T1, t2: T2) { - [#|t1.toString()|]; - } -}`); - // Method type parameter - testExtractMethod("extractMethod18", - `class C { - M(t1: T1, t2: T2) { - [#|t1.toString()|]; - } -}`); - // Coupled constraints - testExtractMethod("extractMethod19", - `function F(v: V) { - [#|v.toString()|]; -}`); - - testExtractMethod("extractMethod20", - `const _ = class { - a() { - [#|let a1 = { x: 1 }; - return a1.x + 10;|] - } -}`); - // Write + void return - testExtractMethod("extractMethod21", - `function foo() { - let x = 10; - [#|x++; - return;|] -}`); - // Return in finally block - testExtractMethod("extractMethod22", - `function test() { - try { - } - finally { - [#|return 1;|] - } -}`); - // Extraction position - namespace - testExtractMethod("extractMethod23", - `namespace NS { - function M1() { } - function M2() { - [#|return 1;|] - } - function M3() { } -}`); - // Extraction position - function - testExtractMethod("extractMethod24", - `function Outer() { - function M1() { } - function M2() { - [#|return 1;|] - } - function M3() { } -}`); - // Extraction position - file - testExtractMethod("extractMethod25", - `function M1() { } -function M2() { - [#|return 1;|] -} -function M3() { }`); - // Extraction position - class without ctor - testExtractMethod("extractMethod26", - `class C { - M1() { } - M2() { - [#|return 1;|] - } - M3() { } -}`); - // Extraction position - class with ctor in middle - testExtractMethod("extractMethod27", - `class C { - M1() { } - M2() { - [#|return 1;|] - } - constructor() { } - M3() { } -}`); - // Extraction position - class with ctor at end - testExtractMethod("extractMethod28", - `class C { - M1() { } - M2() { - [#|return 1;|] - } - M3() { } - constructor() { } -}`); - // Shorthand property names - testExtractMethod("extractMethod29", - `interface UnaryExpression { - kind: "Unary"; - operator: string; - operand: any; -} - -function parseUnaryExpression(operator: string): UnaryExpression { - [#|return { - kind: "Unary", - operator, - operand: parsePrimaryExpression(), - };|] -} - -function parsePrimaryExpression(): any { - throw "Not implemented"; -}`); - // Type parameter as declared type - testExtractMethod("extractMethod30", - `function F() { - [#|let t: T;|] -}`); - // Return in nested function - testExtractMethod("extractMethod31", - `namespace N { - - export const value = 1; - - () => { - var f: () => number; - [#|f = function (): number { - return value; - }|] - } -}`); - // Return in nested class - testExtractMethod("extractMethod32", - `namespace N { - - export const value = 1; - - () => { - [#|var c = class { - M() { - return value; - } - }|] - } -}`); - }); - - - function testExtractMethod(caption: string, text: string) { - it(caption, () => { - Harness.Baseline.runBaseline(`extractMethod/${caption}.ts`, () => { - const t = extractTest(text); - const selectionRange = t.ranges.get("selection"); - if (!selectionRange) { - throw new Error(`Test ${caption} does not specify selection range`); - } - const f = { - path: "/a.ts", - content: t.source - }; - const host = projectSystem.createServerHost([f, projectSystem.libFile]); - const projectService = projectSystem.createProjectService(host); - projectService.openClientFile(f.path); - const program = projectService.inferredProjects[0].getLanguageService().getProgram(); - const sourceFile = program.getSourceFile(f.path); - const context: RefactorContext = { - cancellationToken: { throwIfCancellationRequested() { }, isCancellationRequested() { return false; } }, - newLineCharacter, - program, - file: sourceFile, - startPosition: -1, - rulesProvider: getRuleProvider() - }; - const result = refactor.extractMethod.getRangeToExtract(sourceFile, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); - assert.equal(result.errors, undefined, "expect no errors"); - const results = refactor.extractMethod.getPossibleExtractions(result.targetRange, context); - const data: string[] = []; - data.push(`// ==ORIGINAL==`); - data.push(sourceFile.text); - for (const r of results) { - const { renameLocation, edits } = refactor.extractMethod.getExtractionAtIndex(result.targetRange, context, results.indexOf(r)); - assert.lengthOf(edits, 1); - data.push(`// ==SCOPE::${r.scopeDescription}==`); - const newText = textChanges.applyChanges(sourceFile.text, edits[0].textChanges); - const newTextWithRename = newText.slice(0, renameLocation) + "/*RENAME*/" + newText.slice(renameLocation); - data.push(newTextWithRename); - } - return data.join(newLineCharacter); - }); - }); - } -} diff --git a/src/harness/unittests/extractRanges.ts b/src/harness/unittests/extractRanges.ts new file mode 100644 index 00000000000..fcffffeba9d --- /dev/null +++ b/src/harness/unittests/extractRanges.ts @@ -0,0 +1,319 @@ +/// + +namespace ts { + function testExtractRangeFailed(caption: string, s: string, expectedErrors: string[]) { + return it(caption, () => { + const t = extractTest(s); + const file = createSourceFile("a.ts", t.source, ScriptTarget.Latest, /*setParentNodes*/ true); + const selectionRange = t.ranges.get("selection"); + if (!selectionRange) { + throw new Error(`Test ${s} does not specify selection range`); + } + const result = refactor.extractSymbol.getRangeToExtract(file, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); + assert(result.targetRange === undefined, "failure expected"); + const sortedErrors = result.errors.map(e => e.messageText).sort(); + assert.deepEqual(sortedErrors, expectedErrors.sort(), "unexpected errors"); + }); + } + + function testExtractRange(s: string): void { + const t = extractTest(s); + const f = createSourceFile("a.ts", t.source, ScriptTarget.Latest, /*setParentNodes*/ true); + const selectionRange = t.ranges.get("selection"); + if (!selectionRange) { + throw new Error(`Test ${s} does not specify selection range`); + } + const result = refactor.extractSymbol.getRangeToExtract(f, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); + const expectedRange = t.ranges.get("extracted"); + if (expectedRange) { + let start: number, end: number; + if (ts.isArray(result.targetRange.range)) { + start = result.targetRange.range[0].getStart(f); + end = ts.lastOrUndefined(result.targetRange.range).getEnd(); + } + else { + start = result.targetRange.range.getStart(f); + end = result.targetRange.range.getEnd(); + } + assert.equal(start, expectedRange.start, "incorrect start of range"); + assert.equal(end, expectedRange.end, "incorrect end of range"); + } + else { + assert.isTrue(!result.targetRange, `expected range to extract to be undefined`); + } + } + + describe("extractRanges", () => { + it("get extract range from selection", () => { + testExtractRange(` + [#| + [$|var x = 1; + var y = 2;|]|] + `); + testExtractRange(` + [#| + var x = 1; + var y = 2|]; + `); + testExtractRange(` + [#|var x = 1|]; + var y = 2; + `); + testExtractRange(` + if ([#|[#extracted|a && b && c && d|]|]) { + } + `); + testExtractRange(` + if [#|(a && b && c && d|]) { + } + `); + testExtractRange(` + if (a && b && c && d) { + [#| [$|var x = 1; + console.log(x);|] |] + } + `); + testExtractRange(` + [#| + if (a) { + return 100; + } |] + `); + testExtractRange(` + function foo() { + [#| [$|if (a) { + } + return 100|] |] + } + `); + testExtractRange(` + [#| + [$|l1: + if (x) { + break l1; + }|]|] + `); + testExtractRange(` + [#| + [$|l2: + { + if (x) { + } + break l2; + }|]|] + `); + testExtractRange(` + while (true) { + [#| if(x) { + } + break; |] + } + `); + testExtractRange(` + while (true) { + [#| if(x) { + } + continue; |] + } + `); + testExtractRange(` + l3: + { + [#| + if (x) { + } + break l3; |] + } + `); + testExtractRange(` + function f() { + while (true) { + [#| + if (x) { + return; + } |] + } + } + `); + testExtractRange(` + function f() { + while (true) { + [#| + [$|if (x) { + } + return;|] + |] + } + } + `); + testExtractRange(` + function f() { + return [#| [$|1 + 2|] |]+ 3; + } + } + `); + testExtractRange(` + function f() { + return [$|1 + [#|2 + 3|]|]; + } + } + `); + testExtractRange(` + function f() { + return [$|1 + 2 + [#|3 + 4|]|]; + } + } + `); + }); + + testExtractRangeFailed("extractRangeFailed1", + ` +namespace A { +function f() { + [#| + let x = 1 + if (x) { + return 10; + } + |] +} +} + `, + [ + refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalReturnStatement.message + ]); + + testExtractRangeFailed("extractRangeFailed2", + ` +namespace A { +function f() { + while (true) { + [#| + let x = 1 + if (x) { + break; + } + |] + } +} +} + `, + [ + refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message + ]); + + testExtractRangeFailed("extractRangeFailed3", + ` +namespace A { +function f() { + while (true) { + [#| + let x = 1 + if (x) { + continue; + } + |] + } +} +} + `, + [ + refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message + ]); + + testExtractRangeFailed("extractRangeFailed4", + ` +namespace A { +function f() { + l1: { + [#| + let x = 1 + if (x) { + break l1; + } + |] + } +} +} + `, + [ + refactor.extractSymbol.Messages.CannotExtractRangeContainingLabeledBreakOrContinueStatementWithTargetOutsideOfTheRange.message + ]); + + testExtractRangeFailed("extractRangeFailed5", + ` +namespace A { +function f() { + [#| + try { + f2() + return 10; + } + catch (e) { + } + |] +} +function f2() { +} +} + `, + [ + refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalReturnStatement.message + ]); + + testExtractRangeFailed("extractRangeFailed6", + ` +namespace A { +function f() { + [#| + try { + f2() + } + catch (e) { + return 10; + } + |] +} +function f2() { +} +} + `, + [ + refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalReturnStatement.message + ]); + + testExtractRangeFailed("extractRangeFailed7", + ` +function test(x: number) { +while (x) { + x--; + [#|break;|] +} +} + `, + [ + refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message + ]); + + testExtractRangeFailed("extractRangeFailed8", + ` +function test(x: number) { +switch (x) { + case 1: + [#|break;|] +} +} + `, + [ + refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message + ]); + + testExtractRangeFailed("extractRangeFailed9", + `var x = ([#||]1 + 2);`, + [ + "Cannot extract empty range." + ]); + + testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, [refactor.extractSymbol.Messages.CannotExtractIdentifier.message]); + }); +} \ No newline at end of file diff --git a/src/harness/unittests/extractTestHelpers.ts b/src/harness/unittests/extractTestHelpers.ts new file mode 100644 index 00000000000..ea1cccd32ea --- /dev/null +++ b/src/harness/unittests/extractTestHelpers.ts @@ -0,0 +1,199 @@ +/// +/// + +namespace ts { + export interface Range { + start: number; + end: number; + name: string; + } + + export interface Test { + source: string; + ranges: Map; + } + + export function extractTest(source: string): Test { + const activeRanges: Range[] = []; + let text = ""; + let lastPos = 0; + let pos = 0; + const ranges = createMap(); + + while (pos < source.length) { + if (source.charCodeAt(pos) === CharacterCodes.openBracket && + (source.charCodeAt(pos + 1) === CharacterCodes.hash || source.charCodeAt(pos + 1) === CharacterCodes.$)) { + const saved = pos; + pos += 2; + const s = pos; + consumeIdentifier(); + const e = pos; + if (source.charCodeAt(pos) === CharacterCodes.bar) { + pos++; + text += source.substring(lastPos, saved); + const name = s === e + ? source.charCodeAt(saved + 1) === CharacterCodes.hash ? "selection" : "extracted" + : source.substring(s, e); + activeRanges.push({ name, start: text.length, end: undefined }); + lastPos = pos; + continue; + } + else { + pos = saved; + } + } + else if (source.charCodeAt(pos) === CharacterCodes.bar && source.charCodeAt(pos + 1) === CharacterCodes.closeBracket) { + text += source.substring(lastPos, pos); + activeRanges[activeRanges.length - 1].end = text.length; + const range = activeRanges.pop(); + if (range.name in ranges) { + throw new Error(`Duplicate name of range ${range.name}`); + } + ranges.set(range.name, range); + pos += 2; + lastPos = pos; + continue; + } + pos++; + } + text += source.substring(lastPos, pos); + + function consumeIdentifier() { + while (isIdentifierPart(source.charCodeAt(pos), ScriptTarget.Latest)) { + pos++; + } + } + return { source: text, ranges }; + } + + export const newLineCharacter = "\n"; + export function getRuleProvider(action?: (opts: FormatCodeSettings) => void) { + const options = { + indentSize: 4, + tabSize: 4, + newLineCharacter, + convertTabsToSpaces: true, + indentStyle: ts.IndentStyle.Smart, + insertSpaceAfterConstructor: false, + insertSpaceAfterCommaDelimiter: true, + insertSpaceAfterSemicolonInForStatements: true, + insertSpaceBeforeAndAfterBinaryOperators: true, + insertSpaceAfterKeywordsInControlFlowStatements: true, + insertSpaceAfterFunctionKeywordForAnonymousFunctions: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true, + insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, + insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + insertSpaceBeforeFunctionParenthesis: false, + placeOpenBraceOnNewLineForFunctions: false, + placeOpenBraceOnNewLineForControlBlocks: false, + }; + if (action) { + action(options); + } + const rulesProvider = new formatting.RulesProvider(); + rulesProvider.ensureUpToDate(options); + return rulesProvider; + } + + export function testExtractSymbol(caption: string, text: string, baselineFolder: string, description: DiagnosticMessage) { + const t = extractTest(text); + const selectionRange = t.ranges.get("selection"); + if (!selectionRange) { + throw new Error(`Test ${caption} does not specify selection range`); + } + + [Extension.Ts, Extension.Js].forEach(extension => + it(`${caption} [${extension}]`, () => runBaseline(extension))); + + function runBaseline(extension: Extension) { + const path = "/a" + extension; + const program = makeProgram({ path, content: t.source }); + + if (hasSyntacticDiagnostics(program)) { + // Don't bother generating JS baselines for inputs that aren't valid JS. + assert.equal(Extension.Js, extension); + return; + } + + const sourceFile = program.getSourceFile(path); + const context: RefactorContext = { + cancellationToken: { throwIfCancellationRequested() { }, isCancellationRequested() { return false; } }, + newLineCharacter, + program, + file: sourceFile, + startPosition: selectionRange.start, + endPosition: selectionRange.end, + rulesProvider: getRuleProvider() + }; + const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); + assert.equal(rangeToExtract.errors, undefined, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText); + const infos = refactor.extractSymbol.getAvailableActions(context); + const actions = find(infos, info => info.description === description.message).actions; + + Harness.Baseline.runBaseline(`${baselineFolder}/${caption}${extension}`, () => { + const data: string[] = []; + data.push(`// ==ORIGINAL==`); + data.push(sourceFile.text); + for (const action of actions) { + const { renameLocation, edits } = refactor.extractSymbol.getEditsForAction(context, action.name); + assert.lengthOf(edits, 1); + data.push(`// ==SCOPE::${action.description}==`); + const newText = textChanges.applyChanges(sourceFile.text, edits[0].textChanges); + const newTextWithRename = newText.slice(0, renameLocation) + "/*RENAME*/" + newText.slice(renameLocation); + data.push(newTextWithRename); + + const diagProgram = makeProgram({ path, content: newText }); + assert.isFalse(hasSyntacticDiagnostics(diagProgram)); + } + return data.join(newLineCharacter); + }); + } + + function makeProgram(f: {path: string, content: string }) { + const host = projectSystem.createServerHost([f, projectSystem.libFile]); + const projectService = projectSystem.createProjectService(host); + projectService.openClientFile(f.path); + const program = projectService.inferredProjects[0].getLanguageService().getProgram(); + return program; + } + + function hasSyntacticDiagnostics(program: Program) { + const diags = program.getSyntacticDiagnostics(); + return length(diags) > 0; + } + } + + export function testExtractSymbolFailed(caption: string, text: string, description: DiagnosticMessage) { + it(caption, () => { + const t = extractTest(text); + const selectionRange = t.ranges.get("selection"); + if (!selectionRange) { + throw new Error(`Test ${caption} does not specify selection range`); + } + const f = { + path: "/a.ts", + content: t.source + }; + const host = projectSystem.createServerHost([f, projectSystem.libFile]); + const projectService = projectSystem.createProjectService(host); + projectService.openClientFile(f.path); + const program = projectService.inferredProjects[0].getLanguageService().getProgram(); + const sourceFile = program.getSourceFile(f.path); + const context: RefactorContext = { + cancellationToken: { throwIfCancellationRequested() { }, isCancellationRequested() { return false; } }, + newLineCharacter, + program, + file: sourceFile, + startPosition: selectionRange.start, + endPosition: selectionRange.end, + rulesProvider: getRuleProvider() + }; + const rangeToExtract = refactor.extractSymbol.getRangeToExtract(sourceFile, createTextSpanFromBounds(selectionRange.start, selectionRange.end)); + assert.isUndefined(rangeToExtract.errors, rangeToExtract.errors && "Range error: " + rangeToExtract.errors[0].messageText); + const infos = refactor.extractSymbol.getAvailableActions(context); + assert.isUndefined(find(infos, info => info.description === description.message)); + }); + } +} \ No newline at end of file diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index 0e6221567a2..b7215f5ea35 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -139,6 +139,16 @@ namespace ts { `/** * @param */`); + + parsesIncorrectly("noType", +`/** +* @type +*/`); + + parsesIncorrectly("@augments with no type", +`/** + * @augments + */`); }); describe("parsesCorrectly", () => { @@ -148,12 +158,6 @@ namespace ts { */`); - parsesCorrectly("noType", -`/** - * @type - */`); - - parsesCorrectly("noReturnType", `/** * @return @@ -296,6 +300,11 @@ namespace ts { * @property {number} age * @property {string} name */`); + parsesCorrectly("less-than and greater-than characters", +`/** + * @param x hi +< > still part of the previous comment + */`); }); }); describe("getFirstToken", () => { diff --git a/src/harness/unittests/printer.ts b/src/harness/unittests/printer.ts index 825bfddbb4a..2bbc19881a3 100644 --- a/src/harness/unittests/printer.ts +++ b/src/harness/unittests/printer.ts @@ -110,6 +110,29 @@ namespace ts { createSourceFile("source.ts", "", ScriptTarget.ES2015) )); + + printsCorrectly("emptyGlobalAugmentation", {}, printer => printer.printNode( + EmitHint.Unspecified, + createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ [createToken(SyntaxKind.DeclareKeyword)], + createIdentifier("global"), + createModuleBlock(emptyArray), + NodeFlags.GlobalAugmentation), + createSourceFile("source.ts", "", ScriptTarget.ES2015) + )); + + printsCorrectly("emptyGlobalAugmentationWithNoDeclareKeyword", {}, printer => printer.printNode( + EmitHint.Unspecified, + createModuleDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + createIdentifier("global"), + createModuleBlock(emptyArray), + NodeFlags.GlobalAugmentation), + createSourceFile("source.ts", "", ScriptTarget.ES2015) + )); + // https://github.com/Microsoft/TypeScript/issues/15971 printsCorrectly("classWithOptionalMethodAndProperty", {}, printer => printer.printNode( EmitHint.Unspecified, diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index 18109cfa9db..f37c9ea2392 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -509,7 +509,7 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks: Array<(resp: protocol.Response) => void> = []; + private callbacks: ((resp: protocol.Response) => void)[] = []; private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { diff --git a/src/harness/unittests/transpile.ts b/src/harness/unittests/transpile.ts index e0c96797827..16bef6500f2 100644 --- a/src/harness/unittests/transpile.ts +++ b/src/harness/unittests/transpile.ts @@ -17,32 +17,33 @@ namespace ts { let oldTranspileResult: string; let oldTranspileDiagnostics: Diagnostic[]; + transpileOptions = testSettings.options || {}; + if (!transpileOptions.compilerOptions) { + transpileOptions.compilerOptions = {}; + } + + if (transpileOptions.compilerOptions.newLine === undefined) { + // use \r\n as default new line + transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; + } + + transpileOptions.compilerOptions.sourceMap = true; + + if (!transpileOptions.fileName) { + transpileOptions.fileName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts"; + } + + transpileOptions.reportDiagnostics = true; + + justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? Extension.Tsx : Extension.Ts); + toBeCompiled = [{ + unitName: transpileOptions.fileName, + content: input + }]; + + canUseOldTranspile = !transpileOptions.renamedDependencies; + before(() => { - transpileOptions = testSettings.options || {}; - if (!transpileOptions.compilerOptions) { - transpileOptions.compilerOptions = {}; - } - - if (transpileOptions.compilerOptions.newLine === undefined) { - // use \r\n as default new line - transpileOptions.compilerOptions.newLine = ts.NewLineKind.CarriageReturnLineFeed; - } - - transpileOptions.compilerOptions.sourceMap = true; - - if (!transpileOptions.fileName) { - transpileOptions.fileName = transpileOptions.compilerOptions.jsx ? "file.tsx" : "file.ts"; - } - - transpileOptions.reportDiagnostics = true; - - justName = "transpile/" + name.replace(/[^a-z0-9\-. ]/ig, "") + (transpileOptions.compilerOptions.jsx ? Extension.Tsx : Extension.Ts); - toBeCompiled = [{ - unitName: transpileOptions.fileName, - content: input - }]; - - canUseOldTranspile = !transpileOptions.renamedDependencies; transpileResult = transpileModule(input, transpileOptions); if (canUseOldTranspile) { @@ -52,10 +53,6 @@ namespace ts { }); after(() => { - justName = undefined; - transpileOptions = undefined; - canUseOldTranspile = undefined; - toBeCompiled = undefined; transpileResult = undefined; oldTranspileResult = undefined; oldTranspileDiagnostics = undefined; diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 42d3d1543a0..e7c0d479711 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -10,7 +10,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T | undefined; + find(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -21,7 +21,7 @@ interface Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: T, index: number, obj: T[]) => boolean, thisArg?: any): number; /** * Returns the this object after filling the section identified by start and end with value @@ -52,13 +52,13 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): Array; + from(arrayLike: ArrayLike, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; /** * Returns a new array from a set of elements. * @param items A set of elements to include in the new array object. */ - of(...items: T[]): Array; + of(...items: T[]): T[]; } interface DateConstructor { diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 23e23510d3c..7b84c3e04c4 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -54,7 +54,7 @@ interface ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): Array; + from(iterable: Iterable, mapfn?: (v: T, k: number) => U, thisArg?: any): U[]; } interface ReadonlyArray { @@ -209,10 +209,6 @@ interface String { [Symbol.iterator](): IterableIterator; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { [Symbol.iterator](): IterableIterator; /** @@ -241,10 +237,6 @@ interface Int8ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { [Symbol.iterator](): IterableIterator; /** @@ -273,10 +265,6 @@ interface Uint8ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { [Symbol.iterator](): IterableIterator; /** @@ -308,10 +296,6 @@ interface Uint8ClampedArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { [Symbol.iterator](): IterableIterator; /** @@ -342,10 +326,6 @@ interface Int16ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { [Symbol.iterator](): IterableIterator; /** @@ -374,10 +354,6 @@ interface Uint16ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { [Symbol.iterator](): IterableIterator; /** @@ -406,10 +382,6 @@ interface Int32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { [Symbol.iterator](): IterableIterator; /** @@ -438,10 +410,6 @@ interface Uint32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { [Symbol.iterator](): IterableIterator; /** @@ -470,10 +438,6 @@ interface Float32ArrayConstructor { from(arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { [Symbol.iterator](): IterableIterator; /** diff --git a/src/lib/es2015.reflect.d.ts b/src/lib/es2015.reflect.d.ts index aab3da993dc..61a864b633f 100644 --- a/src/lib/es2015.reflect.d.ts +++ b/src/lib/es2015.reflect.d.ts @@ -8,7 +8,7 @@ declare namespace Reflect { function getPrototypeOf(target: object): object; function has(target: object, propertyKey: PropertyKey): boolean; function isExtensible(target: object): boolean; - function ownKeys(target: object): Array; + function ownKeys(target: object): PropertyKey[]; function preventExtensions(target: object): boolean; function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; function setPrototypeOf(target: object, proto: any): boolean; diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index b7c2610e652..268570ff232 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -240,12 +240,6 @@ interface String { split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[]; } -/** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. - */ interface ArrayBuffer { readonly [Symbol.toStringTag]: "ArrayBuffer"; } @@ -254,74 +248,38 @@ interface DataView { readonly [Symbol.toStringTag]: "DataView"; } -/** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Int8Array { readonly [Symbol.toStringTag]: "Int8Array"; } -/** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint8Array { readonly [Symbol.toStringTag]: "UInt8Array"; } -/** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. - * If the requested number of bytes could not be allocated an exception is raised. - */ interface Uint8ClampedArray { readonly [Symbol.toStringTag]: "Uint8ClampedArray"; } -/** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int16Array { readonly [Symbol.toStringTag]: "Int16Array"; } -/** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint16Array { readonly [Symbol.toStringTag]: "Uint16Array"; } -/** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Int32Array { readonly [Symbol.toStringTag]: "Int32Array"; } -/** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the - * requested number of bytes could not be allocated an exception is raised. - */ interface Uint32Array { readonly [Symbol.toStringTag]: "Uint32Array"; } -/** - * A typed array of 32-bit float values. The contents are initialized to 0. If the requested number - * of bytes could not be allocated an exception is raised. - */ interface Float32Array { readonly [Symbol.toStringTag]: "Float32Array"; } -/** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested - * number of bytes could not be allocated an exception is raised. - */ interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 820a90554ea..e08534d8ba9 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1577,7 +1577,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1588,7 +1588,7 @@ interface Int8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -1844,7 +1844,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1855,7 +1855,7 @@ interface Uint8Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2111,7 +2111,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2122,7 +2122,7 @@ interface Uint8ClampedArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint8ClampedArray) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2377,7 +2377,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2388,7 +2388,7 @@ interface Int16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2644,7 +2644,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2655,7 +2655,7 @@ interface Uint16Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint16Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -2911,7 +2911,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2922,7 +2922,7 @@ interface Int32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Int32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3178,7 +3178,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3189,7 +3189,7 @@ interface Uint32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Uint32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3444,7 +3444,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3455,7 +3455,7 @@ interface Float32Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float32Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. @@ -3712,7 +3712,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number | undefined; + find(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3723,7 +3723,7 @@ interface Float64Array { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - findIndex(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (value: number, index: number, obj: Float64Array) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. diff --git a/src/lib/scripthost.d.ts b/src/lib/scripthost.d.ts index bec8be31735..1fbd185949f 100644 --- a/src/lib/scripthost.d.ts +++ b/src/lib/scripthost.d.ts @@ -201,10 +201,18 @@ declare var WScript: { Sleep(intTime: number): void; }; +/** + * Represents an Automation SAFEARRAY + */ +declare class SafeArray { + private constructor(); + private SafeArray_typekey: SafeArray; +} + /** * Allows enumerating over a COM collection, which may not have indexed item access. */ -interface Enumerator { +interface Enumerator { /** * Returns true if the current item is the last one in the collection, or the collection is empty, * or the current item is undefined. @@ -230,8 +238,9 @@ interface Enumerator { } interface EnumeratorConstructor { - new (collection: any): Enumerator; - new (collection: any): Enumerator; + new (safearray: SafeArray): Enumerator; + new (collection: { Item(index: any): T }): Enumerator; + new (collection: any): Enumerator; } declare var Enumerator: EnumeratorConstructor; @@ -239,7 +248,7 @@ declare var Enumerator: EnumeratorConstructor; /** * Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions. */ -interface VBArray { +interface VBArray { /** * Returns the number of dimensions (1-based). */ @@ -271,8 +280,7 @@ interface VBArray { } interface VBArrayConstructor { - new (safeArray: any): VBArray; - new (safeArray: any): VBArray; + new (safeArray: SafeArray): VBArray; } declare var VBArray: VBArrayConstructor; @@ -280,7 +288,10 @@ declare var VBArray: VBArrayConstructor; /** * Automation date (VT_DATE) */ -interface VarDate { } +declare class VarDate { + private constructor(); + private VarDate_typekey: VarDate; +} interface DateConstructor { new (vd: VarDate): Date; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 3f5b76ae39d..d86f45a9ad9 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -84,7 +84,7 @@ namespace ts.server { } export interface SafeList { - [name: string]: { match: RegExp, exclude?: Array>, types?: string[] }; + [name: string]: { match: RegExp, exclude?: (string | number)[][], types?: string[] }; } function prepareConvertersForEnumLikeCompilerOptions(commandLineOptions: CommandLineOption[]): Map> { @@ -1190,7 +1190,8 @@ namespace ts.server { /*languageServiceEnabled*/ !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); - this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); + const filesToAdd = projectOptions.files.concat(project.getExternalFiles()); + this.addFilesToProjectAndUpdateGraph(project, filesToAdd, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); project.watchConfigFile(project => this.onConfigChangedForConfiguredProject(project)); if (!sizeLimitExceeded) { @@ -1210,7 +1211,7 @@ namespace ts.server { } } - private addFilesToProjectAndUpdateGraph(project: ConfiguredProject | ExternalProject, files: T[], propertyReader: FilePropertyReader, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray): void { + private addFilesToProjectAndUpdateGraph(project: ConfiguredProject | ExternalProject, files: ReadonlyArray, propertyReader: FilePropertyReader, clientFileName: string, typeAcquisition: TypeAcquisition, configFileErrors: ReadonlyArray): void { let errors: Diagnostic[]; for (const f of files) { const rootFileName = propertyReader.getFileName(f); @@ -1779,7 +1780,7 @@ namespace ts.server { if (rule.exclude) { for (const exclude of rule.exclude) { - const processedRule = root.replace(rule.match, (...groups: Array) => { + const processedRule = root.replace(rule.match, (...groups: string[]) => { return exclude.map(groupNumberOrString => { // RegExp group numbers are 1-based, but the first element in groups // is actually the original string, so it all works out in the end. diff --git a/src/server/project.ts b/src/server/project.ts index 8d8d33ddd16..9ef79530e51 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -746,7 +746,8 @@ namespace ts.server { } // compute and return the difference const lastReportedFileNames = this.lastReportedFileNames; - const currentFiles = arrayToSet(this.getFileNames()); + const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f)); + const currentFiles = arrayToSet(this.getFileNames().concat(externalFiles)); const added: string[] = []; const removed: string[] = []; @@ -769,7 +770,8 @@ namespace ts.server { else { // unknown version - return everything const projectFileNames = this.getFileNames(); - this.lastReportedFileNames = arrayToSet(projectFileNames); + const externalFiles = this.getExternalFiles().map(f => toNormalizedPath(f)); + this.lastReportedFileNames = arrayToSet(projectFileNames.concat(externalFiles)); this.lastReportedVersion = this.projectStructureVersion; return { info, files: projectFileNames, projectErrors: this.getGlobalProjectErrors() }; } @@ -1084,6 +1086,9 @@ namespace ts.server { } catch (e) { this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`); + if (e.stack) { + this.projectService.logger.info(e.stack); + } } })); } diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 97e209fe89a..a9583106fc6 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -156,8 +156,9 @@ namespace ts.codefix { const propertyChangeTracker = textChanges.ChangeTracker.fromContext(context); propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter }); - (actions || (actions = [])).push({ - description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Declare_property_0), [tokenName]), + const diag = makeStatic ? Diagnostics.Declare_static_property_0 : Diagnostics.Declare_property_0; + actions = append(actions, { + description: formatStringFromArgs(getLocaleSpecificMessage(diag), [tokenName]), changes: propertyChangeTracker.getChanges() }); @@ -197,11 +198,9 @@ namespace ts.codefix { const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromContext(context); methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter }); + const diag = makeStatic ? Diagnostics.Declare_static_method_0 : Diagnostics.Declare_method_0; return { - description: formatStringFromArgs(getLocaleSpecificMessage(makeStatic ? - Diagnostics.Declare_method_0 : - Diagnostics.Declare_static_method_0), - [tokenName]), + description: formatStringFromArgs(getLocaleSpecificMessage(diag), [tokenName]), changes: methodDeclarationChangeTracker.getChanges() }; } diff --git a/src/services/completions.ts b/src/services/completions.ts index e271ef12104..44ad611de79 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -581,11 +581,10 @@ namespace ts.Completions { return { symbols, isGlobalCompletion, isMemberCompletion, allowStringLiteral, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), request, keywordFilters }; - type JSDocTagWithTypeExpression = JSDocAugmentsTag | JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag; + type JSDocTagWithTypeExpression = JSDocParameterTag | JSDocPropertyTag | JSDocReturnTag | JSDocTypeTag | JSDocTypedefTag; function isTagWithTypeExpression(tag: JSDocTag): tag is JSDocTagWithTypeExpression { switch (tag.kind) { - case SyntaxKind.JSDocAugmentsTag: case SyntaxKind.JSDocParameterTag: case SyntaxKind.JSDocPropertyTag: case SyntaxKind.JSDocReturnTag: diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index 80194c5649b..d4e660295a0 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -515,7 +515,7 @@ namespace ts.FindAllReferences.Core { } // Source file ID → symbol ID → Whether the symbol has been searched for in the source file. - private readonly sourceFileToSeenSymbols: Array> = []; + private readonly sourceFileToSeenSymbols: true[][] = []; /** Returns `true` the first time we search for a symbol in a file and `false` afterwards. */ markSearchedSymbol(sourceFile: SourceFile, symbol: Symbol): boolean { const sourceId = getNodeId(sourceFile); diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 5f26990d3a4..3808cb78940 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -663,9 +663,10 @@ namespace ts.formatting { undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } - // if child is a list item - try to get its indentation + // if child is a list item - try to get its indentation, only if parent is within the original range. let childIndentationAmount = Constants.Unknown; - if (isListItem) { + + if (isListItem && rangeContainsRange(originalRange, parent)) { childIndentationAmount = tryComputeIndentationForListItem(childStartPos, child.end, parentStartLine, originalRange, inheritedIndentation); if (childIndentationAmount !== Constants.Unknown) { inheritedIndentation = childIndentationAmount; diff --git a/src/services/formatting/formattingScanner.ts b/src/services/formatting/formattingScanner.ts index 9b4e1be323b..f126327fa06 100644 --- a/src/services/formatting/formattingScanner.ts +++ b/src/services/formatting/formattingScanner.ts @@ -53,28 +53,19 @@ namespace ts.formatting { return res; function advance(): void { - Debug.assert(scanner !== undefined, "Scanner should be present"); - lastTokenInfo = undefined; const isStarted = scanner.getStartPos() !== startPos; if (isStarted) { - if (trailingTrivia) { - Debug.assert(trailingTrivia.length !== 0); - wasNewLine = lastOrUndefined(trailingTrivia).kind === SyntaxKind.NewLineTrivia; - } - else { - wasNewLine = false; - } + wasNewLine = trailingTrivia && lastOrUndefined(trailingTrivia)!.kind === SyntaxKind.NewLineTrivia; + } + else { + scanner.scan(); } leadingTrivia = undefined; trailingTrivia = undefined; - if (!isStarted) { - scanner.scan(); - } - let pos = scanner.getStartPos(); // Read leading trivia and token @@ -94,25 +85,20 @@ namespace ts.formatting { pos = scanner.getStartPos(); - if (!leadingTrivia) { - leadingTrivia = []; - } - leadingTrivia.push(item); + leadingTrivia = append(leadingTrivia, item); } savedPos = scanner.getStartPos(); } function shouldRescanGreaterThanToken(node: Node): boolean { - if (node) { - switch (node.kind) { - case SyntaxKind.GreaterThanEqualsToken: - case SyntaxKind.GreaterThanGreaterThanEqualsToken: - case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken: - case SyntaxKind.GreaterThanGreaterThanGreaterThanToken: - case SyntaxKind.GreaterThanGreaterThanToken: - return true; - } + switch (node.kind) { + case SyntaxKind.GreaterThanEqualsToken: + case SyntaxKind.GreaterThanGreaterThanEqualsToken: + case SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken: + case SyntaxKind.GreaterThanGreaterThanGreaterThanToken: + case SyntaxKind.GreaterThanGreaterThanToken: + return true; } return false; @@ -125,7 +111,8 @@ namespace ts.formatting { case SyntaxKind.JsxOpeningElement: case SyntaxKind.JsxClosingElement: case SyntaxKind.JsxSelfClosingElement: - return node.kind === SyntaxKind.Identifier; + // May parse an identifier like `module-layout`; that will be scanned as a keyword at first, but we should parse the whole thing to get an identifier. + return isKeyword(node.kind) || node.kind === SyntaxKind.Identifier; } } @@ -133,7 +120,7 @@ namespace ts.formatting { } function shouldRescanJsxText(node: Node): boolean { - return node && node.kind === SyntaxKind.JsxText; + return node.kind === SyntaxKind.JsxText; } function shouldRescanSlashToken(container: Node): boolean { @@ -150,16 +137,7 @@ namespace ts.formatting { } function readTokenInfo(n: Node): TokenInfo { - Debug.assert(scanner !== undefined); - - if (!isOnToken()) { - // scanner is not on the token (either advance was not called yet or scanner is already past the end position) - return { - leadingTrivia, - trailingTrivia: undefined, - token: undefined - }; - } + Debug.assert(isOnToken()); // normally scanner returns the smallest available token // check the kind of context node to determine if scanner should have more greedy behavior and consume more text. @@ -193,33 +171,7 @@ namespace ts.formatting { scanner.scan(); } - let currentToken = scanner.getToken(); - - if (expectedScanAction === ScanAction.RescanGreaterThanToken && currentToken === SyntaxKind.GreaterThanToken) { - currentToken = scanner.reScanGreaterToken(); - Debug.assert(n.kind === currentToken); - lastScanAction = ScanAction.RescanGreaterThanToken; - } - else if (expectedScanAction === ScanAction.RescanSlashToken && startsWithSlashToken(currentToken)) { - currentToken = scanner.reScanSlashToken(); - Debug.assert(n.kind === currentToken); - lastScanAction = ScanAction.RescanSlashToken; - } - else if (expectedScanAction === ScanAction.RescanTemplateToken && currentToken === SyntaxKind.CloseBraceToken) { - currentToken = scanner.reScanTemplateToken(); - lastScanAction = ScanAction.RescanTemplateToken; - } - else if (expectedScanAction === ScanAction.RescanJsxIdentifier && currentToken === SyntaxKind.Identifier) { - currentToken = scanner.scanJsxIdentifier(); - lastScanAction = ScanAction.RescanJsxIdentifier; - } - else if (expectedScanAction === ScanAction.RescanJsxText) { - currentToken = scanner.reScanJsxToken(); - lastScanAction = ScanAction.RescanJsxText; - } - else { - lastScanAction = ScanAction.Scan; - } + let currentToken = getNextToken(n, expectedScanAction); const token: TextRangeWithKind = { pos: scanner.getStartPos(), @@ -260,9 +212,47 @@ namespace ts.formatting { return fixTokenKind(lastTokenInfo, n); } - function isOnToken(): boolean { - Debug.assert(scanner !== undefined); + function getNextToken(n: Node, expectedScanAction: ScanAction): SyntaxKind { + const token = scanner.getToken(); + lastScanAction = ScanAction.Scan; + switch (expectedScanAction) { + case ScanAction.RescanGreaterThanToken: + if (token === SyntaxKind.GreaterThanToken) { + lastScanAction = ScanAction.RescanGreaterThanToken; + const newToken = scanner.reScanGreaterToken(); + Debug.assert(n.kind === newToken); + return newToken; + } + break; + case ScanAction.RescanSlashToken: + if (startsWithSlashToken(token)) { + lastScanAction = ScanAction.RescanSlashToken; + const newToken = scanner.reScanSlashToken(); + Debug.assert(n.kind === newToken); + return newToken; + } + break; + case ScanAction.RescanTemplateToken: + if (token === SyntaxKind.CloseBraceToken) { + lastScanAction = ScanAction.RescanTemplateToken; + return scanner.reScanTemplateToken(); + } + break; + case ScanAction.RescanJsxIdentifier: + lastScanAction = ScanAction.RescanJsxIdentifier; + return scanner.scanJsxIdentifier(); + case ScanAction.RescanJsxText: + lastScanAction = ScanAction.RescanJsxText; + return scanner.reScanJsxToken(); + case ScanAction.Scan: + break; + default: + Debug.assertNever(expectedScanAction); + } + return token; + } + function isOnToken(): boolean { const current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); const startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== SyntaxKind.EndOfFileToken && !isTrivia(current); diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 65b504e7bd8..a6152230218 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -3,7 +3,7 @@ namespace ts.FindAllReferences { export interface ImportsResult { /** For every import of the symbol, the location and local symbol for the import. */ - importSearches: Array<[Identifier, Symbol]>; + importSearches: [Identifier, Symbol][]; /** For rename imports/exports `{ foo as bar }`, `foo` is not a local, so it may be added as a reference immediately without further searching. */ singleReferences: Identifier[]; /** List of source files that may (or may not) use the symbol via a namespace. (For UMD modules this is every file.) */ @@ -180,7 +180,7 @@ namespace ts.FindAllReferences { * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. */ function getSearchesFromDirectImports(directImports: Importer[], exportSymbol: Symbol, exportKind: ExportKind, checker: TypeChecker, isForRename: boolean): Pick { - const importSearches: Array<[Identifier, Symbol]> = []; + const importSearches: [Identifier, Symbol][] = []; const singleReferences: Identifier[] = []; function addSearch(location: Identifier, symbol: Symbol): void { importSearches.push([location, symbol]); diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index f7ed515a18f..bf34f28fed6 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -209,17 +209,24 @@ namespace ts.NavigationBar { case SyntaxKind.BindingElement: case SyntaxKind.VariableDeclaration: - const decl = node; - const name = decl.name; + const { name, initializer } = node; if (isBindingPattern(name)) { addChildrenRecursively(name); } - else if (decl.initializer && isFunctionOrClassExpression(decl.initializer)) { - // For `const x = function() {}`, just use the function node, not the const. - addChildrenRecursively(decl.initializer); + else if (initializer && isFunctionOrClassExpression(initializer)) { + if (initializer.name) { + // Don't add a node for the VariableDeclaration, just for the initializer. + addChildrenRecursively(initializer); + } + else { + // Add a node for the VariableDeclaration, but not for the initializer. + startNode(node); + forEachChild(initializer, addChildrenRecursively); + endNode(); + } } else { - addNodeWithRecursiveChild(decl, decl.initializer); + addNodeWithRecursiveChild(node, initializer); } break; @@ -644,7 +651,14 @@ namespace ts.NavigationBar { } } - function isFunctionOrClassExpression(node: Node): boolean { - return node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction || node.kind === SyntaxKind.ClassExpression; + function isFunctionOrClassExpression(node: Node): node is ArrowFunction | FunctionExpression | ClassExpression { + switch (node.kind) { + case SyntaxKind.ArrowFunction: + case SyntaxKind.FunctionExpression: + case SyntaxKind.ClassExpression: + return true; + default: + return false; + } } } diff --git a/src/services/refactorProvider.ts b/src/services/refactorProvider.ts index 432df8c53d0..c8dc1cf360a 100644 --- a/src/services/refactorProvider.ts +++ b/src/services/refactorProvider.ts @@ -43,4 +43,8 @@ namespace ts { return refactor && refactor.getEditsForAction(context, actionName); } } + + export function getRefactorContextLength(context: RefactorContext): number { + return context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; + } } diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractSymbol.ts similarity index 73% rename from src/services/refactors/extractMethod.ts rename to src/services/refactors/extractSymbol.ts index 3b8ea19a9f0..375acb7e585 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractSymbol.ts @@ -2,19 +2,22 @@ /// /* @internal */ -namespace ts.refactor.extractMethod { - const extractMethod: Refactor = { - name: "Extract Method", - description: Diagnostics.Extract_function.message, +namespace ts.refactor.extractSymbol { + const extractSymbol: Refactor = { + name: "Extract Symbol", + description: Diagnostics.Extract_symbol.message, getAvailableActions, getEditsForAction, }; - registerRefactor(extractMethod); + registerRefactor(extractSymbol); - /** Compute the associated code actions */ - function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined { - const rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: context.endPosition - context.startPosition }); + /** + * Compute the associated code actions + * Exported for tests. + */ + export function getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] | undefined { + const rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: getRefactorContextLength(context) }); const targetRange: TargetRange = rangeToExtract.targetRange; if (targetRange === undefined) { @@ -27,64 +30,103 @@ namespace ts.refactor.extractMethod { return undefined; } - const actions: RefactorActionInfo[] = []; - const usedNames: Map = createMap(); + const functionActions: RefactorActionInfo[] = []; + const usedFunctionNames: Map = createMap(); + + const constantActions: RefactorActionInfo[] = []; + const usedConstantNames: Map = createMap(); let i = 0; - for (const { scopeDescription, errors } of extractions) { + for (const extraction of extractions) { // Skip these since we don't have a way to report errors yet - if (errors.length) { - continue; + if (extraction.functionErrors.length === 0) { + // Don't issue refactorings with duplicated names. + // Scopes come back in "innermost first" order, so extractions will + // preferentially go into nearer scopes + const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extraction.functionDescription]); + if (!usedFunctionNames.has(description)) { + usedFunctionNames.set(description, true); + functionActions.push({ + description, + name: `function_scope_${i}` + }); + } } - // Don't issue refactorings with duplicated names. - // Scopes come back in "innermost first" order, so extractions will - // preferentially go into nearer scopes - const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [scopeDescription]); - if (!usedNames.has(description)) { - usedNames.set(description, true); - actions.push({ - description, - name: `scope_${i}` - }); + // Skip these since we don't have a way to report errors yet + if (extraction.constantErrors.length === 0) { + // Don't issue refactorings with duplicated names. + // Scopes come back in "innermost first" order, so extractions will + // preferentially go into nearer scopes + const description = formatStringFromArgs(Diagnostics.Extract_to_0.message, [extraction.constantDescription]); + if (!usedConstantNames.has(description)) { + usedConstantNames.set(description, true); + constantActions.push({ + description, + name: `constant_scope_${i}` + }); + } } + // *do* increment i anyway because we'll look for the i-th scope // later when actually doing the refactoring if the user requests it i++; } - if (actions.length === 0) { - return undefined; + const infos: ApplicableRefactorInfo[] = []; + + if (functionActions.length) { + infos.push({ + name: extractSymbol.name, + description: Diagnostics.Extract_function.message, + actions: functionActions + }); } - return [{ - name: extractMethod.name, - description: extractMethod.description, - inlineable: true, - actions - }]; + if (constantActions.length) { + infos.push({ + name: extractSymbol.name, + description: Diagnostics.Extract_constant.message, + actions: constantActions + }); + } + + return infos.length ? infos : undefined; } - function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined { - const length = context.endPosition === undefined ? 0 : context.endPosition - context.startPosition; - const rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length }); + /* Exported for tests */ + export function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined { + const rangeToExtract = getRangeToExtract(context.file, { start: context.startPosition, length: getRefactorContextLength(context) }); const targetRange: TargetRange = rangeToExtract.targetRange; - const parsedIndexMatch = /^scope_(\d+)$/.exec(actionName); - Debug.assert(!!parsedIndexMatch, "Scope name should have matched the regexp"); - const index = +parsedIndexMatch[1]; - Debug.assert(isFinite(index), "Expected to parse a finite number from the scope index"); + const parsedFunctionIndexMatch = /^function_scope_(\d+)$/.exec(actionName); + if (parsedFunctionIndexMatch) { + const index = +parsedFunctionIndexMatch[1]; + Debug.assert(isFinite(index), "Expected to parse a finite number from the function scope index"); + return getFunctionExtractionAtIndex(targetRange, context, index); + } - return getExtractionAtIndex(targetRange, context, index); + const parsedConstantIndexMatch = /^constant_scope_(\d+)$/.exec(actionName); + if (parsedConstantIndexMatch) { + const index = +parsedConstantIndexMatch[1]; + Debug.assert(isFinite(index), "Expected to parse a finite number from the constant scope index"); + return getConstantExtractionAtIndex(targetRange, context, index); + } + + Debug.fail("Unrecognized action name"); } // Move these into diagnostic messages if they become user-facing - namespace Messages { + export namespace Messages { function createMessage(message: string): DiagnosticMessage { return { message, code: 0, category: DiagnosticCategory.Message, key: message }; } - export const CannotExtractFunction: DiagnosticMessage = createMessage("Cannot extract function."); + export const CannotExtractRange: DiagnosticMessage = createMessage("Cannot extract range."); + export const CannotExtractImport: DiagnosticMessage = createMessage("Cannot extract import statement."); + export const CannotExtractSuper: DiagnosticMessage = createMessage("Cannot extract super call."); + export const CannotExtractEmpty: DiagnosticMessage = createMessage("Cannot extract empty range."); + export const ExpressionExpected: DiagnosticMessage = createMessage("expression expected."); export const StatementOrExpressionExpected: DiagnosticMessage = createMessage("Statement or expression expected."); export const CannotExtractRangeContainingConditionalBreakOrContinueStatements: DiagnosticMessage = createMessage("Cannot extract range containing conditional break or continue statements."); export const CannotExtractRangeContainingConditionalReturnStatement: DiagnosticMessage = createMessage("Cannot extract range containing conditional return statement."); @@ -92,11 +134,14 @@ namespace ts.refactor.extractMethod { export const CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators: DiagnosticMessage = createMessage("Cannot extract range containing writes to references located outside of the target range in generators."); export const TypeWillNotBeVisibleInTheNewScope = createMessage("Type will not visible in the new scope."); export const FunctionWillNotBeVisibleInTheNewScope = createMessage("Function will not visible in the new scope."); - export const InsufficientSelection = createMessage("Select more than a single identifier."); + export const CannotExtractIdentifier = createMessage("Select more than a single identifier."); export const CannotExtractExportedEntity = createMessage("Cannot extract exported declaration"); export const CannotCombineWritesAndReturns = createMessage("Cannot combine writes and returns"); export const CannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor"); export const CannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts"); + export const CannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes"); + export const CannotExtractToOtherFunctionLike = createMessage("Cannot extract method to a function-like scope that is not a function"); + export const CannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS"); } enum RangeFacts { @@ -148,10 +193,10 @@ namespace ts.refactor.extractMethod { */ // exported only for tests export function getRangeToExtract(sourceFile: SourceFile, span: TextSpan): RangeToExtract { - const length = span.length || 0; + const { length } = span; if (length === 0) { - return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.StatementOrExpressionExpected)] }; + return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractEmpty)] }; } // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. @@ -168,7 +213,7 @@ namespace ts.refactor.extractMethod { if (!start || !end) { // cannot find either start or end node - return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractFunction)] }; + return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractRange)] }; } if (start.parent !== end.parent) { @@ -194,13 +239,13 @@ namespace ts.refactor.extractMethod { } else { // start and end nodes belong to different subtrees - return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractRange)] }; } } if (start !== end) { // start and end should be statements and parent should be either block or a source file if (!isBlockLike(start.parent)) { - return createErrorResult(sourceFile, span.start, length, Messages.CannotExtractFunction); + return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.CannotExtractRange)] }; } const statements: Statement[] = []; for (const statement of (start.parent).statements) { @@ -217,22 +262,17 @@ namespace ts.refactor.extractMethod { } return { targetRange: { range: statements, facts: rangeFacts, declarations } }; } - else { - // We have a single node (start) - const errors = checkRootNode(start) || checkNode(start); - if (errors) { - return { errors }; - } - return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations } }; - } - function createErrorResult(sourceFile: SourceFile, start: number, length: number, message: DiagnosticMessage): RangeToExtract { - return { errors: [createFileDiagnostic(sourceFile, start, length, message)] }; + // We have a single node (start) + const errors = checkRootNode(start) || checkNode(start); + if (errors) { + return { errors }; } + return { targetRange: { range: getStatementOrExpressionRange(start), facts: rangeFacts, declarations } }; function checkRootNode(node: Node): Diagnostic[] | undefined { if (isIdentifier(isExpressionStatement(node) ? node.expression : node)) { - return [createDiagnosticForNode(node, Messages.InsufficientSelection)]; + return [createDiagnosticForNode(node, Messages.CannotExtractIdentifier)]; } return undefined; } @@ -286,7 +326,7 @@ namespace ts.refactor.extractMethod { let errors: Diagnostic[]; let permittedJumps = PermittedJumps.Return; - let seenLabels: Array<__String>; + let seenLabels: __String[]; visit(nodeToCheck); @@ -310,7 +350,7 @@ namespace ts.refactor.extractMethod { // Some things can't be extracted in certain situations switch (node.kind) { case SyntaxKind.ImportDeclaration: - (errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractFunction)); + (errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractImport)); return true; case SyntaxKind.SuperKeyword: // For a super *constructor call*, we have to be extracting the entire class, @@ -319,7 +359,7 @@ namespace ts.refactor.extractMethod { // Super constructor call const containingClass = getContainingClass(node); if (containingClass.pos < span.start || containingClass.end >= (span.start + span.length)) { - (errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractFunction)); + (errors || (errors = [])).push(createDiagnosticForNode(node, Messages.CannotExtractSuper)); return true; } } @@ -329,7 +369,7 @@ namespace ts.refactor.extractMethod { break; } - if (!node || isFunctionLike(node) || isClassLike(node)) { + if (!node || isFunctionLikeDeclaration(node) || isClassLike(node)) { switch (node.kind) { case SyntaxKind.FunctionDeclaration: case SyntaxKind.ClassDeclaration: @@ -440,9 +480,8 @@ namespace ts.refactor.extractMethod { return undefined; } - function isValidExtractionTarget(node: Node): node is Scope { - // Note that we don't use isFunctionLike because we don't want to put the extracted closure *inside* a method - return (node.kind === SyntaxKind.FunctionDeclaration) || isSourceFile(node) || isModuleBlock(node) || isClassLike(node); + function isScope(node: Node): node is Scope { + return isFunctionLikeDeclaration(node) || isSourceFile(node) || isModuleBlock(node) || isClassLike(node); } /** @@ -469,14 +508,14 @@ namespace ts.refactor.extractMethod { // * Function declaration // * Class declaration or expression // * Module/namespace or source file - if (current !== start && isValidExtractionTarget(current)) { + if (current !== start && isScope(current)) { (scopes = scopes || []).push(current); } // A function parameter's initializer is actually in the outer scope, not the function declaration if (current && current.parent && current.parent.kind === SyntaxKind.Parameter) { // Skip all the way to the outer scope of the function that declared this parameter - current = findAncestor(current, parent => isFunctionLike(parent)).parent; + current = findAncestor(current, parent => isFunctionLikeDeclaration(parent)).parent; } else { current = current.parent; @@ -486,29 +525,44 @@ namespace ts.refactor.extractMethod { return scopes; } - // exported only for tests - export function getExtractionAtIndex(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number): RefactorEditInfo { - const { scopes, readsAndWrites: { target, usagesPerScope, errorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); - Debug.assert(!errorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); + function getFunctionExtractionAtIndex(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number): RefactorEditInfo { + const { scopes, readsAndWrites: { target, usagesPerScope, functionErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); + Debug.assert(!functionErrorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); context.cancellationToken.throwIfCancellationRequested(); return extractFunctionInScope(target, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange, context); } + function getConstantExtractionAtIndex(targetRange: TargetRange, context: RefactorContext, requestedChangesIndex: number): RefactorEditInfo { + const { scopes, readsAndWrites: { target, usagesPerScope, constantErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); + Debug.assert(!constantErrorsPerScope[requestedChangesIndex].length, "The extraction went missing? How?"); + context.cancellationToken.throwIfCancellationRequested(); + const expression = isExpression(target) + ? target + : (target.statements[0] as ExpressionStatement).expression; + return extractConstantInScope(expression, scopes[requestedChangesIndex], usagesPerScope[requestedChangesIndex], targetRange.facts, context); + } + interface PossibleExtraction { - readonly scopeDescription: string; - readonly errors: ReadonlyArray; + readonly functionDescription: string; + readonly functionErrors: ReadonlyArray; + readonly constantDescription: string; + readonly constantErrors: ReadonlyArray; } /** * Given a piece of text to extract ('targetRange'), computes a list of possible extractions. * Each returned ExtractResultForScope corresponds to a possible target scope and is either a set of changes * or an error explaining why we can't extract into that scope. */ - // exported only for tests - export function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext): ReadonlyArray | undefined { - const { scopes, readsAndWrites: { errorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); + function getPossibleExtractions(targetRange: TargetRange, context: RefactorContext): ReadonlyArray | undefined { + const { scopes, readsAndWrites: { functionErrorsPerScope, constantErrorsPerScope } } = getPossibleExtractionsWorker(targetRange, context); // Need the inner type annotation to avoid https://github.com/Microsoft/TypeScript/issues/7547 - return scopes.map((scope, i): PossibleExtraction => - ({ scopeDescription: getDescriptionForScope(scope), errors: errorsPerScope[i] })); + const extractions = scopes.map((scope, i): PossibleExtraction => ({ + functionDescription: getDescriptionForFunctionInScope(scope), + functionErrors: functionErrorsPerScope[i], + constantDescription: getDescriptionForConstantInScope(scope), + constantErrors: constantErrorsPerScope[i], + })); + return extractions; } function getPossibleExtractionsWorker(targetRange: TargetRange, context: RefactorContext): { readonly scopes: Scope[], readonly readsAndWrites: ReadsAndWrites } { @@ -534,13 +588,20 @@ namespace ts.refactor.extractMethod { return { scopes, readsAndWrites }; } - function getDescriptionForScope(scope: Scope): string { + function getDescriptionForFunctionInScope(scope: Scope): string { return isFunctionLikeDeclaration(scope) ? `inner function in ${getDescriptionForFunctionLikeDeclaration(scope)}` : isClassLike(scope) ? `method in ${getDescriptionForClassLikeDeclaration(scope)}` : `function in ${getDescriptionForModuleLikeDeclaration(scope)}`; } + function getDescriptionForConstantInScope(scope: Scope): string { + return isFunctionLikeDeclaration(scope) + ? `constant in ${getDescriptionForFunctionLikeDeclaration(scope)}` + : isClassLike(scope) + ? `readonly field in ${getDescriptionForClassLikeDeclaration(scope)}` + : `constant in ${getDescriptionForModuleLikeDeclaration(scope)}`; + } function getDescriptionForFunctionLikeDeclaration(scope: FunctionLikeDeclaration): string { switch (scope.kind) { case SyntaxKind.Constructor: @@ -574,12 +635,12 @@ namespace ts.refactor.extractMethod { : scope.externalModuleIndicator ? "module scope" : "global scope"; } - function getUniqueName(fileText: string): string { - let functionNameText = "newFunction"; - for (let i = 1; fileText.indexOf(functionNameText) !== -1; i++) { - functionNameText = `newFunction_${i}`; + function getUniqueName(baseName: string, fileText: string): string { + let nameText = baseName; + for (let i = 1; fileText.indexOf(nameText) !== -1; i++) { + nameText = `${baseName}_${i}`; } - return functionNameText; + return nameText; } /** @@ -597,7 +658,7 @@ namespace ts.refactor.extractMethod { // Make a unique name for the extracted function const file = scope.getSourceFile(); - const functionNameText = getUniqueName(file.text); + const functionNameText = getUniqueName(isClassLike(scope) ? "newMethod" : "newFunction", file.text); const isJS = isInJavaScriptFile(scope); const functionName = createIdentifier(functionNameText); @@ -664,7 +725,7 @@ namespace ts.refactor.extractMethod { } newFunction = createMethod( /*decorators*/ undefined, - modifiers, + modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? createToken(SyntaxKind.AsteriskToken) : undefined, functionName, /*questionToken*/ undefined, @@ -689,7 +750,7 @@ namespace ts.refactor.extractMethod { const changeTracker = textChanges.ChangeTracker.fromContext(context); const minInsertionPos = (isReadonlyArray(range.range) ? lastOrUndefined(range.range) : range.range).end; - const nodeToInsertBefore = getNodeToInsertBefore(minInsertionPos, scope); + const nodeToInsertBefore = getNodeToInsertFunctionBefore(minInsertionPos, scope); if (nodeToInsertBefore) { changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newFunction, { suffix: context.newLineCharacter + context.newLineCharacter }); } @@ -775,27 +836,126 @@ namespace ts.refactor.extractMethod { const renameRange = isReadonlyArray(range.range) ? range.range[0] : range.range; const renameFilename = renameRange.getSourceFile().fileName; - const renameLocation = getRenameLocation(edits, renameFilename, functionNameText); + const renameLocation = getRenameLocation(edits, renameFilename, functionNameText, /*isDeclaredBeforeUse*/ false); return { renameFilename, renameLocation, edits }; } - function getRenameLocation(edits: ReadonlyArray, renameFilename: string, functionNameText: string): number { + /** + * Result of 'extractRange' operation for a specific scope. + * Stores either a list of changes that should be applied to extract a range or a list of errors + */ + function extractConstantInScope( + node: Expression, + scope: Scope, + { substitutions }: ScopeUsages, + rangeFacts: RangeFacts, + context: RefactorContext): RefactorEditInfo { + + const checker = context.program.getTypeChecker(); + + // Make a unique name for the extracted variable + const file = scope.getSourceFile(); + const localNameText = getUniqueName(isClassLike(scope) ? "newProperty" : "newLocal", file.text); + const isJS = isInJavaScriptFile(scope); + + const variableType = isJS + ? undefined + : checker.typeToTypeNode(checker.getContextualType(node)); + + const initializer = transformConstantInitializer(node, substitutions); + + const changeTracker = textChanges.ChangeTracker.fromContext(context); + + if (isClassLike(scope)) { + Debug.assert(!isJS); // See CannotExtractToJSClass + const modifiers: Modifier[] = []; + modifiers.push(createToken(SyntaxKind.PrivateKeyword)); + if (rangeFacts & RangeFacts.InStaticRegion) { + modifiers.push(createToken(SyntaxKind.StaticKeyword)); + } + modifiers.push(createToken(SyntaxKind.ReadonlyKeyword)); + + const newVariable = createProperty( + /*decorators*/ undefined, + modifiers, + localNameText, + /*questionToken*/ undefined, + variableType, + initializer); + + const localReference = createPropertyAccess( + rangeFacts & RangeFacts.InStaticRegion + ? createIdentifier(scope.name.getText()) + : createThis(), + createIdentifier(localNameText)); + + // Declare + const minInsertionPos = node.end; + const nodeToInsertBefore = getNodeToInsertConstantBefore(minInsertionPos, scope); + changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariable, { suffix: context.newLineCharacter + context.newLineCharacter }); + + // Consume + changeTracker.replaceNodeWithNodes(context.file, node, [localReference], { nodeSeparator: context.newLineCharacter }); + } + else { + const newVariable = createVariableStatement( + /*modifiers*/ undefined, + createVariableDeclarationList( + [createVariableDeclaration(localNameText, variableType, initializer)], + NodeFlags.Const)); + + // If the parent is an expression statement, replace the statement with the declaration + if (node.parent.kind === SyntaxKind.ExpressionStatement) { + changeTracker.replaceNodeWithNodes(context.file, node.parent, [newVariable], { nodeSeparator: context.newLineCharacter }); + } + else { + // Declare + const minInsertionPos = node.end; + const nodeToInsertBefore = getNodeToInsertConstantBefore(minInsertionPos, scope); + changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariable, { suffix: context.newLineCharacter + context.newLineCharacter }); + + // Consume + const localReference = createIdentifier(localNameText); + changeTracker.replaceNodeWithNodes(context.file, node, [localReference], { nodeSeparator: context.newLineCharacter }); + } + } + + const edits = changeTracker.getChanges(); + + const renameFilename = node.getSourceFile().fileName; + const renameLocation = getRenameLocation(edits, renameFilename, localNameText, /*isDeclaredBeforeUse*/ true); + return { renameFilename, renameLocation, edits }; + } + + /** + * @return The index of the (only) reference to the extracted symbol. We want the cursor + * to be on the reference, rather than the declaration, because it's closer to where the + * user was before extracting it. + */ + function getRenameLocation(edits: ReadonlyArray, renameFilename: string, functionNameText: string, isDeclaredBeforeUse: boolean): number { let delta = 0; + let lastPos = -1; for (const { fileName, textChanges } of edits) { Debug.assert(fileName === renameFilename); for (const change of textChanges) { const { span, newText } = change; - // TODO(acasey): We are assuming that the call expression comes before the function declaration, - // because we want the new cursor to be on the call expression, - // which is closer to where the user was before extracting the function. const index = newText.indexOf(functionNameText); if (index !== -1) { - return span.start + delta + index; + lastPos = span.start + delta + index; + + // If the reference comes first, return immediately. + if (!isDeclaredBeforeUse) { + return lastPos; + } } delta += newText.length - span.length; } } - throw new Error(); // Didn't find the text we inserted? + + // If the declaration comes first, return the position of the last occurrence. + Debug.assert(isDeclaredBeforeUse); + Debug.assert(lastPos >= 0); + return lastPos; } function getFirstDeclaration(type: Type): Declaration | undefined { @@ -900,7 +1060,7 @@ namespace ts.refactor.extractMethod { } else { const oldIgnoreReturns = ignoreReturns; - ignoreReturns = ignoreReturns || isFunctionLike(node) || isClassLike(node); + ignoreReturns = ignoreReturns || isFunctionLikeDeclaration(node) || isClassLike(node); const substitution = substitutions.get(getNodeId(node).toString()); const result = substitution || visitEachChild(node, visitor, nullTransformationContext); ignoreReturns = oldIgnoreReturns; @@ -909,8 +1069,19 @@ namespace ts.refactor.extractMethod { } } + function transformConstantInitializer(initializer: Expression, substitutions: ReadonlyMap): Expression { + return substitutions.size + ? visitor(initializer) as Expression + : initializer; + + function visitor(node: Node): VisitResult { + const substitution = substitutions.get(getNodeId(node).toString()); + return substitution || visitEachChild(node, visitor, nullTransformationContext); + } + } + function getStatementsOrClassElements(scope: Scope): ReadonlyArray | ReadonlyArray { - if (isFunctionLike(scope)) { + if (isFunctionLikeDeclaration(scope)) { const body = scope.body; if (isBlock(body)) { return body.statements; @@ -933,13 +1104,31 @@ namespace ts.refactor.extractMethod { * If `scope` contains a function after `minPos`, then return the first such function. * Otherwise, return `undefined`. */ - function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { + function getNodeToInsertFunctionBefore(minPos: number, scope: Scope): Node | undefined { + return find(getStatementsOrClassElements(scope), child => + child.pos >= minPos && isFunctionLikeDeclaration(child) && !isConstructorDeclaration(child)); + } + + // TODO (acasey): need to dig into nested statements + // TODO (acasey): don't insert before pinned comments, directives, or triple-slash references + function getNodeToInsertConstantBefore(maxPos: number, scope: Scope): Node { const children = getStatementsOrClassElements(scope); + Debug.assert(children.length > 0); // There must be at least one child, since we extracted from one. + + const isClassLikeScope = isClassLike(scope); + let prevChild: Statement | ClassElement | undefined = undefined; for (const child of children) { - if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { - return child; + if (child.pos >= maxPos) { + break; + } + prevChild = child; + if (isClassLikeScope && !isPropertyDeclaration(child)) { + break; } } + + Debug.assert(prevChild !== undefined); + return prevChild; } function getPropertyAssignmentsForWrites(writes: ReadonlyArray): ShorthandPropertyAssignment[] { @@ -987,7 +1176,8 @@ namespace ts.refactor.extractMethod { interface ReadsAndWrites { readonly target: Expression | Block; readonly usagesPerScope: ReadonlyArray; - readonly errorsPerScope: ReadonlyArray>; + readonly functionErrorsPerScope: ReadonlyArray>; + readonly constantErrorsPerScope: ReadonlyArray>; } function collectReadsAndWrites( targetRange: TargetRange, @@ -1000,14 +1190,33 @@ namespace ts.refactor.extractMethod { const allTypeParameterUsages = createMap(); // Key is type ID const usagesPerScope: ScopeUsages[] = []; const substitutionsPerScope: Map[] = []; - const errorsPerScope: Diagnostic[][] = []; + const functionErrorsPerScope: Diagnostic[][] = []; + const constantErrorsPerScope: Diagnostic[][] = []; const visibleDeclarationsInExtractedRange: Symbol[] = []; + const expressionDiagnostic = + isReadonlyArray(targetRange.range) && !(targetRange.range.length === 1 && isExpressionStatement(targetRange.range[0])) + ? ((start, end) => createFileDiagnostic(sourceFile, start, end - start, Messages.ExpressionExpected))(firstOrUndefined(targetRange.range).getStart(), lastOrUndefined(targetRange.range).end) + : undefined; + // initialize results - for (const _ of scopes) { + for (const scope of scopes) { usagesPerScope.push({ usages: createMap(), typeParameterUsages: createMap(), substitutions: createMap() }); substitutionsPerScope.push(createMap()); - errorsPerScope.push([]); + + functionErrorsPerScope.push( + isFunctionLikeDeclaration(scope) && scope.kind !== SyntaxKind.FunctionDeclaration + ? [createDiagnosticForNode(scope, Messages.CannotExtractToOtherFunctionLike)] + : []); + + const constantErrors = []; + if (expressionDiagnostic) { + constantErrors.push(expressionDiagnostic); + } + if (isClassLike(scope) && isInJavaScriptFile(scope)) { + constantErrors.push(createDiagnosticForNode(scope, Messages.CannotExtractToJSClass)); + } + constantErrorsPerScope.push(constantErrors); } const seenUsages = createMap(); @@ -1059,6 +1268,13 @@ namespace ts.refactor.extractMethod { } for (let i = 0; i < scopes.length; i++) { + if (!isReadonlyArray(targetRange.range)) { + const scopeUsages = usagesPerScope[i]; + if (scopeUsages.usages.size > 0 || scopeUsages.typeParameterUsages.size > 0) { + constantErrorsPerScope[i].push(createDiagnosticForNode(targetRange.range, Messages.CannotAccessVariablesFromNestedScopes)); + } + } + let hasWrite = false; let readonlyClassPropertyWrite: Declaration | undefined = undefined; usagesPerScope[i].usages.forEach(value => { @@ -1073,10 +1289,14 @@ namespace ts.refactor.extractMethod { }); if (hasWrite && !isReadonlyArray(targetRange.range) && isExpression(targetRange.range)) { - errorsPerScope[i].push(createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns)); + const diag = createDiagnosticForNode(targetRange.range, Messages.CannotCombineWritesAndReturns); + functionErrorsPerScope[i].push(diag); + constantErrorsPerScope[i].push(diag); } else if (readonlyClassPropertyWrite && i > 0) { - errorsPerScope[i].push(createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor)); + const diag = createDiagnosticForNode(readonlyClassPropertyWrite, Messages.CannotExtractReadonlyPropertyInitializerOutsideConstructor); + functionErrorsPerScope[i].push(diag); + constantErrorsPerScope[i].push(diag); } } @@ -1086,7 +1306,7 @@ namespace ts.refactor.extractMethod { forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations); } - return { target, usagesPerScope, errorsPerScope }; + return { target, usagesPerScope, functionErrorsPerScope, constantErrorsPerScope }; function hasTypeParameters(node: Node) { return isDeclarationWithTypeParameters(node) && @@ -1162,9 +1382,9 @@ namespace ts.refactor.extractMethod { if (symbolId) { for (let i = 0; i < scopes.length; i++) { // push substitution from map to map to simplify rewriting - const substitition = substitutionsPerScope[i].get(symbolId); - if (substitition) { - usagesPerScope[i].substitutions.set(getNodeId(n).toString(), substitition); + const substitution = substitutionsPerScope[i].get(symbolId); + if (substitution) { + usagesPerScope[i].substitutions.set(getNodeId(n).toString(), substitution); } } } @@ -1209,15 +1429,19 @@ namespace ts.refactor.extractMethod { if (!declInFile) { return undefined; } - if (rangeContainsRange(enclosingTextRange, declInFile)) { + if (rangeContainsStartEnd(enclosingTextRange, declInFile.getStart(), declInFile.end)) { // declaration is located in range to be extracted - do nothing return undefined; } if (targetRange.facts & RangeFacts.IsGenerator && usage === Usage.Write) { // this is write to a reference located outside of the target scope and range is extracted into generator // currently this is unsupported scenario - for (const errors of errorsPerScope) { - errors.push(createDiagnosticForNode(identifier, Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators)); + const diag = createDiagnosticForNode(identifier, Messages.CannotExtractRangeThatContainsWritesToReferencesLocatedOutsideOfTheTargetRangeInGenerators); + for (const errors of functionErrorsPerScope) { + errors.push(diag); + } + for (const errors of constantErrorsPerScope) { + errors.push(diag); } } for (let i = 0; i < scopes.length; i++) { @@ -1235,7 +1459,9 @@ namespace ts.refactor.extractMethod { // If the symbol is a type parameter that won't be in scope, we'll pass it as a type argument // so there's no problem. if (!(symbol.flags & SymbolFlags.TypeParameter)) { - errorsPerScope[i].push(createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope)); + const diag = createDiagnosticForNode(identifier, Messages.TypeWillNotBeVisibleInTheNewScope); + functionErrorsPerScope[i].push(diag); + constantErrorsPerScope[i].push(diag); } } else { @@ -1255,8 +1481,12 @@ namespace ts.refactor.extractMethod { // Otherwise check and recurse. const sym = checker.getSymbolAtLocation(node); if (sym && visibleDeclarationsInExtractedRange.some(d => d === sym)) { - for (const scope of errorsPerScope) { - scope.push(createDiagnosticForNode(node, Messages.CannotExtractExportedEntity)); + const diag = createDiagnosticForNode(node, Messages.CannotExtractExportedEntity); + for (const errors of functionErrorsPerScope) { + errors.push(diag); + } + for (const errors of constantErrorsPerScope) { + errors.push(diag); } return true; } diff --git a/src/services/refactors/refactors.ts b/src/services/refactors/refactors.ts index 3a33ccc83c2..680b7f8b02f 100644 --- a/src/services/refactors/refactors.ts +++ b/src/services/refactors/refactors.ts @@ -1,2 +1,2 @@ /// -/// +/// diff --git a/src/services/shims.ts b/src/services/shims.ts index 9851d8e6c89..e3103364f73 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -568,11 +568,18 @@ namespace ts { } } - export function realizeDiagnostics(diagnostics: ReadonlyArray, newLine: string): { message: string; start: number; length: number; category: string; code: number; }[] { + interface RealizedDiagnostic { + message: string; + start: number; + length: number; + category: string; + code: number; + } + export function realizeDiagnostics(diagnostics: ReadonlyArray, newLine: string): RealizedDiagnostic[] { return diagnostics.map(d => realizeDiagnostic(d, newLine)); } - function realizeDiagnostic(diagnostic: Diagnostic, newLine: string): { message: string; start: number; length: number; category: string; code: number; } { + function realizeDiagnostic(diagnostic: Diagnostic, newLine: string): RealizedDiagnostic { return { message: flattenDiagnosticMessageText(diagnostic.messageText, newLine), start: diagnostic.start, diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index f3ad7df1607..9e4c2ed3a60 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -152,7 +152,9 @@ namespace ts.textChanges { return position === Position.Start ? start : fullStart; } // get start position of the line following the line that contains fullstart position - let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + // (but only if the fullstart isn't the very beginning of the file) + const nextLineStart = fullStart > 0 ? 1 : 0; + let adjustedStartPosition = getStartPositionOfLine(getLineOfLocalPosition(sourceFile, fullStartLine) + nextLineStart, sourceFile); // skip whitespaces/newlines adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); return getStartPositionOfLine(getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); @@ -224,7 +226,7 @@ namespace ts.textChanges { Debug.fail("node is not a list element"); return this; } - const index = containingList.indexOf(node); + const index = indexOfNode(containingList, node); if (index < 0) { return this; } @@ -356,7 +358,7 @@ namespace ts.textChanges { Debug.fail("node is not a list element"); return this; } - const index = containingList.indexOf(after); + const index = indexOfNode(containingList, after); if (index < 0) { return this; } diff --git a/src/services/utilities.ts b/src/services/utilities.ts index c3a1d5d571d..f367c48ac6f 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -597,7 +597,7 @@ namespace ts { } const children = list.getChildren(); - const listItemIndex = indexOf(children, node); + const listItemIndex = indexOfNode(children, node); return { listItemIndex, @@ -1100,7 +1100,7 @@ namespace ts { /** Returns `true` the first time it encounters a node and `false` afterwards. */ export function nodeSeenTracker(): (node: T) => boolean { - const seen: Array = []; + const seen: true[] = []; return node => { const id = getNodeId(node); return !seen[id] && (seen[id] = true); diff --git a/tests/baselines/reference/APISample_jsdoc.js b/tests/baselines/reference/APISample_jsdoc.js new file mode 100644 index 00000000000..c74e188f38b --- /dev/null +++ b/tests/baselines/reference/APISample_jsdoc.js @@ -0,0 +1,212 @@ +//// [APISample_jsdoc.ts] +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ + +declare var console: any; + +import * as ts from "typescript"; + +// excerpted from https://github.com/YousefED/typescript-json-schema +// (converted from a method and modified; for example, `this: any` to compensate, among other changes) +function parseCommentsIntoDefinition(this: any, + symbol: ts.Symbol, + definition: {description?: string, [s: string]: string | undefined}, + otherAnnotations: { [s: string]: true}): void { + if (!symbol) { + return; + } + + // the comments for a symbol + let comments = symbol.getDocumentationComment(); + + if (comments.length) { + definition.description = comments.map(comment => comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n")).join(""); + } + + // jsdocs are separate from comments + const jsdocs = symbol.getJsDocTags(); + jsdocs.forEach(doc => { + // if we have @TJS-... annotations, we have to parse them + const { name, text } = doc; + if (this.userValidationKeywords[name]) { + definition[name] = this.parseValue(text); + } else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); +} + + +// excerpted from https://github.com/vega/ts-json-schema-generator +export interface Annotations { + [name: string]: any; +} +function getAnnotations(this: any, node: ts.Node): Annotations | undefined { + const symbol: ts.Symbol = (node as any).symbol; + if (!symbol) { + return undefined; + } + + const jsDocTags: ts.JSDocTagInfo[] = symbol.getJsDocTags(); + if (!jsDocTags || !jsDocTags.length) { + return undefined; + } + + const annotations: Annotations = jsDocTags.reduce((result: Annotations, jsDocTag: ts.JSDocTagInfo) => { + const value = this.parseJsDocTag(jsDocTag); + if (value !== undefined) { + result[jsDocTag.name] = value; + } + + return result; + }, {}); + return Object.keys(annotations).length ? annotations : undefined; +} + +// these examples are artificial and mostly nonsensical +function parseSpecificTags(node: ts.Node) { + if (node.kind === ts.SyntaxKind.Parameter) { + return ts.getJSDocParameterTags(node as ts.ParameterDeclaration); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + const func = node as ts.FunctionDeclaration; + if (ts.hasJSDocParameterTags(func)) { + const flat: ts.JSDocTag[] = []; + for (const tags of func.parameters.map(ts.getJSDocParameterTags)) { + if (tags) flat.push(...tags); + } + return flat; + } + } +} + +function getReturnTypeFromJSDoc(node: ts.Node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + let type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return (type as ts.FunctionTypeNode).type; + } +} + +function getAllTags(node: ts.Node) { + ts.getJSDocTags(node); +} + +function getSomeOtherTags(node: ts.Node) { + const tags: (ts.JSDocTag | undefined)[] = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + const type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; +} + + +//// [APISample_jsdoc.js] +"use strict"; +/* + * Note: This test is a public API sample. The original sources can be found + * at: https://github.com/YousefED/typescript-json-schema + * https://github.com/vega/ts-json-schema-generator + * Please log a "breaking change" issue for any API breaking change affecting this issue + */ +exports.__esModule = true; +var ts = require("typescript"); +// excerpted from https://github.com/YousefED/typescript-json-schema +// (converted from a method and modified; for example, `this: any` to compensate, among other changes) +function parseCommentsIntoDefinition(symbol, definition, otherAnnotations) { + var _this = this; + if (!symbol) { + return; + } + // the comments for a symbol + var comments = symbol.getDocumentationComment(); + if (comments.length) { + definition.description = comments.map(function (comment) { return comment.kind === "lineBreak" ? comment.text : comment.text.trim().replace(/\r\n/g, "\n"); }).join(""); + } + // jsdocs are separate from comments + var jsdocs = symbol.getJsDocTags(); + jsdocs.forEach(function (doc) { + // if we have @TJS-... annotations, we have to parse them + var name = doc.name, text = doc.text; + if (_this.userValidationKeywords[name]) { + definition[name] = _this.parseValue(text); + } + else { + // special annotations + otherAnnotations[doc.name] = true; + } + }); +} +function getAnnotations(node) { + var _this = this; + var symbol = node.symbol; + if (!symbol) { + return undefined; + } + var jsDocTags = symbol.getJsDocTags(); + if (!jsDocTags || !jsDocTags.length) { + return undefined; + } + var annotations = jsDocTags.reduce(function (result, jsDocTag) { + var value = _this.parseJsDocTag(jsDocTag); + if (value !== undefined) { + result[jsDocTag.name] = value; + } + return result; + }, {}); + return Object.keys(annotations).length ? annotations : undefined; +} +// these examples are artificial and mostly nonsensical +function parseSpecificTags(node) { + if (node.kind === ts.SyntaxKind.Parameter) { + return ts.getJSDocParameterTags(node); + } + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + var func = node; + if (ts.hasJSDocParameterTags(func)) { + var flat = []; + for (var _i = 0, _a = func.parameters.map(ts.getJSDocParameterTags); _i < _a.length; _i++) { + var tags = _a[_i]; + if (tags) + flat.push.apply(flat, tags); + } + return flat; + } + } +} +function getReturnTypeFromJSDoc(node) { + if (node.kind === ts.SyntaxKind.FunctionDeclaration) { + return ts.getJSDocReturnType(node); + } + var type = ts.getJSDocType(node); + if (type && type.kind === ts.SyntaxKind.FunctionType) { + return type.type; + } +} +function getAllTags(node) { + ts.getJSDocTags(node); +} +function getSomeOtherTags(node) { + var tags = []; + tags.push(ts.getJSDocAugmentsTag(node)); + tags.push(ts.getJSDocClassTag(node)); + tags.push(ts.getJSDocReturnTag(node)); + var type = ts.getJSDocTypeTag(node); + if (type) { + tags.push(type); + } + tags.push(ts.getJSDocTemplateTag(node)); + return tags; +} diff --git a/tests/baselines/reference/ArrowFunction1.symbols b/tests/baselines/reference/ArrowFunction1.symbols new file mode 100644 index 00000000000..2c0b6a3e452 --- /dev/null +++ b/tests/baselines/reference/ArrowFunction1.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction1.ts === +var v = (a: ) => { +>v : Symbol(v, Decl(ArrowFunction1.ts, 0, 3)) +>a : Symbol(a, Decl(ArrowFunction1.ts, 0, 9)) + +}; diff --git a/tests/baselines/reference/ArrowFunction1.types b/tests/baselines/reference/ArrowFunction1.types new file mode 100644 index 00000000000..3f405bd7f36 --- /dev/null +++ b/tests/baselines/reference/ArrowFunction1.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction1.ts === +var v = (a: ) => { +>v : (a: any) => void +>(a: ) => { } : (a: any) => void +>a : any +> : No type information available! + +}; diff --git a/tests/baselines/reference/ArrowFunction3.symbols b/tests/baselines/reference/ArrowFunction3.symbols new file mode 100644 index 00000000000..825b7d54e1e --- /dev/null +++ b/tests/baselines/reference/ArrowFunction3.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts === +var v = (a): => { +>v : Symbol(v, Decl(ArrowFunction3.ts, 0, 3)) +>a : Symbol(a, Decl(ArrowFunction3.ts, 0, 9)) + +}; diff --git a/tests/baselines/reference/ArrowFunction3.types b/tests/baselines/reference/ArrowFunction3.types new file mode 100644 index 00000000000..64b46bd0d63 --- /dev/null +++ b/tests/baselines/reference/ArrowFunction3.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/ArrowFunctions/ArrowFunction3.ts === +var v = (a): => { +>v : (a: any) => any +>(a): => { } : (a: any) => any +>a : any +> : No type information available! + +}; diff --git a/tests/baselines/reference/ArrowFunctionExpression1.symbols b/tests/baselines/reference/ArrowFunctionExpression1.symbols new file mode 100644 index 00000000000..5fe82a1c15b --- /dev/null +++ b/tests/baselines/reference/ArrowFunctionExpression1.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/ArrowFunctionExpression1.ts === +var v = (public x: string) => { }; +>v : Symbol(v, Decl(ArrowFunctionExpression1.ts, 0, 3)) +>x : Symbol(x, Decl(ArrowFunctionExpression1.ts, 0, 9)) + diff --git a/tests/baselines/reference/ArrowFunctionExpression1.types b/tests/baselines/reference/ArrowFunctionExpression1.types new file mode 100644 index 00000000000..c62b1c198b1 --- /dev/null +++ b/tests/baselines/reference/ArrowFunctionExpression1.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/ArrowFunctionExpression1.ts === +var v = (public x: string) => { }; +>v : (public x: string) => void +>(public x: string) => { } : (public x: string) => void +>x : string + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.symbols b/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.symbols new file mode 100644 index 00000000000..5c32f4eadce --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.symbols @@ -0,0 +1,97 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts === +// all expected to be errors + +class clodule1{ +>clodule1 : Symbol(clodule1, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 6, 1)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 2, 15)) + + id: string; +>id : Symbol(clodule1.id, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 2, 18)) + + value: T; +>value : Symbol(clodule1.value, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 4, 15)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 2, 15)) +} + +module clodule1 { +>clodule1 : Symbol(clodule1, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 6, 1)) + + function f(x: T) { } +>f : Symbol(f, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 8, 17)) +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 9, 15)) +} + +class clodule2{ +>clodule2 : Symbol(clodule2, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 10, 1), Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 16, 1)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 12, 15)) + + id: string; +>id : Symbol(clodule2.id, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 12, 18)) + + value: T; +>value : Symbol(clodule2.value, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 14, 15)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 12, 15)) +} + +module clodule2 { +>clodule2 : Symbol(clodule2, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 10, 1), Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 16, 1)) + + var x: T; +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 19, 7)) + + class D{ +>D : Symbol(D, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 19, 13)) +>U : Symbol(U, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 21, 12)) + + id: string; +>id : Symbol(D.id, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 21, 25)) + + value: U; +>value : Symbol(D.value, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 22, 19)) +>U : Symbol(U, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 21, 12)) + } +} + +class clodule3{ +>clodule3 : Symbol(clodule3, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 25, 1), Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 31, 1)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 27, 15)) + + id: string; +>id : Symbol(clodule3.id, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 27, 18)) + + value: T; +>value : Symbol(clodule3.value, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 29, 15)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 27, 15)) +} + +module clodule3 { +>clodule3 : Symbol(clodule3, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 25, 1), Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 31, 1)) + + export var y = { id: T }; +>y : Symbol(y, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 34, 14)) +>id : Symbol(id, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 34, 20)) +} + +class clodule4{ +>clodule4 : Symbol(clodule4, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 35, 1), Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 41, 1)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 37, 15)) + + id: string; +>id : Symbol(clodule4.id, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 37, 18)) + + value: T; +>value : Symbol(clodule4.value, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 39, 15)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 37, 15)) +} + +module clodule4 { +>clodule4 : Symbol(clodule4, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 35, 1), Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 41, 1)) + + class D { +>D : Symbol(D, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 43, 17)) + + name: T; +>name : Symbol(D.name, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 44, 13)) + } +} + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.types b/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.types new file mode 100644 index 00000000000..5afcc735a92 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.types @@ -0,0 +1,103 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts === +// all expected to be errors + +class clodule1{ +>clodule1 : clodule1 +>T : T + + id: string; +>id : string + + value: T; +>value : T +>T : T +} + +module clodule1 { +>clodule1 : typeof clodule1 + + function f(x: T) { } +>f : (x: any) => void +>x : any +>T : No type information available! +} + +class clodule2{ +>clodule2 : clodule2 +>T : T + + id: string; +>id : string + + value: T; +>value : T +>T : T +} + +module clodule2 { +>clodule2 : typeof clodule2 + + var x: T; +>x : any +>T : No type information available! + + class D{ +>D : D +>U : U +>T : No type information available! + + id: string; +>id : string + + value: U; +>value : U +>U : U + } +} + +class clodule3{ +>clodule3 : clodule3 +>T : T + + id: string; +>id : string + + value: T; +>value : T +>T : T +} + +module clodule3 { +>clodule3 : typeof clodule3 + + export var y = { id: T }; +>y : { id: any; } +>{ id: T } : { id: any; } +>id : any +>T : any +} + +class clodule4{ +>clodule4 : clodule4 +>T : T + + id: string; +>id : string + + value: T; +>value : T +>T : T +} + +module clodule4 { +>clodule4 : typeof clodule4 + + class D { +>D : D + + name: T; +>name : any +>T : No type information available! + } +} + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.symbols b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.symbols new file mode 100644 index 00000000000..a601fa9fedd --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.symbols @@ -0,0 +1,38 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts === +class clodule { +>clodule : Symbol(clodule, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 5, 1)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 0, 14)) + + id: string; +>id : Symbol(clodule.id, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 0, 18)) + + value: T; +>value : Symbol(clodule.value, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 1, 15)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 0, 14)) + + static fn(id: U) { } +>fn : Symbol(clodule.fn, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 2, 13)) +>U : Symbol(U, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 4, 14)) +>id : Symbol(id, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 4, 17)) +>U : Symbol(U, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 4, 14)) +} + +module clodule { +>clodule : Symbol(clodule, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 5, 1)) + + // error: duplicate identifier expected + export function fn(x: T, y: T): T { +>fn : Symbol(clodule.fn, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 7, 16)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 9, 23)) +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 9, 26)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 9, 23)) +>y : Symbol(y, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 9, 31)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 9, 23)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 9, 23)) + + return x; +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts, 9, 26)) + } +} + + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.types b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.types new file mode 100644 index 00000000000..99a044d62c1 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.types @@ -0,0 +1,38 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndGenericClassStaticFunctionOfTheSameName.ts === +class clodule { +>clodule : clodule +>T : T + + id: string; +>id : string + + value: T; +>value : T +>T : T + + static fn(id: U) { } +>fn : (id: U) => void +>U : U +>id : U +>U : U +} + +module clodule { +>clodule : typeof clodule + + // error: duplicate identifier expected + export function fn(x: T, y: T): T { +>fn : (x: T, y: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + + return x; +>x : T + } +} + + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.symbols b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.symbols new file mode 100644 index 00000000000..1ad7fa9223d --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts === +class clodule { +>clodule : Symbol(clodule, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 5, 1)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 0, 14)) + + id: string; +>id : Symbol(clodule.id, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 0, 18)) + + value: T; +>value : Symbol(clodule.value, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 1, 15)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 0, 14)) + + static fn(id: string) { } +>fn : Symbol(clodule.fn, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 2, 13)) +>id : Symbol(id, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 4, 14)) +} + +module clodule { +>clodule : Symbol(clodule, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 5, 1)) + + // error: duplicate identifier expected + export function fn(x: T, y: T): T { +>fn : Symbol(clodule.fn, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 7, 16)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 9, 23)) +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 9, 26)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 9, 23)) +>y : Symbol(y, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 9, 31)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 9, 23)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 9, 23)) + + return x; +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts, 9, 26)) + } +} + + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.types b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.types new file mode 100644 index 00000000000..6af2e089dc3 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedGenericFunctionAndNonGenericClassStaticFunctionOfTheSameName.ts === +class clodule { +>clodule : clodule +>T : T + + id: string; +>id : string + + value: T; +>value : T +>T : T + + static fn(id: string) { } +>fn : (id: string) => void +>id : string +} + +module clodule { +>clodule : typeof clodule + + // error: duplicate identifier expected + export function fn(x: T, y: T): T { +>fn : (x: T, y: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + + return x; +>x : T + } +} + + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.symbols b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.symbols new file mode 100644 index 00000000000..13cdbdf66ae --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.symbols @@ -0,0 +1,37 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts === +class clodule { +>clodule : Symbol(clodule, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 5, 1)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 0, 14)) + + id: string; +>id : Symbol(clodule.id, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 0, 18)) + + value: T; +>value : Symbol(clodule.value, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 1, 15)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 0, 14)) + + private static sfn(id: string) { return 42; } +>sfn : Symbol(clodule.sfn, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 2, 13)) +>id : Symbol(id, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 4, 23)) +} + +module clodule { +>clodule : Symbol(clodule, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 5, 1)) + + // error: duplicate identifier expected + export function fn(x: T, y: T): number { +>fn : Symbol(fn, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 7, 16)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 9, 23)) +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 9, 26)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 9, 23)) +>y : Symbol(y, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 9, 31)) +>T : Symbol(T, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 9, 23)) + + return clodule.sfn('a'); +>clodule.sfn : Symbol(clodule.sfn, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 2, 13)) +>clodule : Symbol(clodule, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 0, 0), Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 5, 1)) +>sfn : Symbol(clodule.sfn, Decl(ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts, 2, 13)) + } +} + + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.types b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.types new file mode 100644 index 00000000000..af77997ec6a --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithModulesExportedStaticFunctionUsingClassPrivateStatics.ts === +class clodule { +>clodule : clodule +>T : T + + id: string; +>id : string + + value: T; +>value : T +>T : T + + private static sfn(id: string) { return 42; } +>sfn : (id: string) => number +>id : string +>42 : 42 +} + +module clodule { +>clodule : typeof clodule + + // error: duplicate identifier expected + export function fn(x: T, y: T): number { +>fn : (x: T, y: T) => number +>T : T +>x : T +>T : T +>y : T +>T : T + + return clodule.sfn('a'); +>clodule.sfn('a') : number +>clodule.sfn : (id: string) => number +>clodule : typeof clodule +>sfn : (id: string) => number +>'a' : "a" + } +} + + diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.symbols b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.symbols new file mode 100644 index 00000000000..c8ba6f0277c --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.symbols @@ -0,0 +1,47 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts === +class Point { +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 4, 1)) + + constructor(public x: number, public y: number) { } +>x : Symbol(Point.x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 1, 16)) +>y : Symbol(Point.y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 1, 33)) + + static Origin(): Point { return { x: 0, y: 0 }; } // unexpected error here bug 840246 +>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 1, 55)) +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 4, 1)) +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 3, 37)) +>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 3, 43)) +} + +module Point { +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 4, 1)) + + export function Origin() { return null; } //expected duplicate identifier error +>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 6, 14)) +} + + +module A { +>A : Symbol(A, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 8, 1)) + + export class Point { +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 16, 5)) + + constructor(public x: number, public y: number) { } +>x : Symbol(Point.x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 13, 20)) +>y : Symbol(Point.y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 13, 37)) + + static Origin(): Point { return { x: 0, y: 0 }; } // unexpected error here bug 840246 +>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 13, 59)) +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 16, 5)) +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 15, 41)) +>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 15, 47)) + } + + export module Point { +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 16, 5)) + + export function Origin() { return ""; }//expected duplicate identifier error +>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts, 18, 25)) + } +} diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.types b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.types new file mode 100644 index 00000000000..f3bdde0e6a4 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.types @@ -0,0 +1,55 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticFunctionAndExportedFunctionThatShareAName.ts === +class Point { +>Point : Point + + constructor(public x: number, public y: number) { } +>x : number +>y : number + + static Origin(): Point { return { x: 0, y: 0 }; } // unexpected error here bug 840246 +>Origin : () => Point +>Point : Point +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 +} + +module Point { +>Point : typeof Point + + export function Origin() { return null; } //expected duplicate identifier error +>Origin : () => any +>null : null +} + + +module A { +>A : typeof A + + export class Point { +>Point : Point + + constructor(public x: number, public y: number) { } +>x : number +>y : number + + static Origin(): Point { return { x: 0, y: 0 }; } // unexpected error here bug 840246 +>Origin : () => Point +>Point : Point +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } + + export module Point { +>Point : typeof Point + + export function Origin() { return ""; }//expected duplicate identifier error +>Origin : () => string +>"" : "" + } +} diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.symbols b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.symbols new file mode 100644 index 00000000000..362c149e523 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.symbols @@ -0,0 +1,47 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts === +class Point { +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 4, 1)) + + constructor(public x: number, public y: number) { } +>x : Symbol(Point.x, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 1, 16)) +>y : Symbol(Point.y, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 1, 33)) + + static Origin: Point = { x: 0, y: 0 }; +>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 1, 55)) +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 4, 1)) +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 3, 28)) +>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 3, 34)) +} + +module Point { +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 0, 0), Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 4, 1)) + + export var Origin = ""; //expected duplicate identifier error +>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 7, 14)) +} + + +module A { +>A : Symbol(A, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 8, 1)) + + export class Point { +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 16, 5)) + + constructor(public x: number, public y: number) { } +>x : Symbol(Point.x, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 13, 20)) +>y : Symbol(Point.y, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 13, 37)) + + static Origin: Point = { x: 0, y: 0 }; +>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 13, 59)) +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 16, 5)) +>x : Symbol(x, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 15, 32)) +>y : Symbol(y, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 15, 38)) + } + + export module Point { +>Point : Symbol(Point, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 11, 10), Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 16, 5)) + + export var Origin = ""; //expected duplicate identifier error +>Origin : Symbol(Point.Origin, Decl(ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts, 19, 18)) + } +} diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.types b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.types new file mode 100644 index 00000000000..1c2423316dc --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.types @@ -0,0 +1,55 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/ClassAndModuleThatMergeWithStaticVariableAndExportedVarThatShareAName.ts === +class Point { +>Point : Point + + constructor(public x: number, public y: number) { } +>x : number +>y : number + + static Origin: Point = { x: 0, y: 0 }; +>Origin : Point +>Point : Point +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 +} + +module Point { +>Point : typeof Point + + export var Origin = ""; //expected duplicate identifier error +>Origin : string +>"" : "" +} + + +module A { +>A : typeof A + + export class Point { +>Point : Point + + constructor(public x: number, public y: number) { } +>x : number +>y : number + + static Origin: Point = { x: 0, y: 0 }; +>Origin : Point +>Point : Point +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } + + export module Point { +>Point : typeof Point + + export var Origin = ""; //expected duplicate identifier error +>Origin : string +>"" : "" + } +} diff --git a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.symbols b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.symbols new file mode 100644 index 00000000000..6fd9822c2a9 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.symbols @@ -0,0 +1,98 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/class.ts === +module X.Y { +>X : Symbol(X, Decl(class.ts, 0, 0), Decl(module.ts, 0, 0)) +>Y : Symbol(Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) + + export class Point { +>Point : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) + + constructor(x: number, y: number) { +>x : Symbol(x, Decl(class.ts, 2, 20)) +>y : Symbol(y, Decl(class.ts, 2, 30)) + + this.x = x; +>this.x : Symbol(Point.x, Decl(class.ts, 5, 9)) +>this : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>x : Symbol(Point.x, Decl(class.ts, 5, 9)) +>x : Symbol(x, Decl(class.ts, 2, 20)) + + this.y = y; +>this.y : Symbol(Point.y, Decl(class.ts, 6, 18)) +>this : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>y : Symbol(Point.y, Decl(class.ts, 6, 18)) +>y : Symbol(y, Decl(class.ts, 2, 30)) + } + x: number; +>x : Symbol(Point.x, Decl(class.ts, 5, 9)) + + y: number; +>y : Symbol(Point.y, Decl(class.ts, 6, 18)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module X.Y { +>X : Symbol(X, Decl(class.ts, 0, 0), Decl(module.ts, 0, 0)) +>Y : Symbol(Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) + + export module Point { +>Point : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) + + export var Origin = new Point(0, 0); +>Origin : Symbol(Origin, Decl(module.ts, 2, 18)) +>Point : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts === +//var cl: { x: number; y: number; } +var cl = new X.Y.Point(1,1); +>cl : Symbol(cl, Decl(test.ts, 1, 3), Decl(test.ts, 2, 3)) +>X.Y.Point : Symbol(X.Y.Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>X.Y : Symbol(X.Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) +>X : Symbol(X, Decl(class.ts, 0, 0), Decl(module.ts, 0, 0)) +>Y : Symbol(X.Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) +>Point : Symbol(X.Y.Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) + +var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ? +>cl : Symbol(cl, Decl(test.ts, 1, 3), Decl(test.ts, 2, 3)) +>X.Y.Point.Origin : Symbol(X.Y.Point.Origin, Decl(module.ts, 2, 18)) +>X.Y.Point : Symbol(X.Y.Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>X.Y : Symbol(X.Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) +>X : Symbol(X, Decl(class.ts, 0, 0), Decl(module.ts, 0, 0)) +>Y : Symbol(X.Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) +>Point : Symbol(X.Y.Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>Origin : Symbol(X.Y.Point.Origin, Decl(module.ts, 2, 18)) + + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +class A { +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) + + id: string; +>id : Symbol(A.id, Decl(simple.ts, 0, 9)) +} + +module A { +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) + + export var Instance = new A(); +>Instance : Symbol(Instance, Decl(simple.ts, 5, 14)) +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) +} + +// ensure merging works as expected +var a = A.Instance; +>a : Symbol(a, Decl(simple.ts, 9, 3), Decl(simple.ts, 10, 3), Decl(simple.ts, 11, 3)) +>A.Instance : Symbol(A.Instance, Decl(simple.ts, 5, 14)) +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) +>Instance : Symbol(A.Instance, Decl(simple.ts, 5, 14)) + +var a = new A(); +>a : Symbol(a, Decl(simple.ts, 9, 3), Decl(simple.ts, 10, 3), Decl(simple.ts, 11, 3)) +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) + +var a: { id: string }; +>a : Symbol(a, Decl(simple.ts, 9, 3), Decl(simple.ts, 10, 3), Decl(simple.ts, 11, 3)) +>id : Symbol(id, Decl(simple.ts, 11, 8)) + diff --git a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.types b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.types new file mode 100644 index 00000000000..f3e05acf116 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRoot.types @@ -0,0 +1,108 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/class.ts === +module X.Y { +>X : typeof X +>Y : typeof Y + + export class Point { +>Point : Point + + constructor(x: number, y: number) { +>x : number +>y : number + + this.x = x; +>this.x = x : number +>this.x : number +>this : this +>x : number +>x : number + + this.y = y; +>this.y = y : number +>this.y : number +>this : this +>y : number +>y : number + } + x: number; +>x : number + + y: number; +>y : number + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module X.Y { +>X : typeof X +>Y : typeof Y + + export module Point { +>Point : typeof Point + + export var Origin = new Point(0, 0); +>Origin : Point +>new Point(0, 0) : Point +>Point : typeof Point +>0 : 0 +>0 : 0 + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts === +//var cl: { x: number; y: number; } +var cl = new X.Y.Point(1,1); +>cl : X.Y.Point +>new X.Y.Point(1,1) : X.Y.Point +>X.Y.Point : typeof X.Y.Point +>X.Y : typeof X.Y +>X : typeof X +>Y : typeof X.Y +>Point : typeof X.Y.Point +>1 : 1 +>1 : 1 + +var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ? +>cl : X.Y.Point +>X.Y.Point.Origin : X.Y.Point +>X.Y.Point : typeof X.Y.Point +>X.Y : typeof X.Y +>X : typeof X +>Y : typeof X.Y +>Point : typeof X.Y.Point +>Origin : X.Y.Point + + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +class A { +>A : A + + id: string; +>id : string +} + +module A { +>A : typeof A + + export var Instance = new A(); +>Instance : A +>new A() : A +>A : typeof A +} + +// ensure merging works as expected +var a = A.Instance; +>a : A +>A.Instance : A +>A : typeof A +>Instance : A + +var a = new A(); +>a : A +>new A() : A +>A : typeof A + +var a: { id: string }; +>a : A +>id : string + diff --git a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.symbols b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.symbols new file mode 100644 index 00000000000..6fd9822c2a9 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.symbols @@ -0,0 +1,98 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/class.ts === +module X.Y { +>X : Symbol(X, Decl(class.ts, 0, 0), Decl(module.ts, 0, 0)) +>Y : Symbol(Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) + + export class Point { +>Point : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) + + constructor(x: number, y: number) { +>x : Symbol(x, Decl(class.ts, 2, 20)) +>y : Symbol(y, Decl(class.ts, 2, 30)) + + this.x = x; +>this.x : Symbol(Point.x, Decl(class.ts, 5, 9)) +>this : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>x : Symbol(Point.x, Decl(class.ts, 5, 9)) +>x : Symbol(x, Decl(class.ts, 2, 20)) + + this.y = y; +>this.y : Symbol(Point.y, Decl(class.ts, 6, 18)) +>this : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>y : Symbol(Point.y, Decl(class.ts, 6, 18)) +>y : Symbol(y, Decl(class.ts, 2, 30)) + } + x: number; +>x : Symbol(Point.x, Decl(class.ts, 5, 9)) + + y: number; +>y : Symbol(Point.y, Decl(class.ts, 6, 18)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module X.Y { +>X : Symbol(X, Decl(class.ts, 0, 0), Decl(module.ts, 0, 0)) +>Y : Symbol(Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) + + export module Point { +>Point : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) + + export var Origin = new Point(0, 0); +>Origin : Symbol(Origin, Decl(module.ts, 2, 18)) +>Point : Symbol(Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts === +//var cl: { x: number; y: number; } +var cl = new X.Y.Point(1,1); +>cl : Symbol(cl, Decl(test.ts, 1, 3), Decl(test.ts, 2, 3)) +>X.Y.Point : Symbol(X.Y.Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>X.Y : Symbol(X.Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) +>X : Symbol(X, Decl(class.ts, 0, 0), Decl(module.ts, 0, 0)) +>Y : Symbol(X.Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) +>Point : Symbol(X.Y.Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) + +var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ? +>cl : Symbol(cl, Decl(test.ts, 1, 3), Decl(test.ts, 2, 3)) +>X.Y.Point.Origin : Symbol(X.Y.Point.Origin, Decl(module.ts, 2, 18)) +>X.Y.Point : Symbol(X.Y.Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>X.Y : Symbol(X.Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) +>X : Symbol(X, Decl(class.ts, 0, 0), Decl(module.ts, 0, 0)) +>Y : Symbol(X.Y, Decl(class.ts, 0, 9), Decl(module.ts, 0, 9)) +>Point : Symbol(X.Y.Point, Decl(class.ts, 0, 12), Decl(module.ts, 0, 12)) +>Origin : Symbol(X.Y.Point.Origin, Decl(module.ts, 2, 18)) + + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +class A { +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) + + id: string; +>id : Symbol(A.id, Decl(simple.ts, 0, 9)) +} + +module A { +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) + + export var Instance = new A(); +>Instance : Symbol(Instance, Decl(simple.ts, 5, 14)) +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) +} + +// ensure merging works as expected +var a = A.Instance; +>a : Symbol(a, Decl(simple.ts, 9, 3), Decl(simple.ts, 10, 3), Decl(simple.ts, 11, 3)) +>A.Instance : Symbol(A.Instance, Decl(simple.ts, 5, 14)) +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) +>Instance : Symbol(A.Instance, Decl(simple.ts, 5, 14)) + +var a = new A(); +>a : Symbol(a, Decl(simple.ts, 9, 3), Decl(simple.ts, 10, 3), Decl(simple.ts, 11, 3)) +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) + +var a: { id: string }; +>a : Symbol(a, Decl(simple.ts, 9, 3), Decl(simple.ts, 10, 3), Decl(simple.ts, 11, 3)) +>id : Symbol(id, Decl(simple.ts, 11, 8)) + diff --git a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.types b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.types new file mode 100644 index 00000000000..f3e05acf116 --- /dev/null +++ b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.types @@ -0,0 +1,108 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/class.ts === +module X.Y { +>X : typeof X +>Y : typeof Y + + export class Point { +>Point : Point + + constructor(x: number, y: number) { +>x : number +>y : number + + this.x = x; +>this.x = x : number +>this.x : number +>this : this +>x : number +>x : number + + this.y = y; +>this.y = y : number +>this.y : number +>this : this +>y : number +>y : number + } + x: number; +>x : number + + y: number; +>y : number + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module X.Y { +>X : typeof X +>Y : typeof Y + + export module Point { +>Point : typeof Point + + export var Origin = new Point(0, 0); +>Origin : Point +>new Point(0, 0) : Point +>Point : typeof Point +>0 : 0 +>0 : 0 + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts === +//var cl: { x: number; y: number; } +var cl = new X.Y.Point(1,1); +>cl : X.Y.Point +>new X.Y.Point(1,1) : X.Y.Point +>X.Y.Point : typeof X.Y.Point +>X.Y : typeof X.Y +>X : typeof X +>Y : typeof X.Y +>Point : typeof X.Y.Point +>1 : 1 +>1 : 1 + +var cl = X.Y.Point.Origin; // error not expected here same as bug 83996 ? +>cl : X.Y.Point +>X.Y.Point.Origin : X.Y.Point +>X.Y.Point : typeof X.Y.Point +>X.Y : typeof X.Y +>X : typeof X +>Y : typeof X.Y +>Point : typeof X.Y.Point +>Origin : X.Y.Point + + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +class A { +>A : A + + id: string; +>id : string +} + +module A { +>A : typeof A + + export var Instance = new A(); +>Instance : A +>new A() : A +>A : typeof A +} + +// ensure merging works as expected +var a = A.Instance; +>a : A +>A.Instance : A +>A : typeof A +>Instance : A + +var a = new A(); +>a : A +>new A() : A +>A : typeof A + +var a: { id: string }; +>a : A +>id : string + diff --git a/tests/baselines/reference/ClassDeclaration10.symbols b/tests/baselines/reference/ClassDeclaration10.symbols new file mode 100644 index 00000000000..3b967f70cbe --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration10.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ClassDeclaration10.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration10.ts, 0, 0)) + + constructor(); + foo(); +>foo : Symbol(C.foo, Decl(ClassDeclaration10.ts, 1, 17)) +} diff --git a/tests/baselines/reference/ClassDeclaration10.types b/tests/baselines/reference/ClassDeclaration10.types new file mode 100644 index 00000000000..ec5fac03741 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration10.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ClassDeclaration10.ts === +class C { +>C : C + + constructor(); + foo(); +>foo : () => any +} diff --git a/tests/baselines/reference/ClassDeclaration11.symbols b/tests/baselines/reference/ClassDeclaration11.symbols new file mode 100644 index 00000000000..a231eaf48d3 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration11.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ClassDeclaration11.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration11.ts, 0, 0)) + + constructor(); + foo() { } +>foo : Symbol(C.foo, Decl(ClassDeclaration11.ts, 1, 17)) +} diff --git a/tests/baselines/reference/ClassDeclaration11.types b/tests/baselines/reference/ClassDeclaration11.types new file mode 100644 index 00000000000..d7b3f4f6406 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration11.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ClassDeclaration11.ts === +class C { +>C : C + + constructor(); + foo() { } +>foo : () => void +} diff --git a/tests/baselines/reference/ClassDeclaration13.symbols b/tests/baselines/reference/ClassDeclaration13.symbols new file mode 100644 index 00000000000..fe6e0706a45 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration13.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/ClassDeclaration13.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration13.ts, 0, 0)) + + foo(); +>foo : Symbol(C.foo, Decl(ClassDeclaration13.ts, 0, 9)) + + bar() { } +>bar : Symbol(C.bar, Decl(ClassDeclaration13.ts, 1, 9)) +} diff --git a/tests/baselines/reference/ClassDeclaration13.types b/tests/baselines/reference/ClassDeclaration13.types new file mode 100644 index 00000000000..353dfd02988 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration13.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/ClassDeclaration13.ts === +class C { +>C : C + + foo(); +>foo : () => any + + bar() { } +>bar : () => void +} diff --git a/tests/baselines/reference/ClassDeclaration14.symbols b/tests/baselines/reference/ClassDeclaration14.symbols new file mode 100644 index 00000000000..341f6c984aa --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration14.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/ClassDeclaration14.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration14.ts, 0, 0)) + + foo(); +>foo : Symbol(C.foo, Decl(ClassDeclaration14.ts, 0, 9)) + + constructor(); +} diff --git a/tests/baselines/reference/ClassDeclaration14.types b/tests/baselines/reference/ClassDeclaration14.types new file mode 100644 index 00000000000..7f7038d5710 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration14.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/ClassDeclaration14.ts === +class C { +>C : C + + foo(); +>foo : () => any + + constructor(); +} diff --git a/tests/baselines/reference/ClassDeclaration15.symbols b/tests/baselines/reference/ClassDeclaration15.symbols new file mode 100644 index 00000000000..da6fe683974 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration15.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/ClassDeclaration15.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration15.ts, 0, 0)) + + foo(); +>foo : Symbol(C.foo, Decl(ClassDeclaration15.ts, 0, 9)) + + constructor() { } +} diff --git a/tests/baselines/reference/ClassDeclaration15.types b/tests/baselines/reference/ClassDeclaration15.types new file mode 100644 index 00000000000..9b861b5230c --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration15.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/ClassDeclaration15.ts === +class C { +>C : C + + foo(); +>foo : () => any + + constructor() { } +} diff --git a/tests/baselines/reference/ClassDeclaration21.symbols b/tests/baselines/reference/ClassDeclaration21.symbols new file mode 100644 index 00000000000..f9bd42a3a4f --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration21.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ClassDeclaration21.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration21.ts, 0, 0)) + + 0(); + 1() { } +} diff --git a/tests/baselines/reference/ClassDeclaration21.types b/tests/baselines/reference/ClassDeclaration21.types new file mode 100644 index 00000000000..fa41bb54676 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration21.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ClassDeclaration21.ts === +class C { +>C : C + + 0(); + 1() { } +} diff --git a/tests/baselines/reference/ClassDeclaration22.symbols b/tests/baselines/reference/ClassDeclaration22.symbols new file mode 100644 index 00000000000..059ff9e825c --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration22.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ClassDeclaration22.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration22.ts, 0, 0)) + + "foo"(); + "bar"() { } +} diff --git a/tests/baselines/reference/ClassDeclaration22.types b/tests/baselines/reference/ClassDeclaration22.types new file mode 100644 index 00000000000..359ac950462 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration22.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ClassDeclaration22.ts === +class C { +>C : C + + "foo"(); + "bar"() { } +} diff --git a/tests/baselines/reference/ClassDeclaration24.symbols b/tests/baselines/reference/ClassDeclaration24.symbols new file mode 100644 index 00000000000..e3e28d99582 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration24.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/ClassDeclaration24.ts === +class any { +>any : Symbol(any, Decl(ClassDeclaration24.ts, 0, 0)) +} diff --git a/tests/baselines/reference/ClassDeclaration24.types b/tests/baselines/reference/ClassDeclaration24.types new file mode 100644 index 00000000000..9d39e77c08b --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration24.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/ClassDeclaration24.ts === +class any { +>any : any +} diff --git a/tests/baselines/reference/ClassDeclaration25.symbols b/tests/baselines/reference/ClassDeclaration25.symbols new file mode 100644 index 00000000000..3d792b0b8f4 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration25.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/ClassDeclaration25.ts === +interface IList { +>IList : Symbol(IList, Decl(ClassDeclaration25.ts, 0, 0)) +>T : Symbol(T, Decl(ClassDeclaration25.ts, 0, 16)) + + data(): T; +>data : Symbol(IList.data, Decl(ClassDeclaration25.ts, 0, 20)) +>T : Symbol(T, Decl(ClassDeclaration25.ts, 0, 16)) + + next(): string; +>next : Symbol(IList.next, Decl(ClassDeclaration25.ts, 1, 14)) +} +class List implements IList { +>List : Symbol(List, Decl(ClassDeclaration25.ts, 3, 1)) +>U : Symbol(U, Decl(ClassDeclaration25.ts, 4, 11)) +>IList : Symbol(IList, Decl(ClassDeclaration25.ts, 0, 0)) +>U : Symbol(U, Decl(ClassDeclaration25.ts, 4, 11)) + + data(): U; +>data : Symbol(List.data, Decl(ClassDeclaration25.ts, 4, 35)) +>U : Symbol(U, Decl(ClassDeclaration25.ts, 4, 11)) + + next(): string; +>next : Symbol(List.next, Decl(ClassDeclaration25.ts, 5, 14)) +} + diff --git a/tests/baselines/reference/ClassDeclaration25.types b/tests/baselines/reference/ClassDeclaration25.types new file mode 100644 index 00000000000..cdfc8f9ae1e --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration25.types @@ -0,0 +1,26 @@ +=== tests/cases/compiler/ClassDeclaration25.ts === +interface IList { +>IList : IList +>T : T + + data(): T; +>data : () => T +>T : T + + next(): string; +>next : () => string +} +class List implements IList { +>List : List +>U : U +>IList : IList +>U : U + + data(): U; +>data : () => U +>U : U + + next(): string; +>next : () => string +} + diff --git a/tests/baselines/reference/ClassDeclaration26.symbols b/tests/baselines/reference/ClassDeclaration26.symbols new file mode 100644 index 00000000000..cc4757b97de --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration26.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/ClassDeclaration26.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration26.ts, 0, 0)) + + public const var export foo = 10; +>var : Symbol(C.var, Decl(ClassDeclaration26.ts, 0, 9)) +>foo : Symbol(C.foo, Decl(ClassDeclaration26.ts, 1, 20)) + + var constructor() { } +>constructor : Symbol(constructor, Decl(ClassDeclaration26.ts, 3, 7)) +} diff --git a/tests/baselines/reference/ClassDeclaration26.types b/tests/baselines/reference/ClassDeclaration26.types new file mode 100644 index 00000000000..acdc0d56ab1 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration26.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ClassDeclaration26.ts === +class C { +>C : C + + public const var export foo = 10; +>var : any +>foo : number +>10 : 10 + + var constructor() { } +>constructor : () => void +>() { } : () => void +} diff --git a/tests/baselines/reference/ClassDeclaration8.symbols b/tests/baselines/reference/ClassDeclaration8.symbols new file mode 100644 index 00000000000..bec50a10bbf --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration8.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/ClassDeclaration8.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration8.ts, 0, 0)) + + constructor(); +} diff --git a/tests/baselines/reference/ClassDeclaration8.types b/tests/baselines/reference/ClassDeclaration8.types new file mode 100644 index 00000000000..5f89e84680f --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration8.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/ClassDeclaration8.ts === +class C { +>C : C + + constructor(); +} diff --git a/tests/baselines/reference/ClassDeclaration9.symbols b/tests/baselines/reference/ClassDeclaration9.symbols new file mode 100644 index 00000000000..7a853b8b61b --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration9.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ClassDeclaration9.ts === +class C { +>C : Symbol(C, Decl(ClassDeclaration9.ts, 0, 0)) + + foo(); +>foo : Symbol(C.foo, Decl(ClassDeclaration9.ts, 0, 9)) +} diff --git a/tests/baselines/reference/ClassDeclaration9.types b/tests/baselines/reference/ClassDeclaration9.types new file mode 100644 index 00000000000..f9193d6d567 --- /dev/null +++ b/tests/baselines/reference/ClassDeclaration9.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ClassDeclaration9.ts === +class C { +>C : C + + foo(); +>foo : () => any +} diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.symbols b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.symbols new file mode 100644 index 00000000000..5c9bb23a923 --- /dev/null +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts === +class AtomicNumbers { +>AtomicNumbers : Symbol(AtomicNumbers, Decl(ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts, 0, 0)) + + static const H = 1; +>H : Symbol(AtomicNumbers.H, Decl(ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts, 0, 21)) +} diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.types b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.types new file mode 100644 index 00000000000..81ec49120fd --- /dev/null +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ClassDeclarationWithInvalidConstOnPropertyDeclaration.ts === +class AtomicNumbers { +>AtomicNumbers : AtomicNumbers + + static const H = 1; +>H : number +>1 : 1 +} diff --git a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.symbols b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.symbols new file mode 100644 index 00000000000..f57bd8d6cc4 --- /dev/null +++ b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts === +type T = { x : number } +>T : Symbol(T, Decl(DeclarationErrorsNoEmitOnError.ts, 0, 0)) +>x : Symbol(x, Decl(DeclarationErrorsNoEmitOnError.ts, 0, 10)) + +export interface I { +>I : Symbol(I, Decl(DeclarationErrorsNoEmitOnError.ts, 0, 23)) + + f: T; +>f : Symbol(I.f, Decl(DeclarationErrorsNoEmitOnError.ts, 1, 20)) +>T : Symbol(T, Decl(DeclarationErrorsNoEmitOnError.ts, 0, 0)) +} diff --git a/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types new file mode 100644 index 00000000000..08a65d9c146 --- /dev/null +++ b/tests/baselines/reference/DeclarationErrorsNoEmitOnError.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/DeclarationErrorsNoEmitOnError.ts === +type T = { x : number } +>T : { x: number; } +>x : number + +export interface I { +>I : I + + f: T; +>f : { x: number; } +>T : { x: number; } +} diff --git a/tests/baselines/reference/ES3For-ofTypeCheck1.symbols b/tests/baselines/reference/ES3For-ofTypeCheck1.symbols new file mode 100644 index 00000000000..c7d17a31763 --- /dev/null +++ b/tests/baselines/reference/ES3For-ofTypeCheck1.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts === +for (var v of "") { } +>v : Symbol(v, Decl(ES3For-ofTypeCheck1.ts, 0, 8)) + diff --git a/tests/baselines/reference/ES3For-ofTypeCheck1.types b/tests/baselines/reference/ES3For-ofTypeCheck1.types new file mode 100644 index 00000000000..3b5af3905cc --- /dev/null +++ b/tests/baselines/reference/ES3For-ofTypeCheck1.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck1.ts === +for (var v of "") { } +>v : string +>"" : "" + diff --git a/tests/baselines/reference/ES3For-ofTypeCheck4.symbols b/tests/baselines/reference/ES3For-ofTypeCheck4.symbols new file mode 100644 index 00000000000..31c862025b9 --- /dev/null +++ b/tests/baselines/reference/ES3For-ofTypeCheck4.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts === +var union: string | string[]; +>union : Symbol(union, Decl(ES3For-ofTypeCheck4.ts, 0, 3)) + +for (const v of union) { } +>v : Symbol(v, Decl(ES3For-ofTypeCheck4.ts, 1, 10)) +>union : Symbol(union, Decl(ES3For-ofTypeCheck4.ts, 0, 3)) + diff --git a/tests/baselines/reference/ES3For-ofTypeCheck4.types b/tests/baselines/reference/ES3For-ofTypeCheck4.types new file mode 100644 index 00000000000..bec14ff259f --- /dev/null +++ b/tests/baselines/reference/ES3For-ofTypeCheck4.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES3For-ofTypeCheck4.ts === +var union: string | string[]; +>union : string | string[] + +for (const v of union) { } +>v : string +>union : string | string[] + diff --git a/tests/baselines/reference/ES5For-of1.symbols b/tests/baselines/reference/ES5For-of1.symbols new file mode 100644 index 00000000000..a80c69cd2cf --- /dev/null +++ b/tests/baselines/reference/ES5For-of1.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts === +for (var v of ['a', 'b', 'c']) { +>v : Symbol(v, Decl(ES5For-of1.ts, 0, 8)) + + console.log(v); +>v : Symbol(v, Decl(ES5For-of1.ts, 0, 8)) +} diff --git a/tests/baselines/reference/ES5For-of1.types b/tests/baselines/reference/ES5For-of1.types new file mode 100644 index 00000000000..4f9117740fb --- /dev/null +++ b/tests/baselines/reference/ES5For-of1.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of1.ts === +for (var v of ['a', 'b', 'c']) { +>v : string +>['a', 'b', 'c'] : string[] +>'a' : "a" +>'b' : "b" +>'c' : "c" + + console.log(v); +>console.log(v) : any +>console.log : any +>console : any +>log : any +>v : string +} diff --git a/tests/baselines/reference/ES5For-of12.symbols b/tests/baselines/reference/ES5For-of12.symbols new file mode 100644 index 00000000000..465a644f7bf --- /dev/null +++ b/tests/baselines/reference/ES5For-of12.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts === +for ([""] of [[""]]) { } +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of12.types b/tests/baselines/reference/ES5For-of12.types new file mode 100644 index 00000000000..42ea34cd617 --- /dev/null +++ b/tests/baselines/reference/ES5For-of12.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of12.ts === +for ([""] of [[""]]) { } +>[""] : [string] +>"" : "" +>[[""]] : string[][] +>[""] : string[] +>"" : "" + diff --git a/tests/baselines/reference/ES5For-of17.symbols b/tests/baselines/reference/ES5For-of17.symbols new file mode 100644 index 00000000000..277ffda267e --- /dev/null +++ b/tests/baselines/reference/ES5For-of17.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts === +for (let v of []) { +>v : Symbol(v, Decl(ES5For-of17.ts, 0, 8)) + + v; +>v : Symbol(v, Decl(ES5For-of17.ts, 0, 8)) + + for (let v of [v]) { +>v : Symbol(v, Decl(ES5For-of17.ts, 2, 12)) +>v : Symbol(v, Decl(ES5For-of17.ts, 2, 12)) + + var x = v; +>x : Symbol(x, Decl(ES5For-of17.ts, 3, 11)) +>v : Symbol(v, Decl(ES5For-of17.ts, 2, 12)) + + v++; +>v : Symbol(v, Decl(ES5For-of17.ts, 2, 12)) + } +} diff --git a/tests/baselines/reference/ES5For-of17.types b/tests/baselines/reference/ES5For-of17.types new file mode 100644 index 00000000000..4dafdc0599d --- /dev/null +++ b/tests/baselines/reference/ES5For-of17.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of17.ts === +for (let v of []) { +>v : any +>[] : undefined[] + + v; +>v : any + + for (let v of [v]) { +>v : any +>[v] : any[] +>v : any + + var x = v; +>x : any +>v : any + + v++; +>v++ : number +>v : any + } +} diff --git a/tests/baselines/reference/ES5For-of20.symbols b/tests/baselines/reference/ES5For-of20.symbols new file mode 100644 index 00000000000..01104e621a9 --- /dev/null +++ b/tests/baselines/reference/ES5For-of20.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts === +for (let v of []) { +>v : Symbol(v, Decl(ES5For-of20.ts, 0, 8)) + + let v; +>v : Symbol(v, Decl(ES5For-of20.ts, 1, 7)) + + for (let v of [v]) { +>v : Symbol(v, Decl(ES5For-of20.ts, 2, 12)) +>v : Symbol(v, Decl(ES5For-of20.ts, 2, 12)) + + const v; +>v : Symbol(v, Decl(ES5For-of20.ts, 3, 13)) + } +} diff --git a/tests/baselines/reference/ES5For-of20.types b/tests/baselines/reference/ES5For-of20.types new file mode 100644 index 00000000000..3b07913c3b0 --- /dev/null +++ b/tests/baselines/reference/ES5For-of20.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of20.ts === +for (let v of []) { +>v : any +>[] : undefined[] + + let v; +>v : any + + for (let v of [v]) { +>v : any +>[v] : any[] +>v : any + + const v; +>v : any + } +} diff --git a/tests/baselines/reference/ES5For-of22.symbols b/tests/baselines/reference/ES5For-of22.symbols new file mode 100644 index 00000000000..6511d8c9a8b --- /dev/null +++ b/tests/baselines/reference/ES5For-of22.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts === +for (var x of [1, 2, 3]) { +>x : Symbol(x, Decl(ES5For-of22.ts, 0, 8)) + + let _a = 0; +>_a : Symbol(_a, Decl(ES5For-of22.ts, 1, 7)) + + console.log(x); +>x : Symbol(x, Decl(ES5For-of22.ts, 0, 8)) +} diff --git a/tests/baselines/reference/ES5For-of22.types b/tests/baselines/reference/ES5For-of22.types new file mode 100644 index 00000000000..ec99c310bf7 --- /dev/null +++ b/tests/baselines/reference/ES5For-of22.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of22.ts === +for (var x of [1, 2, 3]) { +>x : number +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + + let _a = 0; +>_a : number +>0 : 0 + + console.log(x); +>console.log(x) : any +>console.log : any +>console : any +>log : any +>x : number +} diff --git a/tests/baselines/reference/ES5For-of23.symbols b/tests/baselines/reference/ES5For-of23.symbols new file mode 100644 index 00000000000..7b030d4e1e3 --- /dev/null +++ b/tests/baselines/reference/ES5For-of23.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts === +for (var x of [1, 2, 3]) { +>x : Symbol(x, Decl(ES5For-of23.ts, 0, 8)) + + var _a = 0; +>_a : Symbol(_a, Decl(ES5For-of23.ts, 1, 7)) + + console.log(x); +>x : Symbol(x, Decl(ES5For-of23.ts, 0, 8)) +} diff --git a/tests/baselines/reference/ES5For-of23.types b/tests/baselines/reference/ES5For-of23.types new file mode 100644 index 00000000000..c519e1c6ee2 --- /dev/null +++ b/tests/baselines/reference/ES5For-of23.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of23.ts === +for (var x of [1, 2, 3]) { +>x : number +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + + var _a = 0; +>_a : number +>0 : 0 + + console.log(x); +>console.log(x) : any +>console.log : any +>console : any +>log : any +>x : number +} diff --git a/tests/baselines/reference/ES5For-of26.symbols b/tests/baselines/reference/ES5For-of26.symbols new file mode 100644 index 00000000000..0c54eaea824 --- /dev/null +++ b/tests/baselines/reference/ES5For-of26.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts === +for (var [a = 0, b = 1] of [2, 3]) { +>a : Symbol(a, Decl(ES5For-of26.ts, 0, 10)) +>b : Symbol(b, Decl(ES5For-of26.ts, 0, 16)) + + a; +>a : Symbol(a, Decl(ES5For-of26.ts, 0, 10)) + + b; +>b : Symbol(b, Decl(ES5For-of26.ts, 0, 16)) +} diff --git a/tests/baselines/reference/ES5For-of26.types b/tests/baselines/reference/ES5For-of26.types new file mode 100644 index 00000000000..17cac39a723 --- /dev/null +++ b/tests/baselines/reference/ES5For-of26.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of26.ts === +for (var [a = 0, b = 1] of [2, 3]) { +>a : any +>0 : 0 +>b : any +>1 : 1 +>[2, 3] : number[] +>2 : 2 +>3 : 3 + + a; +>a : any + + b; +>b : any +} diff --git a/tests/baselines/reference/ES5For-of27.symbols b/tests/baselines/reference/ES5For-of27.symbols new file mode 100644 index 00000000000..31348c4ca8a --- /dev/null +++ b/tests/baselines/reference/ES5For-of27.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts === +for (var {x: a = 0, y: b = 1} of [2, 3]) { +>a : Symbol(a, Decl(ES5For-of27.ts, 0, 10)) +>b : Symbol(b, Decl(ES5For-of27.ts, 0, 19)) + + a; +>a : Symbol(a, Decl(ES5For-of27.ts, 0, 10)) + + b; +>b : Symbol(b, Decl(ES5For-of27.ts, 0, 19)) +} diff --git a/tests/baselines/reference/ES5For-of27.types b/tests/baselines/reference/ES5For-of27.types new file mode 100644 index 00000000000..3bdc3fe9118 --- /dev/null +++ b/tests/baselines/reference/ES5For-of27.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of27.ts === +for (var {x: a = 0, y: b = 1} of [2, 3]) { +>x : any +>a : any +>0 : 0 +>y : any +>b : any +>1 : 1 +>[2, 3] : number[] +>2 : 2 +>3 : 3 + + a; +>a : any + + b; +>b : any +} diff --git a/tests/baselines/reference/ES5For-of28.symbols b/tests/baselines/reference/ES5For-of28.symbols new file mode 100644 index 00000000000..53e1de495ac --- /dev/null +++ b/tests/baselines/reference/ES5For-of28.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts === +for (let [a = 0, b = 1] of [2, 3]) { +>a : Symbol(a, Decl(ES5For-of28.ts, 0, 10)) +>b : Symbol(b, Decl(ES5For-of28.ts, 0, 16)) + + a; +>a : Symbol(a, Decl(ES5For-of28.ts, 0, 10)) + + b; +>b : Symbol(b, Decl(ES5For-of28.ts, 0, 16)) +} diff --git a/tests/baselines/reference/ES5For-of28.types b/tests/baselines/reference/ES5For-of28.types new file mode 100644 index 00000000000..76646ef7596 --- /dev/null +++ b/tests/baselines/reference/ES5For-of28.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of28.ts === +for (let [a = 0, b = 1] of [2, 3]) { +>a : any +>0 : 0 +>b : any +>1 : 1 +>[2, 3] : number[] +>2 : 2 +>3 : 3 + + a; +>a : any + + b; +>b : any +} diff --git a/tests/baselines/reference/ES5For-of29.symbols b/tests/baselines/reference/ES5For-of29.symbols new file mode 100644 index 00000000000..efe7c386741 --- /dev/null +++ b/tests/baselines/reference/ES5For-of29.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts === +for (const {x: a = 0, y: b = 1} of [2, 3]) { +>a : Symbol(a, Decl(ES5For-of29.ts, 0, 12)) +>b : Symbol(b, Decl(ES5For-of29.ts, 0, 21)) + + a; +>a : Symbol(a, Decl(ES5For-of29.ts, 0, 12)) + + b; +>b : Symbol(b, Decl(ES5For-of29.ts, 0, 21)) +} diff --git a/tests/baselines/reference/ES5For-of29.types b/tests/baselines/reference/ES5For-of29.types new file mode 100644 index 00000000000..687dcef6bd5 --- /dev/null +++ b/tests/baselines/reference/ES5For-of29.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of29.ts === +for (const {x: a = 0, y: b = 1} of [2, 3]) { +>x : any +>a : any +>0 : 0 +>y : any +>b : any +>1 : 1 +>[2, 3] : number[] +>2 : 2 +>3 : 3 + + a; +>a : any + + b; +>b : any +} diff --git a/tests/baselines/reference/ES5For-of30.symbols b/tests/baselines/reference/ES5For-of30.symbols new file mode 100644 index 00000000000..60cb2a0a1f5 --- /dev/null +++ b/tests/baselines/reference/ES5For-of30.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts === +var a: string, b: number; +>a : Symbol(a, Decl(ES5For-of30.ts, 0, 3)) +>b : Symbol(b, Decl(ES5For-of30.ts, 0, 14)) + +var tuple: [number, string] = [2, "3"]; +>tuple : Symbol(tuple, Decl(ES5For-of30.ts, 1, 3)) + +for ([a = 1, b = ""] of tuple) { +>a : Symbol(a, Decl(ES5For-of30.ts, 0, 3)) +>b : Symbol(b, Decl(ES5For-of30.ts, 0, 14)) +>tuple : Symbol(tuple, Decl(ES5For-of30.ts, 1, 3)) + + a; +>a : Symbol(a, Decl(ES5For-of30.ts, 0, 3)) + + b; +>b : Symbol(b, Decl(ES5For-of30.ts, 0, 14)) +} diff --git a/tests/baselines/reference/ES5For-of30.types b/tests/baselines/reference/ES5For-of30.types new file mode 100644 index 00000000000..e55ead743ad --- /dev/null +++ b/tests/baselines/reference/ES5For-of30.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts === +var a: string, b: number; +>a : string +>b : number + +var tuple: [number, string] = [2, "3"]; +>tuple : [number, string] +>[2, "3"] : [number, string] +>2 : 2 +>"3" : "3" + +for ([a = 1, b = ""] of tuple) { +>[a = 1, b = ""] : [number, string] +>a = 1 : 1 +>a : string +>1 : 1 +>b = "" : "" +>b : number +>"" : "" +>tuple : [number, string] + + a; +>a : string + + b; +>b : number +} diff --git a/tests/baselines/reference/ES5For-of31.symbols b/tests/baselines/reference/ES5For-of31.symbols new file mode 100644 index 00000000000..73c355fdad2 --- /dev/null +++ b/tests/baselines/reference/ES5For-of31.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts === +var a: string, b: number; +>a : Symbol(a, Decl(ES5For-of31.ts, 0, 3)) +>b : Symbol(b, Decl(ES5For-of31.ts, 0, 14)) + +for ({ a: b = 1, b: a = ""} of []) { +>a : Symbol(a, Decl(ES5For-of31.ts, 2, 6)) +>b : Symbol(b, Decl(ES5For-of31.ts, 0, 14)) +>b : Symbol(b, Decl(ES5For-of31.ts, 2, 16)) +>a : Symbol(a, Decl(ES5For-of31.ts, 0, 3)) + + a; +>a : Symbol(a, Decl(ES5For-of31.ts, 0, 3)) + + b; +>b : Symbol(b, Decl(ES5For-of31.ts, 0, 14)) +} diff --git a/tests/baselines/reference/ES5For-of31.types b/tests/baselines/reference/ES5For-of31.types new file mode 100644 index 00000000000..ee12f3894a8 --- /dev/null +++ b/tests/baselines/reference/ES5For-of31.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of31.ts === +var a: string, b: number; +>a : string +>b : number + +for ({ a: b = 1, b: a = ""} of []) { +>{ a: b = 1, b: a = ""} : { a?: number; b?: string; } +>a : undefined +>b = 1 : 1 +>b : number +>1 : 1 +>b : undefined +>a = "" : "" +>a : string +>"" : "" +>[] : undefined[] + + a; +>a : string + + b; +>b : number +} diff --git a/tests/baselines/reference/ES5For-of33.symbols b/tests/baselines/reference/ES5For-of33.symbols new file mode 100644 index 00000000000..0d3008a5533 --- /dev/null +++ b/tests/baselines/reference/ES5For-of33.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of33.ts === +for (var v of ['a', 'b', 'c']) { +>v : Symbol(v, Decl(ES5For-of33.ts, 0, 8)) + + console.log(v); +>v : Symbol(v, Decl(ES5For-of33.ts, 0, 8)) +} diff --git a/tests/baselines/reference/ES5For-of33.types b/tests/baselines/reference/ES5For-of33.types new file mode 100644 index 00000000000..2bcd7b9fc35 --- /dev/null +++ b/tests/baselines/reference/ES5For-of33.types @@ -0,0 +1,15 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of33.ts === +for (var v of ['a', 'b', 'c']) { +>v : string +>['a', 'b', 'c'] : string[] +>'a' : "a" +>'b' : "b" +>'c' : "c" + + console.log(v); +>console.log(v) : any +>console.log : any +>console : any +>log : any +>v : string +} diff --git a/tests/baselines/reference/ES5For-of34.symbols b/tests/baselines/reference/ES5For-of34.symbols new file mode 100644 index 00000000000..134a7b985b9 --- /dev/null +++ b/tests/baselines/reference/ES5For-of34.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of34.ts === +function foo() { +>foo : Symbol(foo, Decl(ES5For-of34.ts, 0, 0)) + + return { x: 0 }; +>x : Symbol(x, Decl(ES5For-of34.ts, 1, 12)) +} +for (foo().x of ['a', 'b', 'c']) { +>foo().x : Symbol(x, Decl(ES5For-of34.ts, 1, 12)) +>foo : Symbol(foo, Decl(ES5For-of34.ts, 0, 0)) +>x : Symbol(x, Decl(ES5For-of34.ts, 1, 12)) + + var p = foo().x; +>p : Symbol(p, Decl(ES5For-of34.ts, 4, 7)) +>foo().x : Symbol(x, Decl(ES5For-of34.ts, 1, 12)) +>foo : Symbol(foo, Decl(ES5For-of34.ts, 0, 0)) +>x : Symbol(x, Decl(ES5For-of34.ts, 1, 12)) +} diff --git a/tests/baselines/reference/ES5For-of34.types b/tests/baselines/reference/ES5For-of34.types new file mode 100644 index 00000000000..c565b8c8e87 --- /dev/null +++ b/tests/baselines/reference/ES5For-of34.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of34.ts === +function foo() { +>foo : () => { x: number; } + + return { x: 0 }; +>{ x: 0 } : { x: number; } +>x : number +>0 : 0 +} +for (foo().x of ['a', 'b', 'c']) { +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +>['a', 'b', 'c'] : string[] +>'a' : "a" +>'b' : "b" +>'c' : "c" + + var p = foo().x; +>p : number +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +} diff --git a/tests/baselines/reference/ES5For-of35.symbols b/tests/baselines/reference/ES5For-of35.symbols new file mode 100644 index 00000000000..e8dcb07ca5a --- /dev/null +++ b/tests/baselines/reference/ES5For-of35.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of35.ts === +for (const {x: a = 0, y: b = 1} of [2, 3]) { +>a : Symbol(a, Decl(ES5For-of35.ts, 0, 12)) +>b : Symbol(b, Decl(ES5For-of35.ts, 0, 21)) + + a; +>a : Symbol(a, Decl(ES5For-of35.ts, 0, 12)) + + b; +>b : Symbol(b, Decl(ES5For-of35.ts, 0, 21)) +} diff --git a/tests/baselines/reference/ES5For-of35.types b/tests/baselines/reference/ES5For-of35.types new file mode 100644 index 00000000000..dab1b49c57a --- /dev/null +++ b/tests/baselines/reference/ES5For-of35.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of35.ts === +for (const {x: a = 0, y: b = 1} of [2, 3]) { +>x : any +>a : any +>0 : 0 +>y : any +>b : any +>1 : 1 +>[2, 3] : number[] +>2 : 2 +>3 : 3 + + a; +>a : any + + b; +>b : any +} diff --git a/tests/baselines/reference/ES5For-of36.symbols b/tests/baselines/reference/ES5For-of36.symbols new file mode 100644 index 00000000000..d93f5e3f34b --- /dev/null +++ b/tests/baselines/reference/ES5For-of36.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of36.ts === +for (let [a = 0, b = 1] of [2, 3]) { +>a : Symbol(a, Decl(ES5For-of36.ts, 0, 10)) +>b : Symbol(b, Decl(ES5For-of36.ts, 0, 16)) + + a; +>a : Symbol(a, Decl(ES5For-of36.ts, 0, 10)) + + b; +>b : Symbol(b, Decl(ES5For-of36.ts, 0, 16)) +} diff --git a/tests/baselines/reference/ES5For-of36.types b/tests/baselines/reference/ES5For-of36.types new file mode 100644 index 00000000000..89b88e8b335 --- /dev/null +++ b/tests/baselines/reference/ES5For-of36.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of36.ts === +for (let [a = 0, b = 1] of [2, 3]) { +>a : any +>0 : 0 +>b : any +>1 : 1 +>[2, 3] : number[] +>2 : 2 +>3 : 3 + + a; +>a : any + + b; +>b : any +} diff --git a/tests/baselines/reference/ES5For-of7.symbols b/tests/baselines/reference/ES5For-of7.symbols new file mode 100644 index 00000000000..c6cb92b6d88 --- /dev/null +++ b/tests/baselines/reference/ES5For-of7.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts === +for (var w of []) { +>w : Symbol(w, Decl(ES5For-of7.ts, 0, 8)) + + var x = w; +>x : Symbol(x, Decl(ES5For-of7.ts, 1, 7), Decl(ES5For-of7.ts, 5, 7)) +>w : Symbol(w, Decl(ES5For-of7.ts, 0, 8)) +} + +for (var v of []) { +>v : Symbol(v, Decl(ES5For-of7.ts, 4, 8)) + + var x = [w, v]; +>x : Symbol(x, Decl(ES5For-of7.ts, 1, 7), Decl(ES5For-of7.ts, 5, 7)) +>w : Symbol(w, Decl(ES5For-of7.ts, 0, 8)) +>v : Symbol(v, Decl(ES5For-of7.ts, 4, 8)) +} diff --git a/tests/baselines/reference/ES5For-of7.types b/tests/baselines/reference/ES5For-of7.types new file mode 100644 index 00000000000..6e1fdc25ea9 --- /dev/null +++ b/tests/baselines/reference/ES5For-of7.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of7.ts === +for (var w of []) { +>w : any +>[] : undefined[] + + var x = w; +>x : any +>w : any +} + +for (var v of []) { +>v : any +>[] : undefined[] + + var x = [w, v]; +>x : any +>[w, v] : any[] +>w : any +>v : any +} diff --git a/tests/baselines/reference/ES5For-of8.symbols b/tests/baselines/reference/ES5For-of8.symbols new file mode 100644 index 00000000000..e04c3ee7c09 --- /dev/null +++ b/tests/baselines/reference/ES5For-of8.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts === +function foo() { +>foo : Symbol(foo, Decl(ES5For-of8.ts, 0, 0)) + + return { x: 0 }; +>x : Symbol(x, Decl(ES5For-of8.ts, 1, 12)) +} +for (foo().x of ['a', 'b', 'c']) { +>foo().x : Symbol(x, Decl(ES5For-of8.ts, 1, 12)) +>foo : Symbol(foo, Decl(ES5For-of8.ts, 0, 0)) +>x : Symbol(x, Decl(ES5For-of8.ts, 1, 12)) + + var p = foo().x; +>p : Symbol(p, Decl(ES5For-of8.ts, 4, 7)) +>foo().x : Symbol(x, Decl(ES5For-of8.ts, 1, 12)) +>foo : Symbol(foo, Decl(ES5For-of8.ts, 0, 0)) +>x : Symbol(x, Decl(ES5For-of8.ts, 1, 12)) +} diff --git a/tests/baselines/reference/ES5For-of8.types b/tests/baselines/reference/ES5For-of8.types new file mode 100644 index 00000000000..eca192ab612 --- /dev/null +++ b/tests/baselines/reference/ES5For-of8.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-of8.ts === +function foo() { +>foo : () => { x: number; } + + return { x: 0 }; +>{ x: 0 } : { x: number; } +>x : number +>0 : 0 +} +for (foo().x of ['a', 'b', 'c']) { +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +>['a', 'b', 'c'] : string[] +>'a' : "a" +>'b' : "b" +>'c' : "c" + + var p = foo().x; +>p : number +>foo().x : number +>foo() : { x: number; } +>foo : () => { x: number; } +>x : number +} diff --git a/tests/baselines/reference/ES5For-ofTypeCheck10.symbols b/tests/baselines/reference/ES5For-ofTypeCheck10.symbols new file mode 100644 index 00000000000..f3b30e9dfc1 --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck10.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts === +// In ES3/5, you cannot for...of over an arbitrary iterable. +class StringIterator { +>StringIterator : Symbol(StringIterator, Decl(ES5For-ofTypeCheck10.ts, 0, 0)) + + next() { +>next : Symbol(StringIterator.next, Decl(ES5For-ofTypeCheck10.ts, 1, 22)) + + return { + done: true, +>done : Symbol(done, Decl(ES5For-ofTypeCheck10.ts, 3, 16)) + + value: "" +>value : Symbol(value, Decl(ES5For-ofTypeCheck10.ts, 4, 23)) + + }; + } + [Symbol.iterator]() { + return this; +>this : Symbol(StringIterator, Decl(ES5For-ofTypeCheck10.ts, 0, 0)) + } +} + +for (var v of new StringIterator) { } +>v : Symbol(v, Decl(ES5For-ofTypeCheck10.ts, 13, 8)) +>StringIterator : Symbol(StringIterator, Decl(ES5For-ofTypeCheck10.ts, 0, 0)) + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck10.types b/tests/baselines/reference/ES5For-ofTypeCheck10.types new file mode 100644 index 00000000000..8cc3dd26a54 --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck10.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck10.ts === +// In ES3/5, you cannot for...of over an arbitrary iterable. +class StringIterator { +>StringIterator : StringIterator + + next() { +>next : () => { done: boolean; value: string; } + + return { +>{ done: true, value: "" } : { done: boolean; value: string; } + + done: true, +>done : boolean +>true : true + + value: "" +>value : string +>"" : "" + + }; + } + [Symbol.iterator]() { +>Symbol.iterator : any +>Symbol : any +>iterator : any + + return this; +>this : this + } +} + +for (var v of new StringIterator) { } +>v : any +>new StringIterator : StringIterator +>StringIterator : typeof StringIterator + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck11.symbols b/tests/baselines/reference/ES5For-ofTypeCheck11.symbols new file mode 100644 index 00000000000..412920f67de --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck11.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts === +var union: string | number[]; +>union : Symbol(union, Decl(ES5For-ofTypeCheck11.ts, 0, 3)) + +var v: string; +>v : Symbol(v, Decl(ES5For-ofTypeCheck11.ts, 1, 3)) + +for (v of union) { } +>v : Symbol(v, Decl(ES5For-ofTypeCheck11.ts, 1, 3)) +>union : Symbol(union, Decl(ES5For-ofTypeCheck11.ts, 0, 3)) + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck11.types b/tests/baselines/reference/ES5For-ofTypeCheck11.types new file mode 100644 index 00000000000..c18aa4bcd87 --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck11.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck11.ts === +var union: string | number[]; +>union : string | number[] + +var v: string; +>v : string + +for (v of union) { } +>v : string +>union : string | number[] + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck12.symbols b/tests/baselines/reference/ES5For-ofTypeCheck12.symbols new file mode 100644 index 00000000000..425aeb6e63f --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck12.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts === +for (const v of 0) { } +>v : Symbol(v, Decl(ES5For-ofTypeCheck12.ts, 0, 10)) + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck12.types b/tests/baselines/reference/ES5For-ofTypeCheck12.types new file mode 100644 index 00000000000..533c44edd51 --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck12.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts === +for (const v of 0) { } +>v : any +>0 : 0 + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck7.symbols b/tests/baselines/reference/ES5For-ofTypeCheck7.symbols new file mode 100644 index 00000000000..ecdce4da59e --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck7.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck7.ts === +var union: string | number; +>union : Symbol(union, Decl(ES5For-ofTypeCheck7.ts, 0, 3)) + +for (var v of union) { } +>v : Symbol(v, Decl(ES5For-ofTypeCheck7.ts, 1, 8)) +>union : Symbol(union, Decl(ES5For-ofTypeCheck7.ts, 0, 3)) + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck7.types b/tests/baselines/reference/ES5For-ofTypeCheck7.types new file mode 100644 index 00000000000..846fc0b8bfc --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck7.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck7.ts === +var union: string | number; +>union : string | number + +for (var v of union) { } +>v : string +>union : string | number + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck8.symbols b/tests/baselines/reference/ES5For-ofTypeCheck8.symbols new file mode 100644 index 00000000000..67af60ffbd1 --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck8.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck8.ts === +var union: string | string[]| number[]| symbol[]; +>union : Symbol(union, Decl(ES5For-ofTypeCheck8.ts, 0, 3)) + +var v: symbol; +>v : Symbol(v, Decl(ES5For-ofTypeCheck8.ts, 1, 3)) + +for (v of union) { } +>v : Symbol(v, Decl(ES5For-ofTypeCheck8.ts, 1, 3)) +>union : Symbol(union, Decl(ES5For-ofTypeCheck8.ts, 0, 3)) + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck8.types b/tests/baselines/reference/ES5For-ofTypeCheck8.types new file mode 100644 index 00000000000..6888680db93 --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck8.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck8.ts === +var union: string | string[]| number[]| symbol[]; +>union : string | string[] | number[] | symbol[] + +var v: symbol; +>v : symbol + +for (v of union) { } +>v : symbol +>union : string | string[] | number[] | symbol[] + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck9.symbols b/tests/baselines/reference/ES5For-ofTypeCheck9.symbols new file mode 100644 index 00000000000..d820fb62ae8 --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck9.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts === +var union: string | string[] | number | symbol; +>union : Symbol(union, Decl(ES5For-ofTypeCheck9.ts, 0, 3)) + +for (let v of union) { } +>v : Symbol(v, Decl(ES5For-ofTypeCheck9.ts, 1, 8)) +>union : Symbol(union, Decl(ES5For-ofTypeCheck9.ts, 0, 3)) + diff --git a/tests/baselines/reference/ES5For-ofTypeCheck9.types b/tests/baselines/reference/ES5For-ofTypeCheck9.types new file mode 100644 index 00000000000..19c1c593d6e --- /dev/null +++ b/tests/baselines/reference/ES5For-ofTypeCheck9.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck9.ts === +var union: string | string[] | number | symbol; +>union : string | number | symbol | string[] + +for (let v of union) { } +>v : string +>union : string | number | symbol | string[] + diff --git a/tests/baselines/reference/ES5SymbolProperty1.symbols b/tests/baselines/reference/ES5SymbolProperty1.symbols new file mode 100644 index 00000000000..134b0df8e17 --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty1.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty1.ts === +interface SymbolConstructor { +>SymbolConstructor : Symbol(SymbolConstructor, Decl(ES5SymbolProperty1.ts, 0, 0)) + + foo: string; +>foo : Symbol(SymbolConstructor.foo, Decl(ES5SymbolProperty1.ts, 0, 29)) +} +var Symbol: SymbolConstructor; +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty1.ts, 3, 3)) +>SymbolConstructor : Symbol(SymbolConstructor, Decl(ES5SymbolProperty1.ts, 0, 0)) + +var obj = { +>obj : Symbol(obj, Decl(ES5SymbolProperty1.ts, 5, 3)) + + [Symbol.foo]: 0 +>Symbol.foo : Symbol(SymbolConstructor.foo, Decl(ES5SymbolProperty1.ts, 0, 29)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty1.ts, 3, 3)) +>foo : Symbol(SymbolConstructor.foo, Decl(ES5SymbolProperty1.ts, 0, 29)) +} + +obj[Symbol.foo]; +>obj : Symbol(obj, Decl(ES5SymbolProperty1.ts, 5, 3)) +>Symbol.foo : Symbol(SymbolConstructor.foo, Decl(ES5SymbolProperty1.ts, 0, 29)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty1.ts, 3, 3)) +>foo : Symbol(SymbolConstructor.foo, Decl(ES5SymbolProperty1.ts, 0, 29)) + diff --git a/tests/baselines/reference/ES5SymbolProperty1.types b/tests/baselines/reference/ES5SymbolProperty1.types new file mode 100644 index 00000000000..13cf5ae85b5 --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty1.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty1.ts === +interface SymbolConstructor { +>SymbolConstructor : SymbolConstructor + + foo: string; +>foo : string +} +var Symbol: SymbolConstructor; +>Symbol : SymbolConstructor +>SymbolConstructor : SymbolConstructor + +var obj = { +>obj : { [Symbol.foo]: number; } +>{ [Symbol.foo]: 0} : { [Symbol.foo]: number; } + + [Symbol.foo]: 0 +>Symbol.foo : string +>Symbol : SymbolConstructor +>foo : string +>0 : 0 +} + +obj[Symbol.foo]; +>obj[Symbol.foo] : any +>obj : { [Symbol.foo]: number; } +>Symbol.foo : string +>Symbol : SymbolConstructor +>foo : string + diff --git a/tests/baselines/reference/ES5SymbolProperty2.symbols b/tests/baselines/reference/ES5SymbolProperty2.symbols new file mode 100644 index 00000000000..4e784568baa --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty2.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty2.ts === +module M { +>M : Symbol(M, Decl(ES5SymbolProperty2.ts, 0, 0)) + + var Symbol: any; +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty2.ts, 1, 7)) + + export class C { +>C : Symbol(C, Decl(ES5SymbolProperty2.ts, 1, 20)) + + [Symbol.iterator]() { } +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty2.ts, 1, 7)) + } + (new C)[Symbol.iterator]; +>C : Symbol(C, Decl(ES5SymbolProperty2.ts, 1, 20)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty2.ts, 1, 7)) +} + +(new M.C)[Symbol.iterator]; +>M.C : Symbol(M.C, Decl(ES5SymbolProperty2.ts, 1, 20)) +>M : Symbol(M, Decl(ES5SymbolProperty2.ts, 0, 0)) +>C : Symbol(M.C, Decl(ES5SymbolProperty2.ts, 1, 20)) + diff --git a/tests/baselines/reference/ES5SymbolProperty2.types b/tests/baselines/reference/ES5SymbolProperty2.types new file mode 100644 index 00000000000..bea1ad72b6e --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty2.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty2.ts === +module M { +>M : typeof M + + var Symbol: any; +>Symbol : any + + export class C { +>C : C + + [Symbol.iterator]() { } +>Symbol.iterator : any +>Symbol : any +>iterator : any + } + (new C)[Symbol.iterator]; +>(new C)[Symbol.iterator] : any +>(new C) : C +>new C : C +>C : typeof C +>Symbol.iterator : any +>Symbol : any +>iterator : any +} + +(new M.C)[Symbol.iterator]; +>(new M.C)[Symbol.iterator] : any +>(new M.C) : M.C +>new M.C : M.C +>M.C : typeof M.C +>M : typeof M +>C : typeof M.C +>Symbol.iterator : any +>Symbol : any +>iterator : any + diff --git a/tests/baselines/reference/ES5SymbolProperty3.symbols b/tests/baselines/reference/ES5SymbolProperty3.symbols new file mode 100644 index 00000000000..8d6ee1fb607 --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty3.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty3.ts === +var Symbol: any; +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty3.ts, 0, 3)) + +class C { +>C : Symbol(C, Decl(ES5SymbolProperty3.ts, 0, 16)) + + [Symbol.iterator]() { } +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty3.ts, 0, 3)) +} + +(new C)[Symbol.iterator] +>C : Symbol(C, Decl(ES5SymbolProperty3.ts, 0, 16)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty3.ts, 0, 3)) + diff --git a/tests/baselines/reference/ES5SymbolProperty3.types b/tests/baselines/reference/ES5SymbolProperty3.types new file mode 100644 index 00000000000..1a339a88c7c --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty3.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty3.ts === +var Symbol: any; +>Symbol : any + +class C { +>C : C + + [Symbol.iterator]() { } +>Symbol.iterator : any +>Symbol : any +>iterator : any +} + +(new C)[Symbol.iterator] +>(new C)[Symbol.iterator] : any +>(new C) : C +>new C : C +>C : typeof C +>Symbol.iterator : any +>Symbol : any +>iterator : any + diff --git a/tests/baselines/reference/ES5SymbolProperty4.symbols b/tests/baselines/reference/ES5SymbolProperty4.symbols new file mode 100644 index 00000000000..feb3ab8153a --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty4.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty4.ts === +var Symbol: { iterator: string }; +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty4.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty4.ts, 0, 13)) + +class C { +>C : Symbol(C, Decl(ES5SymbolProperty4.ts, 0, 33)) + + [Symbol.iterator]() { } +>Symbol.iterator : Symbol(iterator, Decl(ES5SymbolProperty4.ts, 0, 13)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty4.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty4.ts, 0, 13)) +} + +(new C)[Symbol.iterator] +>C : Symbol(C, Decl(ES5SymbolProperty4.ts, 0, 33)) +>Symbol.iterator : Symbol(iterator, Decl(ES5SymbolProperty4.ts, 0, 13)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty4.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty4.ts, 0, 13)) + diff --git a/tests/baselines/reference/ES5SymbolProperty4.types b/tests/baselines/reference/ES5SymbolProperty4.types new file mode 100644 index 00000000000..98ab97d5888 --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty4.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty4.ts === +var Symbol: { iterator: string }; +>Symbol : { iterator: string; } +>iterator : string + +class C { +>C : C + + [Symbol.iterator]() { } +>Symbol.iterator : string +>Symbol : { iterator: string; } +>iterator : string +} + +(new C)[Symbol.iterator] +>(new C)[Symbol.iterator] : any +>(new C) : C +>new C : C +>C : typeof C +>Symbol.iterator : string +>Symbol : { iterator: string; } +>iterator : string + diff --git a/tests/baselines/reference/ES5SymbolProperty5.symbols b/tests/baselines/reference/ES5SymbolProperty5.symbols new file mode 100644 index 00000000000..30c3f31ca0b --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty5.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty5.ts === +var Symbol: { iterator: symbol }; +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty5.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty5.ts, 0, 13)) + +class C { +>C : Symbol(C, Decl(ES5SymbolProperty5.ts, 0, 33)) + + [Symbol.iterator]() { } +>Symbol.iterator : Symbol(iterator, Decl(ES5SymbolProperty5.ts, 0, 13)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty5.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty5.ts, 0, 13)) +} + +(new C)[Symbol.iterator](0) // Should error +>C : Symbol(C, Decl(ES5SymbolProperty5.ts, 0, 33)) +>Symbol.iterator : Symbol(iterator, Decl(ES5SymbolProperty5.ts, 0, 13)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty5.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty5.ts, 0, 13)) + diff --git a/tests/baselines/reference/ES5SymbolProperty5.types b/tests/baselines/reference/ES5SymbolProperty5.types new file mode 100644 index 00000000000..1e15b6b487f --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty5.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty5.ts === +var Symbol: { iterator: symbol }; +>Symbol : { iterator: symbol; } +>iterator : symbol + +class C { +>C : C + + [Symbol.iterator]() { } +>Symbol.iterator : symbol +>Symbol : { iterator: symbol; } +>iterator : symbol +} + +(new C)[Symbol.iterator](0) // Should error +>(new C)[Symbol.iterator](0) : void +>(new C)[Symbol.iterator] : () => void +>(new C) : C +>new C : C +>C : typeof C +>Symbol.iterator : symbol +>Symbol : { iterator: symbol; } +>iterator : symbol +>0 : 0 + diff --git a/tests/baselines/reference/ES5SymbolProperty6.symbols b/tests/baselines/reference/ES5SymbolProperty6.symbols new file mode 100644 index 00000000000..bb2d23e0c1e --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty6.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty6.ts === +class C { +>C : Symbol(C, Decl(ES5SymbolProperty6.ts, 0, 0)) + + [Symbol.iterator]() { } +} + +(new C)[Symbol.iterator] +>C : Symbol(C, Decl(ES5SymbolProperty6.ts, 0, 0)) + diff --git a/tests/baselines/reference/ES5SymbolProperty6.types b/tests/baselines/reference/ES5SymbolProperty6.types new file mode 100644 index 00000000000..45ac7c31c7b --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty6.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty6.ts === +class C { +>C : C + + [Symbol.iterator]() { } +>Symbol.iterator : any +>Symbol : any +>iterator : any +} + +(new C)[Symbol.iterator] +>(new C)[Symbol.iterator] : any +>(new C) : C +>new C : C +>C : typeof C +>Symbol.iterator : any +>Symbol : any +>iterator : any + diff --git a/tests/baselines/reference/ES5SymbolProperty7.symbols b/tests/baselines/reference/ES5SymbolProperty7.symbols new file mode 100644 index 00000000000..336d79e7356 --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty7.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty7.ts === +var Symbol: { iterator: any }; +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty7.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty7.ts, 0, 13)) + +class C { +>C : Symbol(C, Decl(ES5SymbolProperty7.ts, 0, 30)) + + [Symbol.iterator]() { } +>Symbol.iterator : Symbol(iterator, Decl(ES5SymbolProperty7.ts, 0, 13)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty7.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty7.ts, 0, 13)) +} + +(new C)[Symbol.iterator] +>C : Symbol(C, Decl(ES5SymbolProperty7.ts, 0, 30)) +>Symbol.iterator : Symbol(iterator, Decl(ES5SymbolProperty7.ts, 0, 13)) +>Symbol : Symbol(Symbol, Decl(ES5SymbolProperty7.ts, 0, 3)) +>iterator : Symbol(iterator, Decl(ES5SymbolProperty7.ts, 0, 13)) + diff --git a/tests/baselines/reference/ES5SymbolProperty7.types b/tests/baselines/reference/ES5SymbolProperty7.types new file mode 100644 index 00000000000..b0adad6cf13 --- /dev/null +++ b/tests/baselines/reference/ES5SymbolProperty7.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/Symbols/ES5SymbolProperty7.ts === +var Symbol: { iterator: any }; +>Symbol : { iterator: any; } +>iterator : any + +class C { +>C : C + + [Symbol.iterator]() { } +>Symbol.iterator : any +>Symbol : { iterator: any; } +>iterator : any +} + +(new C)[Symbol.iterator] +>(new C)[Symbol.iterator] : any +>(new C) : C +>new C : C +>C : typeof C +>Symbol.iterator : any +>Symbol : { iterator: any; } +>iterator : any + diff --git a/tests/baselines/reference/ExportAssignment7.symbols b/tests/baselines/reference/ExportAssignment7.symbols new file mode 100644 index 00000000000..162c9c2911e --- /dev/null +++ b/tests/baselines/reference/ExportAssignment7.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/ExportAssignment7.ts === +export class C { +>C : Symbol(C, Decl(ExportAssignment7.ts, 0, 0)) +} + +export = B; diff --git a/tests/baselines/reference/ExportAssignment7.types b/tests/baselines/reference/ExportAssignment7.types new file mode 100644 index 00000000000..2f0871f48a5 --- /dev/null +++ b/tests/baselines/reference/ExportAssignment7.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ExportAssignment7.ts === +export class C { +>C : C +} + +export = B; +>B : No type information available! + diff --git a/tests/baselines/reference/ExportAssignment8.symbols b/tests/baselines/reference/ExportAssignment8.symbols new file mode 100644 index 00000000000..771de032de7 --- /dev/null +++ b/tests/baselines/reference/ExportAssignment8.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/ExportAssignment8.ts === +export = B; + +export class C { +>C : Symbol(C, Decl(ExportAssignment8.ts, 0, 11)) +} diff --git a/tests/baselines/reference/ExportAssignment8.types b/tests/baselines/reference/ExportAssignment8.types new file mode 100644 index 00000000000..1b141b0b216 --- /dev/null +++ b/tests/baselines/reference/ExportAssignment8.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ExportAssignment8.ts === +export = B; +>B : No type information available! + +export class C { +>C : C +} diff --git a/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.symbols b/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.symbols new file mode 100644 index 00000000000..19c587f7148 --- /dev/null +++ b/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.symbols @@ -0,0 +1,111 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/function.ts === +module A { +>A : Symbol(A, Decl(function.ts, 0, 0), Decl(module.ts, 0, 0)) + + export function Point() { +>Point : Symbol(Point, Decl(function.ts, 0, 10), Decl(module.ts, 0, 10)) + + return { x: 0, y: 0 }; +>x : Symbol(x, Decl(function.ts, 2, 16)) +>y : Symbol(y, Decl(function.ts, 2, 22)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module A { +>A : Symbol(A, Decl(function.ts, 0, 0), Decl(module.ts, 0, 0)) + + export module Point { +>Point : Symbol(Point, Decl(function.ts, 0, 10), Decl(module.ts, 0, 10)) + + export var Origin = { x: 0, y: 0 }; +>Origin : Symbol(Origin, Decl(module.ts, 2, 18)) +>x : Symbol(x, Decl(module.ts, 2, 29)) +>y : Symbol(y, Decl(module.ts, 2, 35)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts === +var fn: () => { x: number; y: number }; +>fn : Symbol(fn, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(simple.ts, 11, 3), Decl(simple.ts, 12, 3)) +>x : Symbol(x, Decl(test.ts, 0, 15)) +>y : Symbol(y, Decl(test.ts, 0, 26)) + +var fn = A.Point; +>fn : Symbol(fn, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(simple.ts, 11, 3), Decl(simple.ts, 12, 3)) +>A.Point : Symbol(A.Point, Decl(function.ts, 0, 10), Decl(module.ts, 0, 10)) +>A : Symbol(A, Decl(function.ts, 0, 0), Decl(module.ts, 0, 0)) +>Point : Symbol(A.Point, Decl(function.ts, 0, 10), Decl(module.ts, 0, 10)) + +var cl: { x: number; y: number; } +>cl : Symbol(cl, Decl(test.ts, 3, 3), Decl(test.ts, 4, 3), Decl(test.ts, 5, 3), Decl(simple.ts, 14, 3), Decl(simple.ts, 15, 3) ... and 1 more) +>x : Symbol(x, Decl(test.ts, 3, 9)) +>y : Symbol(y, Decl(test.ts, 3, 20)) + +var cl = A.Point(); +>cl : Symbol(cl, Decl(test.ts, 3, 3), Decl(test.ts, 4, 3), Decl(test.ts, 5, 3), Decl(simple.ts, 14, 3), Decl(simple.ts, 15, 3) ... and 1 more) +>A.Point : Symbol(A.Point, Decl(function.ts, 0, 10), Decl(module.ts, 0, 10)) +>A : Symbol(A, Decl(function.ts, 0, 0), Decl(module.ts, 0, 0)) +>Point : Symbol(A.Point, Decl(function.ts, 0, 10), Decl(module.ts, 0, 10)) + +var cl = A.Point.Origin; // not expected to be an error. +>cl : Symbol(cl, Decl(test.ts, 3, 3), Decl(test.ts, 4, 3), Decl(test.ts, 5, 3), Decl(simple.ts, 14, 3), Decl(simple.ts, 15, 3) ... and 1 more) +>A.Point.Origin : Symbol(A.Point.Origin, Decl(module.ts, 2, 18)) +>A.Point : Symbol(A.Point, Decl(function.ts, 0, 10), Decl(module.ts, 0, 10)) +>A : Symbol(A, Decl(function.ts, 0, 0), Decl(module.ts, 0, 0)) +>Point : Symbol(A.Point, Decl(function.ts, 0, 10), Decl(module.ts, 0, 10)) +>Origin : Symbol(A.Point.Origin, Decl(module.ts, 2, 18)) + + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +module B { +>B : Symbol(B, Decl(simple.ts, 0, 0)) + + export function Point() { +>Point : Symbol(Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) + + return { x: 0, y: 0 }; +>x : Symbol(x, Decl(simple.ts, 3, 16)) +>y : Symbol(y, Decl(simple.ts, 3, 22)) + } + + export module Point { +>Point : Symbol(Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) + + export var Origin = { x: 0, y: 0 }; +>Origin : Symbol(Origin, Decl(simple.ts, 7, 18)) +>x : Symbol(x, Decl(simple.ts, 7, 29)) +>y : Symbol(y, Decl(simple.ts, 7, 35)) + } +} + +var fn: () => { x: number; y: number }; +>fn : Symbol(fn, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(simple.ts, 11, 3), Decl(simple.ts, 12, 3)) +>x : Symbol(x, Decl(simple.ts, 11, 15)) +>y : Symbol(y, Decl(simple.ts, 11, 26)) + +var fn = B.Point; // not expected to be an error. bug 840000: [corelang] Function of fundule not assignalbe as expected +>fn : Symbol(fn, Decl(test.ts, 0, 3), Decl(test.ts, 1, 3), Decl(simple.ts, 11, 3), Decl(simple.ts, 12, 3)) +>B.Point : Symbol(B.Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) +>B : Symbol(B, Decl(simple.ts, 0, 0)) +>Point : Symbol(B.Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) + +var cl: { x: number; y: number; } +>cl : Symbol(cl, Decl(test.ts, 3, 3), Decl(test.ts, 4, 3), Decl(test.ts, 5, 3), Decl(simple.ts, 14, 3), Decl(simple.ts, 15, 3) ... and 1 more) +>x : Symbol(x, Decl(simple.ts, 14, 9)) +>y : Symbol(y, Decl(simple.ts, 14, 20)) + +var cl = B.Point(); +>cl : Symbol(cl, Decl(test.ts, 3, 3), Decl(test.ts, 4, 3), Decl(test.ts, 5, 3), Decl(simple.ts, 14, 3), Decl(simple.ts, 15, 3) ... and 1 more) +>B.Point : Symbol(B.Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) +>B : Symbol(B, Decl(simple.ts, 0, 0)) +>Point : Symbol(B.Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) + +var cl = B.Point.Origin; +>cl : Symbol(cl, Decl(test.ts, 3, 3), Decl(test.ts, 4, 3), Decl(test.ts, 5, 3), Decl(simple.ts, 14, 3), Decl(simple.ts, 15, 3) ... and 1 more) +>B.Point.Origin : Symbol(B.Point.Origin, Decl(simple.ts, 7, 18)) +>B.Point : Symbol(B.Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) +>B : Symbol(B, Decl(simple.ts, 0, 0)) +>Point : Symbol(B.Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) +>Origin : Symbol(B.Point.Origin, Decl(simple.ts, 7, 18)) + diff --git a/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.types b/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.types new file mode 100644 index 00000000000..a38a459f9e5 --- /dev/null +++ b/tests/baselines/reference/FunctionAndModuleWithSameNameAndCommonRoot.types @@ -0,0 +1,125 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/function.ts === +module A { +>A : typeof A + + export function Point() { +>Point : typeof Point + + return { x: 0, y: 0 }; +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module A { +>A : typeof A + + export module Point { +>Point : typeof Point + + export var Origin = { x: 0, y: 0 }; +>Origin : { x: number; y: number; } +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/test.ts === +var fn: () => { x: number; y: number }; +>fn : () => { x: number; y: number; } +>x : number +>y : number + +var fn = A.Point; +>fn : () => { x: number; y: number; } +>A.Point : typeof A.Point +>A : typeof A +>Point : typeof A.Point + +var cl: { x: number; y: number; } +>cl : { x: number; y: number; } +>x : number +>y : number + +var cl = A.Point(); +>cl : { x: number; y: number; } +>A.Point() : { x: number; y: number; } +>A.Point : typeof A.Point +>A : typeof A +>Point : typeof A.Point + +var cl = A.Point.Origin; // not expected to be an error. +>cl : { x: number; y: number; } +>A.Point.Origin : { x: number; y: number; } +>A.Point : typeof A.Point +>A : typeof A +>Point : typeof A.Point +>Origin : { x: number; y: number; } + + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +module B { +>B : typeof B + + export function Point() { +>Point : typeof Point + + return { x: 0, y: 0 }; +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } + + export module Point { +>Point : typeof Point + + export var Origin = { x: 0, y: 0 }; +>Origin : { x: number; y: number; } +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } +} + +var fn: () => { x: number; y: number }; +>fn : () => { x: number; y: number; } +>x : number +>y : number + +var fn = B.Point; // not expected to be an error. bug 840000: [corelang] Function of fundule not assignalbe as expected +>fn : () => { x: number; y: number; } +>B.Point : typeof B.Point +>B : typeof B +>Point : typeof B.Point + +var cl: { x: number; y: number; } +>cl : { x: number; y: number; } +>x : number +>y : number + +var cl = B.Point(); +>cl : { x: number; y: number; } +>B.Point() : { x: number; y: number; } +>B.Point : typeof B.Point +>B : typeof B +>Point : typeof B.Point + +var cl = B.Point.Origin; +>cl : { x: number; y: number; } +>B.Point.Origin : { x: number; y: number; } +>B.Point : typeof B.Point +>B : typeof B +>Point : typeof B.Point +>Origin : { x: number; y: number; } + diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.symbols b/tests/baselines/reference/FunctionDeclaration10_es6.symbols new file mode 100644 index 00000000000..2b1ccb2a636 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration10_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts === +function * foo(a = yield => yield) { +>foo : Symbol(foo, Decl(FunctionDeclaration10_es6.ts, 0, 0)) +>a : Symbol(a, Decl(FunctionDeclaration10_es6.ts, 0, 15)) +} diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.types b/tests/baselines/reference/FunctionDeclaration10_es6.types new file mode 100644 index 00000000000..2bd25f5a630 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration10_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration10_es6.ts === +function * foo(a = yield => yield) { +>foo : (a?: any) => any +>a : any +>yield : any +>yield : any +} diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.symbols b/tests/baselines/reference/FunctionDeclaration12_es6.symbols new file mode 100644 index 00000000000..d2bdccc179e --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration12_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts === +var v = function * yield() { } +>v : Symbol(v, Decl(FunctionDeclaration12_es6.ts, 0, 3)) +>yield : Symbol(yield, Decl(FunctionDeclaration12_es6.ts, 0, 18)) + diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.types b/tests/baselines/reference/FunctionDeclaration12_es6.types new file mode 100644 index 00000000000..5d413f99d07 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration12_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts === +var v = function * yield() { } +>v : () => any +>function * : () => any +>yield : () => void +>() { } : () => void + diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.symbols b/tests/baselines/reference/FunctionDeclaration13_es6.symbols new file mode 100644 index 00000000000..ad40b5623bb --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration13_es6.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts === +function * foo() { +>foo : Symbol(foo, Decl(FunctionDeclaration13_es6.ts, 0, 0)) + + // Legal to use 'yield' in a type context. + var v: yield; +>v : Symbol(v, Decl(FunctionDeclaration13_es6.ts, 2, 6)) +} + diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.types b/tests/baselines/reference/FunctionDeclaration13_es6.types new file mode 100644 index 00000000000..69502a3e37c --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration13_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration13_es6.ts === +function * foo() { +>foo : () => IterableIterator + + // Legal to use 'yield' in a type context. + var v: yield; +>v : any +>yield : No type information available! +} + diff --git a/tests/baselines/reference/FunctionDeclaration3.symbols b/tests/baselines/reference/FunctionDeclaration3.symbols new file mode 100644 index 00000000000..1bc408ca323 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration3.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/FunctionDeclaration3.ts === +function foo(); +>foo : Symbol(foo, Decl(FunctionDeclaration3.ts, 0, 0)) + diff --git a/tests/baselines/reference/FunctionDeclaration3.types b/tests/baselines/reference/FunctionDeclaration3.types new file mode 100644 index 00000000000..8f528adc9ce --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration3.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/FunctionDeclaration3.ts === +function foo(); +>foo : () => any + diff --git a/tests/baselines/reference/FunctionDeclaration3_es6.symbols b/tests/baselines/reference/FunctionDeclaration3_es6.symbols new file mode 100644 index 00000000000..3a797233a47 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration3_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts === +function f(yield = yield) { +>f : Symbol(f, Decl(FunctionDeclaration3_es6.ts, 0, 0)) +>yield : Symbol(yield, Decl(FunctionDeclaration3_es6.ts, 0, 11)) +>yield : Symbol(yield, Decl(FunctionDeclaration3_es6.ts, 0, 11)) +} diff --git a/tests/baselines/reference/FunctionDeclaration3_es6.types b/tests/baselines/reference/FunctionDeclaration3_es6.types new file mode 100644 index 00000000000..ce1e58e34b6 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration3_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration3_es6.ts === +function f(yield = yield) { +>f : (yield?: any) => void +>yield : any +>yield : any +} diff --git a/tests/baselines/reference/FunctionDeclaration4.symbols b/tests/baselines/reference/FunctionDeclaration4.symbols new file mode 100644 index 00000000000..1e22e10cbe5 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration4.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/FunctionDeclaration4.ts === +function foo(); +>foo : Symbol(foo, Decl(FunctionDeclaration4.ts, 0, 0)) + +function bar() { } +>bar : Symbol(bar, Decl(FunctionDeclaration4.ts, 0, 15)) + diff --git a/tests/baselines/reference/FunctionDeclaration4.types b/tests/baselines/reference/FunctionDeclaration4.types new file mode 100644 index 00000000000..ee6d57880cc --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration4.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/FunctionDeclaration4.ts === +function foo(); +>foo : () => any + +function bar() { } +>bar : () => void + diff --git a/tests/baselines/reference/FunctionDeclaration5_es6.symbols b/tests/baselines/reference/FunctionDeclaration5_es6.symbols new file mode 100644 index 00000000000..67732f518e5 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration5_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts === +function*foo(yield) { +>foo : Symbol(foo, Decl(FunctionDeclaration5_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/FunctionDeclaration5_es6.types b/tests/baselines/reference/FunctionDeclaration5_es6.types new file mode 100644 index 00000000000..9478988e7ea --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration5_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration5_es6.ts === +function*foo(yield) { +>foo : () => any +>yield : any +} diff --git a/tests/baselines/reference/FunctionDeclaration6.symbols b/tests/baselines/reference/FunctionDeclaration6.symbols new file mode 100644 index 00000000000..d8c66e83985 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration6.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/FunctionDeclaration6.ts === +{ + function foo(); +>foo : Symbol(foo, Decl(FunctionDeclaration6.ts, 0, 1)) + + function bar() { } +>bar : Symbol(bar, Decl(FunctionDeclaration6.ts, 1, 19)) +} diff --git a/tests/baselines/reference/FunctionDeclaration6.types b/tests/baselines/reference/FunctionDeclaration6.types new file mode 100644 index 00000000000..d3d135a6cfa --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration6.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/FunctionDeclaration6.ts === +{ + function foo(); +>foo : () => any + + function bar() { } +>bar : () => void +} diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.symbols b/tests/baselines/reference/FunctionDeclaration6_es6.symbols new file mode 100644 index 00000000000..36d4624da42 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration6_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts === +function*foo(a = yield) { +>foo : Symbol(foo, Decl(FunctionDeclaration6_es6.ts, 0, 0)) +>a : Symbol(a, Decl(FunctionDeclaration6_es6.ts, 0, 13)) +} diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.types b/tests/baselines/reference/FunctionDeclaration6_es6.types new file mode 100644 index 00000000000..4cfb710a781 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration6_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration6_es6.ts === +function*foo(a = yield) { +>foo : (a?: any) => IterableIterator +>a : any +>yield : any +} diff --git a/tests/baselines/reference/FunctionDeclaration7.symbols b/tests/baselines/reference/FunctionDeclaration7.symbols new file mode 100644 index 00000000000..65199406fea --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration7.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/FunctionDeclaration7.ts === +module M { +>M : Symbol(M, Decl(FunctionDeclaration7.ts, 0, 0)) + + function foo(); +>foo : Symbol(foo, Decl(FunctionDeclaration7.ts, 0, 10)) +} diff --git a/tests/baselines/reference/FunctionDeclaration7.types b/tests/baselines/reference/FunctionDeclaration7.types new file mode 100644 index 00000000000..3142431e4d7 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration7.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/FunctionDeclaration7.ts === +module M { +>M : typeof M + + function foo(); +>foo : () => any +} diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.symbols b/tests/baselines/reference/FunctionDeclaration7_es6.symbols new file mode 100644 index 00000000000..dc15ae760cd --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration7_es6.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts === +function*bar() { +>bar : Symbol(bar, Decl(FunctionDeclaration7_es6.ts, 0, 0)) + + // 'yield' here is an identifier, and not a yield expression. + function*foo(a = yield) { +>foo : Symbol(foo, Decl(FunctionDeclaration7_es6.ts, 0, 16)) +>a : Symbol(a, Decl(FunctionDeclaration7_es6.ts, 2, 15)) + } +} diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.types b/tests/baselines/reference/FunctionDeclaration7_es6.types new file mode 100644 index 00000000000..d9635231e4a --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration7_es6.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration7_es6.ts === +function*bar() { +>bar : () => IterableIterator + + // 'yield' here is an identifier, and not a yield expression. + function*foo(a = yield) { +>foo : (a?: any) => IterableIterator +>a : any +>yield : any + } +} diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.symbols b/tests/baselines/reference/FunctionDeclaration8_es6.symbols new file mode 100644 index 00000000000..037983e8a21 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration8_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts === +var v = { [yield]: foo } +>v : Symbol(v, Decl(FunctionDeclaration8_es6.ts, 0, 3)) + diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.types b/tests/baselines/reference/FunctionDeclaration8_es6.types new file mode 100644 index 00000000000..0d3056053d2 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration8_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts === +var v = { [yield]: foo } +>v : { [x: number]: any; } +>{ [yield]: foo } : { [x: number]: any; } +>yield : any +>foo : any + diff --git a/tests/baselines/reference/FunctionPropertyAssignments2_es6.symbols b/tests/baselines/reference/FunctionPropertyAssignments2_es6.symbols new file mode 100644 index 00000000000..ac135affbb6 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments2_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts === +var v = { *() { } } +>v : Symbol(v, Decl(FunctionPropertyAssignments2_es6.ts, 0, 3)) +> : Symbol((Missing), Decl(FunctionPropertyAssignments2_es6.ts, 0, 9)) + diff --git a/tests/baselines/reference/FunctionPropertyAssignments2_es6.types b/tests/baselines/reference/FunctionPropertyAssignments2_es6.types new file mode 100644 index 00000000000..6b9a2da9408 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments2_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments2_es6.ts === +var v = { *() { } } +>v : { (Missing)(): IterableIterator; } +>{ *() { } } : { (Missing)(): IterableIterator; } +> : () => IterableIterator + diff --git a/tests/baselines/reference/FunctionPropertyAssignments3_es6.symbols b/tests/baselines/reference/FunctionPropertyAssignments3_es6.symbols new file mode 100644 index 00000000000..e16ef01c957 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments3_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts === +var v = { *{ } } +>v : Symbol(v, Decl(FunctionPropertyAssignments3_es6.ts, 0, 3)) +> : Symbol((Missing), Decl(FunctionPropertyAssignments3_es6.ts, 0, 9)) + diff --git a/tests/baselines/reference/FunctionPropertyAssignments3_es6.types b/tests/baselines/reference/FunctionPropertyAssignments3_es6.types new file mode 100644 index 00000000000..9222f6e142d --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments3_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments3_es6.ts === +var v = { *{ } } +>v : { (Missing)(): IterableIterator; } +>{ *{ } } : { (Missing)(): IterableIterator; } +> : () => IterableIterator + diff --git a/tests/baselines/reference/FunctionPropertyAssignments4_es6.symbols b/tests/baselines/reference/FunctionPropertyAssignments4_es6.symbols new file mode 100644 index 00000000000..6b9754f9b50 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments4_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts === +var v = { * } +>v : Symbol(v, Decl(FunctionPropertyAssignments4_es6.ts, 0, 3)) +> : Symbol((Missing), Decl(FunctionPropertyAssignments4_es6.ts, 0, 9)) + diff --git a/tests/baselines/reference/FunctionPropertyAssignments4_es6.types b/tests/baselines/reference/FunctionPropertyAssignments4_es6.types new file mode 100644 index 00000000000..f244fd4fb33 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments4_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments4_es6.ts === +var v = { * } +>v : { (Missing)(): any; } +>{ * } : { (Missing)(): any; } +> : () => any + diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.symbols b/tests/baselines/reference/FunctionPropertyAssignments5_es6.symbols new file mode 100644 index 00000000000..f5746daa2ec --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts === +var v = { *[foo()]() { } } +>v : Symbol(v, Decl(FunctionPropertyAssignments5_es6.ts, 0, 3)) + diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.types b/tests/baselines/reference/FunctionPropertyAssignments5_es6.types new file mode 100644 index 00000000000..e2ff6419bf9 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts === +var v = { *[foo()]() { } } +>v : { [x: number]: () => IterableIterator; } +>{ *[foo()]() { } } : { [x: number]: () => IterableIterator; } +>foo() : any +>foo : any + diff --git a/tests/baselines/reference/FunctionPropertyAssignments6_es6.symbols b/tests/baselines/reference/FunctionPropertyAssignments6_es6.symbols new file mode 100644 index 00000000000..b7e08ae0ed4 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments6_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts === +var v = { *() { } } +>v : Symbol(v, Decl(FunctionPropertyAssignments6_es6.ts, 0, 3)) +> : Symbol((Missing), Decl(FunctionPropertyAssignments6_es6.ts, 0, 9)) +>T : Symbol(T, Decl(FunctionPropertyAssignments6_es6.ts, 0, 12)) + diff --git a/tests/baselines/reference/FunctionPropertyAssignments6_es6.types b/tests/baselines/reference/FunctionPropertyAssignments6_es6.types new file mode 100644 index 00000000000..050d97df735 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments6_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments6_es6.ts === +var v = { *() { } } +>v : { (Missing)(): IterableIterator; } +>{ *() { } } : { (Missing)(): IterableIterator; } +> : () => IterableIterator +>T : T + diff --git a/tests/baselines/reference/InterfaceDeclaration8.symbols b/tests/baselines/reference/InterfaceDeclaration8.symbols new file mode 100644 index 00000000000..cf57f53c899 --- /dev/null +++ b/tests/baselines/reference/InterfaceDeclaration8.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/InterfaceDeclaration8.ts === +interface string { +>string : Symbol(string, Decl(InterfaceDeclaration8.ts, 0, 0)) +} diff --git a/tests/baselines/reference/InterfaceDeclaration8.types b/tests/baselines/reference/InterfaceDeclaration8.types new file mode 100644 index 00000000000..d65b6376457 --- /dev/null +++ b/tests/baselines/reference/InterfaceDeclaration8.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/InterfaceDeclaration8.ts === +interface string { +>string : string +} diff --git a/tests/baselines/reference/InvalidNonInstantiatedModule.symbols b/tests/baselines/reference/InvalidNonInstantiatedModule.symbols new file mode 100644 index 00000000000..1fd5f0839a2 --- /dev/null +++ b/tests/baselines/reference/InvalidNonInstantiatedModule.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts === +module M { +>M : Symbol(M, Decl(InvalidNonInstantiatedModule.ts, 0, 0)) + + export interface Point { x: number; y: number } +>Point : Symbol(Point, Decl(InvalidNonInstantiatedModule.ts, 0, 10)) +>x : Symbol(Point.x, Decl(InvalidNonInstantiatedModule.ts, 1, 28)) +>y : Symbol(Point.y, Decl(InvalidNonInstantiatedModule.ts, 1, 39)) +} + +var m = M; // Error, not instantiated can not be used as var +>m : Symbol(m, Decl(InvalidNonInstantiatedModule.ts, 4, 3)) + +var x: typeof M; // Error only a namespace +>x : Symbol(x, Decl(InvalidNonInstantiatedModule.ts, 6, 3)) + diff --git a/tests/baselines/reference/InvalidNonInstantiatedModule.types b/tests/baselines/reference/InvalidNonInstantiatedModule.types new file mode 100644 index 00000000000..28141c16ec8 --- /dev/null +++ b/tests/baselines/reference/InvalidNonInstantiatedModule.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/internalModules/moduleDeclarations/InvalidNonInstantiatedModule.ts === +module M { +>M : any + + export interface Point { x: number; y: number } +>Point : Point +>x : number +>y : number +} + +var m = M; // Error, not instantiated can not be used as var +>m : any +>M : any + +var x: typeof M; // Error only a namespace +>x : any +>M : any + diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.less-than and greater-than characters.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.less-than and greater-than characters.json new file mode 100644 index 00000000000..93d7cf14737 --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.less-than and greater-than characters.json @@ -0,0 +1,35 @@ +{ + "kind": "JSDocComment", + "pos": 0, + "end": 61, + "tags": { + "0": { + "kind": "JSDocParameterTag", + "pos": 7, + "end": 16, + "atToken": { + "kind": "AtToken", + "pos": 7, + "end": 8 + }, + "tagName": { + "kind": "Identifier", + "pos": 8, + "end": 13, + "escapedText": "param" + }, + "name": { + "kind": "Identifier", + "pos": 14, + "end": 15, + "escapedText": "x" + }, + "isNameFirst": true, + "isBracketed": false, + "comment": "hi\n< > still part of the previous comment" + }, + "length": 1, + "pos": 7, + "end": 16 + } +} \ No newline at end of file diff --git a/tests/baselines/reference/MemberAccessorDeclaration15.symbols b/tests/baselines/reference/MemberAccessorDeclaration15.symbols new file mode 100644 index 00000000000..e7159a4f522 --- /dev/null +++ b/tests/baselines/reference/MemberAccessorDeclaration15.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/MemberAccessorDeclaration15.ts === +class C { +>C : Symbol(C, Decl(MemberAccessorDeclaration15.ts, 0, 0)) + + set Foo(public a: number) { } +>Foo : Symbol(C.Foo, Decl(MemberAccessorDeclaration15.ts, 0, 9)) +>a : Symbol(a, Decl(MemberAccessorDeclaration15.ts, 1, 11)) +} diff --git a/tests/baselines/reference/MemberAccessorDeclaration15.types b/tests/baselines/reference/MemberAccessorDeclaration15.types new file mode 100644 index 00000000000..78245827824 --- /dev/null +++ b/tests/baselines/reference/MemberAccessorDeclaration15.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/MemberAccessorDeclaration15.ts === +class C { +>C : C + + set Foo(public a: number) { } +>Foo : number +>a : number +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.symbols b/tests/baselines/reference/MemberFunctionDeclaration3_es6.symbols new file mode 100644 index 00000000000..e2b8b39b363 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts === +class C { +>C : Symbol(C, Decl(MemberFunctionDeclaration3_es6.ts, 0, 0)) + + *[foo]() { } +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.types b/tests/baselines/reference/MemberFunctionDeclaration3_es6.types new file mode 100644 index 00000000000..fca123d15e6 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration3_es6.ts === +class C { +>C : C + + *[foo]() { } +>foo : any +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration4_es6.symbols b/tests/baselines/reference/MemberFunctionDeclaration4_es6.symbols new file mode 100644 index 00000000000..151fd390621 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration4_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts === +class C { +>C : Symbol(C, Decl(MemberFunctionDeclaration4_es6.ts, 0, 0)) + + *() { } +> : Symbol(C[(Missing)], Decl(MemberFunctionDeclaration4_es6.ts, 0, 9)) +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration4_es6.types b/tests/baselines/reference/MemberFunctionDeclaration4_es6.types new file mode 100644 index 00000000000..7717c30a449 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration4_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration4_es6.ts === +class C { +>C : C + + *() { } +> : () => IterableIterator +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration5_es6.symbols b/tests/baselines/reference/MemberFunctionDeclaration5_es6.symbols new file mode 100644 index 00000000000..60879aadfe6 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration5_es6.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts === +class C { +>C : Symbol(C, Decl(MemberFunctionDeclaration5_es6.ts, 0, 0)) + + * +} +> : Symbol(C[(Missing)], Decl(MemberFunctionDeclaration5_es6.ts, 0, 9)) + diff --git a/tests/baselines/reference/MemberFunctionDeclaration5_es6.types b/tests/baselines/reference/MemberFunctionDeclaration5_es6.types new file mode 100644 index 00000000000..12241a660c4 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration5_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration5_es6.ts === +class C { +>C : C + + * +} +> : () => any + diff --git a/tests/baselines/reference/MemberFunctionDeclaration6_es6.symbols b/tests/baselines/reference/MemberFunctionDeclaration6_es6.symbols new file mode 100644 index 00000000000..bbf4da338e7 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration6_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts === +class C { +>C : Symbol(C, Decl(MemberFunctionDeclaration6_es6.ts, 0, 0)) + + *foo +>foo : Symbol(C.foo, Decl(MemberFunctionDeclaration6_es6.ts, 0, 9)) +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration6_es6.types b/tests/baselines/reference/MemberFunctionDeclaration6_es6.types new file mode 100644 index 00000000000..a74bd86b615 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration6_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration6_es6.ts === +class C { +>C : C + + *foo +>foo : () => any +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration8_es6.symbols b/tests/baselines/reference/MemberFunctionDeclaration8_es6.symbols new file mode 100644 index 00000000000..0229450477c --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration8_es6.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts === +class C { +>C : Symbol(C, Decl(MemberFunctionDeclaration8_es6.ts, 0, 0)) + + foo() { +>foo : Symbol(C.foo, Decl(MemberFunctionDeclaration8_es6.ts, 0, 9)) + + // Make sure we don't think of *bar as the start of a generator method. + if (a) # * bar; + return bar; + } +} diff --git a/tests/baselines/reference/MemberFunctionDeclaration8_es6.types b/tests/baselines/reference/MemberFunctionDeclaration8_es6.types new file mode 100644 index 00000000000..b0234b4135e --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration8_es6.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/memberFunctionDeclarations/MemberFunctionDeclaration8_es6.ts === +class C { +>C : C + + foo() { +>foo : () => any + + // Make sure we don't think of *bar as the start of a generator method. + if (a) # * bar; +>a : any +> : any +>* bar : number +> : any +>bar : any + + return bar; +>bar : any + } +} diff --git a/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.symbols b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.symbols new file mode 100644 index 00000000000..9d90d6dd3cc --- /dev/null +++ b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.symbols @@ -0,0 +1,64 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module X.Y { +>X : Symbol(X, Decl(module.ts, 0, 0), Decl(classPoint.ts, 0, 0)) +>Y : Symbol(Y, Decl(module.ts, 0, 9), Decl(classPoint.ts, 0, 9)) + + export module Point { +>Point : Symbol(Point, Decl(module.ts, 0, 12), Decl(classPoint.ts, 0, 12)) + + export var Origin = new Point(0, 0); +>Origin : Symbol(Origin, Decl(module.ts, 2, 18)) +>Point : Symbol(Point, Decl(module.ts, 0, 12), Decl(classPoint.ts, 0, 12)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/classPoint.ts === +module X.Y { +>X : Symbol(X, Decl(module.ts, 0, 0), Decl(classPoint.ts, 0, 0)) +>Y : Symbol(Y, Decl(module.ts, 0, 9), Decl(classPoint.ts, 0, 9)) + + // duplicate identifier + export class Point { +>Point : Symbol(Point, Decl(module.ts, 0, 12), Decl(classPoint.ts, 0, 12)) + + constructor(x: number, y: number) { +>x : Symbol(x, Decl(classPoint.ts, 3, 20)) +>y : Symbol(y, Decl(classPoint.ts, 3, 30)) + + this.x = x; +>this.x : Symbol(Point.x, Decl(classPoint.ts, 6, 9)) +>this : Symbol(Point, Decl(module.ts, 0, 12), Decl(classPoint.ts, 0, 12)) +>x : Symbol(Point.x, Decl(classPoint.ts, 6, 9)) +>x : Symbol(x, Decl(classPoint.ts, 3, 20)) + + this.y = y; +>this.y : Symbol(Point.y, Decl(classPoint.ts, 7, 18)) +>this : Symbol(Point, Decl(module.ts, 0, 12), Decl(classPoint.ts, 0, 12)) +>y : Symbol(Point.y, Decl(classPoint.ts, 7, 18)) +>y : Symbol(y, Decl(classPoint.ts, 3, 30)) + } + x: number; +>x : Symbol(Point.x, Decl(classPoint.ts, 6, 9)) + + y: number; +>y : Symbol(Point.y, Decl(classPoint.ts, 7, 18)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +module A { +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) + + export var Instance = new A(); +>Instance : Symbol(Instance, Decl(simple.ts, 1, 14)) +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) +} + +// duplicate identifier +class A { +>A : Symbol(A, Decl(simple.ts, 0, 0), Decl(simple.ts, 2, 1)) + + id: string; +>id : Symbol(A.id, Decl(simple.ts, 5, 9)) +} + diff --git a/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.types b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.types new file mode 100644 index 00000000000..0041418426a --- /dev/null +++ b/tests/baselines/reference/ModuleAndClassWithSameNameAndCommonRoot.types @@ -0,0 +1,70 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module X.Y { +>X : typeof X +>Y : typeof Y + + export module Point { +>Point : typeof Point + + export var Origin = new Point(0, 0); +>Origin : Point +>new Point(0, 0) : Point +>Point : typeof Point +>0 : 0 +>0 : 0 + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/classPoint.ts === +module X.Y { +>X : typeof X +>Y : typeof Y + + // duplicate identifier + export class Point { +>Point : Point + + constructor(x: number, y: number) { +>x : number +>y : number + + this.x = x; +>this.x = x : number +>this.x : number +>this : this +>x : number +>x : number + + this.y = y; +>this.y = y : number +>this.y : number +>this : this +>y : number +>y : number + } + x: number; +>x : number + + y: number; +>y : number + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +module A { +>A : typeof A + + export var Instance = new A(); +>Instance : A +>new A() : A +>A : typeof A +} + +// duplicate identifier +class A { +>A : A + + id: string; +>id : string +} + diff --git a/tests/baselines/reference/ModuleAndFunctionWithSameNameAndCommonRoot.symbols b/tests/baselines/reference/ModuleAndFunctionWithSameNameAndCommonRoot.symbols new file mode 100644 index 00000000000..84d2f4be3dc --- /dev/null +++ b/tests/baselines/reference/ModuleAndFunctionWithSameNameAndCommonRoot.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module A { +>A : Symbol(A, Decl(module.ts, 0, 0), Decl(function.ts, 0, 0)) + + export module Point { +>Point : Symbol(Point, Decl(module.ts, 0, 10), Decl(function.ts, 0, 10)) + + export var Origin = { x: 0, y: 0 }; +>Origin : Symbol(Origin, Decl(module.ts, 2, 18)) +>x : Symbol(x, Decl(module.ts, 2, 29)) +>y : Symbol(y, Decl(module.ts, 2, 35)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/function.ts === +module A { +>A : Symbol(A, Decl(module.ts, 0, 0), Decl(function.ts, 0, 0)) + + // duplicate identifier error + export function Point() { +>Point : Symbol(Point, Decl(module.ts, 0, 10), Decl(function.ts, 0, 10)) + + return { x: 0, y: 0 }; +>x : Symbol(x, Decl(function.ts, 3, 16)) +>y : Symbol(y, Decl(function.ts, 3, 22)) + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +module B { +>B : Symbol(B, Decl(simple.ts, 0, 0)) + + export module Point { +>Point : Symbol(Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) + + export var Origin = { x: 0, y: 0 }; +>Origin : Symbol(Origin, Decl(simple.ts, 3, 18)) +>x : Symbol(x, Decl(simple.ts, 3, 29)) +>y : Symbol(y, Decl(simple.ts, 3, 35)) + } + + // duplicate identifier error + export function Point() { +>Point : Symbol(Point, Decl(simple.ts, 0, 10), Decl(simple.ts, 4, 5)) + + return { x: 0, y: 0 }; +>x : Symbol(x, Decl(simple.ts, 8, 16)) +>y : Symbol(y, Decl(simple.ts, 8, 22)) + } +} + diff --git a/tests/baselines/reference/ModuleAndFunctionWithSameNameAndCommonRoot.types b/tests/baselines/reference/ModuleAndFunctionWithSameNameAndCommonRoot.types new file mode 100644 index 00000000000..ffa10552a03 --- /dev/null +++ b/tests/baselines/reference/ModuleAndFunctionWithSameNameAndCommonRoot.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/module.ts === +module A { +>A : typeof A + + export module Point { +>Point : typeof Point + + export var Origin = { x: 0, y: 0 }; +>Origin : { x: number; y: number; } +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/function.ts === +module A { +>A : typeof A + + // duplicate identifier error + export function Point() { +>Point : typeof Point + + return { x: 0, y: 0 }; +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/simple.ts === +module B { +>B : typeof B + + export module Point { +>Point : typeof Point + + export var Origin = { x: 0, y: 0 }; +>Origin : { x: number; y: number; } +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } + + // duplicate identifier error + export function Point() { +>Point : typeof Point + + return { x: 0, y: 0 }; +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + } +} + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.symbols b/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.symbols new file mode 100644 index 00000000000..54bf3dd70e4 --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.symbols @@ -0,0 +1,81 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedClasses.ts === +module A { +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedClasses.ts, 0, 0)) + + export class A { +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedClasses.ts, 0, 10)) + + id: number; +>id : Symbol(A.id, Decl(ModuleWithExportedAndNonExportedClasses.ts, 1, 20)) + + name: string; +>name : Symbol(A.name, Decl(ModuleWithExportedAndNonExportedClasses.ts, 2, 19)) + } + + export class AG{ +>AG : Symbol(AG, Decl(ModuleWithExportedAndNonExportedClasses.ts, 4, 5)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedClasses.ts, 6, 20)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedClasses.ts, 6, 22)) + + id: T; +>id : Symbol(AG.id, Decl(ModuleWithExportedAndNonExportedClasses.ts, 6, 26)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedClasses.ts, 6, 20)) + + name: U; +>name : Symbol(AG.name, Decl(ModuleWithExportedAndNonExportedClasses.ts, 7, 14)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedClasses.ts, 6, 22)) + } + + class A2 { +>A2 : Symbol(A2, Decl(ModuleWithExportedAndNonExportedClasses.ts, 9, 5)) + + id: number; +>id : Symbol(A2.id, Decl(ModuleWithExportedAndNonExportedClasses.ts, 11, 14)) + + name: string; +>name : Symbol(A2.name, Decl(ModuleWithExportedAndNonExportedClasses.ts, 12, 19)) + } + + class AG2{ +>AG2 : Symbol(AG2, Decl(ModuleWithExportedAndNonExportedClasses.ts, 14, 5)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedClasses.ts, 16, 14)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedClasses.ts, 16, 16)) + + id: T; +>id : Symbol(AG2.id, Decl(ModuleWithExportedAndNonExportedClasses.ts, 16, 20)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedClasses.ts, 16, 14)) + + name: U; +>name : Symbol(AG2.name, Decl(ModuleWithExportedAndNonExportedClasses.ts, 17, 14)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedClasses.ts, 16, 16)) + } +} + +// no errors expected, these are all exported +var a: { id: number; name: string }; +>a : Symbol(a, Decl(ModuleWithExportedAndNonExportedClasses.ts, 23, 3), Decl(ModuleWithExportedAndNonExportedClasses.ts, 24, 3)) +>id : Symbol(id, Decl(ModuleWithExportedAndNonExportedClasses.ts, 23, 8)) +>name : Symbol(name, Decl(ModuleWithExportedAndNonExportedClasses.ts, 23, 20)) + +var a = new A.A(); +>a : Symbol(a, Decl(ModuleWithExportedAndNonExportedClasses.ts, 23, 3), Decl(ModuleWithExportedAndNonExportedClasses.ts, 24, 3)) +>A.A : Symbol(A.A, Decl(ModuleWithExportedAndNonExportedClasses.ts, 0, 10)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedClasses.ts, 0, 0)) +>A : Symbol(A.A, Decl(ModuleWithExportedAndNonExportedClasses.ts, 0, 10)) + +var AG = new A.AG() +>AG : Symbol(AG, Decl(ModuleWithExportedAndNonExportedClasses.ts, 26, 3)) +>A.AG : Symbol(A.AG, Decl(ModuleWithExportedAndNonExportedClasses.ts, 4, 5)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedClasses.ts, 0, 0)) +>AG : Symbol(A.AG, Decl(ModuleWithExportedAndNonExportedClasses.ts, 4, 5)) + +// errors expected, these are not exported +var a2 = new A.A2(); +>a2 : Symbol(a2, Decl(ModuleWithExportedAndNonExportedClasses.ts, 29, 3)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedClasses.ts, 0, 0)) + +var ag2 = new A.A2(); +>ag2 : Symbol(ag2, Decl(ModuleWithExportedAndNonExportedClasses.ts, 30, 3)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedClasses.ts, 0, 0)) + + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.types b/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.types new file mode 100644 index 00000000000..233d03cca02 --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedClasses.types @@ -0,0 +1,89 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedClasses.ts === +module A { +>A : typeof A + + export class A { +>A : A + + id: number; +>id : number + + name: string; +>name : string + } + + export class AG{ +>AG : AG +>T : T +>U : U + + id: T; +>id : T +>T : T + + name: U; +>name : U +>U : U + } + + class A2 { +>A2 : A2 + + id: number; +>id : number + + name: string; +>name : string + } + + class AG2{ +>AG2 : AG2 +>T : T +>U : U + + id: T; +>id : T +>T : T + + name: U; +>name : U +>U : U + } +} + +// no errors expected, these are all exported +var a: { id: number; name: string }; +>a : { id: number; name: string; } +>id : number +>name : string + +var a = new A.A(); +>a : { id: number; name: string; } +>new A.A() : A.A +>A.A : typeof A.A +>A : typeof A +>A : typeof A.A + +var AG = new A.AG() +>AG : A.AG +>new A.AG() : A.AG +>A.AG : typeof A.AG +>A : typeof A +>AG : typeof A.AG + +// errors expected, these are not exported +var a2 = new A.A2(); +>a2 : any +>new A.A2() : any +>A.A2 : any +>A : typeof A +>A2 : any + +var ag2 = new A.A2(); +>ag2 : any +>new A.A2() : any +>A.A2 : any +>A : typeof A +>A2 : any + + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.symbols b/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.symbols new file mode 100644 index 00000000000..38b93290f75 --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedEnums.ts === +module A { +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedEnums.ts, 0, 0)) + + export enum Color { Red, Blue } +>Color : Symbol(Color, Decl(ModuleWithExportedAndNonExportedEnums.ts, 0, 10)) +>Red : Symbol(Color.Red, Decl(ModuleWithExportedAndNonExportedEnums.ts, 1, 23)) +>Blue : Symbol(Color.Blue, Decl(ModuleWithExportedAndNonExportedEnums.ts, 1, 28)) + + enum Day { Monday, Tuesday } +>Day : Symbol(Day, Decl(ModuleWithExportedAndNonExportedEnums.ts, 1, 35)) +>Monday : Symbol(Day.Monday, Decl(ModuleWithExportedAndNonExportedEnums.ts, 2, 14)) +>Tuesday : Symbol(Day.Tuesday, Decl(ModuleWithExportedAndNonExportedEnums.ts, 2, 22)) +} + +// not an error since exported +var a: A.Color = A.Color.Red; +>a : Symbol(a, Decl(ModuleWithExportedAndNonExportedEnums.ts, 6, 3)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedEnums.ts, 0, 0)) +>Color : Symbol(A.Color, Decl(ModuleWithExportedAndNonExportedEnums.ts, 0, 10)) +>A.Color.Red : Symbol(A.Color.Red, Decl(ModuleWithExportedAndNonExportedEnums.ts, 1, 23)) +>A.Color : Symbol(A.Color, Decl(ModuleWithExportedAndNonExportedEnums.ts, 0, 10)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedEnums.ts, 0, 0)) +>Color : Symbol(A.Color, Decl(ModuleWithExportedAndNonExportedEnums.ts, 0, 10)) +>Red : Symbol(A.Color.Red, Decl(ModuleWithExportedAndNonExportedEnums.ts, 1, 23)) + +// error not exported +var b = A.Day.Monday; +>b : Symbol(b, Decl(ModuleWithExportedAndNonExportedEnums.ts, 9, 3)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedEnums.ts, 0, 0)) + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.types b/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.types new file mode 100644 index 00000000000..54222846995 --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedEnums.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedEnums.ts === +module A { +>A : typeof A + + export enum Color { Red, Blue } +>Color : Color +>Red : Color.Red +>Blue : Color.Blue + + enum Day { Monday, Tuesday } +>Day : Day +>Monday : Day.Monday +>Tuesday : Day.Tuesday +} + +// not an error since exported +var a: A.Color = A.Color.Red; +>a : A.Color +>A : any +>Color : A.Color +>A.Color.Red : A.Color.Red +>A.Color : typeof A.Color +>A : typeof A +>Color : typeof A.Color +>Red : A.Color.Red + +// error not exported +var b = A.Day.Monday; +>b : any +>A.Day.Monday : any +>A.Day : any +>A : typeof A +>Day : any +>Monday : any + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.symbols b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.symbols new file mode 100644 index 00000000000..83104e9af73 --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.symbols @@ -0,0 +1,75 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts === +module A { +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 0, 0)) + + export function fn(s: string) { +>fn : Symbol(fn, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 0, 10)) +>s : Symbol(s, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 2, 23)) + + return true; + } + + export function fng(s: T): U { +>fng : Symbol(fng, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 4, 5)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 6, 24)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 6, 26)) +>s : Symbol(s, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 6, 30)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 6, 24)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 6, 26)) + + return null; + } + + function fn2(s: string) { +>fn2 : Symbol(fn2, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 8, 5)) +>s : Symbol(s, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 10, 17)) + + return false; + } + + function fng2(s: T): U { +>fng2 : Symbol(fng2, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 12, 5)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 14, 18)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 14, 20)) +>s : Symbol(s, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 14, 24)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 14, 18)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 14, 20)) + + return null; + } +} + +// these should not be errors since the functions are exported +var fn: (s: string) => boolean; +>fn : Symbol(fn, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 20, 3), Decl(ModuleWithExportedAndNonExportedFunctions.ts, 21, 3)) +>s : Symbol(s, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 20, 9)) + +var fn = A.fn; +>fn : Symbol(fn, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 20, 3), Decl(ModuleWithExportedAndNonExportedFunctions.ts, 21, 3)) +>A.fn : Symbol(A.fn, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 0, 10)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 0, 0)) +>fn : Symbol(A.fn, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 0, 10)) + +var fng: (s: T) => U; +>fng : Symbol(fng, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 23, 3), Decl(ModuleWithExportedAndNonExportedFunctions.ts, 24, 3)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 23, 10)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 23, 12)) +>s : Symbol(s, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 23, 16)) +>T : Symbol(T, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 23, 10)) +>U : Symbol(U, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 23, 12)) + +var fng = A.fng; // bug 838015 +>fng : Symbol(fng, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 23, 3), Decl(ModuleWithExportedAndNonExportedFunctions.ts, 24, 3)) +>A.fng : Symbol(A.fng, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 4, 5)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 0, 0)) +>fng : Symbol(A.fng, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 4, 5)) + +// these should be errors since the functions are not exported +var fn2 = A.fn2; +>fn2 : Symbol(fn2, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 27, 3)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 0, 0)) + +var fng2 = A.fng2; +>fng2 : Symbol(fng2, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 28, 3)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedFunctions.ts, 0, 0)) + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.types b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.types new file mode 100644 index 00000000000..123ee413d76 --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.types @@ -0,0 +1,83 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts === +module A { +>A : typeof A + + export function fn(s: string) { +>fn : (s: string) => boolean +>s : string + + return true; +>true : true + } + + export function fng(s: T): U { +>fng : (s: T) => U +>T : T +>U : U +>s : T +>T : T +>U : U + + return null; +>null : null + } + + function fn2(s: string) { +>fn2 : (s: string) => boolean +>s : string + + return false; +>false : false + } + + function fng2(s: T): U { +>fng2 : (s: T) => U +>T : T +>U : U +>s : T +>T : T +>U : U + + return null; +>null : null + } +} + +// these should not be errors since the functions are exported +var fn: (s: string) => boolean; +>fn : (s: string) => boolean +>s : string + +var fn = A.fn; +>fn : (s: string) => boolean +>A.fn : (s: string) => boolean +>A : typeof A +>fn : (s: string) => boolean + +var fng: (s: T) => U; +>fng : (s: T) => U +>T : T +>U : U +>s : T +>T : T +>U : U + +var fng = A.fng; // bug 838015 +>fng : (s: T) => U +>A.fng : (s: T) => U +>A : typeof A +>fng : (s: T) => U + +// these should be errors since the functions are not exported +var fn2 = A.fn2; +>fn2 : any +>A.fn2 : any +>A : typeof A +>fn2 : any + +var fng2 = A.fng2; +>fng2 : any +>A.fng2 : any +>A : typeof A +>fng2 : any + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.symbols b/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.symbols new file mode 100644 index 00000000000..bf2bbb39607 --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.symbols @@ -0,0 +1,109 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedImportAlias.ts === +module A { +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 0)) + + export interface Point { +>Point : Symbol(Point, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 10)) + + x: number; +>x : Symbol(Point.x, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 1, 28)) + + y: number; +>y : Symbol(Point.y, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 2, 18)) + } + + interface Point3d extends Point { +>Point3d : Symbol(Point3d, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 4, 5)) +>Point : Symbol(Point, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 10)) + + z: number; +>z : Symbol(Point3d.z, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 6, 37)) + } +} + +module B { +>B : Symbol(B, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 9, 1)) + + export class Line { +>Line : Symbol(Line, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 11, 10)) + + constructor(public start: A.Point, public end: A.Point) { } +>start : Symbol(Line.start, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 13, 20)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 0)) +>Point : Symbol(A.Point, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 10)) +>end : Symbol(Line.end, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 13, 42)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 0)) +>Point : Symbol(A.Point, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 10)) + } +} + +module Geometry { +>Geometry : Symbol(Geometry, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 15, 1)) + + export import Points = A; +>Points : Symbol(Points, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 17, 17)) +>A : Symbol(Points, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 0)) + + import Lines = B; +>Lines : Symbol(Lines, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 18, 29)) +>B : Symbol(Lines, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 9, 1)) + + export var Origin: Points.Point = { x: 0, y: 0 }; +>Origin : Symbol(Origin, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 21, 14)) +>Points : Symbol(Points, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 17, 17)) +>Point : Symbol(Points.Point, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 10)) +>x : Symbol(x, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 21, 39)) +>y : Symbol(y, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 21, 45)) + + // this is valid since B.Line _is_ visible outside Geometry + export var Unit: Lines.Line = new Lines.Line(Origin, { x: 1, y: 0 }); +>Unit : Symbol(Unit, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 24, 14)) +>Lines : Symbol(Lines, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 18, 29)) +>Line : Symbol(Lines.Line, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 11, 10)) +>Lines.Line : Symbol(Lines.Line, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 11, 10)) +>Lines : Symbol(Lines, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 18, 29)) +>Line : Symbol(Lines.Line, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 11, 10)) +>Origin : Symbol(Origin, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 21, 14)) +>x : Symbol(x, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 24, 58)) +>y : Symbol(y, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 24, 64)) +} + +// expected to work since all are exported +var p: { x: number; y: number }; +>p : Symbol(p, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 28, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 29, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 30, 3)) +>x : Symbol(x, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 28, 8)) +>y : Symbol(y, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 28, 19)) + +var p: Geometry.Points.Point; +>p : Symbol(p, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 28, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 29, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 30, 3)) +>Geometry : Symbol(Geometry, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 15, 1)) +>Points : Symbol(Geometry.Points, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 17, 17)) +>Point : Symbol(A.Point, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 0, 10)) + +var p = Geometry.Origin; +>p : Symbol(p, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 28, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 29, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 30, 3)) +>Geometry.Origin : Symbol(Geometry.Origin, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 21, 14)) +>Geometry : Symbol(Geometry, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 15, 1)) +>Origin : Symbol(Geometry.Origin, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 21, 14)) + +var line: { start: { x: number; y: number }; end: { x: number; y: number; } }; +>line : Symbol(line, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 33, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 36, 3)) +>start : Symbol(start, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 11)) +>x : Symbol(x, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 20)) +>y : Symbol(y, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 31)) +>end : Symbol(end, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 44)) +>x : Symbol(x, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 51)) +>y : Symbol(y, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 62)) + +var line = Geometry.Unit; +>line : Symbol(line, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 33, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 36, 3)) +>Geometry.Unit : Symbol(Geometry.Unit, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 24, 14)) +>Geometry : Symbol(Geometry, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 15, 1)) +>Unit : Symbol(Geometry.Unit, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 24, 14)) + +// not expected to work since non are exported +var line = Geometry.Lines.Line; +>line : Symbol(line, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 32, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 33, 3), Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 36, 3)) +>Geometry : Symbol(Geometry, Decl(ModuleWithExportedAndNonExportedImportAlias.ts, 15, 1)) + + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.types b/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.types new file mode 100644 index 00000000000..74e8d7f271f --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedImportAlias.types @@ -0,0 +1,120 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedImportAlias.ts === +module A { +>A : any + + export interface Point { +>Point : Point + + x: number; +>x : number + + y: number; +>y : number + } + + interface Point3d extends Point { +>Point3d : Point3d +>Point : Point + + z: number; +>z : number + } +} + +module B { +>B : typeof B + + export class Line { +>Line : Line + + constructor(public start: A.Point, public end: A.Point) { } +>start : A.Point +>A : any +>Point : A.Point +>end : A.Point +>A : any +>Point : A.Point + } +} + +module Geometry { +>Geometry : typeof Geometry + + export import Points = A; +>Points : any +>A : any + + import Lines = B; +>Lines : typeof Lines +>B : typeof Lines + + export var Origin: Points.Point = { x: 0, y: 0 }; +>Origin : Points.Point +>Points : any +>Point : Points.Point +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + + // this is valid since B.Line _is_ visible outside Geometry + export var Unit: Lines.Line = new Lines.Line(Origin, { x: 1, y: 0 }); +>Unit : Lines.Line +>Lines : any +>Line : Lines.Line +>new Lines.Line(Origin, { x: 1, y: 0 }) : Lines.Line +>Lines.Line : typeof Lines.Line +>Lines : typeof Lines +>Line : typeof Lines.Line +>Origin : Points.Point +>{ x: 1, y: 0 } : { x: number; y: number; } +>x : number +>1 : 1 +>y : number +>0 : 0 +} + +// expected to work since all are exported +var p: { x: number; y: number }; +>p : { x: number; y: number; } +>x : number +>y : number + +var p: Geometry.Points.Point; +>p : { x: number; y: number; } +>Geometry : any +>Points : any +>Point : A.Point + +var p = Geometry.Origin; +>p : { x: number; y: number; } +>Geometry.Origin : A.Point +>Geometry : typeof Geometry +>Origin : A.Point + +var line: { start: { x: number; y: number }; end: { x: number; y: number; } }; +>line : { start: { x: number; y: number; }; end: { x: number; y: number; }; } +>start : { x: number; y: number; } +>x : number +>y : number +>end : { x: number; y: number; } +>x : number +>y : number + +var line = Geometry.Unit; +>line : { start: { x: number; y: number; }; end: { x: number; y: number; }; } +>Geometry.Unit : B.Line +>Geometry : typeof Geometry +>Unit : B.Line + +// not expected to work since non are exported +var line = Geometry.Lines.Line; +>line : { start: { x: number; y: number; }; end: { x: number; y: number; }; } +>Geometry.Lines.Line : any +>Geometry.Lines : any +>Geometry : typeof Geometry +>Lines : any +>Line : any + + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.symbols b/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.symbols new file mode 100644 index 00000000000..85e84b75476 --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedVariables.ts === +module A { +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedVariables.ts, 0, 0)) + + export var x = 'hello world' +>x : Symbol(x, Decl(ModuleWithExportedAndNonExportedVariables.ts, 1, 14)) + + var y = 12; +>y : Symbol(y, Decl(ModuleWithExportedAndNonExportedVariables.ts, 2, 7)) +} + + +var x: string; +>x : Symbol(x, Decl(ModuleWithExportedAndNonExportedVariables.ts, 6, 3), Decl(ModuleWithExportedAndNonExportedVariables.ts, 7, 3)) + +var x = A.x; +>x : Symbol(x, Decl(ModuleWithExportedAndNonExportedVariables.ts, 6, 3), Decl(ModuleWithExportedAndNonExportedVariables.ts, 7, 3)) +>A.x : Symbol(A.x, Decl(ModuleWithExportedAndNonExportedVariables.ts, 1, 14)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedVariables.ts, 0, 0)) +>x : Symbol(A.x, Decl(ModuleWithExportedAndNonExportedVariables.ts, 1, 14)) + +// Error, since y is not exported +var y = A.y; +>y : Symbol(y, Decl(ModuleWithExportedAndNonExportedVariables.ts, 10, 3)) +>A : Symbol(A, Decl(ModuleWithExportedAndNonExportedVariables.ts, 0, 0)) + diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.types b/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.types new file mode 100644 index 00000000000..67c754765cc --- /dev/null +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedVariables.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedVariables.ts === +module A { +>A : typeof A + + export var x = 'hello world' +>x : string +>'hello world' : "hello world" + + var y = 12; +>y : number +>12 : 12 +} + + +var x: string; +>x : string + +var x = A.x; +>x : string +>A.x : string +>A : typeof A +>x : string + +// Error, since y is not exported +var y = A.y; +>y : any +>A.y : any +>A : typeof A +>y : any + diff --git a/tests/baselines/reference/NonInitializedExportInInternalModule.symbols b/tests/baselines/reference/NonInitializedExportInInternalModule.symbols new file mode 100644 index 00000000000..afa9504856e --- /dev/null +++ b/tests/baselines/reference/NonInitializedExportInInternalModule.symbols @@ -0,0 +1,93 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/NonInitializedExportInInternalModule.ts === +module Inner { +>Inner : Symbol(Inner, Decl(NonInitializedExportInInternalModule.ts, 0, 0)) + + var; + let; + const; + + export var a; +>a : Symbol(a, Decl(NonInitializedExportInInternalModule.ts, 5, 14)) + + export let b; +>b : Symbol(b, Decl(NonInitializedExportInInternalModule.ts, 6, 14)) + + export var c: string; +>c : Symbol(c, Decl(NonInitializedExportInInternalModule.ts, 7, 14)) + + export let d: number; +>d : Symbol(d, Decl(NonInitializedExportInInternalModule.ts, 8, 14)) + + class A {} +>A : Symbol(A, Decl(NonInitializedExportInInternalModule.ts, 8, 25)) + + export var e: A; +>e : Symbol(e, Decl(NonInitializedExportInInternalModule.ts, 10, 14)) +>A : Symbol(A, Decl(NonInitializedExportInInternalModule.ts, 8, 25)) + + export let f: A; +>f : Symbol(f, Decl(NonInitializedExportInInternalModule.ts, 11, 14)) +>A : Symbol(A, Decl(NonInitializedExportInInternalModule.ts, 8, 25)) + + namespace B { +>B : Symbol(B, Decl(NonInitializedExportInInternalModule.ts, 11, 20)) + + export let a = 1, b, c = 2; +>a : Symbol(a, Decl(NonInitializedExportInInternalModule.ts, 14, 18)) +>b : Symbol(b, Decl(NonInitializedExportInInternalModule.ts, 14, 25)) +>c : Symbol(c, Decl(NonInitializedExportInInternalModule.ts, 14, 28)) + + export let x, y, z; +>x : Symbol(x, Decl(NonInitializedExportInInternalModule.ts, 15, 18)) +>y : Symbol(y, Decl(NonInitializedExportInInternalModule.ts, 15, 21)) +>z : Symbol(z, Decl(NonInitializedExportInInternalModule.ts, 15, 24)) + } + + module C { +>C : Symbol(C, Decl(NonInitializedExportInInternalModule.ts, 16, 5)) + + export var a = 1, b, c = 2; +>a : Symbol(a, Decl(NonInitializedExportInInternalModule.ts, 19, 18)) +>b : Symbol(b, Decl(NonInitializedExportInInternalModule.ts, 19, 25)) +>c : Symbol(c, Decl(NonInitializedExportInInternalModule.ts, 19, 28)) + + export var x, y, z; +>x : Symbol(x, Decl(NonInitializedExportInInternalModule.ts, 20, 18)) +>y : Symbol(y, Decl(NonInitializedExportInInternalModule.ts, 20, 21)) +>z : Symbol(z, Decl(NonInitializedExportInInternalModule.ts, 20, 24)) + } + + // Shouldn't be filtered + export var a1 = 1; +>a1 : Symbol(a1, Decl(NonInitializedExportInInternalModule.ts, 24, 14)) + + export let b1 = 1; +>b1 : Symbol(b1, Decl(NonInitializedExportInInternalModule.ts, 25, 14)) + + export var c1: string = 'a'; +>c1 : Symbol(c1, Decl(NonInitializedExportInInternalModule.ts, 26, 14)) + + export let d1: number = 1; +>d1 : Symbol(d1, Decl(NonInitializedExportInInternalModule.ts, 27, 14)) + + class D {} +>D : Symbol(D, Decl(NonInitializedExportInInternalModule.ts, 27, 30)) + + export var e1 = new D; +>e1 : Symbol(e1, Decl(NonInitializedExportInInternalModule.ts, 29, 14)) +>D : Symbol(D, Decl(NonInitializedExportInInternalModule.ts, 27, 30)) + + export let f1 = new D; +>f1 : Symbol(f1, Decl(NonInitializedExportInInternalModule.ts, 30, 14)) +>D : Symbol(D, Decl(NonInitializedExportInInternalModule.ts, 27, 30)) + + export var g1: D = new D; +>g1 : Symbol(g1, Decl(NonInitializedExportInInternalModule.ts, 31, 14)) +>D : Symbol(D, Decl(NonInitializedExportInInternalModule.ts, 27, 30)) +>D : Symbol(D, Decl(NonInitializedExportInInternalModule.ts, 27, 30)) + + export let h1: D = new D; +>h1 : Symbol(h1, Decl(NonInitializedExportInInternalModule.ts, 32, 14)) +>D : Symbol(D, Decl(NonInitializedExportInInternalModule.ts, 27, 30)) +>D : Symbol(D, Decl(NonInitializedExportInInternalModule.ts, 27, 30)) +} diff --git a/tests/baselines/reference/NonInitializedExportInInternalModule.types b/tests/baselines/reference/NonInitializedExportInInternalModule.types new file mode 100644 index 00000000000..4c8581c3283 --- /dev/null +++ b/tests/baselines/reference/NonInitializedExportInInternalModule.types @@ -0,0 +1,107 @@ +=== tests/cases/conformance/internalModules/exportDeclarations/NonInitializedExportInInternalModule.ts === +module Inner { +>Inner : typeof Inner + + var; + let; +>let : any + + const; + + export var a; +>a : any + + export let b; +>b : any + + export var c: string; +>c : string + + export let d: number; +>d : number + + class A {} +>A : A + + export var e: A; +>e : A +>A : A + + export let f: A; +>f : A +>A : A + + namespace B { +>B : typeof B + + export let a = 1, b, c = 2; +>a : number +>1 : 1 +>b : any +>c : number +>2 : 2 + + export let x, y, z; +>x : any +>y : any +>z : any + } + + module C { +>C : typeof C + + export var a = 1, b, c = 2; +>a : number +>1 : 1 +>b : any +>c : number +>2 : 2 + + export var x, y, z; +>x : any +>y : any +>z : any + } + + // Shouldn't be filtered + export var a1 = 1; +>a1 : number +>1 : 1 + + export let b1 = 1; +>b1 : number +>1 : 1 + + export var c1: string = 'a'; +>c1 : string +>'a' : "a" + + export let d1: number = 1; +>d1 : number +>1 : 1 + + class D {} +>D : D + + export var e1 = new D; +>e1 : D +>new D : D +>D : typeof D + + export let f1 = new D; +>f1 : D +>new D : D +>D : typeof D + + export var g1: D = new D; +>g1 : D +>D : D +>new D : D +>D : typeof D + + export let h1: D = new D; +>h1 : D +>D : D +>new D : D +>D : typeof D +} diff --git a/tests/baselines/reference/ParameterList13.symbols b/tests/baselines/reference/ParameterList13.symbols new file mode 100644 index 00000000000..7ed8ca187de --- /dev/null +++ b/tests/baselines/reference/ParameterList13.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ParameterList13.ts === +interface I { +>I : Symbol(I, Decl(ParameterList13.ts, 0, 0)) + + new (public x); +>x : Symbol(x, Decl(ParameterList13.ts, 1, 9)) +} diff --git a/tests/baselines/reference/ParameterList13.types b/tests/baselines/reference/ParameterList13.types new file mode 100644 index 00000000000..22819406560 --- /dev/null +++ b/tests/baselines/reference/ParameterList13.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ParameterList13.ts === +interface I { +>I : I + + new (public x); +>x : any +} diff --git a/tests/baselines/reference/ParameterList4.symbols b/tests/baselines/reference/ParameterList4.symbols new file mode 100644 index 00000000000..262710a77d0 --- /dev/null +++ b/tests/baselines/reference/ParameterList4.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/ParameterList4.ts === +function F(public A) { +>F : Symbol(F, Decl(ParameterList4.ts, 0, 0)) +>A : Symbol(A, Decl(ParameterList4.ts, 0, 11)) +} diff --git a/tests/baselines/reference/ParameterList4.types b/tests/baselines/reference/ParameterList4.types new file mode 100644 index 00000000000..5d947f15c4b --- /dev/null +++ b/tests/baselines/reference/ParameterList4.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/ParameterList4.ts === +function F(public A) { +>F : (public A: any) => void +>A : any +} diff --git a/tests/baselines/reference/ParameterList5.symbols b/tests/baselines/reference/ParameterList5.symbols new file mode 100644 index 00000000000..87b3181249b --- /dev/null +++ b/tests/baselines/reference/ParameterList5.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/ParameterList5.ts === +function A(): (public B) => C { +>A : Symbol(A, Decl(ParameterList5.ts, 0, 0)) +>B : Symbol(B, Decl(ParameterList5.ts, 0, 15)) +} diff --git a/tests/baselines/reference/ParameterList5.types b/tests/baselines/reference/ParameterList5.types new file mode 100644 index 00000000000..3c07e99bb48 --- /dev/null +++ b/tests/baselines/reference/ParameterList5.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/ParameterList5.ts === +function A(): (public B) => C { +>A : () => (public B: any) => any +>B : any +>C : No type information available! +} diff --git a/tests/baselines/reference/ParameterList6.symbols b/tests/baselines/reference/ParameterList6.symbols new file mode 100644 index 00000000000..b7baba3f462 --- /dev/null +++ b/tests/baselines/reference/ParameterList6.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/ParameterList6.ts === +class C { +>C : Symbol(C, Decl(ParameterList6.ts, 0, 0)) + + constructor(C: (public A) => any) { +>C : Symbol(C, Decl(ParameterList6.ts, 1, 14)) +>A : Symbol(A, Decl(ParameterList6.ts, 1, 18)) + } +} diff --git a/tests/baselines/reference/ParameterList6.types b/tests/baselines/reference/ParameterList6.types new file mode 100644 index 00000000000..26947a4a23f --- /dev/null +++ b/tests/baselines/reference/ParameterList6.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/ParameterList6.ts === +class C { +>C : C + + constructor(C: (public A) => any) { +>C : (public A: any) => any +>A : any + } +} diff --git a/tests/baselines/reference/ParameterList7.symbols b/tests/baselines/reference/ParameterList7.symbols new file mode 100644 index 00000000000..8d01805e475 --- /dev/null +++ b/tests/baselines/reference/ParameterList7.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ParameterList7.ts === +class C1 { +>C1 : Symbol(C1, Decl(ParameterList7.ts, 0, 0)) + + constructor(public p1:string); // ERROR +>p1 : Symbol(C1.p1, Decl(ParameterList7.ts, 1, 13)) + + constructor(private p2:number); // ERROR +>p2 : Symbol(C1.p2, Decl(ParameterList7.ts, 2, 13)) + + constructor(public p3:any) {} // OK +>p3 : Symbol(C1.p3, Decl(ParameterList7.ts, 3, 13)) +} diff --git a/tests/baselines/reference/ParameterList7.types b/tests/baselines/reference/ParameterList7.types new file mode 100644 index 00000000000..6503c09e5a5 --- /dev/null +++ b/tests/baselines/reference/ParameterList7.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ParameterList7.ts === +class C1 { +>C1 : C1 + + constructor(public p1:string); // ERROR +>p1 : string + + constructor(private p2:number); // ERROR +>p2 : number + + constructor(public p3:any) {} // OK +>p3 : any +} diff --git a/tests/baselines/reference/ParameterList8.symbols b/tests/baselines/reference/ParameterList8.symbols new file mode 100644 index 00000000000..919de165ea9 --- /dev/null +++ b/tests/baselines/reference/ParameterList8.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ParameterList8.ts === +declare class C2 { +>C2 : Symbol(C2, Decl(ParameterList8.ts, 0, 0)) + + constructor(public p1:string); // ERROR +>p1 : Symbol(C2.p1, Decl(ParameterList8.ts, 1, 13)) + + constructor(private p2:number); // ERROR +>p2 : Symbol(C2.p2, Decl(ParameterList8.ts, 2, 13)) + + constructor(public p3:any); // ERROR +>p3 : Symbol(C2.p3, Decl(ParameterList8.ts, 3, 13)) +} diff --git a/tests/baselines/reference/ParameterList8.types b/tests/baselines/reference/ParameterList8.types new file mode 100644 index 00000000000..150ebb7b7d4 --- /dev/null +++ b/tests/baselines/reference/ParameterList8.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/ParameterList8.ts === +declare class C2 { +>C2 : C2 + + constructor(public p1:string); // ERROR +>p1 : string + + constructor(private p2:number); // ERROR +>p2 : number + + constructor(public p3:any); // ERROR +>p3 : any +} diff --git a/tests/baselines/reference/Protected1.symbols b/tests/baselines/reference/Protected1.symbols new file mode 100644 index 00000000000..1fbefb2a8af --- /dev/null +++ b/tests/baselines/reference/Protected1.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts === +protected class C { +>C : Symbol(C, Decl(Protected1.ts, 0, 0)) +} diff --git a/tests/baselines/reference/Protected1.types b/tests/baselines/reference/Protected1.types new file mode 100644 index 00000000000..3d648e6a4b4 --- /dev/null +++ b/tests/baselines/reference/Protected1.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected1.ts === +protected class C { +>C : C +} diff --git a/tests/baselines/reference/Protected2.symbols b/tests/baselines/reference/Protected2.symbols new file mode 100644 index 00000000000..c1d9deec2c1 --- /dev/null +++ b/tests/baselines/reference/Protected2.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts === +protected module M { +>M : Symbol(M, Decl(Protected2.ts, 0, 0)) +} diff --git a/tests/baselines/reference/Protected2.types b/tests/baselines/reference/Protected2.types new file mode 100644 index 00000000000..d4a18b3f2fc --- /dev/null +++ b/tests/baselines/reference/Protected2.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected2.ts === +protected module M { +>M : any +} diff --git a/tests/baselines/reference/Protected4.symbols b/tests/baselines/reference/Protected4.symbols new file mode 100644 index 00000000000..54814def624 --- /dev/null +++ b/tests/baselines/reference/Protected4.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected4.ts === +class C { +>C : Symbol(C, Decl(Protected4.ts, 0, 0)) + + protected public m() { } +>m : Symbol(C.m, Decl(Protected4.ts, 0, 9)) +} diff --git a/tests/baselines/reference/Protected4.types b/tests/baselines/reference/Protected4.types new file mode 100644 index 00000000000..af4d56083c5 --- /dev/null +++ b/tests/baselines/reference/Protected4.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected4.ts === +class C { +>C : C + + protected public m() { } +>m : () => void +} diff --git a/tests/baselines/reference/Protected6.symbols b/tests/baselines/reference/Protected6.symbols new file mode 100644 index 00000000000..321c9fbe887 --- /dev/null +++ b/tests/baselines/reference/Protected6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected6.ts === +class C { +>C : Symbol(C, Decl(Protected6.ts, 0, 0)) + + static protected m() { } +>m : Symbol(C.m, Decl(Protected6.ts, 0, 9)) +} diff --git a/tests/baselines/reference/Protected6.types b/tests/baselines/reference/Protected6.types new file mode 100644 index 00000000000..4a902fe5460 --- /dev/null +++ b/tests/baselines/reference/Protected6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected6.ts === +class C { +>C : C + + static protected m() { } +>m : () => void +} diff --git a/tests/baselines/reference/Protected7.symbols b/tests/baselines/reference/Protected7.symbols new file mode 100644 index 00000000000..e72be44f210 --- /dev/null +++ b/tests/baselines/reference/Protected7.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected7.ts === +class C { +>C : Symbol(C, Decl(Protected7.ts, 0, 0)) + + protected private m() { } +>m : Symbol(C.m, Decl(Protected7.ts, 0, 9)) +} diff --git a/tests/baselines/reference/Protected7.types b/tests/baselines/reference/Protected7.types new file mode 100644 index 00000000000..d3b770676ce --- /dev/null +++ b/tests/baselines/reference/Protected7.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/parser/ecmascript5/Protected/Protected7.ts === +class C { +>C : C + + protected private m() { } +>m : () => void +} diff --git a/tests/baselines/reference/TemplateExpression1.symbols b/tests/baselines/reference/TemplateExpression1.symbols new file mode 100644 index 00000000000..d272dae79d2 --- /dev/null +++ b/tests/baselines/reference/TemplateExpression1.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/templates/TemplateExpression1.ts === +var v = `foo ${ a +>v : Symbol(v, Decl(TemplateExpression1.ts, 0, 3)) + diff --git a/tests/baselines/reference/TemplateExpression1.types b/tests/baselines/reference/TemplateExpression1.types new file mode 100644 index 00000000000..e23083d83ec --- /dev/null +++ b/tests/baselines/reference/TemplateExpression1.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/templates/TemplateExpression1.ts === +var v = `foo ${ a +>v : string +>`foo ${ a : string +>a : any + diff --git a/tests/baselines/reference/TupleType3.symbols b/tests/baselines/reference/TupleType3.symbols new file mode 100644 index 00000000000..a2466e85121 --- /dev/null +++ b/tests/baselines/reference/TupleType3.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType3.ts === +var v: [] +>v : Symbol(v, Decl(TupleType3.ts, 0, 3)) + diff --git a/tests/baselines/reference/TupleType3.types b/tests/baselines/reference/TupleType3.types new file mode 100644 index 00000000000..5944aabd7d4 --- /dev/null +++ b/tests/baselines/reference/TupleType3.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType3.ts === +var v: [] +>v : [] + diff --git a/tests/baselines/reference/TupleType4.symbols b/tests/baselines/reference/TupleType4.symbols new file mode 100644 index 00000000000..9b5e4a1c00c --- /dev/null +++ b/tests/baselines/reference/TupleType4.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType4.ts === +var v: [ +>v : Symbol(v, Decl(TupleType4.ts, 0, 3)) + diff --git a/tests/baselines/reference/TupleType4.types b/tests/baselines/reference/TupleType4.types new file mode 100644 index 00000000000..7ad64f5606b --- /dev/null +++ b/tests/baselines/reference/TupleType4.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType4.ts === +var v: [ +>v : [] + diff --git a/tests/baselines/reference/TupleType5.symbols b/tests/baselines/reference/TupleType5.symbols new file mode 100644 index 00000000000..6c20b3f7a66 --- /dev/null +++ b/tests/baselines/reference/TupleType5.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType5.ts === +var v: [number,] +>v : Symbol(v, Decl(TupleType5.ts, 0, 3)) + diff --git a/tests/baselines/reference/TupleType5.types b/tests/baselines/reference/TupleType5.types new file mode 100644 index 00000000000..6c23baf57d9 --- /dev/null +++ b/tests/baselines/reference/TupleType5.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType5.ts === +var v: [number,] +>v : [number] + diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.symbols b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.symbols new file mode 100644 index 00000000000..95ce9c7e429 --- /dev/null +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.symbols @@ -0,0 +1,63 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts === +module A { +>A : Symbol(A, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 0, 0), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 5, 1)) + + export class Point { +>Point : Symbol(Point, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 0, 10)) + + x: number; +>x : Symbol(Point.x, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 1, 24)) + + y: number; +>y : Symbol(Point.y, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 2, 18)) + } +} + +module A{ +>A : Symbol(A, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 0, 0), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 5, 1)) + + // expected error + export class Point { +>Point : Symbol(A.Point, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 7, 9)) + + origin: number; +>origin : Symbol(A.Point.origin, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 9, 24)) + + angle: number; +>angle : Symbol(A.Point.angle, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 10, 23)) + } +} + +module X.Y.Z { +>X : Symbol(X, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 13, 1), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 19, 1)) +>Y : Symbol(Y, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 15, 9), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 21, 10)) +>Z : Symbol(Z, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 15, 11), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 22, 21)) + + export class Line { +>Line : Symbol(Line, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 15, 14)) + + length: number; +>length : Symbol(Line.length, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 16, 23)) + } +} + +module X { +>X : Symbol(X, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 13, 1), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 19, 1)) + + export module Y { +>Y : Symbol(Y, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 15, 9), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 21, 10)) + + export module Z { +>Z : Symbol(Z, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 15, 11), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 22, 21)) + + // expected error + export class Line { +>Line : Symbol(Z.Line, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 23, 25)) + + name: string; +>name : Symbol(Z.Line.name, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 25, 31)) + } + } + } +} + diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.types b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.types new file mode 100644 index 00000000000..bc4b6c847c5 --- /dev/null +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.types @@ -0,0 +1,63 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts === +module A { +>A : typeof A + + export class Point { +>Point : Point + + x: number; +>x : number + + y: number; +>y : number + } +} + +module A{ +>A : typeof A + + // expected error + export class Point { +>Point : A.Point + + origin: number; +>origin : number + + angle: number; +>angle : number + } +} + +module X.Y.Z { +>X : typeof X +>Y : typeof Y +>Z : typeof Z + + export class Line { +>Line : Line + + length: number; +>length : number + } +} + +module X { +>X : typeof X + + export module Y { +>Y : typeof Y + + export module Z { +>Z : typeof Z + + // expected error + export class Line { +>Line : Z.Line + + name: string; +>name : string + } + } + } +} + diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.symbols b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.symbols new file mode 100644 index 00000000000..a9d0459064a --- /dev/null +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.symbols @@ -0,0 +1,66 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/part1.ts === +export module A { +>A : Symbol(A, Decl(part1.ts, 0, 0)) + + export interface Point { +>Point : Symbol(Point, Decl(part1.ts, 0, 17)) + + x: number; +>x : Symbol(Point.x, Decl(part1.ts, 1, 28)) + + y: number; +>y : Symbol(Point.y, Decl(part1.ts, 2, 18)) + } + + export module Utils { +>Utils : Symbol(Utils, Decl(part1.ts, 4, 5)) + + export function mirror(p: T) { +>mirror : Symbol(mirror, Decl(part1.ts, 6, 25)) +>T : Symbol(T, Decl(part1.ts, 7, 31)) +>Point : Symbol(Point, Decl(part1.ts, 0, 17)) +>p : Symbol(p, Decl(part1.ts, 7, 48)) +>T : Symbol(T, Decl(part1.ts, 7, 31)) + + return { x: p.y, y: p.x }; +>x : Symbol(x, Decl(part1.ts, 8, 20)) +>p.y : Symbol(Point.y, Decl(part1.ts, 2, 18)) +>p : Symbol(p, Decl(part1.ts, 7, 48)) +>y : Symbol(Point.y, Decl(part1.ts, 2, 18)) +>y : Symbol(y, Decl(part1.ts, 8, 28)) +>p.x : Symbol(Point.x, Decl(part1.ts, 1, 28)) +>p : Symbol(p, Decl(part1.ts, 7, 48)) +>x : Symbol(Point.x, Decl(part1.ts, 1, 28)) + } + } + + export var Origin: Point = { x: 0, y: 0 }; +>Origin : Symbol(Origin, Decl(part1.ts, 12, 14)) +>Point : Symbol(Point, Decl(part1.ts, 0, 17)) +>x : Symbol(x, Decl(part1.ts, 12, 32)) +>y : Symbol(y, Decl(part1.ts, 12, 38)) +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/part2.ts === +export module A { +>A : Symbol(A, Decl(part2.ts, 0, 0)) + + // collision with 'Origin' var in other part of merged module + export var Origin: Point = { x: 0, y: 0 }; +>Origin : Symbol(Origin, Decl(part2.ts, 2, 14)) +>x : Symbol(x, Decl(part2.ts, 2, 32)) +>y : Symbol(y, Decl(part2.ts, 2, 38)) + + export module Utils { +>Utils : Symbol(Utils, Decl(part2.ts, 2, 46)) + + export class Plane { +>Plane : Symbol(Plane, Decl(part2.ts, 4, 25)) + + constructor(public tl: Point, public br: Point) { } +>tl : Symbol(Plane.tl, Decl(part2.ts, 6, 24)) +>br : Symbol(Plane.br, Decl(part2.ts, 6, 41)) + } + } +} + diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.types b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.types new file mode 100644 index 00000000000..b9132a1d2cb --- /dev/null +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.types @@ -0,0 +1,76 @@ +=== tests/cases/conformance/internalModules/DeclarationMerging/part1.ts === +export module A { +>A : typeof A + + export interface Point { +>Point : Point + + x: number; +>x : number + + y: number; +>y : number + } + + export module Utils { +>Utils : typeof Utils + + export function mirror(p: T) { +>mirror : (p: T) => { x: number; y: number; } +>T : T +>Point : Point +>p : T +>T : T + + return { x: p.y, y: p.x }; +>{ x: p.y, y: p.x } : { x: number; y: number; } +>x : number +>p.y : number +>p : T +>y : number +>y : number +>p.x : number +>p : T +>x : number + } + } + + export var Origin: Point = { x: 0, y: 0 }; +>Origin : Point +>Point : Point +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 +} + +=== tests/cases/conformance/internalModules/DeclarationMerging/part2.ts === +export module A { +>A : typeof A + + // collision with 'Origin' var in other part of merged module + export var Origin: Point = { x: 0, y: 0 }; +>Origin : any +>Point : No type information available! +>{ x: 0, y: 0 } : { x: number; y: number; } +>x : number +>0 : 0 +>y : number +>0 : 0 + + export module Utils { +>Utils : typeof Utils + + export class Plane { +>Plane : Plane + + constructor(public tl: Point, public br: Point) { } +>tl : any +>Point : No type information available! +>br : any +>Point : No type information available! + } + } +} + diff --git a/tests/baselines/reference/TypeArgumentList1.symbols b/tests/baselines/reference/TypeArgumentList1.symbols new file mode 100644 index 00000000000..d2803e79101 --- /dev/null +++ b/tests/baselines/reference/TypeArgumentList1.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts === +Foo(4, 5, 6); +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/TypeArgumentList1.types b/tests/baselines/reference/TypeArgumentList1.types new file mode 100644 index 00000000000..5d346592c49 --- /dev/null +++ b/tests/baselines/reference/TypeArgumentList1.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/TypeArgumentLists/TypeArgumentList1.ts === +Foo(4, 5, 6); +>FooFooFooFoo : any +>A : any +>B : any +> : any +>C>(4, 5, 6) : boolean +>C : any +>(4, 5, 6) : 6 +>4, 5, 6 : 6 +>4, 5 : 5 +>4 : 4 +>5 : 5 +>6 : 6 + diff --git a/tests/baselines/reference/VariableDeclaration11_es6.symbols b/tests/baselines/reference/VariableDeclaration11_es6.symbols new file mode 100644 index 00000000000..feaeb047073 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration11_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts === +"use strict"; +No type information for this code.let +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration11_es6.types b/tests/baselines/reference/VariableDeclaration11_es6.types new file mode 100644 index 00000000000..8806d07de0c --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration11_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts === +"use strict"; +>"use strict" : "use strict" + +let +>let : any + diff --git a/tests/baselines/reference/VariableDeclaration13_es6.symbols b/tests/baselines/reference/VariableDeclaration13_es6.symbols new file mode 100644 index 00000000000..7e2d3a370ec --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration13_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts === +// An ExpressionStatement cannot start with the two token sequence `let [` because +// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern. +var let: any; +>let : Symbol(let, Decl(VariableDeclaration13_es6.ts, 2, 3)) + +let[0] = 100; diff --git a/tests/baselines/reference/VariableDeclaration13_es6.types b/tests/baselines/reference/VariableDeclaration13_es6.types new file mode 100644 index 00000000000..1e40a719c3b --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration13_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts === +// An ExpressionStatement cannot start with the two token sequence `let [` because +// that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern. +var let: any; +>let : any + +let[0] = 100; +>0 : 0 +>100 : 100 + diff --git a/tests/baselines/reference/VariableDeclaration1_es6.symbols b/tests/baselines/reference/VariableDeclaration1_es6.symbols new file mode 100644 index 00000000000..183f9495caa --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration1_es6.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts === +const +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration1_es6.types b/tests/baselines/reference/VariableDeclaration1_es6.types new file mode 100644 index 00000000000..183f9495caa --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration1_es6.types @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration1_es6.ts === +const +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration2_es6.symbols b/tests/baselines/reference/VariableDeclaration2_es6.symbols new file mode 100644 index 00000000000..93d36394e59 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration2_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts === +const a +>a : Symbol(a, Decl(VariableDeclaration2_es6.ts, 0, 5)) + diff --git a/tests/baselines/reference/VariableDeclaration2_es6.types b/tests/baselines/reference/VariableDeclaration2_es6.types new file mode 100644 index 00000000000..60f6c46499e --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration2_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration2_es6.ts === +const a +>a : any + diff --git a/tests/baselines/reference/VariableDeclaration4_es6.symbols b/tests/baselines/reference/VariableDeclaration4_es6.symbols new file mode 100644 index 00000000000..e0ed56d9f2c --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration4_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts === +const a: number +>a : Symbol(a, Decl(VariableDeclaration4_es6.ts, 0, 5)) + diff --git a/tests/baselines/reference/VariableDeclaration4_es6.types b/tests/baselines/reference/VariableDeclaration4_es6.types new file mode 100644 index 00000000000..622d6bb6ba6 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration4_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration4_es6.ts === +const a: number +>a : number + diff --git a/tests/baselines/reference/VariableDeclaration6_es6.symbols b/tests/baselines/reference/VariableDeclaration6_es6.symbols new file mode 100644 index 00000000000..8d18e77c1a3 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration6_es6.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts === +let +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration6_es6.types b/tests/baselines/reference/VariableDeclaration6_es6.types new file mode 100644 index 00000000000..a47682673fc --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration6_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration6_es6.ts === +let +>let : any + diff --git a/tests/baselines/reference/YieldExpression10_es6.symbols b/tests/baselines/reference/YieldExpression10_es6.symbols new file mode 100644 index 00000000000..90b6f777338 --- /dev/null +++ b/tests/baselines/reference/YieldExpression10_es6.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts === +var v = { * foo() { +>v : Symbol(v, Decl(YieldExpression10_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(YieldExpression10_es6.ts, 0, 9)) + + yield(foo); + } +} + diff --git a/tests/baselines/reference/YieldExpression10_es6.types b/tests/baselines/reference/YieldExpression10_es6.types new file mode 100644 index 00000000000..966baa031ed --- /dev/null +++ b/tests/baselines/reference/YieldExpression10_es6.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression10_es6.ts === +var v = { * foo() { +>v : { foo(): IterableIterator; } +>{ * foo() { yield(foo); }} : { foo(): IterableIterator; } +>foo : () => IterableIterator + + yield(foo); +>yield(foo) : any +>(foo) : any +>foo : any + } +} + diff --git a/tests/baselines/reference/YieldExpression11_es6.symbols b/tests/baselines/reference/YieldExpression11_es6.symbols new file mode 100644 index 00000000000..fb0302abe66 --- /dev/null +++ b/tests/baselines/reference/YieldExpression11_es6.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts === +class C { +>C : Symbol(C, Decl(YieldExpression11_es6.ts, 0, 0)) + + *foo() { +>foo : Symbol(C.foo, Decl(YieldExpression11_es6.ts, 0, 9)) + + yield(foo); + } +} diff --git a/tests/baselines/reference/YieldExpression11_es6.types b/tests/baselines/reference/YieldExpression11_es6.types new file mode 100644 index 00000000000..01257e4f95f --- /dev/null +++ b/tests/baselines/reference/YieldExpression11_es6.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression11_es6.ts === +class C { +>C : C + + *foo() { +>foo : () => IterableIterator + + yield(foo); +>yield(foo) : any +>(foo) : any +>foo : any + } +} diff --git a/tests/baselines/reference/YieldExpression12_es6.symbols b/tests/baselines/reference/YieldExpression12_es6.symbols new file mode 100644 index 00000000000..aaa62f47cd1 --- /dev/null +++ b/tests/baselines/reference/YieldExpression12_es6.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts === +class C { +>C : Symbol(C, Decl(YieldExpression12_es6.ts, 0, 0)) + + constructor() { + yield foo + } +} diff --git a/tests/baselines/reference/YieldExpression12_es6.types b/tests/baselines/reference/YieldExpression12_es6.types new file mode 100644 index 00000000000..a5743c0c1a7 --- /dev/null +++ b/tests/baselines/reference/YieldExpression12_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression12_es6.ts === +class C { +>C : C + + constructor() { + yield foo +>yield foo : any +>foo : any + } +} diff --git a/tests/baselines/reference/YieldExpression14_es6.symbols b/tests/baselines/reference/YieldExpression14_es6.symbols new file mode 100644 index 00000000000..4ec09c3bef2 --- /dev/null +++ b/tests/baselines/reference/YieldExpression14_es6.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts === +class C { +>C : Symbol(C, Decl(YieldExpression14_es6.ts, 0, 0)) + + foo() { +>foo : Symbol(C.foo, Decl(YieldExpression14_es6.ts, 0, 9)) + + yield foo + } +} diff --git a/tests/baselines/reference/YieldExpression14_es6.types b/tests/baselines/reference/YieldExpression14_es6.types new file mode 100644 index 00000000000..3b878347b76 --- /dev/null +++ b/tests/baselines/reference/YieldExpression14_es6.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression14_es6.ts === +class C { +>C : C + + foo() { +>foo : () => void + + yield foo +>yield foo : any +>foo : any + } +} diff --git a/tests/baselines/reference/YieldExpression15_es6.symbols b/tests/baselines/reference/YieldExpression15_es6.symbols new file mode 100644 index 00000000000..0d55bef21ac --- /dev/null +++ b/tests/baselines/reference/YieldExpression15_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts === +var v = () => { +>v : Symbol(v, Decl(YieldExpression15_es6.ts, 0, 3)) + + yield foo + } diff --git a/tests/baselines/reference/YieldExpression15_es6.types b/tests/baselines/reference/YieldExpression15_es6.types new file mode 100644 index 00000000000..33eedb854b0 --- /dev/null +++ b/tests/baselines/reference/YieldExpression15_es6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression15_es6.ts === +var v = () => { +>v : () => void +>() => { yield foo } : () => void + + yield foo +>yield foo : any +>foo : any + } diff --git a/tests/baselines/reference/YieldExpression16_es6.symbols b/tests/baselines/reference/YieldExpression16_es6.symbols new file mode 100644 index 00000000000..50bedfcb15a --- /dev/null +++ b/tests/baselines/reference/YieldExpression16_es6.symbols @@ -0,0 +1,11 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts === +function* foo() { +>foo : Symbol(foo, Decl(YieldExpression16_es6.ts, 0, 0)) + + function bar() { +>bar : Symbol(bar, Decl(YieldExpression16_es6.ts, 0, 17)) + + yield foo; +>foo : Symbol(foo, Decl(YieldExpression16_es6.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/YieldExpression16_es6.types b/tests/baselines/reference/YieldExpression16_es6.types new file mode 100644 index 00000000000..661d60a5b58 --- /dev/null +++ b/tests/baselines/reference/YieldExpression16_es6.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression16_es6.ts === +function* foo() { +>foo : () => IterableIterator + + function bar() { +>bar : () => void + + yield foo; +>yield foo : any +>foo : () => IterableIterator + } +} diff --git a/tests/baselines/reference/YieldExpression17_es6.symbols b/tests/baselines/reference/YieldExpression17_es6.symbols new file mode 100644 index 00000000000..69a5caa9532 --- /dev/null +++ b/tests/baselines/reference/YieldExpression17_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts === +var v = { get foo() { yield foo; } } +>v : Symbol(v, Decl(YieldExpression17_es6.ts, 0, 3)) +>foo : Symbol(foo, Decl(YieldExpression17_es6.ts, 0, 9)) + diff --git a/tests/baselines/reference/YieldExpression17_es6.types b/tests/baselines/reference/YieldExpression17_es6.types new file mode 100644 index 00000000000..08a8989b9ab --- /dev/null +++ b/tests/baselines/reference/YieldExpression17_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression17_es6.ts === +var v = { get foo() { yield foo; } } +>v : { readonly foo: void; } +>{ get foo() { yield foo; } } : { readonly foo: void; } +>foo : void +>yield foo : any +>foo : any + diff --git a/tests/baselines/reference/YieldExpression18_es6.symbols b/tests/baselines/reference/YieldExpression18_es6.symbols new file mode 100644 index 00000000000..34772327eae --- /dev/null +++ b/tests/baselines/reference/YieldExpression18_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts === +"use strict"; +No type information for this code.yield(foo); +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression18_es6.types b/tests/baselines/reference/YieldExpression18_es6.types new file mode 100644 index 00000000000..8322d4721d1 --- /dev/null +++ b/tests/baselines/reference/YieldExpression18_es6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts === +"use strict"; +>"use strict" : "use strict" + +yield(foo); +>yield(foo) : any +>yield : any +>foo : any + diff --git a/tests/baselines/reference/YieldExpression1_es6.symbols b/tests/baselines/reference/YieldExpression1_es6.symbols new file mode 100644 index 00000000000..9ca9f6cc899 --- /dev/null +++ b/tests/baselines/reference/YieldExpression1_es6.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts === +yield; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression1_es6.types b/tests/baselines/reference/YieldExpression1_es6.types new file mode 100644 index 00000000000..bf582b5b7a5 --- /dev/null +++ b/tests/baselines/reference/YieldExpression1_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression1_es6.ts === +yield; +>yield : any + diff --git a/tests/baselines/reference/YieldExpression2_es6.symbols b/tests/baselines/reference/YieldExpression2_es6.symbols new file mode 100644 index 00000000000..99510808bd7 --- /dev/null +++ b/tests/baselines/reference/YieldExpression2_es6.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts === +yield foo; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/YieldExpression2_es6.types b/tests/baselines/reference/YieldExpression2_es6.types new file mode 100644 index 00000000000..abe61e5ea07 --- /dev/null +++ b/tests/baselines/reference/YieldExpression2_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression2_es6.ts === +yield foo; +>yield foo : any +>foo : any + diff --git a/tests/baselines/reference/YieldExpression5_es6.symbols b/tests/baselines/reference/YieldExpression5_es6.symbols new file mode 100644 index 00000000000..61b51d002c0 --- /dev/null +++ b/tests/baselines/reference/YieldExpression5_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts === +function* foo() { +>foo : Symbol(foo, Decl(YieldExpression5_es6.ts, 0, 0)) + + yield* +} diff --git a/tests/baselines/reference/YieldExpression5_es6.types b/tests/baselines/reference/YieldExpression5_es6.types new file mode 100644 index 00000000000..77a003d0922 --- /dev/null +++ b/tests/baselines/reference/YieldExpression5_es6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression5_es6.ts === +function* foo() { +>foo : () => IterableIterator + + yield* +>yield* : any +} +> : any + diff --git a/tests/baselines/reference/YieldExpression6_es6.symbols b/tests/baselines/reference/YieldExpression6_es6.symbols new file mode 100644 index 00000000000..67b9059dc0d --- /dev/null +++ b/tests/baselines/reference/YieldExpression6_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts === +function* foo() { +>foo : Symbol(foo, Decl(YieldExpression6_es6.ts, 0, 0)) + + yield*foo +>foo : Symbol(foo, Decl(YieldExpression6_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/YieldExpression6_es6.types b/tests/baselines/reference/YieldExpression6_es6.types new file mode 100644 index 00000000000..c30fc64c8ad --- /dev/null +++ b/tests/baselines/reference/YieldExpression6_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression6_es6.ts === +function* foo() { +>foo : () => IterableIterator + + yield*foo +>yield*foo : any +>foo : () => IterableIterator +} diff --git a/tests/baselines/reference/YieldExpression8_es6.symbols b/tests/baselines/reference/YieldExpression8_es6.symbols new file mode 100644 index 00000000000..028ef8dcaa1 --- /dev/null +++ b/tests/baselines/reference/YieldExpression8_es6.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts === +yield(foo); +>foo : Symbol(foo, Decl(YieldExpression8_es6.ts, 0, 11)) + +function* foo() { +>foo : Symbol(foo, Decl(YieldExpression8_es6.ts, 0, 11)) + + yield(foo); +>foo : Symbol(foo, Decl(YieldExpression8_es6.ts, 0, 11)) +} diff --git a/tests/baselines/reference/YieldExpression8_es6.types b/tests/baselines/reference/YieldExpression8_es6.types new file mode 100644 index 00000000000..67343e3fbfc --- /dev/null +++ b/tests/baselines/reference/YieldExpression8_es6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression8_es6.ts === +yield(foo); +>yield(foo) : any +>yield : any +>foo : () => IterableIterator + +function* foo() { +>foo : () => IterableIterator + + yield(foo); +>yield(foo) : any +>(foo) : () => IterableIterator +>foo : () => IterableIterator +} diff --git a/tests/baselines/reference/YieldExpression9_es6.symbols b/tests/baselines/reference/YieldExpression9_es6.symbols new file mode 100644 index 00000000000..a7d55e4a045 --- /dev/null +++ b/tests/baselines/reference/YieldExpression9_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts === +var v = function*() { +>v : Symbol(v, Decl(YieldExpression9_es6.ts, 0, 3)) + + yield(foo); +} diff --git a/tests/baselines/reference/YieldExpression9_es6.types b/tests/baselines/reference/YieldExpression9_es6.types new file mode 100644 index 00000000000..109dc270583 --- /dev/null +++ b/tests/baselines/reference/YieldExpression9_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldExpression9_es6.ts === +var v = function*() { +>v : () => IterableIterator +>function*() { yield(foo);} : () => IterableIterator + + yield(foo); +>yield(foo) : any +>(foo) : any +>foo : any +} diff --git a/tests/baselines/reference/YieldStarExpression1_es6.symbols b/tests/baselines/reference/YieldStarExpression1_es6.symbols new file mode 100644 index 00000000000..c01128e880c --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression1_es6.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts === +yield * []; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression1_es6.types b/tests/baselines/reference/YieldStarExpression1_es6.types new file mode 100644 index 00000000000..df3a2325acf --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression1_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression1_es6.ts === +yield * []; +>yield * [] : number +>yield : any +>[] : undefined[] + diff --git a/tests/baselines/reference/YieldStarExpression2_es6.symbols b/tests/baselines/reference/YieldStarExpression2_es6.symbols new file mode 100644 index 00000000000..758acfdfece --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression2_es6.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts === +yield *; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/YieldStarExpression2_es6.types b/tests/baselines/reference/YieldStarExpression2_es6.types new file mode 100644 index 00000000000..ecfd8b2d43e --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression2_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression2_es6.ts === +yield *; +>yield * : number +>yield : any +> : any + diff --git a/tests/baselines/reference/YieldStarExpression3_es6.symbols b/tests/baselines/reference/YieldStarExpression3_es6.symbols new file mode 100644 index 00000000000..5440d616c73 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression3_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts === +function *g() { +>g : Symbol(g, Decl(YieldStarExpression3_es6.ts, 0, 0)) + + yield *; +} diff --git a/tests/baselines/reference/YieldStarExpression3_es6.types b/tests/baselines/reference/YieldStarExpression3_es6.types new file mode 100644 index 00000000000..5bc03855b19 --- /dev/null +++ b/tests/baselines/reference/YieldStarExpression3_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/yieldExpressions/YieldStarExpression3_es6.ts === +function *g() { +>g : () => IterableIterator + + yield *; +>yield * : any +> : any +} diff --git a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.symbols b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.symbols new file mode 100644 index 00000000000..9b8ce6d417b --- /dev/null +++ b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/abstractClassInLocalScopeIsAbstract.ts === +(() => { + abstract class A {} +>A : Symbol(A, Decl(abstractClassInLocalScopeIsAbstract.ts, 0, 8)) + + class B extends A {} +>B : Symbol(B, Decl(abstractClassInLocalScopeIsAbstract.ts, 1, 23)) +>A : Symbol(A, Decl(abstractClassInLocalScopeIsAbstract.ts, 0, 8)) + + new A(); +>A : Symbol(A, Decl(abstractClassInLocalScopeIsAbstract.ts, 0, 8)) + + new B(); +>B : Symbol(B, Decl(abstractClassInLocalScopeIsAbstract.ts, 1, 23)) + +})() + diff --git a/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.types b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.types new file mode 100644 index 00000000000..106559c7be3 --- /dev/null +++ b/tests/baselines/reference/abstractClassInLocalScopeIsAbstract.types @@ -0,0 +1,23 @@ +=== tests/cases/compiler/abstractClassInLocalScopeIsAbstract.ts === +(() => { +>(() => { abstract class A {} class B extends A {} new A(); new B();})() : void +>(() => { abstract class A {} class B extends A {} new A(); new B();}) : () => void +>() => { abstract class A {} class B extends A {} new A(); new B();} : () => void + + abstract class A {} +>A : A + + class B extends A {} +>B : B +>A : A + + new A(); +>new A() : any +>A : typeof A + + new B(); +>new B() : B +>B : typeof B + +})() + diff --git a/tests/baselines/reference/abstractPropertyNegative.symbols b/tests/baselines/reference/abstractPropertyNegative.symbols new file mode 100644 index 00000000000..16fa75b309f --- /dev/null +++ b/tests/baselines/reference/abstractPropertyNegative.symbols @@ -0,0 +1,107 @@ +=== tests/cases/compiler/abstractPropertyNegative.ts === +interface A { +>A : Symbol(A, Decl(abstractPropertyNegative.ts, 0, 0)) + + prop: string; +>prop : Symbol(A.prop, Decl(abstractPropertyNegative.ts, 0, 13)) + + m(): string; +>m : Symbol(A.m, Decl(abstractPropertyNegative.ts, 1, 17)) +} +abstract class B implements A { +>B : Symbol(B, Decl(abstractPropertyNegative.ts, 3, 1)) +>A : Symbol(A, Decl(abstractPropertyNegative.ts, 0, 0)) + + abstract prop: string; +>prop : Symbol(B.prop, Decl(abstractPropertyNegative.ts, 4, 31)) + + public abstract readonly ro: string; +>ro : Symbol(B.ro, Decl(abstractPropertyNegative.ts, 5, 26)) + + abstract get readonlyProp(): string; +>readonlyProp : Symbol(B.readonlyProp, Decl(abstractPropertyNegative.ts, 6, 40)) + + abstract m(): string; +>m : Symbol(B.m, Decl(abstractPropertyNegative.ts, 7, 40)) + + abstract get mismatch(): string; +>mismatch : Symbol(B.mismatch, Decl(abstractPropertyNegative.ts, 8, 25), Decl(abstractPropertyNegative.ts, 9, 36)) + + abstract set mismatch(val: number); // error, not same type +>mismatch : Symbol(B.mismatch, Decl(abstractPropertyNegative.ts, 8, 25), Decl(abstractPropertyNegative.ts, 9, 36)) +>val : Symbol(val, Decl(abstractPropertyNegative.ts, 10, 26)) +} +class C extends B { +>C : Symbol(C, Decl(abstractPropertyNegative.ts, 11, 1)) +>B : Symbol(B, Decl(abstractPropertyNegative.ts, 3, 1)) + + readonly ro = "readonly please"; +>ro : Symbol(C.ro, Decl(abstractPropertyNegative.ts, 12, 19)) + + abstract notAllowed: string; +>notAllowed : Symbol(C.notAllowed, Decl(abstractPropertyNegative.ts, 13, 36)) + + get concreteWithNoBody(): string; +>concreteWithNoBody : Symbol(C.concreteWithNoBody, Decl(abstractPropertyNegative.ts, 14, 32)) +} +let c = new C(); +>c : Symbol(c, Decl(abstractPropertyNegative.ts, 17, 3)) +>C : Symbol(C, Decl(abstractPropertyNegative.ts, 11, 1)) + +c.ro = "error: lhs of assignment can't be readonly"; +>c.ro : Symbol(C.ro, Decl(abstractPropertyNegative.ts, 12, 19)) +>c : Symbol(c, Decl(abstractPropertyNegative.ts, 17, 3)) +>ro : Symbol(C.ro, Decl(abstractPropertyNegative.ts, 12, 19)) + +abstract class WrongTypeProperty { +>WrongTypeProperty : Symbol(WrongTypeProperty, Decl(abstractPropertyNegative.ts, 18, 52)) + + abstract num: number; +>num : Symbol(WrongTypeProperty.num, Decl(abstractPropertyNegative.ts, 20, 34)) +} +class WrongTypePropertyImpl extends WrongTypeProperty { +>WrongTypePropertyImpl : Symbol(WrongTypePropertyImpl, Decl(abstractPropertyNegative.ts, 22, 1)) +>WrongTypeProperty : Symbol(WrongTypeProperty, Decl(abstractPropertyNegative.ts, 18, 52)) + + num = "nope, wrong"; +>num : Symbol(WrongTypePropertyImpl.num, Decl(abstractPropertyNegative.ts, 23, 55)) +} +abstract class WrongTypeAccessor { +>WrongTypeAccessor : Symbol(WrongTypeAccessor, Decl(abstractPropertyNegative.ts, 25, 1)) + + abstract get num(): number; +>num : Symbol(WrongTypeAccessor.num, Decl(abstractPropertyNegative.ts, 26, 34)) +} +class WrongTypeAccessorImpl extends WrongTypeAccessor { +>WrongTypeAccessorImpl : Symbol(WrongTypeAccessorImpl, Decl(abstractPropertyNegative.ts, 28, 1)) +>WrongTypeAccessor : Symbol(WrongTypeAccessor, Decl(abstractPropertyNegative.ts, 25, 1)) + + get num() { return "nope, wrong"; } +>num : Symbol(WrongTypeAccessorImpl.num, Decl(abstractPropertyNegative.ts, 29, 55)) +} +class WrongTypeAccessorImpl2 extends WrongTypeAccessor { +>WrongTypeAccessorImpl2 : Symbol(WrongTypeAccessorImpl2, Decl(abstractPropertyNegative.ts, 31, 1)) +>WrongTypeAccessor : Symbol(WrongTypeAccessor, Decl(abstractPropertyNegative.ts, 25, 1)) + + num = "nope, wrong"; +>num : Symbol(WrongTypeAccessorImpl2.num, Decl(abstractPropertyNegative.ts, 32, 56)) +} + +abstract class AbstractAccessorMismatch { +>AbstractAccessorMismatch : Symbol(AbstractAccessorMismatch, Decl(abstractPropertyNegative.ts, 34, 1)) + + abstract get p1(): string; +>p1 : Symbol(AbstractAccessorMismatch.p1, Decl(abstractPropertyNegative.ts, 36, 41), Decl(abstractPropertyNegative.ts, 37, 30)) + + set p1(val: string) { }; +>p1 : Symbol(AbstractAccessorMismatch.p1, Decl(abstractPropertyNegative.ts, 36, 41), Decl(abstractPropertyNegative.ts, 37, 30)) +>val : Symbol(val, Decl(abstractPropertyNegative.ts, 38, 11)) + + get p2(): string { return "should work"; } +>p2 : Symbol(AbstractAccessorMismatch.p2, Decl(abstractPropertyNegative.ts, 38, 28), Decl(abstractPropertyNegative.ts, 39, 46)) + + abstract set p2(val: string); +>p2 : Symbol(AbstractAccessorMismatch.p2, Decl(abstractPropertyNegative.ts, 38, 28), Decl(abstractPropertyNegative.ts, 39, 46)) +>val : Symbol(val, Decl(abstractPropertyNegative.ts, 40, 20)) +} + diff --git a/tests/baselines/reference/abstractPropertyNegative.types b/tests/baselines/reference/abstractPropertyNegative.types new file mode 100644 index 00000000000..371a84e8e91 --- /dev/null +++ b/tests/baselines/reference/abstractPropertyNegative.types @@ -0,0 +1,115 @@ +=== tests/cases/compiler/abstractPropertyNegative.ts === +interface A { +>A : A + + prop: string; +>prop : string + + m(): string; +>m : () => string +} +abstract class B implements A { +>B : B +>A : A + + abstract prop: string; +>prop : string + + public abstract readonly ro: string; +>ro : string + + abstract get readonlyProp(): string; +>readonlyProp : string + + abstract m(): string; +>m : () => string + + abstract get mismatch(): string; +>mismatch : string + + abstract set mismatch(val: number); // error, not same type +>mismatch : string +>val : number +} +class C extends B { +>C : C +>B : B + + readonly ro = "readonly please"; +>ro : "readonly please" +>"readonly please" : "readonly please" + + abstract notAllowed: string; +>notAllowed : string + + get concreteWithNoBody(): string; +>concreteWithNoBody : string +} +let c = new C(); +>c : C +>new C() : C +>C : typeof C + +c.ro = "error: lhs of assignment can't be readonly"; +>c.ro = "error: lhs of assignment can't be readonly" : "error: lhs of assignment can't be readonly" +>c.ro : any +>c : C +>ro : any +>"error: lhs of assignment can't be readonly" : "error: lhs of assignment can't be readonly" + +abstract class WrongTypeProperty { +>WrongTypeProperty : WrongTypeProperty + + abstract num: number; +>num : number +} +class WrongTypePropertyImpl extends WrongTypeProperty { +>WrongTypePropertyImpl : WrongTypePropertyImpl +>WrongTypeProperty : WrongTypeProperty + + num = "nope, wrong"; +>num : string +>"nope, wrong" : "nope, wrong" +} +abstract class WrongTypeAccessor { +>WrongTypeAccessor : WrongTypeAccessor + + abstract get num(): number; +>num : number +} +class WrongTypeAccessorImpl extends WrongTypeAccessor { +>WrongTypeAccessorImpl : WrongTypeAccessorImpl +>WrongTypeAccessor : WrongTypeAccessor + + get num() { return "nope, wrong"; } +>num : string +>"nope, wrong" : "nope, wrong" +} +class WrongTypeAccessorImpl2 extends WrongTypeAccessor { +>WrongTypeAccessorImpl2 : WrongTypeAccessorImpl2 +>WrongTypeAccessor : WrongTypeAccessor + + num = "nope, wrong"; +>num : string +>"nope, wrong" : "nope, wrong" +} + +abstract class AbstractAccessorMismatch { +>AbstractAccessorMismatch : AbstractAccessorMismatch + + abstract get p1(): string; +>p1 : string + + set p1(val: string) { }; +>p1 : string +>val : string + + get p2(): string { return "should work"; } +>p2 : string +>"should work" : "should work" + + abstract set p2(val: string); +>p2 : string +>val : string +} + diff --git a/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.symbols b/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.symbols new file mode 100644 index 00000000000..3c311ab6fab --- /dev/null +++ b/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts === +class C { +>C : Symbol(C, Decl(accessInstanceMemberFromStaticMethod01.ts, 0, 0)) + + static foo: string; +>foo : Symbol(C.foo, Decl(accessInstanceMemberFromStaticMethod01.ts, 0, 9)) + + bar() { +>bar : Symbol(C.bar, Decl(accessInstanceMemberFromStaticMethod01.ts, 1, 23)) + + let k = foo; +>k : Symbol(k, Decl(accessInstanceMemberFromStaticMethod01.ts, 4, 11)) + } +} diff --git a/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.types b/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.types new file mode 100644 index 00000000000..a0538378bd5 --- /dev/null +++ b/tests/baselines/reference/accessInstanceMemberFromStaticMethod01.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/accessInstanceMemberFromStaticMethod01.ts === +class C { +>C : C + + static foo: string; +>foo : string + + bar() { +>bar : () => void + + let k = foo; +>k : any +>foo : any + } +} diff --git a/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.symbols b/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.symbols new file mode 100644 index 00000000000..f805a90ccc4 --- /dev/null +++ b/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts === +class C { +>C : Symbol(C, Decl(accessStaticMemberFromInstanceMethod01.ts, 0, 0)) + + foo: string; +>foo : Symbol(C.foo, Decl(accessStaticMemberFromInstanceMethod01.ts, 0, 9)) + + static bar() { +>bar : Symbol(C.bar, Decl(accessStaticMemberFromInstanceMethod01.ts, 1, 16)) + + let k = foo; +>k : Symbol(k, Decl(accessStaticMemberFromInstanceMethod01.ts, 4, 11)) + } +} diff --git a/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.types b/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.types new file mode 100644 index 00000000000..7411ba1de69 --- /dev/null +++ b/tests/baselines/reference/accessStaticMemberFromInstanceMethod01.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/accessStaticMemberFromInstanceMethod01.ts === +class C { +>C : C + + foo: string; +>foo : string + + static bar() { +>bar : () => void + + let k = foo; +>k : any +>foo : any + } +} diff --git a/tests/baselines/reference/accessibilityModifiers.symbols b/tests/baselines/reference/accessibilityModifiers.symbols new file mode 100644 index 00000000000..09548fe13a1 --- /dev/null +++ b/tests/baselines/reference/accessibilityModifiers.symbols @@ -0,0 +1,107 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts === +// No errors +class C { +>C : Symbol(C, Decl(accessibilityModifiers.ts, 0, 0)) + + private static privateProperty; +>privateProperty : Symbol(C.privateProperty, Decl(accessibilityModifiers.ts, 1, 9)) + + private static privateMethod() { } +>privateMethod : Symbol(C.privateMethod, Decl(accessibilityModifiers.ts, 2, 35)) + + private static get privateGetter() { return 0; } +>privateGetter : Symbol(C.privateGetter, Decl(accessibilityModifiers.ts, 3, 38)) + + private static set privateSetter(a: number) { } +>privateSetter : Symbol(C.privateSetter, Decl(accessibilityModifiers.ts, 4, 52)) +>a : Symbol(a, Decl(accessibilityModifiers.ts, 5, 37)) + + protected static protectedProperty; +>protectedProperty : Symbol(C.protectedProperty, Decl(accessibilityModifiers.ts, 5, 51)) + + protected static protectedMethod() { } +>protectedMethod : Symbol(C.protectedMethod, Decl(accessibilityModifiers.ts, 7, 39)) + + protected static get protectedGetter() { return 0; } +>protectedGetter : Symbol(C.protectedGetter, Decl(accessibilityModifiers.ts, 8, 42)) + + protected static set protectedSetter(a: number) { } +>protectedSetter : Symbol(C.protectedSetter, Decl(accessibilityModifiers.ts, 9, 56)) +>a : Symbol(a, Decl(accessibilityModifiers.ts, 10, 41)) + + public static publicProperty; +>publicProperty : Symbol(C.publicProperty, Decl(accessibilityModifiers.ts, 10, 55)) + + public static publicMethod() { } +>publicMethod : Symbol(C.publicMethod, Decl(accessibilityModifiers.ts, 12, 33)) + + public static get publicGetter() { return 0; } +>publicGetter : Symbol(C.publicGetter, Decl(accessibilityModifiers.ts, 13, 36)) + + public static set publicSetter(a: number) { } +>publicSetter : Symbol(C.publicSetter, Decl(accessibilityModifiers.ts, 14, 50)) +>a : Symbol(a, Decl(accessibilityModifiers.ts, 15, 35)) +} + +// Errors, accessibility modifiers must precede static +class D { +>D : Symbol(D, Decl(accessibilityModifiers.ts, 16, 1)) + + static private privateProperty; +>privateProperty : Symbol(D.privateProperty, Decl(accessibilityModifiers.ts, 19, 9)) + + static private privateMethod() { } +>privateMethod : Symbol(D.privateMethod, Decl(accessibilityModifiers.ts, 20, 35)) + + static private get privateGetter() { return 0; } +>privateGetter : Symbol(D.privateGetter, Decl(accessibilityModifiers.ts, 21, 38)) + + static private set privateSetter(a: number) { } +>privateSetter : Symbol(D.privateSetter, Decl(accessibilityModifiers.ts, 22, 52)) +>a : Symbol(a, Decl(accessibilityModifiers.ts, 23, 37)) + + static protected protectedProperty; +>protectedProperty : Symbol(D.protectedProperty, Decl(accessibilityModifiers.ts, 23, 51)) + + static protected protectedMethod() { } +>protectedMethod : Symbol(D.protectedMethod, Decl(accessibilityModifiers.ts, 25, 39)) + + static protected get protectedGetter() { return 0; } +>protectedGetter : Symbol(D.protectedGetter, Decl(accessibilityModifiers.ts, 26, 42)) + + static protected set protectedSetter(a: number) { } +>protectedSetter : Symbol(D.protectedSetter, Decl(accessibilityModifiers.ts, 27, 56)) +>a : Symbol(a, Decl(accessibilityModifiers.ts, 28, 41)) + + static public publicProperty; +>publicProperty : Symbol(D.publicProperty, Decl(accessibilityModifiers.ts, 28, 55)) + + static public publicMethod() { } +>publicMethod : Symbol(D.publicMethod, Decl(accessibilityModifiers.ts, 30, 33)) + + static public get publicGetter() { return 0; } +>publicGetter : Symbol(D.publicGetter, Decl(accessibilityModifiers.ts, 31, 36)) + + static public set publicSetter(a: number) { } +>publicSetter : Symbol(D.publicSetter, Decl(accessibilityModifiers.ts, 32, 50)) +>a : Symbol(a, Decl(accessibilityModifiers.ts, 33, 35)) +} + +// Errors, multiple accessibility modifier +class E { +>E : Symbol(E, Decl(accessibilityModifiers.ts, 34, 1)) + + private public protected property; +>property : Symbol(E.property, Decl(accessibilityModifiers.ts, 37, 9)) + + public protected method() { } +>method : Symbol(E.method, Decl(accessibilityModifiers.ts, 38, 38)) + + private protected get getter() { return 0; } +>getter : Symbol(E.getter, Decl(accessibilityModifiers.ts, 39, 33)) + + public public set setter(a: number) { } +>setter : Symbol(E.setter, Decl(accessibilityModifiers.ts, 40, 48)) +>a : Symbol(a, Decl(accessibilityModifiers.ts, 41, 29)) +} + diff --git a/tests/baselines/reference/accessibilityModifiers.types b/tests/baselines/reference/accessibilityModifiers.types new file mode 100644 index 00000000000..5dd3f3b7608 --- /dev/null +++ b/tests/baselines/reference/accessibilityModifiers.types @@ -0,0 +1,114 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/accessibilityModifiers.ts === +// No errors +class C { +>C : C + + private static privateProperty; +>privateProperty : any + + private static privateMethod() { } +>privateMethod : () => void + + private static get privateGetter() { return 0; } +>privateGetter : number +>0 : 0 + + private static set privateSetter(a: number) { } +>privateSetter : number +>a : number + + protected static protectedProperty; +>protectedProperty : any + + protected static protectedMethod() { } +>protectedMethod : () => void + + protected static get protectedGetter() { return 0; } +>protectedGetter : number +>0 : 0 + + protected static set protectedSetter(a: number) { } +>protectedSetter : number +>a : number + + public static publicProperty; +>publicProperty : any + + public static publicMethod() { } +>publicMethod : () => void + + public static get publicGetter() { return 0; } +>publicGetter : number +>0 : 0 + + public static set publicSetter(a: number) { } +>publicSetter : number +>a : number +} + +// Errors, accessibility modifiers must precede static +class D { +>D : D + + static private privateProperty; +>privateProperty : any + + static private privateMethod() { } +>privateMethod : () => void + + static private get privateGetter() { return 0; } +>privateGetter : number +>0 : 0 + + static private set privateSetter(a: number) { } +>privateSetter : number +>a : number + + static protected protectedProperty; +>protectedProperty : any + + static protected protectedMethod() { } +>protectedMethod : () => void + + static protected get protectedGetter() { return 0; } +>protectedGetter : number +>0 : 0 + + static protected set protectedSetter(a: number) { } +>protectedSetter : number +>a : number + + static public publicProperty; +>publicProperty : any + + static public publicMethod() { } +>publicMethod : () => void + + static public get publicGetter() { return 0; } +>publicGetter : number +>0 : 0 + + static public set publicSetter(a: number) { } +>publicSetter : number +>a : number +} + +// Errors, multiple accessibility modifier +class E { +>E : E + + private public protected property; +>property : any + + public protected method() { } +>method : () => void + + private protected get getter() { return 0; } +>getter : number +>0 : 0 + + public public set setter(a: number) { } +>setter : number +>a : number +} + diff --git a/tests/baselines/reference/accessorParameterAccessibilityModifier.symbols b/tests/baselines/reference/accessorParameterAccessibilityModifier.symbols new file mode 100644 index 00000000000..76290d8d209 --- /dev/null +++ b/tests/baselines/reference/accessorParameterAccessibilityModifier.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/accessorParameterAccessibilityModifier.ts === +class C { +>C : Symbol(C, Decl(accessorParameterAccessibilityModifier.ts, 0, 0)) + + set X(public v) { } +>X : Symbol(C.X, Decl(accessorParameterAccessibilityModifier.ts, 0, 9)) +>v : Symbol(v, Decl(accessorParameterAccessibilityModifier.ts, 1, 10)) + + static set X(public v2) { } +>X : Symbol(C.X, Decl(accessorParameterAccessibilityModifier.ts, 1, 23)) +>v2 : Symbol(v2, Decl(accessorParameterAccessibilityModifier.ts, 2, 17)) +} diff --git a/tests/baselines/reference/accessorParameterAccessibilityModifier.types b/tests/baselines/reference/accessorParameterAccessibilityModifier.types new file mode 100644 index 00000000000..0201a9d60ee --- /dev/null +++ b/tests/baselines/reference/accessorParameterAccessibilityModifier.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/accessorParameterAccessibilityModifier.ts === +class C { +>C : C + + set X(public v) { } +>X : any +>v : any + + static set X(public v2) { } +>X : any +>v2 : any +} diff --git a/tests/baselines/reference/accessorWithES3.symbols b/tests/baselines/reference/accessorWithES3.symbols new file mode 100644 index 00000000000..5b1e0cae1b7 --- /dev/null +++ b/tests/baselines/reference/accessorWithES3.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts === +// error to use accessors in ES3 mode + +class C { +>C : Symbol(C, Decl(accessorWithES3.ts, 0, 0)) + + get x() { +>x : Symbol(C.x, Decl(accessorWithES3.ts, 2, 9)) + + return 1; + } +} + +class D { +>D : Symbol(D, Decl(accessorWithES3.ts, 6, 1)) + + set x(v) { +>x : Symbol(D.x, Decl(accessorWithES3.ts, 8, 9)) +>v : Symbol(v, Decl(accessorWithES3.ts, 9, 10)) + } +} + +var x = { +>x : Symbol(x, Decl(accessorWithES3.ts, 13, 3)) + + get a() { return 1 } +>a : Symbol(a, Decl(accessorWithES3.ts, 13, 9)) +} + +var y = { +>y : Symbol(y, Decl(accessorWithES3.ts, 17, 3)) + + set b(v) { } +>b : Symbol(b, Decl(accessorWithES3.ts, 17, 9)) +>v : Symbol(v, Decl(accessorWithES3.ts, 18, 10)) +} diff --git a/tests/baselines/reference/accessorWithES3.types b/tests/baselines/reference/accessorWithES3.types new file mode 100644 index 00000000000..b3c8353b96c --- /dev/null +++ b/tests/baselines/reference/accessorWithES3.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithES3.ts === +// error to use accessors in ES3 mode + +class C { +>C : C + + get x() { +>x : number + + return 1; +>1 : 1 + } +} + +class D { +>D : D + + set x(v) { +>x : any +>v : any + } +} + +var x = { +>x : { readonly a: number; } +>{ get a() { return 1 }} : { readonly a: number; } + + get a() { return 1 } +>a : number +>1 : 1 +} + +var y = { +>y : { b: any; } +>{ set b(v) { }} : { b: any; } + + set b(v) { } +>b : any +>v : any +} diff --git a/tests/baselines/reference/accessorWithInitializer.symbols b/tests/baselines/reference/accessorWithInitializer.symbols new file mode 100644 index 00000000000..7bf6716f146 --- /dev/null +++ b/tests/baselines/reference/accessorWithInitializer.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/accessorWithInitializer.ts === +class C { +>C : Symbol(C, Decl(accessorWithInitializer.ts, 0, 0)) + + set X(v = 0) { } +>X : Symbol(C.X, Decl(accessorWithInitializer.ts, 0, 9)) +>v : Symbol(v, Decl(accessorWithInitializer.ts, 1, 10)) + + static set X(v2 = 0) { } +>X : Symbol(C.X, Decl(accessorWithInitializer.ts, 1, 20)) +>v2 : Symbol(v2, Decl(accessorWithInitializer.ts, 2, 17)) +} diff --git a/tests/baselines/reference/accessorWithInitializer.types b/tests/baselines/reference/accessorWithInitializer.types new file mode 100644 index 00000000000..407bf158d1c --- /dev/null +++ b/tests/baselines/reference/accessorWithInitializer.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/accessorWithInitializer.ts === +class C { +>C : C + + set X(v = 0) { } +>X : any +>v : number +>0 : 0 + + static set X(v2 = 0) { } +>X : any +>v2 : number +>0 : 0 +} diff --git a/tests/baselines/reference/accessorWithMismatchedAccessibilityModifiers.symbols b/tests/baselines/reference/accessorWithMismatchedAccessibilityModifiers.symbols new file mode 100644 index 00000000000..b3c626c0283 --- /dev/null +++ b/tests/baselines/reference/accessorWithMismatchedAccessibilityModifiers.symbols @@ -0,0 +1,56 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts === +class C { +>C : Symbol(C, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 0, 0)) + + get x() { +>x : Symbol(C.x, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 0, 9), Decl(accessorWithMismatchedAccessibilityModifiers.ts, 3, 5)) + + return 1; + } + private set x(v) { +>x : Symbol(C.x, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 0, 9), Decl(accessorWithMismatchedAccessibilityModifiers.ts, 3, 5)) +>v : Symbol(v, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 4, 18)) + } +} + +class D { +>D : Symbol(D, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 6, 1)) + + protected get x() { +>x : Symbol(D.x, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 8, 9), Decl(accessorWithMismatchedAccessibilityModifiers.ts, 11, 5)) + + return 1; + } + private set x(v) { +>x : Symbol(D.x, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 8, 9), Decl(accessorWithMismatchedAccessibilityModifiers.ts, 11, 5)) +>v : Symbol(v, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 12, 18)) + } +} + +class E { +>E : Symbol(E, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 14, 1)) + + protected set x(v) { +>x : Symbol(E.x, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 16, 9), Decl(accessorWithMismatchedAccessibilityModifiers.ts, 18, 5)) +>v : Symbol(v, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 17, 20)) + } + get x() { +>x : Symbol(E.x, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 16, 9), Decl(accessorWithMismatchedAccessibilityModifiers.ts, 18, 5)) + + return 1; + } +} + +class F { +>F : Symbol(F, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 22, 1)) + + protected static set x(v) { +>x : Symbol(F.x, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 24, 9), Decl(accessorWithMismatchedAccessibilityModifiers.ts, 26, 5)) +>v : Symbol(v, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 25, 27)) + } + static get x() { +>x : Symbol(F.x, Decl(accessorWithMismatchedAccessibilityModifiers.ts, 24, 9), Decl(accessorWithMismatchedAccessibilityModifiers.ts, 26, 5)) + + return 1; + } +} diff --git a/tests/baselines/reference/accessorWithMismatchedAccessibilityModifiers.types b/tests/baselines/reference/accessorWithMismatchedAccessibilityModifiers.types new file mode 100644 index 00000000000..82902331573 --- /dev/null +++ b/tests/baselines/reference/accessorWithMismatchedAccessibilityModifiers.types @@ -0,0 +1,60 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorWithMismatchedAccessibilityModifiers.ts === +class C { +>C : C + + get x() { +>x : number + + return 1; +>1 : 1 + } + private set x(v) { +>x : number +>v : number + } +} + +class D { +>D : D + + protected get x() { +>x : number + + return 1; +>1 : 1 + } + private set x(v) { +>x : number +>v : number + } +} + +class E { +>E : E + + protected set x(v) { +>x : number +>v : number + } + get x() { +>x : number + + return 1; +>1 : 1 + } +} + +class F { +>F : F + + protected static set x(v) { +>x : number +>v : number + } + static get x() { +>x : number + + return 1; +>1 : 1 + } +} diff --git a/tests/baselines/reference/accessorWithRestParam.symbols b/tests/baselines/reference/accessorWithRestParam.symbols new file mode 100644 index 00000000000..204df594b24 --- /dev/null +++ b/tests/baselines/reference/accessorWithRestParam.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/accessorWithRestParam.ts === +class C { +>C : Symbol(C, Decl(accessorWithRestParam.ts, 0, 0)) + + set X(...v) { } +>X : Symbol(C.X, Decl(accessorWithRestParam.ts, 0, 9)) +>v : Symbol(v, Decl(accessorWithRestParam.ts, 1, 10)) + + static set X(...v2) { } +>X : Symbol(C.X, Decl(accessorWithRestParam.ts, 1, 19)) +>v2 : Symbol(v2, Decl(accessorWithRestParam.ts, 2, 17)) +} diff --git a/tests/baselines/reference/accessorWithRestParam.types b/tests/baselines/reference/accessorWithRestParam.types new file mode 100644 index 00000000000..d447c1693d1 --- /dev/null +++ b/tests/baselines/reference/accessorWithRestParam.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/accessorWithRestParam.ts === +class C { +>C : C + + set X(...v) { } +>X : any +>v : any[] + + static set X(...v2) { } +>X : any +>v2 : any[] +} diff --git a/tests/baselines/reference/accessorWithoutBody1.symbols b/tests/baselines/reference/accessorWithoutBody1.symbols new file mode 100644 index 00000000000..8b7b5f4fc6d --- /dev/null +++ b/tests/baselines/reference/accessorWithoutBody1.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/accessorWithoutBody1.ts === +var v = { get foo() } +>v : Symbol(v, Decl(accessorWithoutBody1.ts, 0, 3)) +>foo : Symbol(foo, Decl(accessorWithoutBody1.ts, 0, 9)) + diff --git a/tests/baselines/reference/accessorWithoutBody1.types b/tests/baselines/reference/accessorWithoutBody1.types new file mode 100644 index 00000000000..aa70f78e120 --- /dev/null +++ b/tests/baselines/reference/accessorWithoutBody1.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/accessorWithoutBody1.ts === +var v = { get foo() } +>v : { readonly foo: any; } +>{ get foo() } : { readonly foo: any; } +>foo : any + diff --git a/tests/baselines/reference/accessorWithoutBody2.symbols b/tests/baselines/reference/accessorWithoutBody2.symbols new file mode 100644 index 00000000000..242f59a7f50 --- /dev/null +++ b/tests/baselines/reference/accessorWithoutBody2.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/accessorWithoutBody2.ts === +var v = { set foo(a) } +>v : Symbol(v, Decl(accessorWithoutBody2.ts, 0, 3)) +>foo : Symbol(foo, Decl(accessorWithoutBody2.ts, 0, 9)) +>a : Symbol(a, Decl(accessorWithoutBody2.ts, 0, 18)) + diff --git a/tests/baselines/reference/accessorWithoutBody2.types b/tests/baselines/reference/accessorWithoutBody2.types new file mode 100644 index 00000000000..19e9b941ead --- /dev/null +++ b/tests/baselines/reference/accessorWithoutBody2.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/accessorWithoutBody2.ts === +var v = { set foo(a) } +>v : { foo: any; } +>{ set foo(a) } : { foo: any; } +>foo : any +>a : any + diff --git a/tests/baselines/reference/accessorsAreNotContextuallyTyped.symbols b/tests/baselines/reference/accessorsAreNotContextuallyTyped.symbols new file mode 100644 index 00000000000..0589eb7f4a8 --- /dev/null +++ b/tests/baselines/reference/accessorsAreNotContextuallyTyped.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorsAreNotContextuallyTyped.ts === +// accessors are not contextually typed + +class C { +>C : Symbol(C, Decl(accessorsAreNotContextuallyTyped.ts, 0, 0)) + + set x(v: (a: string) => string) { +>x : Symbol(C.x, Decl(accessorsAreNotContextuallyTyped.ts, 2, 9), Decl(accessorsAreNotContextuallyTyped.ts, 4, 5)) +>v : Symbol(v, Decl(accessorsAreNotContextuallyTyped.ts, 3, 10)) +>a : Symbol(a, Decl(accessorsAreNotContextuallyTyped.ts, 3, 14)) + } + + get x() { +>x : Symbol(C.x, Decl(accessorsAreNotContextuallyTyped.ts, 2, 9), Decl(accessorsAreNotContextuallyTyped.ts, 4, 5)) + + return (x: string) => ""; +>x : Symbol(x, Decl(accessorsAreNotContextuallyTyped.ts, 7, 16)) + } +} + +var c: C; +>c : Symbol(c, Decl(accessorsAreNotContextuallyTyped.ts, 11, 3)) +>C : Symbol(C, Decl(accessorsAreNotContextuallyTyped.ts, 0, 0)) + +var r = c.x(''); // string +>r : Symbol(r, Decl(accessorsAreNotContextuallyTyped.ts, 12, 3)) +>c.x : Symbol(C.x, Decl(accessorsAreNotContextuallyTyped.ts, 2, 9), Decl(accessorsAreNotContextuallyTyped.ts, 4, 5)) +>c : Symbol(c, Decl(accessorsAreNotContextuallyTyped.ts, 11, 3)) +>x : Symbol(C.x, Decl(accessorsAreNotContextuallyTyped.ts, 2, 9), Decl(accessorsAreNotContextuallyTyped.ts, 4, 5)) + diff --git a/tests/baselines/reference/accessorsAreNotContextuallyTyped.types b/tests/baselines/reference/accessorsAreNotContextuallyTyped.types new file mode 100644 index 00000000000..c48ad593724 --- /dev/null +++ b/tests/baselines/reference/accessorsAreNotContextuallyTyped.types @@ -0,0 +1,34 @@ +=== tests/cases/conformance/classes/propertyMemberDeclarations/memberAccessorDeclarations/accessorsAreNotContextuallyTyped.ts === +// accessors are not contextually typed + +class C { +>C : C + + set x(v: (a: string) => string) { +>x : (a: string) => string +>v : (a: string) => string +>a : string + } + + get x() { +>x : (a: string) => string + + return (x: string) => ""; +>(x: string) => "" : (x: string) => string +>x : string +>"" : "" + } +} + +var c: C; +>c : C +>C : C + +var r = c.x(''); // string +>r : string +>c.x('') : string +>c.x : (a: string) => string +>c : C +>x : (a: string) => string +>'' : "" + diff --git a/tests/baselines/reference/accessorsEmit.symbols b/tests/baselines/reference/accessorsEmit.symbols new file mode 100644 index 00000000000..119d81d369a --- /dev/null +++ b/tests/baselines/reference/accessorsEmit.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/accessorsEmit.ts === +class Result { } +>Result : Symbol(Result, Decl(accessorsEmit.ts, 0, 0)) + +class Test { +>Test : Symbol(Test, Decl(accessorsEmit.ts, 0, 16)) + + get Property(): Result { +>Property : Symbol(Test.Property, Decl(accessorsEmit.ts, 2, 12)) +>Result : Symbol(Result, Decl(accessorsEmit.ts, 0, 0)) + + var x = 1; +>x : Symbol(x, Decl(accessorsEmit.ts, 4, 11)) + + return null; + } +} + +class Test2 { +>Test2 : Symbol(Test2, Decl(accessorsEmit.ts, 7, 1)) + + get Property() { +>Property : Symbol(Test2.Property, Decl(accessorsEmit.ts, 9, 13)) + + var x = 1; +>x : Symbol(x, Decl(accessorsEmit.ts, 11, 11)) + + return null; + } +} diff --git a/tests/baselines/reference/accessorsEmit.types b/tests/baselines/reference/accessorsEmit.types new file mode 100644 index 00000000000..84759cefe87 --- /dev/null +++ b/tests/baselines/reference/accessorsEmit.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/accessorsEmit.ts === +class Result { } +>Result : Result + +class Test { +>Test : Test + + get Property(): Result { +>Property : Result +>Result : Result + + var x = 1; +>x : number +>1 : 1 + + return null; +>null : null + } +} + +class Test2 { +>Test2 : Test2 + + get Property() { +>Property : any + + var x = 1; +>x : number +>1 : 1 + + return null; +>null : null + } +} diff --git a/tests/baselines/reference/accessorsInAmbientContext.symbols b/tests/baselines/reference/accessorsInAmbientContext.symbols new file mode 100644 index 00000000000..4e19cd08f55 --- /dev/null +++ b/tests/baselines/reference/accessorsInAmbientContext.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/accessorsInAmbientContext.ts === +declare module M { +>M : Symbol(M, Decl(accessorsInAmbientContext.ts, 0, 0)) + + class C { +>C : Symbol(C, Decl(accessorsInAmbientContext.ts, 0, 18)) + + get X() { return 1; } +>X : Symbol(C.X, Decl(accessorsInAmbientContext.ts, 1, 13), Decl(accessorsInAmbientContext.ts, 2, 29)) + + set X(v) { } +>X : Symbol(C.X, Decl(accessorsInAmbientContext.ts, 1, 13), Decl(accessorsInAmbientContext.ts, 2, 29)) +>v : Symbol(v, Decl(accessorsInAmbientContext.ts, 3, 14)) + + static get Y() { return 1; } +>Y : Symbol(C.Y, Decl(accessorsInAmbientContext.ts, 3, 20), Decl(accessorsInAmbientContext.ts, 5, 36)) + + static set Y(v) { } +>Y : Symbol(C.Y, Decl(accessorsInAmbientContext.ts, 3, 20), Decl(accessorsInAmbientContext.ts, 5, 36)) +>v : Symbol(v, Decl(accessorsInAmbientContext.ts, 6, 21)) + } +} + +declare class C { +>C : Symbol(C, Decl(accessorsInAmbientContext.ts, 8, 1)) + + get X() { return 1; } +>X : Symbol(C.X, Decl(accessorsInAmbientContext.ts, 10, 17), Decl(accessorsInAmbientContext.ts, 11, 25)) + + set X(v) { } +>X : Symbol(C.X, Decl(accessorsInAmbientContext.ts, 10, 17), Decl(accessorsInAmbientContext.ts, 11, 25)) +>v : Symbol(v, Decl(accessorsInAmbientContext.ts, 12, 10)) + + static get Y() { return 1; } +>Y : Symbol(C.Y, Decl(accessorsInAmbientContext.ts, 12, 16), Decl(accessorsInAmbientContext.ts, 14, 32)) + + static set Y(v) { } +>Y : Symbol(C.Y, Decl(accessorsInAmbientContext.ts, 12, 16), Decl(accessorsInAmbientContext.ts, 14, 32)) +>v : Symbol(v, Decl(accessorsInAmbientContext.ts, 15, 17)) +} diff --git a/tests/baselines/reference/accessorsInAmbientContext.types b/tests/baselines/reference/accessorsInAmbientContext.types new file mode 100644 index 00000000000..fd21b158ac3 --- /dev/null +++ b/tests/baselines/reference/accessorsInAmbientContext.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/accessorsInAmbientContext.ts === +declare module M { +>M : typeof M + + class C { +>C : C + + get X() { return 1; } +>X : number +>1 : 1 + + set X(v) { } +>X : number +>v : number + + static get Y() { return 1; } +>Y : number +>1 : 1 + + static set Y(v) { } +>Y : number +>v : number + } +} + +declare class C { +>C : C + + get X() { return 1; } +>X : number +>1 : 1 + + set X(v) { } +>X : number +>v : number + + static get Y() { return 1; } +>Y : number +>1 : 1 + + static set Y(v) { } +>Y : number +>v : number +} diff --git a/tests/baselines/reference/accessorsNotAllowedInES3.symbols b/tests/baselines/reference/accessorsNotAllowedInES3.symbols new file mode 100644 index 00000000000..fc527434f35 --- /dev/null +++ b/tests/baselines/reference/accessorsNotAllowedInES3.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/accessorsNotAllowedInES3.ts === +class C { +>C : Symbol(C, Decl(accessorsNotAllowedInES3.ts, 0, 0)) + + get x(): number { return 1; } +>x : Symbol(C.x, Decl(accessorsNotAllowedInES3.ts, 0, 9)) +} +var y = { get foo() { return 3; } }; +>y : Symbol(y, Decl(accessorsNotAllowedInES3.ts, 3, 3)) +>foo : Symbol(foo, Decl(accessorsNotAllowedInES3.ts, 3, 9)) + diff --git a/tests/baselines/reference/accessorsNotAllowedInES3.types b/tests/baselines/reference/accessorsNotAllowedInES3.types new file mode 100644 index 00000000000..d83911586aa --- /dev/null +++ b/tests/baselines/reference/accessorsNotAllowedInES3.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/accessorsNotAllowedInES3.ts === +class C { +>C : C + + get x(): number { return 1; } +>x : number +>1 : 1 +} +var y = { get foo() { return 3; } }; +>y : { readonly foo: number; } +>{ get foo() { return 3; } } : { readonly foo: number; } +>foo : number +>3 : 3 + diff --git a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.symbols b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.symbols new file mode 100644 index 00000000000..0e8b5ab7b9a --- /dev/null +++ b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts === +class LanguageSpec_section_4_5_error_cases { +>LanguageSpec_section_4_5_error_cases : Symbol(LanguageSpec_section_4_5_error_cases, Decl(accessors_spec_section-4.5_error-cases.ts, 0, 0)) + + public set AnnotatedSetter_SetterFirst(a: number) { } +>AnnotatedSetter_SetterFirst : Symbol(LanguageSpec_section_4_5_error_cases.AnnotatedSetter_SetterFirst, Decl(accessors_spec_section-4.5_error-cases.ts, 0, 44), Decl(accessors_spec_section-4.5_error-cases.ts, 1, 57)) +>a : Symbol(a, Decl(accessors_spec_section-4.5_error-cases.ts, 1, 43)) + + public get AnnotatedSetter_SetterFirst() { return ""; } +>AnnotatedSetter_SetterFirst : Symbol(LanguageSpec_section_4_5_error_cases.AnnotatedSetter_SetterFirst, Decl(accessors_spec_section-4.5_error-cases.ts, 0, 44), Decl(accessors_spec_section-4.5_error-cases.ts, 1, 57)) + + public get AnnotatedSetter_SetterLast() { return ""; } +>AnnotatedSetter_SetterLast : Symbol(LanguageSpec_section_4_5_error_cases.AnnotatedSetter_SetterLast, Decl(accessors_spec_section-4.5_error-cases.ts, 2, 59), Decl(accessors_spec_section-4.5_error-cases.ts, 4, 58)) + + public set AnnotatedSetter_SetterLast(a: number) { } +>AnnotatedSetter_SetterLast : Symbol(LanguageSpec_section_4_5_error_cases.AnnotatedSetter_SetterLast, Decl(accessors_spec_section-4.5_error-cases.ts, 2, 59), Decl(accessors_spec_section-4.5_error-cases.ts, 4, 58)) +>a : Symbol(a, Decl(accessors_spec_section-4.5_error-cases.ts, 5, 42)) + + public get AnnotatedGetter_GetterFirst(): string { return ""; } +>AnnotatedGetter_GetterFirst : Symbol(LanguageSpec_section_4_5_error_cases.AnnotatedGetter_GetterFirst, Decl(accessors_spec_section-4.5_error-cases.ts, 5, 56), Decl(accessors_spec_section-4.5_error-cases.ts, 7, 67)) + + public set AnnotatedGetter_GetterFirst(aStr) { aStr = 0; } +>AnnotatedGetter_GetterFirst : Symbol(LanguageSpec_section_4_5_error_cases.AnnotatedGetter_GetterFirst, Decl(accessors_spec_section-4.5_error-cases.ts, 5, 56), Decl(accessors_spec_section-4.5_error-cases.ts, 7, 67)) +>aStr : Symbol(aStr, Decl(accessors_spec_section-4.5_error-cases.ts, 8, 43)) +>aStr : Symbol(aStr, Decl(accessors_spec_section-4.5_error-cases.ts, 8, 43)) + + public set AnnotatedGetter_GetterLast(aStr) { aStr = 0; } +>AnnotatedGetter_GetterLast : Symbol(LanguageSpec_section_4_5_error_cases.AnnotatedGetter_GetterLast, Decl(accessors_spec_section-4.5_error-cases.ts, 8, 62), Decl(accessors_spec_section-4.5_error-cases.ts, 10, 61)) +>aStr : Symbol(aStr, Decl(accessors_spec_section-4.5_error-cases.ts, 10, 42)) +>aStr : Symbol(aStr, Decl(accessors_spec_section-4.5_error-cases.ts, 10, 42)) + + public get AnnotatedGetter_GetterLast(): string { return ""; } +>AnnotatedGetter_GetterLast : Symbol(LanguageSpec_section_4_5_error_cases.AnnotatedGetter_GetterLast, Decl(accessors_spec_section-4.5_error-cases.ts, 8, 62), Decl(accessors_spec_section-4.5_error-cases.ts, 10, 61)) +} diff --git a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.types b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.types new file mode 100644 index 00000000000..1fd475c579c --- /dev/null +++ b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts === +class LanguageSpec_section_4_5_error_cases { +>LanguageSpec_section_4_5_error_cases : LanguageSpec_section_4_5_error_cases + + public set AnnotatedSetter_SetterFirst(a: number) { } +>AnnotatedSetter_SetterFirst : number +>a : number + + public get AnnotatedSetter_SetterFirst() { return ""; } +>AnnotatedSetter_SetterFirst : number +>"" : "" + + public get AnnotatedSetter_SetterLast() { return ""; } +>AnnotatedSetter_SetterLast : number +>"" : "" + + public set AnnotatedSetter_SetterLast(a: number) { } +>AnnotatedSetter_SetterLast : number +>a : number + + public get AnnotatedGetter_GetterFirst(): string { return ""; } +>AnnotatedGetter_GetterFirst : string +>"" : "" + + public set AnnotatedGetter_GetterFirst(aStr) { aStr = 0; } +>AnnotatedGetter_GetterFirst : string +>aStr : string +>aStr = 0 : 0 +>aStr : string +>0 : 0 + + public set AnnotatedGetter_GetterLast(aStr) { aStr = 0; } +>AnnotatedGetter_GetterLast : string +>aStr : string +>aStr = 0 : 0 +>aStr : string +>0 : 0 + + public get AnnotatedGetter_GetterLast(): string { return ""; } +>AnnotatedGetter_GetterLast : string +>"" : "" +} diff --git a/tests/baselines/reference/accessors_spec_section-4.5_inference.symbols b/tests/baselines/reference/accessors_spec_section-4.5_inference.symbols new file mode 100644 index 00000000000..de8781c42b0 --- /dev/null +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.symbols @@ -0,0 +1,64 @@ +=== tests/cases/compiler/accessors_spec_section-4.5_inference.ts === +class A { } +>A : Symbol(A, Decl(accessors_spec_section-4.5_inference.ts, 0, 0)) + +class B extends A { } +>B : Symbol(B, Decl(accessors_spec_section-4.5_inference.ts, 0, 11)) +>A : Symbol(A, Decl(accessors_spec_section-4.5_inference.ts, 0, 0)) + +class LanguageSpec_section_4_5_inference { +>LanguageSpec_section_4_5_inference : Symbol(LanguageSpec_section_4_5_inference, Decl(accessors_spec_section-4.5_inference.ts, 1, 21)) + + public set InferredGetterFromSetterAnnotation(a: A) { } +>InferredGetterFromSetterAnnotation : Symbol(LanguageSpec_section_4_5_inference.InferredGetterFromSetterAnnotation, Decl(accessors_spec_section-4.5_inference.ts, 3, 42), Decl(accessors_spec_section-4.5_inference.ts, 5, 59)) +>a : Symbol(a, Decl(accessors_spec_section-4.5_inference.ts, 5, 50)) +>A : Symbol(A, Decl(accessors_spec_section-4.5_inference.ts, 0, 0)) + + public get InferredGetterFromSetterAnnotation() { return new B(); } +>InferredGetterFromSetterAnnotation : Symbol(LanguageSpec_section_4_5_inference.InferredGetterFromSetterAnnotation, Decl(accessors_spec_section-4.5_inference.ts, 3, 42), Decl(accessors_spec_section-4.5_inference.ts, 5, 59)) +>B : Symbol(B, Decl(accessors_spec_section-4.5_inference.ts, 0, 11)) + + public get InferredGetterFromSetterAnnotation_GetterFirst() { return new B(); } +>InferredGetterFromSetterAnnotation_GetterFirst : Symbol(LanguageSpec_section_4_5_inference.InferredGetterFromSetterAnnotation_GetterFirst, Decl(accessors_spec_section-4.5_inference.ts, 6, 71), Decl(accessors_spec_section-4.5_inference.ts, 8, 83)) +>B : Symbol(B, Decl(accessors_spec_section-4.5_inference.ts, 0, 11)) + + public set InferredGetterFromSetterAnnotation_GetterFirst(a: A) { } +>InferredGetterFromSetterAnnotation_GetterFirst : Symbol(LanguageSpec_section_4_5_inference.InferredGetterFromSetterAnnotation_GetterFirst, Decl(accessors_spec_section-4.5_inference.ts, 6, 71), Decl(accessors_spec_section-4.5_inference.ts, 8, 83)) +>a : Symbol(a, Decl(accessors_spec_section-4.5_inference.ts, 9, 62)) +>A : Symbol(A, Decl(accessors_spec_section-4.5_inference.ts, 0, 0)) + + + public get InferredFromGetter() { return new B(); } +>InferredFromGetter : Symbol(LanguageSpec_section_4_5_inference.InferredFromGetter, Decl(accessors_spec_section-4.5_inference.ts, 9, 71), Decl(accessors_spec_section-4.5_inference.ts, 12, 55)) +>B : Symbol(B, Decl(accessors_spec_section-4.5_inference.ts, 0, 11)) + + public set InferredFromGetter(a) { } +>InferredFromGetter : Symbol(LanguageSpec_section_4_5_inference.InferredFromGetter, Decl(accessors_spec_section-4.5_inference.ts, 9, 71), Decl(accessors_spec_section-4.5_inference.ts, 12, 55)) +>a : Symbol(a, Decl(accessors_spec_section-4.5_inference.ts, 13, 34)) + + public set InferredFromGetter_SetterFirst(a) { } +>InferredFromGetter_SetterFirst : Symbol(LanguageSpec_section_4_5_inference.InferredFromGetter_SetterFirst, Decl(accessors_spec_section-4.5_inference.ts, 13, 40), Decl(accessors_spec_section-4.5_inference.ts, 15, 52)) +>a : Symbol(a, Decl(accessors_spec_section-4.5_inference.ts, 15, 46)) + + public get InferredFromGetter_SetterFirst() { return new B(); } +>InferredFromGetter_SetterFirst : Symbol(LanguageSpec_section_4_5_inference.InferredFromGetter_SetterFirst, Decl(accessors_spec_section-4.5_inference.ts, 13, 40), Decl(accessors_spec_section-4.5_inference.ts, 15, 52)) +>B : Symbol(B, Decl(accessors_spec_section-4.5_inference.ts, 0, 11)) + + public set InferredSetterFromGetterAnnotation(a) { } +>InferredSetterFromGetterAnnotation : Symbol(LanguageSpec_section_4_5_inference.InferredSetterFromGetterAnnotation, Decl(accessors_spec_section-4.5_inference.ts, 16, 67), Decl(accessors_spec_section-4.5_inference.ts, 18, 56)) +>a : Symbol(a, Decl(accessors_spec_section-4.5_inference.ts, 18, 50)) + + public get InferredSetterFromGetterAnnotation() : A { return new B(); } +>InferredSetterFromGetterAnnotation : Symbol(LanguageSpec_section_4_5_inference.InferredSetterFromGetterAnnotation, Decl(accessors_spec_section-4.5_inference.ts, 16, 67), Decl(accessors_spec_section-4.5_inference.ts, 18, 56)) +>A : Symbol(A, Decl(accessors_spec_section-4.5_inference.ts, 0, 0)) +>B : Symbol(B, Decl(accessors_spec_section-4.5_inference.ts, 0, 11)) + + public get InferredSetterFromGetterAnnotation_GetterFirst() : A { return new B(); } +>InferredSetterFromGetterAnnotation_GetterFirst : Symbol(LanguageSpec_section_4_5_inference.InferredSetterFromGetterAnnotation_GetterFirst, Decl(accessors_spec_section-4.5_inference.ts, 19, 75), Decl(accessors_spec_section-4.5_inference.ts, 21, 87)) +>A : Symbol(A, Decl(accessors_spec_section-4.5_inference.ts, 0, 0)) +>B : Symbol(B, Decl(accessors_spec_section-4.5_inference.ts, 0, 11)) + + public set InferredSetterFromGetterAnnotation_GetterFirst(a) { } +>InferredSetterFromGetterAnnotation_GetterFirst : Symbol(LanguageSpec_section_4_5_inference.InferredSetterFromGetterAnnotation_GetterFirst, Decl(accessors_spec_section-4.5_inference.ts, 19, 75), Decl(accessors_spec_section-4.5_inference.ts, 21, 87)) +>a : Symbol(a, Decl(accessors_spec_section-4.5_inference.ts, 22, 62)) +} diff --git a/tests/baselines/reference/accessors_spec_section-4.5_inference.types b/tests/baselines/reference/accessors_spec_section-4.5_inference.types new file mode 100644 index 00000000000..a1d96120634 --- /dev/null +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.types @@ -0,0 +1,70 @@ +=== tests/cases/compiler/accessors_spec_section-4.5_inference.ts === +class A { } +>A : A + +class B extends A { } +>B : B +>A : A + +class LanguageSpec_section_4_5_inference { +>LanguageSpec_section_4_5_inference : LanguageSpec_section_4_5_inference + + public set InferredGetterFromSetterAnnotation(a: A) { } +>InferredGetterFromSetterAnnotation : A +>a : A +>A : A + + public get InferredGetterFromSetterAnnotation() { return new B(); } +>InferredGetterFromSetterAnnotation : A +>new B() : B +>B : typeof B + + public get InferredGetterFromSetterAnnotation_GetterFirst() { return new B(); } +>InferredGetterFromSetterAnnotation_GetterFirst : A +>new B() : B +>B : typeof B + + public set InferredGetterFromSetterAnnotation_GetterFirst(a: A) { } +>InferredGetterFromSetterAnnotation_GetterFirst : A +>a : A +>A : A + + + public get InferredFromGetter() { return new B(); } +>InferredFromGetter : B +>new B() : B +>B : typeof B + + public set InferredFromGetter(a) { } +>InferredFromGetter : B +>a : B + + public set InferredFromGetter_SetterFirst(a) { } +>InferredFromGetter_SetterFirst : B +>a : B + + public get InferredFromGetter_SetterFirst() { return new B(); } +>InferredFromGetter_SetterFirst : B +>new B() : B +>B : typeof B + + public set InferredSetterFromGetterAnnotation(a) { } +>InferredSetterFromGetterAnnotation : A +>a : A + + public get InferredSetterFromGetterAnnotation() : A { return new B(); } +>InferredSetterFromGetterAnnotation : A +>A : A +>new B() : B +>B : typeof B + + public get InferredSetterFromGetterAnnotation_GetterFirst() : A { return new B(); } +>InferredSetterFromGetterAnnotation_GetterFirst : A +>A : A +>new B() : B +>B : typeof B + + public set InferredSetterFromGetterAnnotation_GetterFirst(a) { } +>InferredSetterFromGetterAnnotation_GetterFirst : A +>a : A +} diff --git a/tests/baselines/reference/addMoreOverloadsToBaseSignature.symbols b/tests/baselines/reference/addMoreOverloadsToBaseSignature.symbols new file mode 100644 index 00000000000..b75df57e2dc --- /dev/null +++ b/tests/baselines/reference/addMoreOverloadsToBaseSignature.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/addMoreOverloadsToBaseSignature.ts === +interface Foo { +>Foo : Symbol(Foo, Decl(addMoreOverloadsToBaseSignature.ts, 0, 0)) + + f(): string; +>f : Symbol(Foo.f, Decl(addMoreOverloadsToBaseSignature.ts, 0, 15)) +} + +interface Bar extends Foo { +>Bar : Symbol(Bar, Decl(addMoreOverloadsToBaseSignature.ts, 2, 1)) +>Foo : Symbol(Foo, Decl(addMoreOverloadsToBaseSignature.ts, 0, 0)) + + f(key: string): string; +>f : Symbol(Bar.f, Decl(addMoreOverloadsToBaseSignature.ts, 4, 27)) +>key : Symbol(key, Decl(addMoreOverloadsToBaseSignature.ts, 5, 6)) +} + diff --git a/tests/baselines/reference/addMoreOverloadsToBaseSignature.types b/tests/baselines/reference/addMoreOverloadsToBaseSignature.types new file mode 100644 index 00000000000..02a566217ad --- /dev/null +++ b/tests/baselines/reference/addMoreOverloadsToBaseSignature.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/addMoreOverloadsToBaseSignature.ts === +interface Foo { +>Foo : Foo + + f(): string; +>f : () => string +} + +interface Bar extends Foo { +>Bar : Bar +>Foo : Foo + + f(key: string): string; +>f : (key: string) => string +>key : string +} + diff --git a/tests/baselines/reference/additionOperatorWithInvalidOperands.symbols b/tests/baselines/reference/additionOperatorWithInvalidOperands.symbols new file mode 100644 index 00000000000..7f734550635 --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithInvalidOperands.symbols @@ -0,0 +1,142 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts === +function foo() { } +>foo : Symbol(foo, Decl(additionOperatorWithInvalidOperands.ts, 0, 0)) + +class C { +>C : Symbol(C, Decl(additionOperatorWithInvalidOperands.ts, 0, 18)) + + public a: string; +>a : Symbol(C.a, Decl(additionOperatorWithInvalidOperands.ts, 1, 9)) + + static foo() { } +>foo : Symbol(C.foo, Decl(additionOperatorWithInvalidOperands.ts, 2, 21)) +} +enum E { a, b, c } +>E : Symbol(E, Decl(additionOperatorWithInvalidOperands.ts, 4, 1)) +>a : Symbol(E.a, Decl(additionOperatorWithInvalidOperands.ts, 5, 8)) +>b : Symbol(E.b, Decl(additionOperatorWithInvalidOperands.ts, 5, 11)) +>c : Symbol(E.c, Decl(additionOperatorWithInvalidOperands.ts, 5, 14)) + +module M { export var a } +>M : Symbol(M, Decl(additionOperatorWithInvalidOperands.ts, 5, 18)) +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 6, 21)) + +var a: boolean; +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 8, 3)) + +var b: number; +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) + +var c: Object; +>c : Symbol(c, Decl(additionOperatorWithInvalidOperands.ts, 10, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var d: Number; +>d : Symbol(d, Decl(additionOperatorWithInvalidOperands.ts, 11, 3)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +// boolean + every type except any and string +var r1 = a + a; +>r1 : Symbol(r1, Decl(additionOperatorWithInvalidOperands.ts, 14, 3)) +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 8, 3)) + +var r2 = a + b; +>r2 : Symbol(r2, Decl(additionOperatorWithInvalidOperands.ts, 15, 3)) +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) + +var r3 = a + c; +>r3 : Symbol(r3, Decl(additionOperatorWithInvalidOperands.ts, 16, 3)) +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(additionOperatorWithInvalidOperands.ts, 10, 3)) + +// number + every type except any and string +var r4 = b + a; +>r4 : Symbol(r4, Decl(additionOperatorWithInvalidOperands.ts, 19, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 8, 3)) + +var r5 = b + b; // number + number is valid +>r5 : Symbol(r5, Decl(additionOperatorWithInvalidOperands.ts, 20, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) + +var r6 = b + c; +>r6 : Symbol(r6, Decl(additionOperatorWithInvalidOperands.ts, 21, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(additionOperatorWithInvalidOperands.ts, 10, 3)) + +// object + every type except any and string +var r7 = c + a; +>r7 : Symbol(r7, Decl(additionOperatorWithInvalidOperands.ts, 24, 3)) +>c : Symbol(c, Decl(additionOperatorWithInvalidOperands.ts, 10, 3)) +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 8, 3)) + +var r8 = c + b; +>r8 : Symbol(r8, Decl(additionOperatorWithInvalidOperands.ts, 25, 3)) +>c : Symbol(c, Decl(additionOperatorWithInvalidOperands.ts, 10, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) + +var r9 = c + c; +>r9 : Symbol(r9, Decl(additionOperatorWithInvalidOperands.ts, 26, 3)) +>c : Symbol(c, Decl(additionOperatorWithInvalidOperands.ts, 10, 3)) +>c : Symbol(c, Decl(additionOperatorWithInvalidOperands.ts, 10, 3)) + +// other cases +var r10 = a + true; +>r10 : Symbol(r10, Decl(additionOperatorWithInvalidOperands.ts, 29, 3)) +>a : Symbol(a, Decl(additionOperatorWithInvalidOperands.ts, 8, 3)) + +var r11 = true + false; +>r11 : Symbol(r11, Decl(additionOperatorWithInvalidOperands.ts, 30, 3)) + +var r12 = true + 123; +>r12 : Symbol(r12, Decl(additionOperatorWithInvalidOperands.ts, 31, 3)) + +var r13 = {} + {}; +>r13 : Symbol(r13, Decl(additionOperatorWithInvalidOperands.ts, 32, 3)) + +var r14 = b + d; +>r14 : Symbol(r14, Decl(additionOperatorWithInvalidOperands.ts, 33, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(additionOperatorWithInvalidOperands.ts, 11, 3)) + +var r15 = b + foo; +>r15 : Symbol(r15, Decl(additionOperatorWithInvalidOperands.ts, 34, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) +>foo : Symbol(foo, Decl(additionOperatorWithInvalidOperands.ts, 0, 0)) + +var r16 = b + foo(); +>r16 : Symbol(r16, Decl(additionOperatorWithInvalidOperands.ts, 35, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) +>foo : Symbol(foo, Decl(additionOperatorWithInvalidOperands.ts, 0, 0)) + +var r17 = b + C; +>r17 : Symbol(r17, Decl(additionOperatorWithInvalidOperands.ts, 36, 3)) +>b : Symbol(b, Decl(additionOperatorWithInvalidOperands.ts, 9, 3)) +>C : Symbol(C, Decl(additionOperatorWithInvalidOperands.ts, 0, 18)) + +var r18 = E.a + new C(); +>r18 : Symbol(r18, Decl(additionOperatorWithInvalidOperands.ts, 37, 3)) +>E.a : Symbol(E.a, Decl(additionOperatorWithInvalidOperands.ts, 5, 8)) +>E : Symbol(E, Decl(additionOperatorWithInvalidOperands.ts, 4, 1)) +>a : Symbol(E.a, Decl(additionOperatorWithInvalidOperands.ts, 5, 8)) +>C : Symbol(C, Decl(additionOperatorWithInvalidOperands.ts, 0, 18)) + +var r19 = E.a + C.foo(); +>r19 : Symbol(r19, Decl(additionOperatorWithInvalidOperands.ts, 38, 3)) +>E.a : Symbol(E.a, Decl(additionOperatorWithInvalidOperands.ts, 5, 8)) +>E : Symbol(E, Decl(additionOperatorWithInvalidOperands.ts, 4, 1)) +>a : Symbol(E.a, Decl(additionOperatorWithInvalidOperands.ts, 5, 8)) +>C.foo : Symbol(C.foo, Decl(additionOperatorWithInvalidOperands.ts, 2, 21)) +>C : Symbol(C, Decl(additionOperatorWithInvalidOperands.ts, 0, 18)) +>foo : Symbol(C.foo, Decl(additionOperatorWithInvalidOperands.ts, 2, 21)) + +var r20 = E.a + M; +>r20 : Symbol(r20, Decl(additionOperatorWithInvalidOperands.ts, 39, 3)) +>E.a : Symbol(E.a, Decl(additionOperatorWithInvalidOperands.ts, 5, 8)) +>E : Symbol(E, Decl(additionOperatorWithInvalidOperands.ts, 4, 1)) +>a : Symbol(E.a, Decl(additionOperatorWithInvalidOperands.ts, 5, 8)) +>M : Symbol(M, Decl(additionOperatorWithInvalidOperands.ts, 5, 18)) + diff --git a/tests/baselines/reference/additionOperatorWithInvalidOperands.types b/tests/baselines/reference/additionOperatorWithInvalidOperands.types new file mode 100644 index 00000000000..9701d8552dd --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithInvalidOperands.types @@ -0,0 +1,172 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts === +function foo() { } +>foo : () => void + +class C { +>C : C + + public a: string; +>a : string + + static foo() { } +>foo : () => void +} +enum E { a, b, c } +>E : E +>a : E.a +>b : E.b +>c : E.c + +module M { export var a } +>M : typeof M +>a : any + +var a: boolean; +>a : boolean + +var b: number; +>b : number + +var c: Object; +>c : Object +>Object : Object + +var d: Number; +>d : Number +>Number : Number + +// boolean + every type except any and string +var r1 = a + a; +>r1 : any +>a + a : any +>a : boolean +>a : boolean + +var r2 = a + b; +>r2 : any +>a + b : any +>a : boolean +>b : number + +var r3 = a + c; +>r3 : any +>a + c : any +>a : boolean +>c : Object + +// number + every type except any and string +var r4 = b + a; +>r4 : any +>b + a : any +>b : number +>a : boolean + +var r5 = b + b; // number + number is valid +>r5 : number +>b + b : number +>b : number +>b : number + +var r6 = b + c; +>r6 : any +>b + c : any +>b : number +>c : Object + +// object + every type except any and string +var r7 = c + a; +>r7 : any +>c + a : any +>c : Object +>a : boolean + +var r8 = c + b; +>r8 : any +>c + b : any +>c : Object +>b : number + +var r9 = c + c; +>r9 : any +>c + c : any +>c : Object +>c : Object + +// other cases +var r10 = a + true; +>r10 : any +>a + true : any +>a : boolean +>true : true + +var r11 = true + false; +>r11 : any +>true + false : any +>true : true +>false : false + +var r12 = true + 123; +>r12 : any +>true + 123 : any +>true : true +>123 : 123 + +var r13 = {} + {}; +>r13 : any +>{} + {} : any +>{} : {} +>{} : {} + +var r14 = b + d; +>r14 : any +>b + d : any +>b : number +>d : Number + +var r15 = b + foo; +>r15 : any +>b + foo : any +>b : number +>foo : () => void + +var r16 = b + foo(); +>r16 : any +>b + foo() : any +>b : number +>foo() : void +>foo : () => void + +var r17 = b + C; +>r17 : any +>b + C : any +>b : number +>C : typeof C + +var r18 = E.a + new C(); +>r18 : any +>E.a + new C() : any +>E.a : E.a +>E : typeof E +>a : E.a +>new C() : C +>C : typeof C + +var r19 = E.a + C.foo(); +>r19 : any +>E.a + C.foo() : any +>E.a : E.a +>E : typeof E +>a : E.a +>C.foo() : void +>C.foo : () => void +>C : typeof C +>foo : () => void + +var r20 = E.a + M; +>r20 : any +>E.a + M : any +>E.a : E.a +>E : typeof E +>a : E.a +>M : typeof M + diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.symbols b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.symbols new file mode 100644 index 00000000000..5ee9952329e --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.symbols @@ -0,0 +1,65 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts === +// If one operand is the null or undefined value, it is treated as having the type of the other operand. + +function foo(): void { return undefined } +>foo : Symbol(foo, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 0, 0)) +>undefined : Symbol(undefined) + +var a: boolean; +>a : Symbol(a, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 4, 3)) + +var b: Object; +>b : Symbol(b, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 5, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var c: void; +>c : Symbol(c, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 6, 3)) + +var d: Number; +>d : Symbol(d, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 7, 3)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +// null + boolean/Object +var r1 = null + a; +>r1 : Symbol(r1, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 10, 3)) +>a : Symbol(a, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 4, 3)) + +var r2 = null + b; +>r2 : Symbol(r2, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 11, 3)) +>b : Symbol(b, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 5, 3)) + +var r3 = null + c; +>r3 : Symbol(r3, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 12, 3)) +>c : Symbol(c, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 6, 3)) + +var r4 = a + null; +>r4 : Symbol(r4, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 13, 3)) +>a : Symbol(a, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 4, 3)) + +var r5 = b + null; +>r5 : Symbol(r5, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 14, 3)) +>b : Symbol(b, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 5, 3)) + +var r6 = null + c; +>r6 : Symbol(r6, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 15, 3)) +>c : Symbol(c, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 6, 3)) + +// other cases +var r7 = null + d; +>r7 : Symbol(r7, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 18, 3)) +>d : Symbol(d, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 7, 3)) + +var r8 = null + true; +>r8 : Symbol(r8, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 19, 3)) + +var r9 = null + { a: '' }; +>r9 : Symbol(r9, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 20, 3)) +>a : Symbol(a, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 20, 17)) + +var r10 = null + foo(); +>r10 : Symbol(r10, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 21, 3)) +>foo : Symbol(foo, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 0, 0)) + +var r11 = null + (() => { }); +>r11 : Symbol(r11, Decl(additionOperatorWithNullValueAndInvalidOperator.ts, 22, 3)) + diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.types b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.types new file mode 100644 index 00000000000..7e0d5d7ab31 --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.types @@ -0,0 +1,93 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts === +// If one operand is the null or undefined value, it is treated as having the type of the other operand. + +function foo(): void { return undefined } +>foo : () => void +>undefined : undefined + +var a: boolean; +>a : boolean + +var b: Object; +>b : Object +>Object : Object + +var c: void; +>c : void + +var d: Number; +>d : Number +>Number : Number + +// null + boolean/Object +var r1 = null + a; +>r1 : any +>null + a : any +>null : null +>a : boolean + +var r2 = null + b; +>r2 : any +>null + b : any +>null : null +>b : Object + +var r3 = null + c; +>r3 : any +>null + c : any +>null : null +>c : void + +var r4 = a + null; +>r4 : any +>a + null : any +>a : boolean +>null : null + +var r5 = b + null; +>r5 : any +>b + null : any +>b : Object +>null : null + +var r6 = null + c; +>r6 : any +>null + c : any +>null : null +>c : void + +// other cases +var r7 = null + d; +>r7 : any +>null + d : any +>null : null +>d : Number + +var r8 = null + true; +>r8 : any +>null + true : any +>null : null +>true : true + +var r9 = null + { a: '' }; +>r9 : any +>null + { a: '' } : any +>null : null +>{ a: '' } : { a: string; } +>a : string +>'' : "" + +var r10 = null + foo(); +>r10 : any +>null + foo() : any +>null : null +>foo() : void +>foo : () => void + +var r11 = null + (() => { }); +>r11 : any +>null + (() => { }) : any +>null : null +>(() => { }) : () => void +>() => { } : () => void + diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.types b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.types index d0feec523b0..e6c8e919de2 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.types +++ b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.types @@ -35,68 +35,68 @@ var r2: any = a + null; // null + number/enum var r3 = null + b; ->r3 : number ->null + b : number +>r3 : any +>null + b : any >null : null >b : number var r4 = null + 1; ->r4 : number ->null + 1 : number +>r4 : any +>null + 1 : any >null : null >1 : 1 var r5 = null + c; ->r5 : number ->null + c : number +>r5 : any +>null + c : any >null : null >c : E var r6 = null + E.a; ->r6 : number ->null + E.a : number +>r6 : any +>null + E.a : any >null : null >E.a : E.a >E : typeof E >a : E.a var r7 = null + E['a']; ->r7 : number ->null + E['a'] : number +>r7 : any +>null + E['a'] : any >null : null >E['a'] : E.a >E : typeof E >'a' : "a" var r8 = b + null; ->r8 : number ->b + null : number +>r8 : any +>b + null : any >b : number >null : null var r9 = 1 + null; ->r9 : number ->1 + null : number +>r9 : any +>1 + null : any >1 : 1 >null : null var r10 = c + null ->r10 : number ->c + null : number +>r10 : any +>c + null : any >c : E >null : null var r11 = E.a + null; ->r11 : number ->E.a + null : number +>r11 : any +>E.a + null : any >E.a : E.a >E : typeof E >a : E.a >null : null var r12 = E['a'] + null; ->r12 : number ->E['a'] + null : number +>r12 : any +>E['a'] + null : any >E['a'] : E.a >E : typeof E >'a' : "a" diff --git a/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.symbols b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.symbols new file mode 100644 index 00000000000..87ae4f5578d --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts === +// bug 819721 +var r1 = null + null; +>r1 : Symbol(r1, Decl(additionOperatorWithOnlyNullValueOrUndefinedValue.ts, 1, 3)) + +var r2 = null + undefined; +>r2 : Symbol(r2, Decl(additionOperatorWithOnlyNullValueOrUndefinedValue.ts, 2, 3)) +>undefined : Symbol(undefined) + +var r3 = undefined + null; +>r3 : Symbol(r3, Decl(additionOperatorWithOnlyNullValueOrUndefinedValue.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r4 = undefined + undefined; +>r4 : Symbol(r4, Decl(additionOperatorWithOnlyNullValueOrUndefinedValue.ts, 4, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.types b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.types new file mode 100644 index 00000000000..b0b4955a846 --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithOnlyNullValueOrUndefinedValue.types @@ -0,0 +1,26 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithOnlyNullValueOrUndefinedValue.ts === +// bug 819721 +var r1 = null + null; +>r1 : any +>null + null : any +>null : null +>null : null + +var r2 = null + undefined; +>r2 : any +>null + undefined : any +>null : null +>undefined : undefined + +var r3 = undefined + null; +>r3 : any +>undefined + null : any +>undefined : undefined +>null : null + +var r4 = undefined + undefined; +>r4 : any +>undefined + undefined : any +>undefined : undefined +>undefined : undefined + diff --git a/tests/baselines/reference/additionOperatorWithTypeParameter.symbols b/tests/baselines/reference/additionOperatorWithTypeParameter.symbols new file mode 100644 index 00000000000..586b85195b6 --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithTypeParameter.symbols @@ -0,0 +1,139 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts === +// type parameter type is not a valid operand of addition operator +enum E { a, b } +>E : Symbol(E, Decl(additionOperatorWithTypeParameter.ts, 0, 0)) +>a : Symbol(E.a, Decl(additionOperatorWithTypeParameter.ts, 1, 8)) +>b : Symbol(E.b, Decl(additionOperatorWithTypeParameter.ts, 1, 11)) + +function foo(t: T, u: U) { +>foo : Symbol(foo, Decl(additionOperatorWithTypeParameter.ts, 1, 15)) +>T : Symbol(T, Decl(additionOperatorWithTypeParameter.ts, 3, 13)) +>U : Symbol(U, Decl(additionOperatorWithTypeParameter.ts, 3, 15)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>T : Symbol(T, Decl(additionOperatorWithTypeParameter.ts, 3, 13)) +>u : Symbol(u, Decl(additionOperatorWithTypeParameter.ts, 3, 24)) +>U : Symbol(U, Decl(additionOperatorWithTypeParameter.ts, 3, 15)) + + var a: any; +>a : Symbol(a, Decl(additionOperatorWithTypeParameter.ts, 4, 7)) + + var b: boolean; +>b : Symbol(b, Decl(additionOperatorWithTypeParameter.ts, 5, 7)) + + var c: number; +>c : Symbol(c, Decl(additionOperatorWithTypeParameter.ts, 6, 7)) + + var d: string; +>d : Symbol(d, Decl(additionOperatorWithTypeParameter.ts, 7, 7)) + + var e: Object; +>e : Symbol(e, Decl(additionOperatorWithTypeParameter.ts, 8, 7)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + var g: E; +>g : Symbol(g, Decl(additionOperatorWithTypeParameter.ts, 9, 7)) +>E : Symbol(E, Decl(additionOperatorWithTypeParameter.ts, 0, 0)) + + var f: void; +>f : Symbol(f, Decl(additionOperatorWithTypeParameter.ts, 10, 7)) + + // type parameter as left operand + var r1: any = t + a; // ok, one operand is any +>r1 : Symbol(r1, Decl(additionOperatorWithTypeParameter.ts, 13, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>a : Symbol(a, Decl(additionOperatorWithTypeParameter.ts, 4, 7)) + + var r2 = t + b; +>r2 : Symbol(r2, Decl(additionOperatorWithTypeParameter.ts, 14, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>b : Symbol(b, Decl(additionOperatorWithTypeParameter.ts, 5, 7)) + + var r3 = t + c; +>r3 : Symbol(r3, Decl(additionOperatorWithTypeParameter.ts, 15, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>c : Symbol(c, Decl(additionOperatorWithTypeParameter.ts, 6, 7)) + + var r4 = t + d; // ok, one operand is string +>r4 : Symbol(r4, Decl(additionOperatorWithTypeParameter.ts, 16, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>d : Symbol(d, Decl(additionOperatorWithTypeParameter.ts, 7, 7)) + + var r5 = t + e; +>r5 : Symbol(r5, Decl(additionOperatorWithTypeParameter.ts, 17, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>e : Symbol(e, Decl(additionOperatorWithTypeParameter.ts, 8, 7)) + + var r6 = t + g; +>r6 : Symbol(r6, Decl(additionOperatorWithTypeParameter.ts, 18, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>g : Symbol(g, Decl(additionOperatorWithTypeParameter.ts, 9, 7)) + + var r7 = t + f; +>r7 : Symbol(r7, Decl(additionOperatorWithTypeParameter.ts, 19, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>f : Symbol(f, Decl(additionOperatorWithTypeParameter.ts, 10, 7)) + + // type parameter as right operand + var r8 = a + t; // ok, one operand is any +>r8 : Symbol(r8, Decl(additionOperatorWithTypeParameter.ts, 22, 7)) +>a : Symbol(a, Decl(additionOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r9 = b + t; +>r9 : Symbol(r9, Decl(additionOperatorWithTypeParameter.ts, 23, 7)) +>b : Symbol(b, Decl(additionOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r10 = c + t; +>r10 : Symbol(r10, Decl(additionOperatorWithTypeParameter.ts, 24, 7)) +>c : Symbol(c, Decl(additionOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r11 = d + t; // ok, one operand is string +>r11 : Symbol(r11, Decl(additionOperatorWithTypeParameter.ts, 25, 7)) +>d : Symbol(d, Decl(additionOperatorWithTypeParameter.ts, 7, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r12 = e + t; +>r12 : Symbol(r12, Decl(additionOperatorWithTypeParameter.ts, 26, 7)) +>e : Symbol(e, Decl(additionOperatorWithTypeParameter.ts, 8, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r13 = g + t; +>r13 : Symbol(r13, Decl(additionOperatorWithTypeParameter.ts, 27, 7)) +>g : Symbol(g, Decl(additionOperatorWithTypeParameter.ts, 9, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r14 = f + t; +>r14 : Symbol(r14, Decl(additionOperatorWithTypeParameter.ts, 28, 7)) +>f : Symbol(f, Decl(additionOperatorWithTypeParameter.ts, 10, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + // other cases + var r15 = t + null; +>r15 : Symbol(r15, Decl(additionOperatorWithTypeParameter.ts, 31, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r16 = t + undefined; +>r16 : Symbol(r16, Decl(additionOperatorWithTypeParameter.ts, 32, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>undefined : Symbol(undefined) + + var r17 = t + t; +>r17 : Symbol(r17, Decl(additionOperatorWithTypeParameter.ts, 33, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r18 = t + u; +>r18 : Symbol(r18, Decl(additionOperatorWithTypeParameter.ts, 34, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +>u : Symbol(u, Decl(additionOperatorWithTypeParameter.ts, 3, 24)) + + var r19 = t + (() => { }); +>r19 : Symbol(r19, Decl(additionOperatorWithTypeParameter.ts, 35, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) + + var r20 = t + []; +>r20 : Symbol(r20, Decl(additionOperatorWithTypeParameter.ts, 36, 7)) +>t : Symbol(t, Decl(additionOperatorWithTypeParameter.ts, 3, 19)) +} diff --git a/tests/baselines/reference/additionOperatorWithTypeParameter.types b/tests/baselines/reference/additionOperatorWithTypeParameter.types new file mode 100644 index 00000000000..1ebc2d5b02f --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithTypeParameter.types @@ -0,0 +1,163 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithTypeParameter.ts === +// type parameter type is not a valid operand of addition operator +enum E { a, b } +>E : E +>a : E.a +>b : E.b + +function foo(t: T, u: U) { +>foo : (t: T, u: U) => void +>T : T +>U : U +>t : T +>T : T +>u : U +>U : U + + var a: any; +>a : any + + var b: boolean; +>b : boolean + + var c: number; +>c : number + + var d: string; +>d : string + + var e: Object; +>e : Object +>Object : Object + + var g: E; +>g : E +>E : E + + var f: void; +>f : void + + // type parameter as left operand + var r1: any = t + a; // ok, one operand is any +>r1 : any +>t + a : any +>t : T +>a : any + + var r2 = t + b; +>r2 : any +>t + b : any +>t : T +>b : boolean + + var r3 = t + c; +>r3 : any +>t + c : any +>t : T +>c : number + + var r4 = t + d; // ok, one operand is string +>r4 : string +>t + d : string +>t : T +>d : string + + var r5 = t + e; +>r5 : any +>t + e : any +>t : T +>e : Object + + var r6 = t + g; +>r6 : any +>t + g : any +>t : T +>g : E + + var r7 = t + f; +>r7 : any +>t + f : any +>t : T +>f : void + + // type parameter as right operand + var r8 = a + t; // ok, one operand is any +>r8 : any +>a + t : any +>a : any +>t : T + + var r9 = b + t; +>r9 : any +>b + t : any +>b : boolean +>t : T + + var r10 = c + t; +>r10 : any +>c + t : any +>c : number +>t : T + + var r11 = d + t; // ok, one operand is string +>r11 : string +>d + t : string +>d : string +>t : T + + var r12 = e + t; +>r12 : any +>e + t : any +>e : Object +>t : T + + var r13 = g + t; +>r13 : any +>g + t : any +>g : E +>t : T + + var r14 = f + t; +>r14 : any +>f + t : any +>f : void +>t : T + + // other cases + var r15 = t + null; +>r15 : any +>t + null : any +>t : T +>null : null + + var r16 = t + undefined; +>r16 : any +>t + undefined : any +>t : T +>undefined : undefined + + var r17 = t + t; +>r17 : any +>t + t : any +>t : T +>t : T + + var r18 = t + u; +>r18 : any +>t + u : any +>t : T +>u : U + + var r19 = t + (() => { }); +>r19 : any +>t + (() => { }) : any +>t : T +>(() => { }) : () => void +>() => { } : () => void + + var r20 = t + []; +>r20 : any +>t + [] : any +>t : T +>[] : undefined[] +} diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.symbols b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.symbols new file mode 100644 index 00000000000..eac61496e1a --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.symbols @@ -0,0 +1,76 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts === +// If one operand is the null or undefined value, it is treated as having the type of the other operand. + +function foo(): void { return undefined } +>foo : Symbol(foo, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 0, 0)) +>undefined : Symbol(undefined) + +var a: boolean; +>a : Symbol(a, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var b: Object; +>b : Symbol(b, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var c: void; +>c : Symbol(c, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 6, 3)) + +var d: Number; +>d : Symbol(d, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 7, 3)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +// undefined + boolean/Object +var r1 = undefined + a; +>r1 : Symbol(r1, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 10, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r2 = undefined + b; +>r2 : Symbol(r2, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 11, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r3 = undefined + c; +>r3 : Symbol(r3, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 12, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 6, 3)) + +var r4 = a + undefined; +>r4 : Symbol(r4, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 13, 3)) +>a : Symbol(a, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r5 = b + undefined; +>r5 : Symbol(r5, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 14, 3)) +>b : Symbol(b, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r6 = undefined + c; +>r6 : Symbol(r6, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 15, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 6, 3)) + +// other cases +var r7 = undefined + d; +>r7 : Symbol(r7, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 18, 3)) +>undefined : Symbol(undefined) +>d : Symbol(d, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 7, 3)) + +var r8 = undefined + true; +>r8 : Symbol(r8, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 19, 3)) +>undefined : Symbol(undefined) + +var r9 = undefined + { a: '' }; +>r9 : Symbol(r9, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 20, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 20, 22)) + +var r10 = undefined + foo(); +>r10 : Symbol(r10, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 21, 3)) +>undefined : Symbol(undefined) +>foo : Symbol(foo, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 0, 0)) + +var r11 = undefined + (() => { }); +>r11 : Symbol(r11, Decl(additionOperatorWithUndefinedValueAndInvalidOperands.ts, 22, 3)) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.types b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.types new file mode 100644 index 00000000000..4a38511c10e --- /dev/null +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.types @@ -0,0 +1,93 @@ +=== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts === +// If one operand is the null or undefined value, it is treated as having the type of the other operand. + +function foo(): void { return undefined } +>foo : () => void +>undefined : undefined + +var a: boolean; +>a : boolean + +var b: Object; +>b : Object +>Object : Object + +var c: void; +>c : void + +var d: Number; +>d : Number +>Number : Number + +// undefined + boolean/Object +var r1 = undefined + a; +>r1 : any +>undefined + a : any +>undefined : undefined +>a : boolean + +var r2 = undefined + b; +>r2 : any +>undefined + b : any +>undefined : undefined +>b : Object + +var r3 = undefined + c; +>r3 : any +>undefined + c : any +>undefined : undefined +>c : void + +var r4 = a + undefined; +>r4 : any +>a + undefined : any +>a : boolean +>undefined : undefined + +var r5 = b + undefined; +>r5 : any +>b + undefined : any +>b : Object +>undefined : undefined + +var r6 = undefined + c; +>r6 : any +>undefined + c : any +>undefined : undefined +>c : void + +// other cases +var r7 = undefined + d; +>r7 : any +>undefined + d : any +>undefined : undefined +>d : Number + +var r8 = undefined + true; +>r8 : any +>undefined + true : any +>undefined : undefined +>true : true + +var r9 = undefined + { a: '' }; +>r9 : any +>undefined + { a: '' } : any +>undefined : undefined +>{ a: '' } : { a: string; } +>a : string +>'' : "" + +var r10 = undefined + foo(); +>r10 : any +>undefined + foo() : any +>undefined : undefined +>foo() : void +>foo : () => void + +var r11 = undefined + (() => { }); +>r11 : any +>undefined + (() => { }) : any +>undefined : undefined +>(() => { }) : () => void +>() => { } : () => void + diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.types b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.types index 46ba3a147e6..2d0177c1675 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.types +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.types @@ -35,68 +35,68 @@ var r2: any = a + undefined; // undefined + number/enum var r3 = undefined + b; ->r3 : number ->undefined + b : number +>r3 : any +>undefined + b : any >undefined : undefined >b : number var r4 = undefined + 1; ->r4 : number ->undefined + 1 : number +>r4 : any +>undefined + 1 : any >undefined : undefined >1 : 1 var r5 = undefined + c; ->r5 : number ->undefined + c : number +>r5 : any +>undefined + c : any >undefined : undefined >c : E var r6 = undefined + E.a; ->r6 : number ->undefined + E.a : number +>r6 : any +>undefined + E.a : any >undefined : undefined >E.a : E.a >E : typeof E >a : E.a var r7 = undefined + E['a']; ->r7 : number ->undefined + E['a'] : number +>r7 : any +>undefined + E['a'] : any >undefined : undefined >E['a'] : E.a >E : typeof E >'a' : "a" var r8 = b + undefined; ->r8 : number ->b + undefined : number +>r8 : any +>b + undefined : any >b : number >undefined : undefined var r9 = 1 + undefined; ->r9 : number ->1 + undefined : number +>r9 : any +>1 + undefined : any >1 : 1 >undefined : undefined var r10 = c + undefined ->r10 : number ->c + undefined : number +>r10 : any +>c + undefined : any >c : E >undefined : undefined var r11 = E.a + undefined; ->r11 : number ->E.a + undefined : number +>r11 : any +>E.a + undefined : any >E.a : E.a >E : typeof E >a : E.a >undefined : undefined var r12 = E['a'] + undefined; ->r12 : number ->E['a'] + undefined : number +>r12 : any +>E['a'] + undefined : any >E['a'] : E.a >E : typeof E >'a' : "a" diff --git a/tests/baselines/reference/aliasAssignments.symbols b/tests/baselines/reference/aliasAssignments.symbols new file mode 100644 index 00000000000..e5d9594c847 --- /dev/null +++ b/tests/baselines/reference/aliasAssignments.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/aliasAssignments_1.ts === +import moduleA = require("./aliasAssignments_moduleA"); +>moduleA : Symbol(moduleA, Decl(aliasAssignments_1.ts, 0, 0)) + +var x = moduleA; +>x : Symbol(x, Decl(aliasAssignments_1.ts, 1, 3)) +>moduleA : Symbol(moduleA, Decl(aliasAssignments_1.ts, 0, 0)) + +x = 1; // Should be error +>x : Symbol(x, Decl(aliasAssignments_1.ts, 1, 3)) + +var y = 1; +>y : Symbol(y, Decl(aliasAssignments_1.ts, 3, 3)) + +y = moduleA; // should be error +>y : Symbol(y, Decl(aliasAssignments_1.ts, 3, 3)) +>moduleA : Symbol(moduleA, Decl(aliasAssignments_1.ts, 0, 0)) + +=== tests/cases/compiler/aliasAssignments_moduleA.ts === +export class someClass { +>someClass : Symbol(someClass, Decl(aliasAssignments_moduleA.ts, 0, 0)) + + public someData: string; +>someData : Symbol(someClass.someData, Decl(aliasAssignments_moduleA.ts, 0, 24)) +} + diff --git a/tests/baselines/reference/aliasAssignments.types b/tests/baselines/reference/aliasAssignments.types new file mode 100644 index 00000000000..efb36541a48 --- /dev/null +++ b/tests/baselines/reference/aliasAssignments.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/aliasAssignments_1.ts === +import moduleA = require("./aliasAssignments_moduleA"); +>moduleA : typeof moduleA + +var x = moduleA; +>x : typeof moduleA +>moduleA : typeof moduleA + +x = 1; // Should be error +>x = 1 : 1 +>x : typeof moduleA +>1 : 1 + +var y = 1; +>y : number +>1 : 1 + +y = moduleA; // should be error +>y = moduleA : typeof moduleA +>y : number +>moduleA : typeof moduleA + +=== tests/cases/compiler/aliasAssignments_moduleA.ts === +export class someClass { +>someClass : someClass + + public someData: string; +>someData : string +} + diff --git a/tests/baselines/reference/aliasBug.symbols b/tests/baselines/reference/aliasBug.symbols new file mode 100644 index 00000000000..8dae267b5be --- /dev/null +++ b/tests/baselines/reference/aliasBug.symbols @@ -0,0 +1,54 @@ +=== tests/cases/compiler/aliasBug.ts === +module foo { +>foo : Symbol(foo, Decl(aliasBug.ts, 0, 0)) + + export class Provide { +>Provide : Symbol(Provide, Decl(aliasBug.ts, 0, 12)) + } + + export module bar { export module baz {export class boo {}}} +>bar : Symbol(bar, Decl(aliasBug.ts, 2, 5)) +>baz : Symbol(baz, Decl(aliasBug.ts, 4, 23)) +>boo : Symbol(boo, Decl(aliasBug.ts, 4, 43)) +} + +import provide = foo; +>provide : Symbol(provide, Decl(aliasBug.ts, 5, 1)) +>foo : Symbol(foo, Decl(aliasBug.ts, 0, 0)) + +import booz = foo.bar.baz; +>booz : Symbol(booz, Decl(aliasBug.ts, 7, 21)) +>foo : Symbol(foo, Decl(aliasBug.ts, 0, 0)) +>bar : Symbol(provide.bar, Decl(aliasBug.ts, 2, 5)) +>baz : Symbol(booz, Decl(aliasBug.ts, 4, 23)) + +var p = new provide.Provide(); +>p : Symbol(p, Decl(aliasBug.ts, 10, 3)) +>provide.Provide : Symbol(provide.Provide, Decl(aliasBug.ts, 0, 12)) +>provide : Symbol(provide, Decl(aliasBug.ts, 5, 1)) +>Provide : Symbol(provide.Provide, Decl(aliasBug.ts, 0, 12)) + +function use() { +>use : Symbol(use, Decl(aliasBug.ts, 10, 30)) + + var p1: provide.Provide; // error here, but should be okay +>p1 : Symbol(p1, Decl(aliasBug.ts, 13, 5)) +>provide : Symbol(provide, Decl(aliasBug.ts, 5, 1)) +>Provide : Symbol(provide.Provide, Decl(aliasBug.ts, 0, 12)) + + var p2: foo.Provide; +>p2 : Symbol(p2, Decl(aliasBug.ts, 14, 5)) +>foo : Symbol(foo, Decl(aliasBug.ts, 0, 0)) +>Provide : Symbol(provide.Provide, Decl(aliasBug.ts, 0, 12)) + + var p3:booz.bar; +>p3 : Symbol(p3, Decl(aliasBug.ts, 15, 5)) +>booz : Symbol(booz, Decl(aliasBug.ts, 7, 21)) + + var p22 = new provide.Provide(); +>p22 : Symbol(p22, Decl(aliasBug.ts, 16, 5)) +>provide.Provide : Symbol(provide.Provide, Decl(aliasBug.ts, 0, 12)) +>provide : Symbol(provide, Decl(aliasBug.ts, 5, 1)) +>Provide : Symbol(provide.Provide, Decl(aliasBug.ts, 0, 12)) +} + diff --git a/tests/baselines/reference/aliasBug.types b/tests/baselines/reference/aliasBug.types new file mode 100644 index 00000000000..6a896a64c29 --- /dev/null +++ b/tests/baselines/reference/aliasBug.types @@ -0,0 +1,57 @@ +=== tests/cases/compiler/aliasBug.ts === +module foo { +>foo : typeof foo + + export class Provide { +>Provide : Provide + } + + export module bar { export module baz {export class boo {}}} +>bar : typeof bar +>baz : typeof baz +>boo : boo +} + +import provide = foo; +>provide : typeof foo +>foo : typeof foo + +import booz = foo.bar.baz; +>booz : typeof booz +>foo : typeof foo +>bar : typeof provide.bar +>baz : typeof booz + +var p = new provide.Provide(); +>p : provide.Provide +>new provide.Provide() : provide.Provide +>provide.Provide : typeof provide.Provide +>provide : typeof foo +>Provide : typeof provide.Provide + +function use() { +>use : () => void + + var p1: provide.Provide; // error here, but should be okay +>p1 : provide.Provide +>provide : any +>Provide : provide.Provide + + var p2: foo.Provide; +>p2 : provide.Provide +>foo : any +>Provide : provide.Provide + + var p3:booz.bar; +>p3 : any +>booz : any +>bar : No type information available! + + var p22 = new provide.Provide(); +>p22 : provide.Provide +>new provide.Provide() : provide.Provide +>provide.Provide : typeof provide.Provide +>provide : typeof foo +>Provide : typeof provide.Provide +} + diff --git a/tests/baselines/reference/aliasErrors.symbols b/tests/baselines/reference/aliasErrors.symbols new file mode 100644 index 00000000000..2a0e5b58256 --- /dev/null +++ b/tests/baselines/reference/aliasErrors.symbols @@ -0,0 +1,85 @@ +=== tests/cases/compiler/aliasErrors.ts === +module foo { +>foo : Symbol(foo, Decl(aliasErrors.ts, 0, 0)) + + export class Provide { +>Provide : Symbol(Provide, Decl(aliasErrors.ts, 0, 12)) + } + export module bar { export module baz {export class boo {}}} +>bar : Symbol(bar, Decl(aliasErrors.ts, 2, 5)) +>baz : Symbol(baz, Decl(aliasErrors.ts, 3, 23)) +>boo : Symbol(boo, Decl(aliasErrors.ts, 3, 43)) +} + +import provide = foo; +>provide : Symbol(provide, Decl(aliasErrors.ts, 4, 1)) +>foo : Symbol(foo, Decl(aliasErrors.ts, 0, 0)) + +import booz = foo.bar.baz; +>booz : Symbol(booz, Decl(aliasErrors.ts, 6, 21)) +>foo : Symbol(foo, Decl(aliasErrors.ts, 0, 0)) +>bar : Symbol(provide.bar, Decl(aliasErrors.ts, 2, 5)) +>baz : Symbol(booz, Decl(aliasErrors.ts, 3, 23)) + +import beez = foo.bar; +>beez : Symbol(beez, Decl(aliasErrors.ts, 7, 26)) +>foo : Symbol(foo, Decl(aliasErrors.ts, 0, 0)) +>bar : Symbol(provide.bar, Decl(aliasErrors.ts, 2, 5)) + +import m = no; +>m : Symbol(m, Decl(aliasErrors.ts, 8, 22)) + +import m2 = no.mod; +>m2 : Symbol(m2, Decl(aliasErrors.ts, 10, 14)) + +import n = 5; +>n : Symbol(n, Decl(aliasErrors.ts, 11, 19)) + +import o = "s"; +>o : Symbol(o, Decl(aliasErrors.ts, 12, 13)) + +import q = null; +>q : Symbol(q, Decl(aliasErrors.ts, 13, 15)) + +import r = undefined; +>r : Symbol(r, Decl(aliasErrors.ts, 14, 16)) + + +var p = new provide.Provide(); +>p : Symbol(p, Decl(aliasErrors.ts, 18, 3)) +>provide.Provide : Symbol(provide.Provide, Decl(aliasErrors.ts, 0, 12)) +>provide : Symbol(provide, Decl(aliasErrors.ts, 4, 1)) +>Provide : Symbol(provide.Provide, Decl(aliasErrors.ts, 0, 12)) + +function use() { +>use : Symbol(use, Decl(aliasErrors.ts, 18, 30)) + + beez.baz.boo; +>beez.baz.boo : Symbol(booz.boo, Decl(aliasErrors.ts, 3, 43)) +>beez.baz : Symbol(booz, Decl(aliasErrors.ts, 3, 23)) +>beez : Symbol(beez, Decl(aliasErrors.ts, 7, 26)) +>baz : Symbol(booz, Decl(aliasErrors.ts, 3, 23)) +>boo : Symbol(booz.boo, Decl(aliasErrors.ts, 3, 43)) + + var p1: provide.Provide; +>p1 : Symbol(p1, Decl(aliasErrors.ts, 23, 5)) +>provide : Symbol(provide, Decl(aliasErrors.ts, 4, 1)) +>Provide : Symbol(provide.Provide, Decl(aliasErrors.ts, 0, 12)) + + var p2: foo.Provide; +>p2 : Symbol(p2, Decl(aliasErrors.ts, 24, 5)) +>foo : Symbol(foo, Decl(aliasErrors.ts, 0, 0)) +>Provide : Symbol(provide.Provide, Decl(aliasErrors.ts, 0, 12)) + + var p3:booz.bar; +>p3 : Symbol(p3, Decl(aliasErrors.ts, 25, 5)) +>booz : Symbol(booz, Decl(aliasErrors.ts, 6, 21)) + + var p22 = new provide.Provide(); +>p22 : Symbol(p22, Decl(aliasErrors.ts, 26, 5)) +>provide.Provide : Symbol(provide.Provide, Decl(aliasErrors.ts, 0, 12)) +>provide : Symbol(provide, Decl(aliasErrors.ts, 4, 1)) +>Provide : Symbol(provide.Provide, Decl(aliasErrors.ts, 0, 12)) +} + + diff --git a/tests/baselines/reference/aliasErrors.types b/tests/baselines/reference/aliasErrors.types new file mode 100644 index 00000000000..6dc25ef9a33 --- /dev/null +++ b/tests/baselines/reference/aliasErrors.types @@ -0,0 +1,98 @@ +=== tests/cases/compiler/aliasErrors.ts === +module foo { +>foo : typeof foo + + export class Provide { +>Provide : Provide + } + export module bar { export module baz {export class boo {}}} +>bar : typeof bar +>baz : typeof baz +>boo : boo +} + +import provide = foo; +>provide : typeof foo +>foo : typeof foo + +import booz = foo.bar.baz; +>booz : typeof booz +>foo : typeof foo +>bar : typeof provide.bar +>baz : typeof booz + +import beez = foo.bar; +>beez : typeof provide.bar +>foo : typeof foo +>bar : typeof provide.bar + +import m = no; +>m : any +>no : No type information available! + +import m2 = no.mod; +>m2 : any +>no : No type information available! +>mod : No type information available! + +import n = 5; +>n : any +> : No type information available! +>5 : 5 + +import o = "s"; +>o : any +> : No type information available! +>"s" : "s" + +import q = null; +>q : any +> : No type information available! +>null : null + +import r = undefined; +>r : any +>undefined : No type information available! + + +var p = new provide.Provide(); +>p : provide.Provide +>new provide.Provide() : provide.Provide +>provide.Provide : typeof provide.Provide +>provide : typeof foo +>Provide : typeof provide.Provide + +function use() { +>use : () => void + + beez.baz.boo; +>beez.baz.boo : typeof booz.boo +>beez.baz : typeof booz +>beez : typeof provide.bar +>baz : typeof booz +>boo : typeof booz.boo + + var p1: provide.Provide; +>p1 : provide.Provide +>provide : any +>Provide : provide.Provide + + var p2: foo.Provide; +>p2 : provide.Provide +>foo : any +>Provide : provide.Provide + + var p3:booz.bar; +>p3 : any +>booz : any +>bar : No type information available! + + var p22 = new provide.Provide(); +>p22 : provide.Provide +>new provide.Provide() : provide.Provide +>provide.Provide : typeof provide.Provide +>provide : typeof foo +>Provide : typeof provide.Provide +} + + diff --git a/tests/baselines/reference/aliasInaccessibleModule.symbols b/tests/baselines/reference/aliasInaccessibleModule.symbols new file mode 100644 index 00000000000..d4424e275c9 --- /dev/null +++ b/tests/baselines/reference/aliasInaccessibleModule.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/aliasInaccessibleModule.ts === +module M { +>M : Symbol(M, Decl(aliasInaccessibleModule.ts, 0, 0)) + + module N { +>N : Symbol(N, Decl(aliasInaccessibleModule.ts, 0, 10)) + } + export import X = N; +>X : Symbol(X, Decl(aliasInaccessibleModule.ts, 2, 5)) +>N : Symbol(N, Decl(aliasInaccessibleModule.ts, 0, 10)) +} diff --git a/tests/baselines/reference/aliasInaccessibleModule.types b/tests/baselines/reference/aliasInaccessibleModule.types new file mode 100644 index 00000000000..fc5e85f37cb --- /dev/null +++ b/tests/baselines/reference/aliasInaccessibleModule.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/aliasInaccessibleModule.ts === +module M { +>M : typeof M + + module N { +>N : any + } + export import X = N; +>X : any +>N : any +} diff --git a/tests/baselines/reference/aliasInaccessibleModule2.symbols b/tests/baselines/reference/aliasInaccessibleModule2.symbols new file mode 100644 index 00000000000..b5025845d73 --- /dev/null +++ b/tests/baselines/reference/aliasInaccessibleModule2.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/aliasInaccessibleModule2.ts === +module M { +>M : Symbol(M, Decl(aliasInaccessibleModule2.ts, 0, 0)) + + module N { +>N : Symbol(N, Decl(aliasInaccessibleModule2.ts, 0, 10)) + + class C { +>C : Symbol(C, Decl(aliasInaccessibleModule2.ts, 1, 14)) + } + + } + import R = N; +>R : Symbol(R, Decl(aliasInaccessibleModule2.ts, 5, 5)) +>N : Symbol(N, Decl(aliasInaccessibleModule2.ts, 0, 10)) + + export import X = R; +>X : Symbol(X, Decl(aliasInaccessibleModule2.ts, 6, 17)) +>R : Symbol(R, Decl(aliasInaccessibleModule2.ts, 5, 5)) +} diff --git a/tests/baselines/reference/aliasInaccessibleModule2.types b/tests/baselines/reference/aliasInaccessibleModule2.types new file mode 100644 index 00000000000..1ad25ae0cf9 --- /dev/null +++ b/tests/baselines/reference/aliasInaccessibleModule2.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/aliasInaccessibleModule2.ts === +module M { +>M : typeof M + + module N { +>N : typeof N + + class C { +>C : C + } + + } + import R = N; +>R : typeof N +>N : typeof N + + export import X = R; +>X : typeof N +>R : typeof N +} diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.symbols b/tests/baselines/reference/aliasOnMergedModuleInterface.symbols new file mode 100644 index 00000000000..c4f5c0730a1 --- /dev/null +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/aliasOnMergedModuleInterface_1.ts === +/// +import foo = require("foo") +>foo : Symbol(foo, Decl(aliasOnMergedModuleInterface_1.ts, 0, 0)) + +var z: foo; +>z : Symbol(z, Decl(aliasOnMergedModuleInterface_1.ts, 2, 3)) +>foo : Symbol(foo, Decl(aliasOnMergedModuleInterface_1.ts, 0, 0)) + +z.bar("hello"); // This should be ok +>z.bar : Symbol(foo.bar, Decl(aliasOnMergedModuleInterface_0.ts, 6, 17)) +>z : Symbol(z, Decl(aliasOnMergedModuleInterface_1.ts, 2, 3)) +>bar : Symbol(foo.bar, Decl(aliasOnMergedModuleInterface_0.ts, 6, 17)) + +var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be error +>x : Symbol(x, Decl(aliasOnMergedModuleInterface_1.ts, 4, 3)) +>foo : Symbol(foo, Decl(aliasOnMergedModuleInterface_1.ts, 0, 0)) +>A : Symbol(foo.A, Decl(aliasOnMergedModuleInterface_0.ts, 2, 14)) + +=== tests/cases/compiler/aliasOnMergedModuleInterface_0.ts === +declare module "foo" +{ + module B { +>B : Symbol(B, Decl(aliasOnMergedModuleInterface_0.ts, 1, 1), Decl(aliasOnMergedModuleInterface_0.ts, 5, 5)) + + export interface A { +>A : Symbol(A, Decl(aliasOnMergedModuleInterface_0.ts, 2, 14)) + } + } + interface B { +>B : Symbol(B, Decl(aliasOnMergedModuleInterface_0.ts, 1, 1), Decl(aliasOnMergedModuleInterface_0.ts, 5, 5)) + + bar(name: string): B.A; +>bar : Symbol(B.bar, Decl(aliasOnMergedModuleInterface_0.ts, 6, 17)) +>name : Symbol(name, Decl(aliasOnMergedModuleInterface_0.ts, 7, 12)) +>B : Symbol(B, Decl(aliasOnMergedModuleInterface_0.ts, 1, 1), Decl(aliasOnMergedModuleInterface_0.ts, 5, 5)) +>A : Symbol(B.A, Decl(aliasOnMergedModuleInterface_0.ts, 2, 14)) + } + export = B; +>B : Symbol(B, Decl(aliasOnMergedModuleInterface_0.ts, 1, 1), Decl(aliasOnMergedModuleInterface_0.ts, 5, 5)) +} + diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.types b/tests/baselines/reference/aliasOnMergedModuleInterface.types new file mode 100644 index 00000000000..9ba023a8dd8 --- /dev/null +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.types @@ -0,0 +1,49 @@ +=== tests/cases/compiler/aliasOnMergedModuleInterface_1.ts === +/// +import foo = require("foo") +>foo : any + +var z: foo; +>z : foo +>foo : foo + +z.bar("hello"); // This should be ok +>z.bar("hello") : foo.A +>z.bar : (name: string) => foo.A +>z : foo +>bar : (name: string) => foo.A +>"hello" : "hello" + +var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be error +>x : foo.A +>foo : any +>A : foo.A +>foo.bar("hello") : any +>foo.bar : any +>foo : any +>bar : any +>"hello" : "hello" + +=== tests/cases/compiler/aliasOnMergedModuleInterface_0.ts === +declare module "foo" +{ + module B { +>B : any + + export interface A { +>A : A + } + } + interface B { +>B : B + + bar(name: string): B.A; +>bar : (name: string) => B.A +>name : string +>B : any +>A : B.A + } + export = B; +>B : B +} + diff --git a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.symbols b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.symbols new file mode 100644 index 00000000000..5d4ac0be473 --- /dev/null +++ b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts === +import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); +>moduleA : Symbol(moduleA, Decl(aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts, 0, 0)) + +var d = b.q3; +>d : Symbol(d, Decl(aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts, 1, 3)) + +=== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts === +interface c { +>c : Symbol(c, Decl(aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts, 0, 0)) + + q3: number; +>q3 : Symbol(c.q3, Decl(aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts, 0, 13)) +} +export = c; +>c : Symbol(c, Decl(aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts, 0, 0)) + diff --git a/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.types b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.types new file mode 100644 index 00000000000..6a80fcc768c --- /dev/null +++ b/tests/baselines/reference/aliasWithInterfaceExportAssignmentUsedInVarInitializer.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_1.ts === +import moduleA = require("./aliasWithInterfaceExportAssignmentUsedInVarInitializer_0"); +>moduleA : any + +var d = b.q3; +>d : any +>b.q3 : any +>b : any +>q3 : any + +=== tests/cases/compiler/aliasWithInterfaceExportAssignmentUsedInVarInitializer_0.ts === +interface c { +>c : c + + q3: number; +>q3 : number +} +export = c; +>c : c + diff --git a/tests/baselines/reference/aliasesInSystemModule1.symbols b/tests/baselines/reference/aliasesInSystemModule1.symbols new file mode 100644 index 00000000000..fe5f4a550a6 --- /dev/null +++ b/tests/baselines/reference/aliasesInSystemModule1.symbols @@ -0,0 +1,47 @@ +=== tests/cases/compiler/aliasesInSystemModule1.ts === +import alias = require('foo'); +>alias : Symbol(alias, Decl(aliasesInSystemModule1.ts, 0, 0)) + +import cls = alias.Class; +>cls : Symbol(cls, Decl(aliasesInSystemModule1.ts, 0, 30)) +>alias : Symbol(alias, Decl(aliasesInSystemModule1.ts, 0, 0)) +>Class : Symbol(alias) + +export import cls2 = alias.Class; +>cls2 : Symbol(cls2, Decl(aliasesInSystemModule1.ts, 1, 25)) +>alias : Symbol(alias, Decl(aliasesInSystemModule1.ts, 0, 0)) +>Class : Symbol(alias) + +let x = new alias.Class(); +>x : Symbol(x, Decl(aliasesInSystemModule1.ts, 4, 3)) +>alias : Symbol(alias, Decl(aliasesInSystemModule1.ts, 0, 0)) + +let y = new cls(); +>y : Symbol(y, Decl(aliasesInSystemModule1.ts, 5, 3)) +>cls : Symbol(cls, Decl(aliasesInSystemModule1.ts, 0, 30)) + +let z = new cls2(); +>z : Symbol(z, Decl(aliasesInSystemModule1.ts, 6, 3)) +>cls2 : Symbol(cls2, Decl(aliasesInSystemModule1.ts, 1, 25)) + +module M { +>M : Symbol(M, Decl(aliasesInSystemModule1.ts, 6, 19)) + + export import cls = alias.Class; +>cls : Symbol(cls, Decl(aliasesInSystemModule1.ts, 8, 10)) +>alias : Symbol(alias, Decl(aliasesInSystemModule1.ts, 0, 0)) +>Class : Symbol(cls) + + let x = new alias.Class(); +>x : Symbol(x, Decl(aliasesInSystemModule1.ts, 10, 5)) +>alias : Symbol(alias, Decl(aliasesInSystemModule1.ts, 0, 0)) + + let y = new cls(); +>y : Symbol(y, Decl(aliasesInSystemModule1.ts, 11, 5)) +>cls : Symbol(cls, Decl(aliasesInSystemModule1.ts, 8, 10)) + + let z = new cls2(); +>z : Symbol(z, Decl(aliasesInSystemModule1.ts, 12, 5)) +>cls2 : Symbol(cls2, Decl(aliasesInSystemModule1.ts, 1, 25)) +} + diff --git a/tests/baselines/reference/aliasesInSystemModule1.types b/tests/baselines/reference/aliasesInSystemModule1.types new file mode 100644 index 00000000000..14ed376f20b --- /dev/null +++ b/tests/baselines/reference/aliasesInSystemModule1.types @@ -0,0 +1,57 @@ +=== tests/cases/compiler/aliasesInSystemModule1.ts === +import alias = require('foo'); +>alias : any + +import cls = alias.Class; +>cls : any +>alias : any +>Class : any + +export import cls2 = alias.Class; +>cls2 : any +>alias : any +>Class : any + +let x = new alias.Class(); +>x : any +>new alias.Class() : any +>alias.Class : any +>alias : any +>Class : any + +let y = new cls(); +>y : any +>new cls() : any +>cls : any + +let z = new cls2(); +>z : any +>new cls2() : any +>cls2 : any + +module M { +>M : typeof M + + export import cls = alias.Class; +>cls : any +>alias : any +>Class : any + + let x = new alias.Class(); +>x : any +>new alias.Class() : any +>alias.Class : any +>alias : any +>Class : any + + let y = new cls(); +>y : any +>new cls() : any +>cls : any + + let z = new cls2(); +>z : any +>new cls2() : any +>cls2 : any +} + diff --git a/tests/baselines/reference/aliasesInSystemModule2.symbols b/tests/baselines/reference/aliasesInSystemModule2.symbols new file mode 100644 index 00000000000..c40b0257104 --- /dev/null +++ b/tests/baselines/reference/aliasesInSystemModule2.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/aliasesInSystemModule2.ts === +import {alias} from "foo"; +>alias : Symbol(alias, Decl(aliasesInSystemModule2.ts, 0, 8)) + +import cls = alias.Class; +>cls : Symbol(cls, Decl(aliasesInSystemModule2.ts, 0, 26)) +>alias : Symbol(alias, Decl(aliasesInSystemModule2.ts, 0, 8)) +>Class : Symbol(alias) + +export import cls2 = alias.Class; +>cls2 : Symbol(cls2, Decl(aliasesInSystemModule2.ts, 1, 25)) +>alias : Symbol(alias, Decl(aliasesInSystemModule2.ts, 0, 8)) +>Class : Symbol(alias) + +let x = new alias.Class(); +>x : Symbol(x, Decl(aliasesInSystemModule2.ts, 4, 3)) +>alias : Symbol(alias, Decl(aliasesInSystemModule2.ts, 0, 8)) + +let y = new cls(); +>y : Symbol(y, Decl(aliasesInSystemModule2.ts, 5, 3)) +>cls : Symbol(cls, Decl(aliasesInSystemModule2.ts, 0, 26)) + +let z = new cls2(); +>z : Symbol(z, Decl(aliasesInSystemModule2.ts, 6, 3)) +>cls2 : Symbol(cls2, Decl(aliasesInSystemModule2.ts, 1, 25)) + +module M { +>M : Symbol(M, Decl(aliasesInSystemModule2.ts, 6, 19)) + + export import cls = alias.Class; +>cls : Symbol(cls, Decl(aliasesInSystemModule2.ts, 8, 10)) +>alias : Symbol(alias, Decl(aliasesInSystemModule2.ts, 0, 8)) +>Class : Symbol(cls) + + let x = new alias.Class(); +>x : Symbol(x, Decl(aliasesInSystemModule2.ts, 10, 5)) +>alias : Symbol(alias, Decl(aliasesInSystemModule2.ts, 0, 8)) + + let y = new cls(); +>y : Symbol(y, Decl(aliasesInSystemModule2.ts, 11, 5)) +>cls : Symbol(cls, Decl(aliasesInSystemModule2.ts, 8, 10)) + + let z = new cls2(); +>z : Symbol(z, Decl(aliasesInSystemModule2.ts, 12, 5)) +>cls2 : Symbol(cls2, Decl(aliasesInSystemModule2.ts, 1, 25)) +} diff --git a/tests/baselines/reference/aliasesInSystemModule2.types b/tests/baselines/reference/aliasesInSystemModule2.types new file mode 100644 index 00000000000..10009721222 --- /dev/null +++ b/tests/baselines/reference/aliasesInSystemModule2.types @@ -0,0 +1,56 @@ +=== tests/cases/compiler/aliasesInSystemModule2.ts === +import {alias} from "foo"; +>alias : any + +import cls = alias.Class; +>cls : any +>alias : any +>Class : any + +export import cls2 = alias.Class; +>cls2 : any +>alias : any +>Class : any + +let x = new alias.Class(); +>x : any +>new alias.Class() : any +>alias.Class : any +>alias : any +>Class : any + +let y = new cls(); +>y : any +>new cls() : any +>cls : any + +let z = new cls2(); +>z : any +>new cls2() : any +>cls2 : any + +module M { +>M : typeof M + + export import cls = alias.Class; +>cls : any +>alias : any +>Class : any + + let x = new alias.Class(); +>x : any +>new alias.Class() : any +>alias.Class : any +>alias : any +>Class : any + + let y = new cls(); +>y : any +>new cls() : any +>cls : any + + let z = new cls2(); +>z : any +>new cls2() : any +>cls2 : any +} diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.errors.txt b/tests/baselines/reference/allowImportClausesToMergeWithTypes.errors.txt new file mode 100644 index 00000000000..684921ae126 --- /dev/null +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.errors.txt @@ -0,0 +1,34 @@ +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/b.ts (0 errors) ==== + export const zzz = 123; + export default zzz; + +==== tests/cases/compiler/a.ts (0 errors) ==== + export default interface zzz { + x: string; + } + + import zzz from "./b"; + + const x: zzz = { x: "" }; + zzz; + + export { zzz as default }; + +==== tests/cases/compiler/index.ts (2 errors) ==== + import zzz from "./a"; + + const x: zzz = { x: "" }; + zzz; + ~~~ +!!! error TS2693: 'zzz' only refers to a type, but is being used as a value here. + + import originalZZZ from "./b"; + originalZZZ; + + const y: originalZZZ = x; + ~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'originalZZZ'. \ No newline at end of file diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.js b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js new file mode 100644 index 00000000000..1679fa10372 --- /dev/null +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.js @@ -0,0 +1,49 @@ +//// [tests/cases/compiler/allowImportClausesToMergeWithTypes.ts] //// + +//// [b.ts] +export const zzz = 123; +export default zzz; + +//// [a.ts] +export default interface zzz { + x: string; +} + +import zzz from "./b"; + +const x: zzz = { x: "" }; +zzz; + +export { zzz as default }; + +//// [index.ts] +import zzz from "./a"; + +const x: zzz = { x: "" }; +zzz; + +import originalZZZ from "./b"; +originalZZZ; + +const y: originalZZZ = x; + +//// [b.js] +"use strict"; +exports.__esModule = true; +exports.zzz = 123; +exports["default"] = exports.zzz; +//// [a.js] +"use strict"; +exports.__esModule = true; +var b_1 = require("./b"); +exports["default"] = b_1["default"]; +var x = { x: "" }; +b_1["default"]; +//// [index.js] +"use strict"; +exports.__esModule = true; +var x = { x: "" }; +zzz; +var b_1 = require("./b"); +b_1["default"]; +var y = x; diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.symbols b/tests/baselines/reference/allowImportClausesToMergeWithTypes.symbols new file mode 100644 index 00000000000..2195912a395 --- /dev/null +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/b.ts === +export const zzz = 123; +>zzz : Symbol(zzz, Decl(b.ts, 0, 12)) + +export default zzz; +>zzz : Symbol(zzz, Decl(b.ts, 0, 12)) + +=== tests/cases/compiler/a.ts === +export default interface zzz { +>zzz : Symbol(zzz, Decl(a.ts, 0, 0), Decl(a.ts, 9, 8)) + + x: string; +>x : Symbol(zzz.x, Decl(a.ts, 0, 30)) +} + +import zzz from "./b"; +>zzz : Symbol(zzz, Decl(a.ts, 0, 0), Decl(a.ts, 4, 6)) + +const x: zzz = { x: "" }; +>x : Symbol(x, Decl(a.ts, 6, 5)) +>zzz : Symbol(zzz, Decl(a.ts, 0, 0), Decl(a.ts, 9, 8)) +>x : Symbol(x, Decl(a.ts, 6, 16)) + +zzz; +>zzz : Symbol(zzz, Decl(a.ts, 0, 0), Decl(a.ts, 4, 6)) + +export { zzz as default }; +>zzz : Symbol(zzz, Decl(a.ts, 0, 0), Decl(a.ts, 9, 8)) +>default : Symbol(zzz, Decl(a.ts, 0, 0), Decl(a.ts, 9, 8)) + +=== tests/cases/compiler/index.ts === +import zzz from "./a"; +>zzz : Symbol(zzz, Decl(index.ts, 0, 6)) + +const x: zzz = { x: "" }; +>x : Symbol(x, Decl(index.ts, 2, 5)) +>zzz : Symbol(zzz, Decl(index.ts, 0, 6)) +>x : Symbol(x, Decl(index.ts, 2, 16)) + +zzz; + +import originalZZZ from "./b"; +>originalZZZ : Symbol(originalZZZ, Decl(index.ts, 5, 6)) + +originalZZZ; +>originalZZZ : Symbol(originalZZZ, Decl(index.ts, 5, 6)) + +const y: originalZZZ = x; +>y : Symbol(y, Decl(index.ts, 8, 5)) +>x : Symbol(x, Decl(index.ts, 2, 5)) + diff --git a/tests/baselines/reference/allowImportClausesToMergeWithTypes.types b/tests/baselines/reference/allowImportClausesToMergeWithTypes.types new file mode 100644 index 00000000000..89d6a416ff3 --- /dev/null +++ b/tests/baselines/reference/allowImportClausesToMergeWithTypes.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/b.ts === +export const zzz = 123; +>zzz : 123 +>123 : 123 + +export default zzz; +>zzz : 123 + +=== tests/cases/compiler/a.ts === +export default interface zzz { +>zzz : zzz + + x: string; +>x : string +} + +import zzz from "./b"; +>zzz : 123 + +const x: zzz = { x: "" }; +>x : zzz +>zzz : zzz +>{ x: "" } : { x: string; } +>x : string +>"" : "" + +zzz; +>zzz : 123 + +export { zzz as default }; +>zzz : 123 +>default : 123 + +=== tests/cases/compiler/index.ts === +import zzz from "./a"; +>zzz : any + +const x: zzz = { x: "" }; +>x : zzz +>zzz : zzz +>{ x: "" } : { x: string; } +>x : string +>"" : "" + +zzz; +>zzz : any + +import originalZZZ from "./b"; +>originalZZZ : 123 + +originalZZZ; +>originalZZZ : 123 + +const y: originalZZZ = x; +>y : any +>originalZZZ : No type information available! +>x : zzz + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.symbols b/tests/baselines/reference/allowSyntheticDefaultImports10.symbols new file mode 100644 index 00000000000..5c079cd8f74 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/a.ts === +import Foo = require("./b"); +>Foo : Symbol(Foo, Decl(a.ts, 0, 0)) + +Foo.default.bar(); +>Foo : Symbol(Foo, Decl(a.ts, 0, 0)) + +Foo.default.default.foo(); +>Foo : Symbol(Foo, Decl(a.ts, 0, 0)) + +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : Symbol(foo, Decl(b.d.ts, 0, 0)) + +export function bar(); +>bar : Symbol(bar, Decl(b.d.ts, 0, 22)) + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.types b/tests/baselines/reference/allowSyntheticDefaultImports10.types new file mode 100644 index 00000000000..3262dfd66b7 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/a.ts === +import Foo = require("./b"); +>Foo : typeof Foo + +Foo.default.bar(); +>Foo.default.bar() : any +>Foo.default.bar : any +>Foo.default : any +>Foo : typeof Foo +>default : any +>bar : any + +Foo.default.default.foo(); +>Foo.default.default.foo() : any +>Foo.default.default.foo : any +>Foo.default.default : any +>Foo.default : any +>Foo : typeof Foo +>default : any +>default : any +>foo : any + +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : () => any + +export function bar(); +>bar : () => any + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports3.symbols b/tests/baselines/reference/allowSyntheticDefaultImports3.symbols new file mode 100644 index 00000000000..4d5add178c8 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports3.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/a.ts === +import Namespace from "./b"; +>Namespace : Symbol(Namespace, Decl(a.ts, 0, 6)) + +export var x = new Namespace.Foo(); +>x : Symbol(x, Decl(a.ts, 1, 10)) +>Namespace : Symbol(Namespace, Decl(a.ts, 0, 6)) + +=== tests/cases/compiler/b.ts === +export class Foo { +>Foo : Symbol(Foo, Decl(b.ts, 0, 0)) + + member: string; +>member : Symbol(Foo.member, Decl(b.ts, 0, 18)) +} + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports3.types b/tests/baselines/reference/allowSyntheticDefaultImports3.types new file mode 100644 index 00000000000..e7af1777f16 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports3.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/a.ts === +import Namespace from "./b"; +>Namespace : any + +export var x = new Namespace.Foo(); +>x : any +>new Namespace.Foo() : any +>Namespace.Foo : any +>Namespace : any +>Foo : any + +=== tests/cases/compiler/b.ts === +export class Foo { +>Foo : Foo + + member: string; +>member : string +} + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports6.symbols b/tests/baselines/reference/allowSyntheticDefaultImports6.symbols new file mode 100644 index 00000000000..22887d48bd9 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports6.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/b.d.ts === +declare class Foo { +>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) + + member: string; +>member : Symbol(Foo.member, Decl(b.d.ts, 0, 19)) +} +export = Foo; +>Foo : Symbol(Foo, Decl(b.d.ts, 0, 0)) + +=== tests/cases/compiler/a.ts === +import Foo from "./b"; +>Foo : Symbol(Foo, Decl(a.ts, 0, 6)) + +export var x = new Foo(); +>x : Symbol(x, Decl(a.ts, 1, 10)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 6)) + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports6.types b/tests/baselines/reference/allowSyntheticDefaultImports6.types new file mode 100644 index 00000000000..8a70a0eef8c --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports6.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/b.d.ts === +declare class Foo { +>Foo : Foo + + member: string; +>member : string +} +export = Foo; +>Foo : Foo + +=== tests/cases/compiler/a.ts === +import Foo from "./b"; +>Foo : any + +export var x = new Foo(); +>x : any +>new Foo() : any +>Foo : any + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports8.symbols b/tests/baselines/reference/allowSyntheticDefaultImports8.symbols new file mode 100644 index 00000000000..cf5eece0999 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports8.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : Symbol(foo, Decl(b.d.ts, 0, 0)) + +export function bar(); +>bar : Symbol(bar, Decl(b.d.ts, 0, 22)) + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : Symbol(Foo, Decl(a.ts, 0, 8)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) + +Foo.bar(); +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) + +Foo.foo(); +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports8.types b/tests/baselines/reference/allowSyntheticDefaultImports8.types new file mode 100644 index 00000000000..38d2c03fba9 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports8.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : () => any + +export function bar(); +>bar : () => any + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : any +>Foo : any + +Foo.bar(); +>Foo.bar() : any +>Foo.bar : any +>Foo : any +>bar : any + +Foo.foo(); +>Foo.foo() : any +>Foo.foo : any +>Foo : any +>foo : any + diff --git a/tests/baselines/reference/alwaysStrict.symbols b/tests/baselines/reference/alwaysStrict.symbols new file mode 100644 index 00000000000..f045db29e46 --- /dev/null +++ b/tests/baselines/reference/alwaysStrict.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/alwaysStrict.ts === +function f() { +>f : Symbol(f, Decl(alwaysStrict.ts, 0, 0)) + + var arguments = []; +>arguments : Symbol(arguments, Decl(alwaysStrict.ts, 1, 7)) +} diff --git a/tests/baselines/reference/alwaysStrict.types b/tests/baselines/reference/alwaysStrict.types new file mode 100644 index 00000000000..4cf345a244a --- /dev/null +++ b/tests/baselines/reference/alwaysStrict.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/alwaysStrict.ts === +function f() { +>f : () => void + + var arguments = []; +>arguments : any[] +>[] : undefined[] +} diff --git a/tests/baselines/reference/alwaysStrictES6.symbols b/tests/baselines/reference/alwaysStrictES6.symbols new file mode 100644 index 00000000000..540146bdad2 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictES6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/alwaysStrictES6.ts === +function f() { +>f : Symbol(f, Decl(alwaysStrictES6.ts, 0, 0)) + + var arguments = []; +>arguments : Symbol(arguments, Decl(alwaysStrictES6.ts, 1, 7)) +} diff --git a/tests/baselines/reference/alwaysStrictES6.types b/tests/baselines/reference/alwaysStrictES6.types new file mode 100644 index 00000000000..832656d54bc --- /dev/null +++ b/tests/baselines/reference/alwaysStrictES6.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/alwaysStrictES6.ts === +function f() { +>f : () => void + + var arguments = []; +>arguments : any[] +>[] : undefined[] +} diff --git a/tests/baselines/reference/alwaysStrictModule.symbols b/tests/baselines/reference/alwaysStrictModule.symbols new file mode 100644 index 00000000000..0814d039bc6 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictModule.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/alwaysStrictModule.ts === +module M { +>M : Symbol(M, Decl(alwaysStrictModule.ts, 0, 0)) + + export function f() { +>f : Symbol(f, Decl(alwaysStrictModule.ts, 0, 10)) + + var arguments = []; +>arguments : Symbol(arguments, Decl(alwaysStrictModule.ts, 2, 11)) + } +} diff --git a/tests/baselines/reference/alwaysStrictModule.types b/tests/baselines/reference/alwaysStrictModule.types new file mode 100644 index 00000000000..20d3a43bc1a --- /dev/null +++ b/tests/baselines/reference/alwaysStrictModule.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/alwaysStrictModule.ts === +module M { +>M : typeof M + + export function f() { +>f : () => void + + var arguments = []; +>arguments : any[] +>[] : undefined[] + } +} diff --git a/tests/baselines/reference/alwaysStrictModule2.symbols b/tests/baselines/reference/alwaysStrictModule2.symbols new file mode 100644 index 00000000000..e25fc11ec19 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictModule2.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/a.ts === +module M { +>M : Symbol(M, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0)) + + export function f() { +>f : Symbol(f, Decl(a.ts, 0, 10)) + + var arguments = []; +>arguments : Symbol(arguments, Decl(a.ts, 2, 11)) + } +} + +=== tests/cases/compiler/b.ts === +module M { +>M : Symbol(M, Decl(a.ts, 0, 0), Decl(b.ts, 0, 0)) + + export function f2() { +>f2 : Symbol(f2, Decl(b.ts, 0, 10)) + + var arguments = []; +>arguments : Symbol(arguments, Decl(b.ts, 2, 11)) + } +} diff --git a/tests/baselines/reference/alwaysStrictModule2.types b/tests/baselines/reference/alwaysStrictModule2.types new file mode 100644 index 00000000000..494c38b90f9 --- /dev/null +++ b/tests/baselines/reference/alwaysStrictModule2.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.ts === +module M { +>M : typeof M + + export function f() { +>f : () => void + + var arguments = []; +>arguments : any[] +>[] : undefined[] + } +} + +=== tests/cases/compiler/b.ts === +module M { +>M : typeof M + + export function f2() { +>f2 : () => void + + var arguments = []; +>arguments : any[] +>[] : undefined[] + } +} diff --git a/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.symbols b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.symbols new file mode 100644 index 00000000000..3b799d34f6e --- /dev/null +++ b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts === +module M { +>M : Symbol(M, Decl(alwaysStrictNoImplicitUseStrict.ts, 0, 0)) + + export function f() { +>f : Symbol(f, Decl(alwaysStrictNoImplicitUseStrict.ts, 0, 10)) + + var arguments = []; +>arguments : Symbol(arguments, Decl(alwaysStrictNoImplicitUseStrict.ts, 2, 11)) + } +} diff --git a/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.types b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.types new file mode 100644 index 00000000000..3ce5e15ed3a --- /dev/null +++ b/tests/baselines/reference/alwaysStrictNoImplicitUseStrict.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/alwaysStrictNoImplicitUseStrict.ts === +module M { +>M : typeof M + + export function f() { +>f : () => void + + var arguments = []; +>arguments : any[] +>[] : undefined[] + } +} diff --git a/tests/baselines/reference/ambientClassOverloadForFunction.symbols b/tests/baselines/reference/ambientClassOverloadForFunction.symbols new file mode 100644 index 00000000000..7ba3fa34593 --- /dev/null +++ b/tests/baselines/reference/ambientClassOverloadForFunction.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/ambientClassOverloadForFunction.ts === +declare class foo{}; +>foo : Symbol(foo, Decl(ambientClassOverloadForFunction.ts, 0, 0)) + +function foo() { return null; } +>foo : Symbol(foo, Decl(ambientClassOverloadForFunction.ts, 0, 20)) + diff --git a/tests/baselines/reference/ambientClassOverloadForFunction.types b/tests/baselines/reference/ambientClassOverloadForFunction.types new file mode 100644 index 00000000000..fef745bd971 --- /dev/null +++ b/tests/baselines/reference/ambientClassOverloadForFunction.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/ambientClassOverloadForFunction.ts === +declare class foo{}; +>foo : foo + +function foo() { return null; } +>foo : () => any +>null : null + diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.symbols b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.symbols new file mode 100644 index 00000000000..63d50b6c85e --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts === +declare module "too*many*asterisks" { } +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types new file mode 100644 index 00000000000..63d50b6c85e --- /dev/null +++ b/tests/baselines/reference/ambientDeclarationsPatterns_tooManyAsterisks.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/ambient/ambientDeclarationsPatterns_tooManyAsterisks.ts === +declare module "too*many*asterisks" { } +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/ambientEnum1.symbols b/tests/baselines/reference/ambientEnum1.symbols new file mode 100644 index 00000000000..46116c4de19 --- /dev/null +++ b/tests/baselines/reference/ambientEnum1.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/ambientEnum1.ts === + declare enum E1 { +>E1 : Symbol(E1, Decl(ambientEnum1.ts, 0, 0)) + + y = 4.23 +>y : Symbol(E1.y, Decl(ambientEnum1.ts, 0, 21)) + } + + // Ambient enum with computer member + declare enum E2 { +>E2 : Symbol(E2, Decl(ambientEnum1.ts, 2, 5)) + + x = 'foo'.length +>x : Symbol(E2.x, Decl(ambientEnum1.ts, 5, 21)) +>'foo'.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } diff --git a/tests/baselines/reference/ambientEnum1.types b/tests/baselines/reference/ambientEnum1.types new file mode 100644 index 00000000000..968299f4d0a --- /dev/null +++ b/tests/baselines/reference/ambientEnum1.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/ambientEnum1.ts === + declare enum E1 { +>E1 : E1 + + y = 4.23 +>y : E1 +>4.23 : 4.23 + } + + // Ambient enum with computer member + declare enum E2 { +>E2 : E2 + + x = 'foo'.length +>x : E2 +>'foo'.length : number +>'foo' : "foo" +>length : number + } diff --git a/tests/baselines/reference/ambientErrors.symbols b/tests/baselines/reference/ambientErrors.symbols new file mode 100644 index 00000000000..684e87b1fd4 --- /dev/null +++ b/tests/baselines/reference/ambientErrors.symbols @@ -0,0 +1,109 @@ +=== tests/cases/conformance/ambient/ambientErrors.ts === +// Ambient variable with an initializer +declare var x = 4; +>x : Symbol(x, Decl(ambientErrors.ts, 1, 11)) + +// Ambient functions with invalid overloads +declare function fn(x: number): string; +>fn : Symbol(fn, Decl(ambientErrors.ts, 1, 18), Decl(ambientErrors.ts, 4, 39)) +>x : Symbol(x, Decl(ambientErrors.ts, 4, 20)) + +declare function fn(x: 'foo'): number; +>fn : Symbol(fn, Decl(ambientErrors.ts, 1, 18), Decl(ambientErrors.ts, 4, 39)) +>x : Symbol(x, Decl(ambientErrors.ts, 5, 20)) + +// Ambient functions with duplicate signatures +declare function fn1(x: number): string; +>fn1 : Symbol(fn1, Decl(ambientErrors.ts, 5, 38), Decl(ambientErrors.ts, 8, 40)) +>x : Symbol(x, Decl(ambientErrors.ts, 8, 21)) + +declare function fn1(x: number): string; +>fn1 : Symbol(fn1, Decl(ambientErrors.ts, 5, 38), Decl(ambientErrors.ts, 8, 40)) +>x : Symbol(x, Decl(ambientErrors.ts, 9, 21)) + +// Ambient function overloads that differ only by return type +declare function fn2(x: number): string; +>fn2 : Symbol(fn2, Decl(ambientErrors.ts, 9, 40), Decl(ambientErrors.ts, 12, 40)) +>x : Symbol(x, Decl(ambientErrors.ts, 12, 21)) + +declare function fn2(x: number): number; +>fn2 : Symbol(fn2, Decl(ambientErrors.ts, 9, 40), Decl(ambientErrors.ts, 12, 40)) +>x : Symbol(x, Decl(ambientErrors.ts, 13, 21)) + +// Ambient function with default parameter values +declare function fn3(x = 3); +>fn3 : Symbol(fn3, Decl(ambientErrors.ts, 13, 40)) +>x : Symbol(x, Decl(ambientErrors.ts, 16, 21)) + +// Ambient function with function body +declare function fn4() { }; +>fn4 : Symbol(fn4, Decl(ambientErrors.ts, 16, 28)) + +// Ambient enum with non - integer literal constant member +declare enum E1 { +>E1 : Symbol(E1, Decl(ambientErrors.ts, 19, 27)) + + y = 4.23 +>y : Symbol(E1.y, Decl(ambientErrors.ts, 22, 17)) +} + +// Ambient enum with computer member +declare enum E2 { +>E2 : Symbol(E2, Decl(ambientErrors.ts, 24, 1)) + + x = 'foo'.length +>x : Symbol(E2.x, Decl(ambientErrors.ts, 27, 17)) +>'foo'.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +} + +// Ambient module with initializers for values, bodies for functions / classes +declare module M1 { +>M1 : Symbol(M1, Decl(ambientErrors.ts, 29, 1)) + + var x = 3; +>x : Symbol(x, Decl(ambientErrors.ts, 33, 7)) + + function fn() { } +>fn : Symbol(fn, Decl(ambientErrors.ts, 33, 14)) + + class C { +>C : Symbol(C, Decl(ambientErrors.ts, 34, 21)) + + static x = 3; +>x : Symbol(C.x, Decl(ambientErrors.ts, 35, 13)) + + y = 4; +>y : Symbol(C.y, Decl(ambientErrors.ts, 36, 21)) + + constructor() { } + fn() { } +>fn : Symbol(C.fn, Decl(ambientErrors.ts, 38, 25)) + + static sfn() { } +>sfn : Symbol(C.sfn, Decl(ambientErrors.ts, 39, 16)) + } +} + +// Ambient external module not in the global module +module M2 { +>M2 : Symbol(M2, Decl(ambientErrors.ts, 42, 1)) + + declare module 'nope' { } +} + +// Ambient external module with a string literal name that isn't a top level external module name +declare module '../foo' { } + +// Ambient external module with export assignment and other exported members +declare module 'bar' { + var n; +>n : Symbol(n, Decl(ambientErrors.ts, 54, 7)) + + export var q; +>q : Symbol(q, Decl(ambientErrors.ts, 55, 14)) + + export = n; +>n : Symbol(n, Decl(ambientErrors.ts, 54, 7)) +} + diff --git a/tests/baselines/reference/ambientErrors.types b/tests/baselines/reference/ambientErrors.types new file mode 100644 index 00000000000..3cd46066219 --- /dev/null +++ b/tests/baselines/reference/ambientErrors.types @@ -0,0 +1,116 @@ +=== tests/cases/conformance/ambient/ambientErrors.ts === +// Ambient variable with an initializer +declare var x = 4; +>x : number +>4 : 4 + +// Ambient functions with invalid overloads +declare function fn(x: number): string; +>fn : { (x: number): string; (x: "foo"): number; } +>x : number + +declare function fn(x: 'foo'): number; +>fn : { (x: number): string; (x: "foo"): number; } +>x : "foo" + +// Ambient functions with duplicate signatures +declare function fn1(x: number): string; +>fn1 : { (x: number): string; (x: number): string; } +>x : number + +declare function fn1(x: number): string; +>fn1 : { (x: number): string; (x: number): string; } +>x : number + +// Ambient function overloads that differ only by return type +declare function fn2(x: number): string; +>fn2 : { (x: number): string; (x: number): number; } +>x : number + +declare function fn2(x: number): number; +>fn2 : { (x: number): string; (x: number): number; } +>x : number + +// Ambient function with default parameter values +declare function fn3(x = 3); +>fn3 : (x?: number) => any +>x : number +>3 : 3 + +// Ambient function with function body +declare function fn4() { }; +>fn4 : () => void + +// Ambient enum with non - integer literal constant member +declare enum E1 { +>E1 : E1 + + y = 4.23 +>y : E1 +>4.23 : 4.23 +} + +// Ambient enum with computer member +declare enum E2 { +>E2 : E2 + + x = 'foo'.length +>x : E2 +>'foo'.length : number +>'foo' : "foo" +>length : number +} + +// Ambient module with initializers for values, bodies for functions / classes +declare module M1 { +>M1 : typeof M1 + + var x = 3; +>x : number +>3 : 3 + + function fn() { } +>fn : () => void + + class C { +>C : C + + static x = 3; +>x : number +>3 : 3 + + y = 4; +>y : number +>4 : 4 + + constructor() { } + fn() { } +>fn : () => void + + static sfn() { } +>sfn : () => void + } +} + +// Ambient external module not in the global module +module M2 { +>M2 : any + + declare module 'nope' { } +} + +// Ambient external module with a string literal name that isn't a top level external module name +declare module '../foo' { } + +// Ambient external module with export assignment and other exported members +declare module 'bar' { + var n; +>n : any + + export var q; +>q : any + + export = n; +>n : any +} + diff --git a/tests/baselines/reference/ambientErrors1.symbols b/tests/baselines/reference/ambientErrors1.symbols new file mode 100644 index 00000000000..65efc571619 --- /dev/null +++ b/tests/baselines/reference/ambientErrors1.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/ambientErrors1.ts === +declare var x = 4; +>x : Symbol(x, Decl(ambientErrors1.ts, 0, 11)) + diff --git a/tests/baselines/reference/ambientErrors1.types b/tests/baselines/reference/ambientErrors1.types new file mode 100644 index 00000000000..edf186a9024 --- /dev/null +++ b/tests/baselines/reference/ambientErrors1.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/ambientErrors1.ts === +declare var x = 4; +>x : number +>4 : 4 + diff --git a/tests/baselines/reference/ambientExportDefaultErrors.symbols b/tests/baselines/reference/ambientExportDefaultErrors.symbols new file mode 100644 index 00000000000..bfec3520347 --- /dev/null +++ b/tests/baselines/reference/ambientExportDefaultErrors.symbols @@ -0,0 +1,33 @@ +=== tests/cases/compiler/consumer.ts === +/// +No type information for this code./// +No type information for this code.import "indirect"; +No type information for this code.import "foo"; +No type information for this code.import "indirect2"; +No type information for this code.import "foo2"; +No type information for this code.=== tests/cases/compiler/foo.d.ts === +export default 2 + 2; +export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 0, 21)) + +=== tests/cases/compiler/foo2.d.ts === +export = 2 + 2; +export as namespace Foo2; +>Foo2 : Symbol(Foo2, Decl(foo2.d.ts, 0, 15)) + +=== tests/cases/compiler/indirection.d.ts === +/// +declare module "indirect" { + export default typeof Foo.default; +>Foo.default : Symbol(Foo.default, Decl(foo.d.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(foo.d.ts, 0, 21)) +>default : Symbol(Foo.default, Decl(foo.d.ts, 0, 0)) +} + +=== tests/cases/compiler/indirection2.d.ts === +/// +declare module "indirect2" { + export = typeof Foo2; +>Foo2 : Symbol(Foo2, Decl(foo2.d.ts, 0, 15)) +} + diff --git a/tests/baselines/reference/ambientExportDefaultErrors.types b/tests/baselines/reference/ambientExportDefaultErrors.types new file mode 100644 index 00000000000..97d2051a70a --- /dev/null +++ b/tests/baselines/reference/ambientExportDefaultErrors.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/consumer.ts === +/// +No type information for this code./// +No type information for this code.import "indirect"; +No type information for this code.import "foo"; +No type information for this code.import "indirect2"; +No type information for this code.import "foo2"; +No type information for this code.=== tests/cases/compiler/foo.d.ts === +export default 2 + 2; +>2 + 2 : number +>2 : 2 +>2 : 2 + +export as namespace Foo; +>Foo : typeof "tests/cases/compiler/foo" + +=== tests/cases/compiler/foo2.d.ts === +export = 2 + 2; +>2 + 2 : number +>2 : 2 +>2 : 2 + +export as namespace Foo2; +>Foo2 : number + +=== tests/cases/compiler/indirection.d.ts === +/// +declare module "indirect" { + export default typeof Foo.default; +>typeof Foo.default : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>Foo.default : number +>Foo : typeof Foo +>default : number +} + +=== tests/cases/compiler/indirection2.d.ts === +/// +declare module "indirect2" { + export = typeof Foo2; +>typeof Foo2 : "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" +>Foo2 : number +} + diff --git a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.symbols b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.symbols new file mode 100644 index 00000000000..7ab22e063e3 --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts === +class D { } +>D : Symbol(D, Decl(ambientExternalModuleInAnotherExternalModule.ts, 0, 0)) + +export = D; +>D : Symbol(D, Decl(ambientExternalModuleInAnotherExternalModule.ts, 0, 0)) + +declare module "ext" { + export class C { } +>C : Symbol(C, Decl(ambientExternalModuleInAnotherExternalModule.ts, 3, 22)) +} + +// Cannot resolve this ext module reference +import ext = require("ext"); +>ext : Symbol(ext, Decl(ambientExternalModuleInAnotherExternalModule.ts, 5, 1)) + +var x = ext; +>x : Symbol(x, Decl(ambientExternalModuleInAnotherExternalModule.ts, 9, 3)) +>ext : Symbol(ext, Decl(ambientExternalModuleInAnotherExternalModule.ts, 5, 1)) + diff --git a/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types new file mode 100644 index 00000000000..e7d852d7a3d --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleInAnotherExternalModule.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/ambientExternalModuleInAnotherExternalModule.ts === +class D { } +>D : D + +export = D; +>D : D + +declare module "ext" { + export class C { } +>C : C +} + +// Cannot resolve this ext module reference +import ext = require("ext"); +>ext : any + +var x = ext; +>x : any +>ext : any + diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.symbols b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.symbols new file mode 100644 index 00000000000..a2b535c5b80 --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts === +module M { +>M : Symbol(M, Decl(ambientExternalModuleInsideNonAmbient.ts, 0, 0)) + + export declare module "M" { } +} diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types new file mode 100644 index 00000000000..d635bfd1d1e --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbient.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbient.ts === +module M { +>M : any + + export declare module "M" { } +} diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.symbols b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.symbols new file mode 100644 index 00000000000..10841ebc4cd --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.symbols @@ -0,0 +1,3 @@ +=== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts === +export declare module "M" { } +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.types b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.types new file mode 100644 index 00000000000..10841ebc4cd --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleInsideNonAmbientExternalModule.types @@ -0,0 +1,3 @@ +=== tests/cases/conformance/ambient/ambientExternalModuleInsideNonAmbientExternalModule.ts === +export declare module "M" { } +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.symbols b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.symbols new file mode 100644 index 00000000000..1e8ad3c5fa5 --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/ambientExternalModuleWithRelativeExternalImportDeclaration.ts === +declare module "OuterModule" { + import m2 = require("./SubModule"); +>m2 : Symbol(m2, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 0, 30)) + + class SubModule { +>SubModule : Symbol(SubModule, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 1, 39)) + + public static StaticVar: number; +>StaticVar : Symbol(SubModule.StaticVar, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 2, 21)) + + public InstanceVar: number; +>InstanceVar : Symbol(SubModule.InstanceVar, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 3, 40)) + + public x: m2.c; +>x : Symbol(SubModule.x, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 4, 35)) +>m2 : Symbol(m2, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 0, 30)) +>c : Symbol(m2) + + constructor(); + } + export = SubModule; +>SubModule : Symbol(SubModule, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 1, 39)) +} diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types new file mode 100644 index 00000000000..0d173e5e7a9 --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/ambientExternalModuleWithRelativeExternalImportDeclaration.ts === +declare module "OuterModule" { + import m2 = require("./SubModule"); +>m2 : any + + class SubModule { +>SubModule : SubModule + + public static StaticVar: number; +>StaticVar : number + + public InstanceVar: number; +>InstanceVar : number + + public x: m2.c; +>x : any +>m2 : any +>c : any + + constructor(); + } + export = SubModule; +>SubModule : SubModule +} diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.symbols b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.symbols new file mode 100644 index 00000000000..a8ef371e805 --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts === +declare module "./relativeModule" { + var x: string; +>x : Symbol(x, Decl(ambientExternalModuleWithRelativeModuleName.ts, 1, 7)) +} + +declare module ".\\relativeModule" { + var x: string; +>x : Symbol(x, Decl(ambientExternalModuleWithRelativeModuleName.ts, 5, 7)) +} diff --git a/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types new file mode 100644 index 00000000000..ab0f2b62f58 --- /dev/null +++ b/tests/baselines/reference/ambientExternalModuleWithRelativeModuleName.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/ambientExternalModuleWithRelativeModuleName.ts === +declare module "./relativeModule" { + var x: string; +>x : string +} + +declare module ".\\relativeModule" { + var x: string; +>x : string +} diff --git a/tests/baselines/reference/ambientGetters.symbols b/tests/baselines/reference/ambientGetters.symbols new file mode 100644 index 00000000000..39a34e1d10b --- /dev/null +++ b/tests/baselines/reference/ambientGetters.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/ambientGetters.ts === +declare class A { +>A : Symbol(A, Decl(ambientGetters.ts, 0, 0)) + + get length() : number; +>length : Symbol(A.length, Decl(ambientGetters.ts, 0, 17)) +} + +declare class B { +>B : Symbol(B, Decl(ambientGetters.ts, 2, 1)) + + get length() { return 0; } +>length : Symbol(B.length, Decl(ambientGetters.ts, 4, 17)) +} diff --git a/tests/baselines/reference/ambientGetters.types b/tests/baselines/reference/ambientGetters.types new file mode 100644 index 00000000000..369742daba5 --- /dev/null +++ b/tests/baselines/reference/ambientGetters.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/ambientGetters.ts === +declare class A { +>A : A + + get length() : number; +>length : number +} + +declare class B { +>B : B + + get length() { return 0; } +>length : number +>0 : 0 +} diff --git a/tests/baselines/reference/ambientStatement1.symbols b/tests/baselines/reference/ambientStatement1.symbols new file mode 100644 index 00000000000..8e05372693c --- /dev/null +++ b/tests/baselines/reference/ambientStatement1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/ambientStatement1.ts === + declare module M1 { +>M1 : Symbol(M1, Decl(ambientStatement1.ts, 0, 0)) + + while(true); + + export var v1 = () => false; +>v1 : Symbol(v1, Decl(ambientStatement1.ts, 3, 15)) + } diff --git a/tests/baselines/reference/ambientStatement1.types b/tests/baselines/reference/ambientStatement1.types new file mode 100644 index 00000000000..da6b2ffc445 --- /dev/null +++ b/tests/baselines/reference/ambientStatement1.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/ambientStatement1.ts === + declare module M1 { +>M1 : typeof M1 + + while(true); +>true : true + + export var v1 = () => false; +>v1 : () => boolean +>() => false : () => boolean +>false : false + } diff --git a/tests/baselines/reference/ambientWithStatements.symbols b/tests/baselines/reference/ambientWithStatements.symbols new file mode 100644 index 00000000000..c5312f356ef --- /dev/null +++ b/tests/baselines/reference/ambientWithStatements.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/ambientWithStatements.ts === +declare module M { +>M : Symbol(M, Decl(ambientWithStatements.ts, 0, 0)) + + break; + continue; + debugger; + do { } while (true); + var x; +>x : Symbol(x, Decl(ambientWithStatements.ts, 5, 7)) + + for (x in null) { } +>x : Symbol(x, Decl(ambientWithStatements.ts, 5, 7)) + + if (true) { } else { } + 1; + L: var y; +>y : Symbol(y, Decl(ambientWithStatements.ts, 9, 10)) + + return; + switch (x) { +>x : Symbol(x, Decl(ambientWithStatements.ts, 5, 7)) + + case 1: + break; + default: + break; + } + throw "nooo"; + try { + } + catch (e) { +>e : Symbol(e, Decl(ambientWithStatements.ts, 20, 11)) + } + finally { + } + with (x) { +>x : Symbol(x, Decl(ambientWithStatements.ts, 5, 7)) + } +} diff --git a/tests/baselines/reference/ambientWithStatements.types b/tests/baselines/reference/ambientWithStatements.types new file mode 100644 index 00000000000..0769200aeb8 --- /dev/null +++ b/tests/baselines/reference/ambientWithStatements.types @@ -0,0 +1,52 @@ +=== tests/cases/compiler/ambientWithStatements.ts === +declare module M { +>M : typeof M + + break; + continue; + debugger; + do { } while (true); +>true : true + + var x; +>x : any + + for (x in null) { } +>x : any +>null : null + + if (true) { } else { } +>true : true + + 1; +>1 : 1 + + L: var y; +>L : any +>y : any + + return; + switch (x) { +>x : any + + case 1: +>1 : 1 + + break; + default: + break; + } + throw "nooo"; +>"nooo" : "nooo" + + try { + } + catch (e) { +>e : any + } + finally { + } + with (x) { +>x : any + } +} diff --git a/tests/baselines/reference/ambiguousGenericAssertion1.symbols b/tests/baselines/reference/ambiguousGenericAssertion1.symbols new file mode 100644 index 00000000000..dab5bcbc4eb --- /dev/null +++ b/tests/baselines/reference/ambiguousGenericAssertion1.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/ambiguousGenericAssertion1.ts === +function f(x: T): T { return null; } +>f : Symbol(f, Decl(ambiguousGenericAssertion1.ts, 0, 0)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 0, 11)) +>x : Symbol(x, Decl(ambiguousGenericAssertion1.ts, 0, 14)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 0, 11)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 0, 11)) + +var r = (x: T) => x; +>r : Symbol(r, Decl(ambiguousGenericAssertion1.ts, 1, 3)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 1, 9)) +>x : Symbol(x, Decl(ambiguousGenericAssertion1.ts, 1, 12)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 1, 9)) +>x : Symbol(x, Decl(ambiguousGenericAssertion1.ts, 1, 12)) + +var r2 = < (x: T) => T>f; // valid +>r2 : Symbol(r2, Decl(ambiguousGenericAssertion1.ts, 2, 3)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 2, 12)) +>x : Symbol(x, Decl(ambiguousGenericAssertion1.ts, 2, 15)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 2, 12)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 2, 12)) +>f : Symbol(f, Decl(ambiguousGenericAssertion1.ts, 0, 0)) + +var r3 = <(x: T) => T>f; // ambiguous, appears to the parser as a << operation +>r3 : Symbol(r3, Decl(ambiguousGenericAssertion1.ts, 3, 3)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 3, 16)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 3, 16)) +>T : Symbol(T, Decl(ambiguousGenericAssertion1.ts, 3, 16)) +>f : Symbol(f, Decl(ambiguousGenericAssertion1.ts, 0, 0)) + diff --git a/tests/baselines/reference/ambiguousGenericAssertion1.types b/tests/baselines/reference/ambiguousGenericAssertion1.types new file mode 100644 index 00000000000..380de5b7e1c --- /dev/null +++ b/tests/baselines/reference/ambiguousGenericAssertion1.types @@ -0,0 +1,39 @@ +=== tests/cases/compiler/ambiguousGenericAssertion1.ts === +function f(x: T): T { return null; } +>f : (x: T) => T +>T : T +>x : T +>T : T +>T : T +>null : null + +var r = (x: T) => x; +>r : (x: T) => T +>(x: T) => x : (x: T) => T +>T : T +>x : T +>T : T +>x : T + +var r2 = < (x: T) => T>f; // valid +>r2 : (x: T) => T +>< (x: T) => T>f : (x: T) => T +>T : T +>x : T +>T : T +>T : T +>f : (x: T) => T + +var r3 = <(x: T) => T>f; // ambiguous, appears to the parser as a << operation +>r3 : boolean +><(x : boolean +>< : any +>T : any +>(x : any +>x : any +>T : any +>T>f : boolean +>T : any +>f : (x: T) => T + diff --git a/tests/baselines/reference/ambiguousOverload.symbols b/tests/baselines/reference/ambiguousOverload.symbols new file mode 100644 index 00000000000..cddb82a7078 --- /dev/null +++ b/tests/baselines/reference/ambiguousOverload.symbols @@ -0,0 +1,47 @@ +=== tests/cases/compiler/ambiguousOverload.ts === +function foof(bar: string, y): number; +>foof : Symbol(foof, Decl(ambiguousOverload.ts, 0, 0), Decl(ambiguousOverload.ts, 0, 38), Decl(ambiguousOverload.ts, 1, 38)) +>bar : Symbol(bar, Decl(ambiguousOverload.ts, 0, 14)) +>y : Symbol(y, Decl(ambiguousOverload.ts, 0, 26)) + +function foof(bar: string, x): string; +>foof : Symbol(foof, Decl(ambiguousOverload.ts, 0, 0), Decl(ambiguousOverload.ts, 0, 38), Decl(ambiguousOverload.ts, 1, 38)) +>bar : Symbol(bar, Decl(ambiguousOverload.ts, 1, 14)) +>x : Symbol(x, Decl(ambiguousOverload.ts, 1, 26)) + +function foof(bar: any): any { return bar }; +>foof : Symbol(foof, Decl(ambiguousOverload.ts, 0, 0), Decl(ambiguousOverload.ts, 0, 38), Decl(ambiguousOverload.ts, 1, 38)) +>bar : Symbol(bar, Decl(ambiguousOverload.ts, 2, 14)) +>bar : Symbol(bar, Decl(ambiguousOverload.ts, 2, 14)) + +var x: number = foof("s", null); +>x : Symbol(x, Decl(ambiguousOverload.ts, 3, 3)) +>foof : Symbol(foof, Decl(ambiguousOverload.ts, 0, 0), Decl(ambiguousOverload.ts, 0, 38), Decl(ambiguousOverload.ts, 1, 38)) + +var y: string = foof("s", null); +>y : Symbol(y, Decl(ambiguousOverload.ts, 4, 3)) +>foof : Symbol(foof, Decl(ambiguousOverload.ts, 0, 0), Decl(ambiguousOverload.ts, 0, 38), Decl(ambiguousOverload.ts, 1, 38)) + +function foof2(bar: string, x): string; +>foof2 : Symbol(foof2, Decl(ambiguousOverload.ts, 4, 32), Decl(ambiguousOverload.ts, 6, 39), Decl(ambiguousOverload.ts, 7, 39)) +>bar : Symbol(bar, Decl(ambiguousOverload.ts, 6, 15)) +>x : Symbol(x, Decl(ambiguousOverload.ts, 6, 27)) + +function foof2(bar: string, y): number; +>foof2 : Symbol(foof2, Decl(ambiguousOverload.ts, 4, 32), Decl(ambiguousOverload.ts, 6, 39), Decl(ambiguousOverload.ts, 7, 39)) +>bar : Symbol(bar, Decl(ambiguousOverload.ts, 7, 15)) +>y : Symbol(y, Decl(ambiguousOverload.ts, 7, 27)) + +function foof2(bar: any): any { return bar }; +>foof2 : Symbol(foof2, Decl(ambiguousOverload.ts, 4, 32), Decl(ambiguousOverload.ts, 6, 39), Decl(ambiguousOverload.ts, 7, 39)) +>bar : Symbol(bar, Decl(ambiguousOverload.ts, 8, 15)) +>bar : Symbol(bar, Decl(ambiguousOverload.ts, 8, 15)) + +var x2: string = foof2("s", null); +>x2 : Symbol(x2, Decl(ambiguousOverload.ts, 9, 3)) +>foof2 : Symbol(foof2, Decl(ambiguousOverload.ts, 4, 32), Decl(ambiguousOverload.ts, 6, 39), Decl(ambiguousOverload.ts, 7, 39)) + +var y2: number = foof2("s", null); +>y2 : Symbol(y2, Decl(ambiguousOverload.ts, 10, 3)) +>foof2 : Symbol(foof2, Decl(ambiguousOverload.ts, 4, 32), Decl(ambiguousOverload.ts, 6, 39), Decl(ambiguousOverload.ts, 7, 39)) + diff --git a/tests/baselines/reference/ambiguousOverload.types b/tests/baselines/reference/ambiguousOverload.types new file mode 100644 index 00000000000..15fe1e988b8 --- /dev/null +++ b/tests/baselines/reference/ambiguousOverload.types @@ -0,0 +1,59 @@ +=== tests/cases/compiler/ambiguousOverload.ts === +function foof(bar: string, y): number; +>foof : { (bar: string, y: any): number; (bar: string, x: any): string; } +>bar : string +>y : any + +function foof(bar: string, x): string; +>foof : { (bar: string, y: any): number; (bar: string, x: any): string; } +>bar : string +>x : any + +function foof(bar: any): any { return bar }; +>foof : { (bar: string, y: any): number; (bar: string, x: any): string; } +>bar : any +>bar : any + +var x: number = foof("s", null); +>x : number +>foof("s", null) : number +>foof : { (bar: string, y: any): number; (bar: string, x: any): string; } +>"s" : "s" +>null : null + +var y: string = foof("s", null); +>y : string +>foof("s", null) : number +>foof : { (bar: string, y: any): number; (bar: string, x: any): string; } +>"s" : "s" +>null : null + +function foof2(bar: string, x): string; +>foof2 : { (bar: string, x: any): string; (bar: string, y: any): number; } +>bar : string +>x : any + +function foof2(bar: string, y): number; +>foof2 : { (bar: string, x: any): string; (bar: string, y: any): number; } +>bar : string +>y : any + +function foof2(bar: any): any { return bar }; +>foof2 : { (bar: string, x: any): string; (bar: string, y: any): number; } +>bar : any +>bar : any + +var x2: string = foof2("s", null); +>x2 : string +>foof2("s", null) : string +>foof2 : { (bar: string, x: any): string; (bar: string, y: any): number; } +>"s" : "s" +>null : null + +var y2: number = foof2("s", null); +>y2 : number +>foof2("s", null) : string +>foof2 : { (bar: string, x: any): string; (bar: string, y: any): number; } +>"s" : "s" +>null : null + diff --git a/tests/baselines/reference/amdDependencyComment1.symbols b/tests/baselines/reference/amdDependencyComment1.symbols new file mode 100644 index 00000000000..01502620ab9 --- /dev/null +++ b/tests/baselines/reference/amdDependencyComment1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/amdDependencyComment1.ts === +/// + +import m1 = require("m2") +>m1 : Symbol(m1, Decl(amdDependencyComment1.ts, 0, 0)) + +m1.f(); +>m1 : Symbol(m1, Decl(amdDependencyComment1.ts, 0, 0)) + diff --git a/tests/baselines/reference/amdDependencyComment1.types b/tests/baselines/reference/amdDependencyComment1.types new file mode 100644 index 00000000000..c81dfa5d470 --- /dev/null +++ b/tests/baselines/reference/amdDependencyComment1.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/amdDependencyComment1.ts === +/// + +import m1 = require("m2") +>m1 : any + +m1.f(); +>m1.f() : any +>m1.f : any +>m1 : any +>f : any + diff --git a/tests/baselines/reference/amdDependencyComment2.symbols b/tests/baselines/reference/amdDependencyComment2.symbols new file mode 100644 index 00000000000..0a8fdc9875a --- /dev/null +++ b/tests/baselines/reference/amdDependencyComment2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/amdDependencyComment2.ts === +/// + +import m1 = require("m2") +>m1 : Symbol(m1, Decl(amdDependencyComment2.ts, 0, 0)) + +m1.f(); +>m1 : Symbol(m1, Decl(amdDependencyComment2.ts, 0, 0)) + diff --git a/tests/baselines/reference/amdDependencyComment2.types b/tests/baselines/reference/amdDependencyComment2.types new file mode 100644 index 00000000000..88e98fb6764 --- /dev/null +++ b/tests/baselines/reference/amdDependencyComment2.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/amdDependencyComment2.ts === +/// + +import m1 = require("m2") +>m1 : any + +m1.f(); +>m1.f() : any +>m1.f : any +>m1 : any +>f : any + diff --git a/tests/baselines/reference/amdDependencyCommentName1.symbols b/tests/baselines/reference/amdDependencyCommentName1.symbols new file mode 100644 index 00000000000..bea7334dd43 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/amdDependencyCommentName1.ts === +/// + +import m1 = require("m2") +>m1 : Symbol(m1, Decl(amdDependencyCommentName1.ts, 0, 0)) + +m1.f(); +>m1 : Symbol(m1, Decl(amdDependencyCommentName1.ts, 0, 0)) + diff --git a/tests/baselines/reference/amdDependencyCommentName1.types b/tests/baselines/reference/amdDependencyCommentName1.types new file mode 100644 index 00000000000..da083613b79 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName1.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/amdDependencyCommentName1.ts === +/// + +import m1 = require("m2") +>m1 : any + +m1.f(); +>m1.f() : any +>m1.f : any +>m1 : any +>f : any + diff --git a/tests/baselines/reference/amdDependencyCommentName2.symbols b/tests/baselines/reference/amdDependencyCommentName2.symbols new file mode 100644 index 00000000000..302c9cdb461 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName2.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/amdDependencyCommentName2.ts === +/// + +import m1 = require("m2") +>m1 : Symbol(m1, Decl(amdDependencyCommentName2.ts, 0, 0)) + +m1.f(); +>m1 : Symbol(m1, Decl(amdDependencyCommentName2.ts, 0, 0)) + diff --git a/tests/baselines/reference/amdDependencyCommentName2.types b/tests/baselines/reference/amdDependencyCommentName2.types new file mode 100644 index 00000000000..a90deec2187 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName2.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/amdDependencyCommentName2.ts === +/// + +import m1 = require("m2") +>m1 : any + +m1.f(); +>m1.f() : any +>m1.f : any +>m1 : any +>f : any + diff --git a/tests/baselines/reference/amdDependencyCommentName3.symbols b/tests/baselines/reference/amdDependencyCommentName3.symbols new file mode 100644 index 00000000000..43c677c1270 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName3.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/amdDependencyCommentName3.ts === +/// +/// +/// + +import m1 = require("m2") +>m1 : Symbol(m1, Decl(amdDependencyCommentName3.ts, 0, 0)) + +m1.f(); +>m1 : Symbol(m1, Decl(amdDependencyCommentName3.ts, 0, 0)) + diff --git a/tests/baselines/reference/amdDependencyCommentName3.types b/tests/baselines/reference/amdDependencyCommentName3.types new file mode 100644 index 00000000000..caa6360875d --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName3.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/amdDependencyCommentName3.ts === +/// +/// +/// + +import m1 = require("m2") +>m1 : any + +m1.f(); +>m1.f() : any +>m1.f : any +>m1 : any +>f : any + diff --git a/tests/baselines/reference/amdDependencyCommentName4.symbols b/tests/baselines/reference/amdDependencyCommentName4.symbols new file mode 100644 index 00000000000..5b7e58c8178 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName4.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/amdDependencyCommentName4.ts === +/// +/// +/// +/// + +import "unaliasedModule1"; + +import r1 = require("aliasedModule1"); +>r1 : Symbol(r1, Decl(amdDependencyCommentName4.ts, 5, 26)) + +r1; +>r1 : Symbol(r1, Decl(amdDependencyCommentName4.ts, 5, 26)) + +import {p1, p2, p3} from "aliasedModule2"; +>p1 : Symbol(p1, Decl(amdDependencyCommentName4.ts, 10, 8)) +>p2 : Symbol(p2, Decl(amdDependencyCommentName4.ts, 10, 11)) +>p3 : Symbol(p3, Decl(amdDependencyCommentName4.ts, 10, 15)) + +p1; +>p1 : Symbol(p1, Decl(amdDependencyCommentName4.ts, 10, 8)) + +import d from "aliasedModule3"; +>d : Symbol(d, Decl(amdDependencyCommentName4.ts, 13, 6)) + +d; +>d : Symbol(d, Decl(amdDependencyCommentName4.ts, 13, 6)) + +import * as ns from "aliasedModule4"; +>ns : Symbol(ns, Decl(amdDependencyCommentName4.ts, 16, 6)) + +ns; +>ns : Symbol(ns, Decl(amdDependencyCommentName4.ts, 16, 6)) + +import "unaliasedModule2"; diff --git a/tests/baselines/reference/amdDependencyCommentName4.types b/tests/baselines/reference/amdDependencyCommentName4.types new file mode 100644 index 00000000000..19042f96d67 --- /dev/null +++ b/tests/baselines/reference/amdDependencyCommentName4.types @@ -0,0 +1,35 @@ +=== tests/cases/compiler/amdDependencyCommentName4.ts === +/// +/// +/// +/// + +import "unaliasedModule1"; + +import r1 = require("aliasedModule1"); +>r1 : any + +r1; +>r1 : any + +import {p1, p2, p3} from "aliasedModule2"; +>p1 : any +>p2 : any +>p3 : any + +p1; +>p1 : any + +import d from "aliasedModule3"; +>d : any + +d; +>d : any + +import * as ns from "aliasedModule4"; +>ns : any + +ns; +>ns : any + +import "unaliasedModule2"; diff --git a/tests/baselines/reference/amdModuleName2.symbols b/tests/baselines/reference/amdModuleName2.symbols new file mode 100644 index 00000000000..48c8e3fbdb4 --- /dev/null +++ b/tests/baselines/reference/amdModuleName2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/amdModuleName2.ts === +/// +/// +class Foo { +>Foo : Symbol(Foo, Decl(amdModuleName2.ts, 0, 0)) + + x: number; +>x : Symbol(Foo.x, Decl(amdModuleName2.ts, 2, 11)) + + constructor() { + this.x = 5; +>this.x : Symbol(Foo.x, Decl(amdModuleName2.ts, 2, 11)) +>this : Symbol(Foo, Decl(amdModuleName2.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(amdModuleName2.ts, 2, 11)) + } +} +export = Foo; +>Foo : Symbol(Foo, Decl(amdModuleName2.ts, 0, 0)) + diff --git a/tests/baselines/reference/amdModuleName2.types b/tests/baselines/reference/amdModuleName2.types new file mode 100644 index 00000000000..7989db303ff --- /dev/null +++ b/tests/baselines/reference/amdModuleName2.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/amdModuleName2.ts === +/// +/// +class Foo { +>Foo : Foo + + x: number; +>x : number + + constructor() { + this.x = 5; +>this.x = 5 : 5 +>this.x : number +>this : this +>x : number +>5 : 5 + } +} +export = Foo; +>Foo : Foo + diff --git a/tests/baselines/reference/anonymousClassExpression2.symbols b/tests/baselines/reference/anonymousClassExpression2.symbols new file mode 100644 index 00000000000..70a193deff7 --- /dev/null +++ b/tests/baselines/reference/anonymousClassExpression2.symbols @@ -0,0 +1,33 @@ +=== tests/cases/compiler/anonymousClassExpression2.ts === +// Fixes #14860 +// note: repros with `while (0);` too +// but it's less inscrutable and more obvious to put it *inside* the loop +while (0) { + class A { +>A : Symbol(A, Decl(anonymousClassExpression2.ts, 3, 11)) + + methodA() { +>methodA : Symbol(A.methodA, Decl(anonymousClassExpression2.ts, 4, 13)) + + this; //note: a this reference of some kind is required to trigger the bug +>this : Symbol(A, Decl(anonymousClassExpression2.ts, 3, 11)) + } + } + + class B { +>B : Symbol(B, Decl(anonymousClassExpression2.ts, 8, 5)) + + methodB() { +>methodB : Symbol(B.methodB, Decl(anonymousClassExpression2.ts, 10, 13)) + + this.methodA; // error +>this : Symbol(B, Decl(anonymousClassExpression2.ts, 8, 5)) + + this.methodB; // ok +>this.methodB : Symbol(B.methodB, Decl(anonymousClassExpression2.ts, 10, 13)) +>this : Symbol(B, Decl(anonymousClassExpression2.ts, 8, 5)) +>methodB : Symbol(B.methodB, Decl(anonymousClassExpression2.ts, 10, 13)) + } + } +} + diff --git a/tests/baselines/reference/anonymousClassExpression2.types b/tests/baselines/reference/anonymousClassExpression2.types new file mode 100644 index 00000000000..f26f8e497ca --- /dev/null +++ b/tests/baselines/reference/anonymousClassExpression2.types @@ -0,0 +1,37 @@ +=== tests/cases/compiler/anonymousClassExpression2.ts === +// Fixes #14860 +// note: repros with `while (0);` too +// but it's less inscrutable and more obvious to put it *inside* the loop +while (0) { +>0 : 0 + + class A { +>A : A + + methodA() { +>methodA : () => void + + this; //note: a this reference of some kind is required to trigger the bug +>this : this + } + } + + class B { +>B : B + + methodB() { +>methodB : () => void + + this.methodA; // error +>this.methodA : any +>this : this +>methodA : any + + this.methodB; // ok +>this.methodB : () => void +>this : this +>methodB : () => void + } + } +} + diff --git a/tests/baselines/reference/anonymousModules.symbols b/tests/baselines/reference/anonymousModules.symbols new file mode 100644 index 00000000000..1967e246648 --- /dev/null +++ b/tests/baselines/reference/anonymousModules.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/anonymousModules.ts === +module { + export var foo = 1; +>foo : Symbol(foo, Decl(anonymousModules.ts, 1, 11)) + + module { + export var bar = 1; +>bar : Symbol(bar, Decl(anonymousModules.ts, 4, 12), Decl(anonymousModules.ts, 7, 4)) + } + + var bar = 2; +>bar : Symbol(bar, Decl(anonymousModules.ts, 4, 12), Decl(anonymousModules.ts, 7, 4)) + + module { + var x = bar; +>x : Symbol(x, Decl(anonymousModules.ts, 10, 5)) +>bar : Symbol(bar, Decl(anonymousModules.ts, 4, 12), Decl(anonymousModules.ts, 7, 4)) + } +} diff --git a/tests/baselines/reference/anonymousModules.types b/tests/baselines/reference/anonymousModules.types new file mode 100644 index 00000000000..d06ff96ba37 --- /dev/null +++ b/tests/baselines/reference/anonymousModules.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/anonymousModules.ts === +module { +>module : any + + export var foo = 1; +>foo : number +>1 : 1 + + module { +>module : any + + export var bar = 1; +>bar : number +>1 : 1 + } + + var bar = 2; +>bar : number +>2 : 2 + + module { +>module : any + + var x = bar; +>x : number +>bar : number + } +} diff --git a/tests/baselines/reference/anyAsConstructor.symbols b/tests/baselines/reference/anyAsConstructor.symbols new file mode 100644 index 00000000000..440d77730da --- /dev/null +++ b/tests/baselines/reference/anyAsConstructor.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/types/any/anyAsConstructor.ts === +// any is considered an untyped function call +// can be called except with type arguments which is an error + +var x: any; +>x : Symbol(x, Decl(anyAsConstructor.ts, 3, 3)) + +var a = new x(); +>a : Symbol(a, Decl(anyAsConstructor.ts, 4, 3)) +>x : Symbol(x, Decl(anyAsConstructor.ts, 3, 3)) + +var b = new x('hello'); +>b : Symbol(b, Decl(anyAsConstructor.ts, 5, 3)) +>x : Symbol(x, Decl(anyAsConstructor.ts, 3, 3)) + +var c = new x(x); +>c : Symbol(c, Decl(anyAsConstructor.ts, 6, 3)) +>x : Symbol(x, Decl(anyAsConstructor.ts, 3, 3)) +>x : Symbol(x, Decl(anyAsConstructor.ts, 3, 3)) + +// grammar allows this for constructors +var d = new x(x); // no error +>d : Symbol(d, Decl(anyAsConstructor.ts, 9, 3)) +>x : Symbol(x, Decl(anyAsConstructor.ts, 3, 3)) +>x : Symbol(x, Decl(anyAsConstructor.ts, 3, 3)) + diff --git a/tests/baselines/reference/anyAsConstructor.types b/tests/baselines/reference/anyAsConstructor.types new file mode 100644 index 00000000000..56ae4315b75 --- /dev/null +++ b/tests/baselines/reference/anyAsConstructor.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/types/any/anyAsConstructor.ts === +// any is considered an untyped function call +// can be called except with type arguments which is an error + +var x: any; +>x : any + +var a = new x(); +>a : any +>new x() : any +>x : any + +var b = new x('hello'); +>b : any +>new x('hello') : any +>x : any +>'hello' : "hello" + +var c = new x(x); +>c : any +>new x(x) : any +>x : any +>x : any + +// grammar allows this for constructors +var d = new x(x); // no error +>d : any +>new x(x) : any +>x : any +>x : any + diff --git a/tests/baselines/reference/anyAsGenericFunctionCall.symbols b/tests/baselines/reference/anyAsGenericFunctionCall.symbols new file mode 100644 index 00000000000..be29f1def44 --- /dev/null +++ b/tests/baselines/reference/anyAsGenericFunctionCall.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/types/any/anyAsGenericFunctionCall.ts === +// any is considered an untyped function call +// can be called except with type arguments which is an error + +var x: any; +>x : Symbol(x, Decl(anyAsGenericFunctionCall.ts, 3, 3)) + +var a = x(); +>a : Symbol(a, Decl(anyAsGenericFunctionCall.ts, 4, 3)) +>x : Symbol(x, Decl(anyAsGenericFunctionCall.ts, 3, 3)) + +var b = x('hello'); +>b : Symbol(b, Decl(anyAsGenericFunctionCall.ts, 5, 3)) +>x : Symbol(x, Decl(anyAsGenericFunctionCall.ts, 3, 3)) + +class C { foo: string; } +>C : Symbol(C, Decl(anyAsGenericFunctionCall.ts, 5, 27)) +>foo : Symbol(C.foo, Decl(anyAsGenericFunctionCall.ts, 7, 9)) + +var c = x(x); +>c : Symbol(c, Decl(anyAsGenericFunctionCall.ts, 8, 3)) +>x : Symbol(x, Decl(anyAsGenericFunctionCall.ts, 3, 3)) +>C : Symbol(C, Decl(anyAsGenericFunctionCall.ts, 5, 27)) +>x : Symbol(x, Decl(anyAsGenericFunctionCall.ts, 3, 3)) + +var d = x(x); +>d : Symbol(d, Decl(anyAsGenericFunctionCall.ts, 9, 3)) +>x : Symbol(x, Decl(anyAsGenericFunctionCall.ts, 3, 3)) +>x : Symbol(x, Decl(anyAsGenericFunctionCall.ts, 3, 3)) + diff --git a/tests/baselines/reference/anyAsGenericFunctionCall.types b/tests/baselines/reference/anyAsGenericFunctionCall.types new file mode 100644 index 00000000000..4cf5dd8990d --- /dev/null +++ b/tests/baselines/reference/anyAsGenericFunctionCall.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/types/any/anyAsGenericFunctionCall.ts === +// any is considered an untyped function call +// can be called except with type arguments which is an error + +var x: any; +>x : any + +var a = x(); +>a : any +>x() : any +>x : any + +var b = x('hello'); +>b : any +>x('hello') : any +>x : any +>'hello' : "hello" + +class C { foo: string; } +>C : C +>foo : string + +var c = x(x); +>c : any +>x(x) : any +>x : any +>C : C +>x : any + +var d = x(x); +>d : any +>x(x) : any +>x : any +>x : any + diff --git a/tests/baselines/reference/anyAssignabilityInInheritance.symbols b/tests/baselines/reference/anyAssignabilityInInheritance.symbols index d1043256962..56bb982fea1 100644 --- a/tests/baselines/reference/anyAssignabilityInInheritance.symbols +++ b/tests/baselines/reference/anyAssignabilityInInheritance.symbols @@ -23,7 +23,7 @@ declare function foo2(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 10, 22)) var r3 = foo2(a); // any, not a subtype of number so it skips that overload, is a subtype of itself so it picks second (if truly ambiguous it would pick first overload) ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo2 : Symbol(foo2, Decl(anyAssignabilityInInheritance.ts, 7, 11), Decl(anyAssignabilityInInheritance.ts, 9, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -36,7 +36,7 @@ declare function foo3(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 14, 22)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -49,7 +49,7 @@ declare function foo4(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 18, 22)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -64,7 +64,7 @@ declare function foo5(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 22, 22)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -79,7 +79,7 @@ declare function foo6(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 26, 22)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -94,7 +94,7 @@ declare function foo7(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 30, 22)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -107,7 +107,7 @@ declare function foo8(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 34, 22)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -126,7 +126,7 @@ declare function foo9(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 39, 22)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -145,7 +145,7 @@ declare function foo10(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 44, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -166,7 +166,7 @@ declare function foo11(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 49, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -181,7 +181,7 @@ declare function foo12(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 53, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -202,7 +202,7 @@ declare function foo13(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 57, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -221,7 +221,7 @@ declare function foo14(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 62, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -245,7 +245,7 @@ declare function foo15(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 70, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -270,7 +270,7 @@ declare function foo16(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 78, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -285,7 +285,7 @@ declare function foo17(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 82, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) @@ -298,7 +298,7 @@ declare function foo18(x: any): any; >x : Symbol(x, Decl(anyAssignabilityInInheritance.ts, 86, 23)) var r3 = foo3(a); // any ->r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3), Decl(anyAssignabilityInInheritance.ts, 31, 3), Decl(anyAssignabilityInInheritance.ts, 35, 3), Decl(anyAssignabilityInInheritance.ts, 40, 3), Decl(anyAssignabilityInInheritance.ts, 45, 3), Decl(anyAssignabilityInInheritance.ts, 50, 3), Decl(anyAssignabilityInInheritance.ts, 54, 3), Decl(anyAssignabilityInInheritance.ts, 58, 3), Decl(anyAssignabilityInInheritance.ts, 63, 3), Decl(anyAssignabilityInInheritance.ts, 71, 3), Decl(anyAssignabilityInInheritance.ts, 79, 3), Decl(anyAssignabilityInInheritance.ts, 83, 3), Decl(anyAssignabilityInInheritance.ts, 87, 3)) +>r3 : Symbol(r3, Decl(anyAssignabilityInInheritance.ts, 11, 3), Decl(anyAssignabilityInInheritance.ts, 15, 3), Decl(anyAssignabilityInInheritance.ts, 19, 3), Decl(anyAssignabilityInInheritance.ts, 23, 3), Decl(anyAssignabilityInInheritance.ts, 27, 3) ... and 12 more) >foo3 : Symbol(foo3, Decl(anyAssignabilityInInheritance.ts, 11, 17), Decl(anyAssignabilityInInheritance.ts, 13, 41)) >a : Symbol(a, Decl(anyAssignabilityInInheritance.ts, 7, 3)) diff --git a/tests/baselines/reference/anyDeclare.symbols b/tests/baselines/reference/anyDeclare.symbols new file mode 100644 index 00000000000..8975677a7c2 --- /dev/null +++ b/tests/baselines/reference/anyDeclare.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/anyDeclare.ts === +declare var x: any; +>x : Symbol(x, Decl(anyDeclare.ts, 0, 11)) + +module myMod { +>myMod : Symbol(myMod, Decl(anyDeclare.ts, 0, 19)) + + var myFn; +>myFn : Symbol(myFn, Decl(anyDeclare.ts, 2, 7)) + + function myFn() { } +>myFn : Symbol(myFn, Decl(anyDeclare.ts, 2, 13)) +} + diff --git a/tests/baselines/reference/anyDeclare.types b/tests/baselines/reference/anyDeclare.types new file mode 100644 index 00000000000..6d1e85a4ae8 --- /dev/null +++ b/tests/baselines/reference/anyDeclare.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/anyDeclare.ts === +declare var x: any; +>x : any + +module myMod { +>myMod : typeof myMod + + var myFn; +>myFn : any + + function myFn() { } +>myFn : () => void +} + diff --git a/tests/baselines/reference/anyIdenticalToItself.symbols b/tests/baselines/reference/anyIdenticalToItself.symbols new file mode 100644 index 00000000000..f09459d6bfc --- /dev/null +++ b/tests/baselines/reference/anyIdenticalToItself.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/anyIdenticalToItself.ts === +function foo(x: any); +>foo : Symbol(foo, Decl(anyIdenticalToItself.ts, 0, 0), Decl(anyIdenticalToItself.ts, 0, 21), Decl(anyIdenticalToItself.ts, 1, 21)) +>x : Symbol(x, Decl(anyIdenticalToItself.ts, 0, 13)) + +function foo(x: any); +>foo : Symbol(foo, Decl(anyIdenticalToItself.ts, 0, 0), Decl(anyIdenticalToItself.ts, 0, 21), Decl(anyIdenticalToItself.ts, 1, 21)) +>x : Symbol(x, Decl(anyIdenticalToItself.ts, 1, 13)) + +function foo(x: any, y: number) { } +>foo : Symbol(foo, Decl(anyIdenticalToItself.ts, 0, 0), Decl(anyIdenticalToItself.ts, 0, 21), Decl(anyIdenticalToItself.ts, 1, 21)) +>x : Symbol(x, Decl(anyIdenticalToItself.ts, 2, 13)) +>y : Symbol(y, Decl(anyIdenticalToItself.ts, 2, 20)) + +class C { +>C : Symbol(C, Decl(anyIdenticalToItself.ts, 2, 35)) + + get X(): any { +>X : Symbol(C.X, Decl(anyIdenticalToItself.ts, 4, 9), Decl(anyIdenticalToItself.ts, 8, 5)) + + var y: any; +>y : Symbol(y, Decl(anyIdenticalToItself.ts, 6, 11)) + + return y; +>y : Symbol(y, Decl(anyIdenticalToItself.ts, 6, 11)) + } + set X(v: any) { +>X : Symbol(C.X, Decl(anyIdenticalToItself.ts, 4, 9), Decl(anyIdenticalToItself.ts, 8, 5)) +>v : Symbol(v, Decl(anyIdenticalToItself.ts, 9, 10)) + } +} diff --git a/tests/baselines/reference/anyIdenticalToItself.types b/tests/baselines/reference/anyIdenticalToItself.types new file mode 100644 index 00000000000..fa71f579cbb --- /dev/null +++ b/tests/baselines/reference/anyIdenticalToItself.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/anyIdenticalToItself.ts === +function foo(x: any); +>foo : { (x: any): any; (x: any): any; } +>x : any + +function foo(x: any); +>foo : { (x: any): any; (x: any): any; } +>x : any + +function foo(x: any, y: number) { } +>foo : { (x: any): any; (x: any): any; } +>x : any +>y : number + +class C { +>C : C + + get X(): any { +>X : any + + var y: any; +>y : any + + return y; +>y : any + } + set X(v: any) { +>X : any +>v : any + } +} diff --git a/tests/baselines/reference/anyIndexedAccessArrayNoException.symbols b/tests/baselines/reference/anyIndexedAccessArrayNoException.symbols new file mode 100644 index 00000000000..31e706cb8cd --- /dev/null +++ b/tests/baselines/reference/anyIndexedAccessArrayNoException.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/anyIndexedAccessArrayNoException.ts === +var x: any[[]]; +>x : Symbol(x, Decl(anyIndexedAccessArrayNoException.ts, 0, 3)) + diff --git a/tests/baselines/reference/anyIndexedAccessArrayNoException.types b/tests/baselines/reference/anyIndexedAccessArrayNoException.types new file mode 100644 index 00000000000..b915911ca61 --- /dev/null +++ b/tests/baselines/reference/anyIndexedAccessArrayNoException.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/anyIndexedAccessArrayNoException.ts === +var x: any[[]]; +>x : any + diff --git a/tests/baselines/reference/apparentTypeSubtyping.symbols b/tests/baselines/reference/apparentTypeSubtyping.symbols new file mode 100644 index 00000000000..dae469bfc9a --- /dev/null +++ b/tests/baselines/reference/apparentTypeSubtyping.symbols @@ -0,0 +1,48 @@ +=== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts === +// subtype checks use the apparent type of the target type +// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: + +class Base { +>Base : Symbol(Base, Decl(apparentTypeSubtyping.ts, 0, 0)) +>U : Symbol(U, Decl(apparentTypeSubtyping.ts, 3, 11)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + x: U; +>x : Symbol(Base.x, Decl(apparentTypeSubtyping.ts, 3, 30)) +>U : Symbol(U, Decl(apparentTypeSubtyping.ts, 3, 11)) +} + +// is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T) +class Derived extends Base { // error +>Derived : Symbol(Derived, Decl(apparentTypeSubtyping.ts, 5, 1)) +>U : Symbol(U, Decl(apparentTypeSubtyping.ts, 8, 14)) +>Base : Symbol(Base, Decl(apparentTypeSubtyping.ts, 0, 0)) + + x: String; +>x : Symbol(Derived.x, Decl(apparentTypeSubtyping.ts, 8, 39)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +class Base2 { +>Base2 : Symbol(Base2, Decl(apparentTypeSubtyping.ts, 10, 1)) + + x: String; +>x : Symbol(Base2.x, Decl(apparentTypeSubtyping.ts, 12, 13)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + static s: String; +>s : Symbol(Base2.s, Decl(apparentTypeSubtyping.ts, 13, 14)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +// is U extends String (S) a subtype of String (T)? Apparent type of U is String so it succeeds +class Derived2 extends Base2 { // error because of the prototype's not matching, not because of the instance side +>Derived2 : Symbol(Derived2, Decl(apparentTypeSubtyping.ts, 15, 1)) +>U : Symbol(U, Decl(apparentTypeSubtyping.ts, 18, 15)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base2 : Symbol(Base2, Decl(apparentTypeSubtyping.ts, 10, 1)) + + x: U; +>x : Symbol(Derived2.x, Decl(apparentTypeSubtyping.ts, 18, 48)) +>U : Symbol(U, Decl(apparentTypeSubtyping.ts, 18, 15)) +} diff --git a/tests/baselines/reference/apparentTypeSubtyping.types b/tests/baselines/reference/apparentTypeSubtyping.types new file mode 100644 index 00000000000..7eba6ac5941 --- /dev/null +++ b/tests/baselines/reference/apparentTypeSubtyping.types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts === +// subtype checks use the apparent type of the target type +// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: + +class Base { +>Base : Base +>U : U +>String : String + + x: U; +>x : U +>U : U +} + +// is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T) +class Derived extends Base { // error +>Derived : Derived +>U : U +>Base : Base + + x: String; +>x : String +>String : String +} + +class Base2 { +>Base2 : Base2 + + x: String; +>x : String +>String : String + + static s: String; +>s : String +>String : String +} + +// is U extends String (S) a subtype of String (T)? Apparent type of U is String so it succeeds +class Derived2 extends Base2 { // error because of the prototype's not matching, not because of the instance side +>Derived2 : Derived2 +>U : U +>String : String +>Base2 : Base2 + + x: U; +>x : U +>U : U +} diff --git a/tests/baselines/reference/apparentTypeSupertype.symbols b/tests/baselines/reference/apparentTypeSupertype.symbols new file mode 100644 index 00000000000..d572fae2ca7 --- /dev/null +++ b/tests/baselines/reference/apparentTypeSupertype.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts === +// subtype checks use the apparent type of the target type +// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: + +class Base { +>Base : Symbol(Base, Decl(apparentTypeSupertype.ts, 0, 0)) + + x: string; +>x : Symbol(Base.x, Decl(apparentTypeSupertype.ts, 3, 12)) +} + +// is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T) +class Derived extends Base { // error +>Derived : Symbol(Derived, Decl(apparentTypeSupertype.ts, 5, 1)) +>U : Symbol(U, Decl(apparentTypeSupertype.ts, 8, 14)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(apparentTypeSupertype.ts, 0, 0)) + + x: U; +>x : Symbol(Derived.x, Decl(apparentTypeSupertype.ts, 8, 46)) +>U : Symbol(U, Decl(apparentTypeSupertype.ts, 8, 14)) +} diff --git a/tests/baselines/reference/apparentTypeSupertype.types b/tests/baselines/reference/apparentTypeSupertype.types new file mode 100644 index 00000000000..626a4c0632d --- /dev/null +++ b/tests/baselines/reference/apparentTypeSupertype.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts === +// subtype checks use the apparent type of the target type +// S is a subtype of a type T, and T is a supertype of S, if one of the following is true, where S' denotes the apparent type (section 3.8.1) of S: + +class Base { +>Base : Base + + x: string; +>x : string +} + +// is String (S) a subtype of U extends String (T)? Would only be true if we used the apparent type of U (T) +class Derived extends Base { // error +>Derived : Derived +>U : U +>String : String +>Base : Base + + x: U; +>x : U +>U : U +} diff --git a/tests/baselines/reference/argumentExpressionContextualTyping.symbols b/tests/baselines/reference/argumentExpressionContextualTyping.symbols new file mode 100644 index 00000000000..9ed7d130795 --- /dev/null +++ b/tests/baselines/reference/argumentExpressionContextualTyping.symbols @@ -0,0 +1,85 @@ +=== tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts === +// In a typed function call, argument expressions are contextually typed by their corresponding parameter types. +function foo({x: [a, b], y: {c, d, e}}) { } +>foo : Symbol(foo, Decl(argumentExpressionContextualTyping.ts, 0, 0)) +>x : Symbol(x) +>a : Symbol(a, Decl(argumentExpressionContextualTyping.ts, 1, 18)) +>b : Symbol(b, Decl(argumentExpressionContextualTyping.ts, 1, 20)) +>y : Symbol(y) +>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 1, 29)) +>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 1, 31)) +>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 1, 34)) + +function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { } +>bar : Symbol(bar, Decl(argumentExpressionContextualTyping.ts, 1, 43)) +>x : Symbol(x) +>a : Symbol(a, Decl(argumentExpressionContextualTyping.ts, 2, 18)) +>b : Symbol(b, Decl(argumentExpressionContextualTyping.ts, 2, 20)) +>y : Symbol(y) +>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 2, 34)) +>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 2, 36)) +>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 2, 39)) +>f : Symbol(f, Decl(argumentExpressionContextualTyping.ts, 2, 45)) + +function baz(x: [string, number, boolean]) { } +>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58)) +>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 3, 13)) + +var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +>o : Symbol(o, Decl(argumentExpressionContextualTyping.ts, 5, 3)) +>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 5, 9)) +>y : Symbol(y, Decl(argumentExpressionContextualTyping.ts, 5, 27)) +>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 5, 32)) +>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 5, 41)) +>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 5, 53)) + +var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +>o1 : Symbol(o1, Decl(argumentExpressionContextualTyping.ts, 6, 3)) +>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 6, 9)) +>y : Symbol(y, Decl(argumentExpressionContextualTyping.ts, 6, 30)) +>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 6, 35)) +>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 6, 47)) +>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 6, 58)) +>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 6, 76)) +>y : Symbol(y, Decl(argumentExpressionContextualTyping.ts, 6, 94)) +>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 6, 99)) +>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 6, 108)) +>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 6, 120)) + +foo(o1); // Not error since x has contextual type of tuple namely [string, number] +>foo : Symbol(foo, Decl(argumentExpressionContextualTyping.ts, 0, 0)) +>o1 : Symbol(o1, Decl(argumentExpressionContextualTyping.ts, 6, 3)) + +foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error +>foo : Symbol(foo, Decl(argumentExpressionContextualTyping.ts, 0, 0)) +>x : Symbol(x, Decl(argumentExpressionContextualTyping.ts, 8, 5)) +>y : Symbol(y, Decl(argumentExpressionContextualTyping.ts, 8, 23)) +>c : Symbol(c, Decl(argumentExpressionContextualTyping.ts, 8, 28)) +>d : Symbol(d, Decl(argumentExpressionContextualTyping.ts, 8, 37)) +>e : Symbol(e, Decl(argumentExpressionContextualTyping.ts, 8, 49)) + +var array = ["string", 1, true]; +>array : Symbol(array, Decl(argumentExpressionContextualTyping.ts, 10, 3)) + +var tuple: [string, number, boolean] = ["string", 1, true]; +>tuple : Symbol(tuple, Decl(argumentExpressionContextualTyping.ts, 11, 3)) + +baz(tuple); +>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58)) +>tuple : Symbol(tuple, Decl(argumentExpressionContextualTyping.ts, 11, 3)) + +baz(["string", 1, true]); +>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58)) + +baz(array); // Error +>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58)) +>array : Symbol(array, Decl(argumentExpressionContextualTyping.ts, 10, 3)) + +baz(["string", 1, true, ...array]); // Error +>baz : Symbol(baz, Decl(argumentExpressionContextualTyping.ts, 2, 58)) +>array : Symbol(array, Decl(argumentExpressionContextualTyping.ts, 10, 3)) + +foo(o); // Error because x has an array type namely (string|number)[] +>foo : Symbol(foo, Decl(argumentExpressionContextualTyping.ts, 0, 0)) +>o : Symbol(o, Decl(argumentExpressionContextualTyping.ts, 5, 3)) + diff --git a/tests/baselines/reference/argumentExpressionContextualTyping.types b/tests/baselines/reference/argumentExpressionContextualTyping.types new file mode 100644 index 00000000000..3b0fec11aa2 --- /dev/null +++ b/tests/baselines/reference/argumentExpressionContextualTyping.types @@ -0,0 +1,136 @@ +=== tests/cases/conformance/expressions/contextualTyping/argumentExpressionContextualTyping.ts === +// In a typed function call, argument expressions are contextually typed by their corresponding parameter types. +function foo({x: [a, b], y: {c, d, e}}) { } +>foo : ({ x: [a, b], y: { c, d, e } }: { x: [any, any]; y: { c: any; d: any; e: any; }; }) => void +>x : any +>a : any +>b : any +>y : any +>c : any +>d : any +>e : any + +function bar({x: [a, b = 10], y: {c, d, e = { f:1 }}}) { } +>bar : ({ x: [a, b], y: { c, d, e } }: { x: [any, number]; y: { c: any; d: any; e?: { f: number; }; }; }) => void +>x : any +>a : any +>b : number +>10 : 10 +>y : any +>c : any +>d : any +>e : { f: number; } +>{ f:1 } : { f: number; } +>f : number +>1 : 1 + +function baz(x: [string, number, boolean]) { } +>baz : (x: [string, number, boolean]) => void +>x : [string, number, boolean] + +var o = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +>o : { x: (string | number)[]; y: { c: boolean; d: string; e: number; }; } +>{ x: ["string", 1], y: { c: true, d: "world", e: 3 } } : { x: (string | number)[]; y: { c: boolean; d: string; e: number; }; } +>x : (string | number)[] +>["string", 1] : (string | number)[] +>"string" : "string" +>1 : 1 +>y : { c: boolean; d: string; e: number; } +>{ c: true, d: "world", e: 3 } : { c: boolean; d: string; e: number; } +>c : boolean +>true : true +>d : string +>"world" : "world" +>e : number +>3 : 3 + +var o1: { x: [string, number], y: { c: boolean, d: string, e: number } } = { x: ["string", 1], y: { c: true, d: "world", e: 3 } }; +>o1 : { x: [string, number]; y: { c: boolean; d: string; e: number; }; } +>x : [string, number] +>y : { c: boolean; d: string; e: number; } +>c : boolean +>d : string +>e : number +>{ x: ["string", 1], y: { c: true, d: "world", e: 3 } } : { x: [string, number]; y: { c: true; d: string; e: number; }; } +>x : [string, number] +>["string", 1] : [string, number] +>"string" : "string" +>1 : 1 +>y : { c: true; d: string; e: number; } +>{ c: true, d: "world", e: 3 } : { c: true; d: string; e: number; } +>c : boolean +>true : true +>d : string +>"world" : "world" +>e : number +>3 : 3 + +foo(o1); // Not error since x has contextual type of tuple namely [string, number] +>foo(o1) : void +>foo : ({ x: [a, b], y: { c, d, e } }: { x: [any, any]; y: { c: any; d: any; e: any; }; }) => void +>o1 : { x: [string, number]; y: { c: boolean; d: string; e: number; }; } + +foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }); // Not error +>foo({ x: ["string", 1], y: { c: true, d: "world", e: 3 } }) : void +>foo : ({ x: [a, b], y: { c, d, e } }: { x: [any, any]; y: { c: any; d: any; e: any; }; }) => void +>{ x: ["string", 1], y: { c: true, d: "world", e: 3 } } : { x: [string, number]; y: { c: boolean; d: string; e: number; }; } +>x : [string, number] +>["string", 1] : [string, number] +>"string" : "string" +>1 : 1 +>y : { c: boolean; d: string; e: number; } +>{ c: true, d: "world", e: 3 } : { c: boolean; d: string; e: number; } +>c : boolean +>true : true +>d : string +>"world" : "world" +>e : number +>3 : 3 + +var array = ["string", 1, true]; +>array : (string | number | boolean)[] +>["string", 1, true] : (string | number | boolean)[] +>"string" : "string" +>1 : 1 +>true : true + +var tuple: [string, number, boolean] = ["string", 1, true]; +>tuple : [string, number, boolean] +>["string", 1, true] : [string, number, true] +>"string" : "string" +>1 : 1 +>true : true + +baz(tuple); +>baz(tuple) : void +>baz : (x: [string, number, boolean]) => void +>tuple : [string, number, boolean] + +baz(["string", 1, true]); +>baz(["string", 1, true]) : void +>baz : (x: [string, number, boolean]) => void +>["string", 1, true] : [string, number, true] +>"string" : "string" +>1 : 1 +>true : true + +baz(array); // Error +>baz(array) : void +>baz : (x: [string, number, boolean]) => void +>array : (string | number | boolean)[] + +baz(["string", 1, true, ...array]); // Error +>baz(["string", 1, true, ...array]) : void +>baz : (x: [string, number, boolean]) => void +>["string", 1, true, ...array] : (string | number | boolean)[] +>"string" : "string" +>1 : 1 +>true : true +>...array : string | number | boolean +>array : (string | number | boolean)[] + +foo(o); // Error because x has an array type namely (string|number)[] +>foo(o) : void +>foo : ({ x: [a, b], y: { c, d, e } }: { x: [any, any]; y: { c: any; d: any; e: any; }; }) => void +>o : { x: (string | number)[]; y: { c: boolean; d: string; e: number; }; } + diff --git a/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.symbols b/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.symbols new file mode 100644 index 00000000000..f8741f53c84 --- /dev/null +++ b/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts === +var arguments = 10; +>arguments : Symbol(arguments, Decl(argumentsBindsToFunctionScopeArgumentList.ts, 0, 3)) + +function foo(a) { +>foo : Symbol(foo, Decl(argumentsBindsToFunctionScopeArgumentList.ts, 0, 19)) +>a : Symbol(a, Decl(argumentsBindsToFunctionScopeArgumentList.ts, 1, 13)) + + arguments = 10; /// This shouldnt be of type number and result in error. +>arguments : Symbol(arguments) +} diff --git a/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.types b/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.types new file mode 100644 index 00000000000..4aecd3bc4be --- /dev/null +++ b/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts === +var arguments = 10; +>arguments : number +>10 : 10 + +function foo(a) { +>foo : (a: any) => void +>a : any + + arguments = 10; /// This shouldnt be of type number and result in error. +>arguments = 10 : 10 +>arguments : IArguments +>10 : 10 +} diff --git a/tests/baselines/reference/argumentsObjectIterator01_ES5.symbols b/tests/baselines/reference/argumentsObjectIterator01_ES5.symbols new file mode 100644 index 00000000000..7eb2736b3ea --- /dev/null +++ b/tests/baselines/reference/argumentsObjectIterator01_ES5.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/argumentsObjectIterator01_ES5.ts === +function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] { +>doubleAndReturnAsArray : Symbol(doubleAndReturnAsArray, Decl(argumentsObjectIterator01_ES5.ts, 0, 0)) +>x : Symbol(x, Decl(argumentsObjectIterator01_ES5.ts, 0, 32)) +>y : Symbol(y, Decl(argumentsObjectIterator01_ES5.ts, 0, 42)) +>z : Symbol(z, Decl(argumentsObjectIterator01_ES5.ts, 0, 53)) + + let result = []; +>result : Symbol(result, Decl(argumentsObjectIterator01_ES5.ts, 1, 7)) + + for (let arg of arguments) { +>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES5.ts, 2, 12)) +>arguments : Symbol(arguments) + + result.push(arg + arg); +>result.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>result : Symbol(result, Decl(argumentsObjectIterator01_ES5.ts, 1, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES5.ts, 2, 12)) +>arg : Symbol(arg, Decl(argumentsObjectIterator01_ES5.ts, 2, 12)) + } + return <[any, any, any]>result; +>result : Symbol(result, Decl(argumentsObjectIterator01_ES5.ts, 1, 7)) +} diff --git a/tests/baselines/reference/argumentsObjectIterator01_ES5.types b/tests/baselines/reference/argumentsObjectIterator01_ES5.types new file mode 100644 index 00000000000..60ca2090880 --- /dev/null +++ b/tests/baselines/reference/argumentsObjectIterator01_ES5.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/argumentsObjectIterator01_ES5.ts === +function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] { +>doubleAndReturnAsArray : (x: number, y: number, z: number) => [number, number, number] +>x : number +>y : number +>z : number + + let result = []; +>result : any[] +>[] : undefined[] + + for (let arg of arguments) { +>arg : any +>arguments : IArguments + + result.push(arg + arg); +>result.push(arg + arg) : number +>result.push : (...items: any[]) => number +>result : any[] +>push : (...items: any[]) => number +>arg + arg : any +>arg : any +>arg : any + } + return <[any, any, any]>result; +><[any, any, any]>result : [any, any, any] +>result : any[] +} diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES5.symbols b/tests/baselines/reference/argumentsObjectIterator02_ES5.symbols new file mode 100644 index 00000000000..0e1af3a76ad --- /dev/null +++ b/tests/baselines/reference/argumentsObjectIterator02_ES5.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/argumentsObjectIterator02_ES5.ts === +function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] { +>doubleAndReturnAsArray : Symbol(doubleAndReturnAsArray, Decl(argumentsObjectIterator02_ES5.ts, 0, 0)) +>x : Symbol(x, Decl(argumentsObjectIterator02_ES5.ts, 0, 32)) +>y : Symbol(y, Decl(argumentsObjectIterator02_ES5.ts, 0, 42)) +>z : Symbol(z, Decl(argumentsObjectIterator02_ES5.ts, 0, 53)) + + let blah = arguments[Symbol.iterator]; +>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES5.ts, 1, 7)) +>arguments : Symbol(arguments) + + let result = []; +>result : Symbol(result, Decl(argumentsObjectIterator02_ES5.ts, 3, 7)) + + for (let arg of blah()) { +>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES5.ts, 4, 12)) +>blah : Symbol(blah, Decl(argumentsObjectIterator02_ES5.ts, 1, 7)) + + result.push(arg + arg); +>result.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>result : Symbol(result, Decl(argumentsObjectIterator02_ES5.ts, 3, 7)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES5.ts, 4, 12)) +>arg : Symbol(arg, Decl(argumentsObjectIterator02_ES5.ts, 4, 12)) + } + return <[any, any, any]>result; +>result : Symbol(result, Decl(argumentsObjectIterator02_ES5.ts, 3, 7)) +} + + diff --git a/tests/baselines/reference/argumentsObjectIterator02_ES5.types b/tests/baselines/reference/argumentsObjectIterator02_ES5.types new file mode 100644 index 00000000000..0cfa15d9021 --- /dev/null +++ b/tests/baselines/reference/argumentsObjectIterator02_ES5.types @@ -0,0 +1,39 @@ +=== tests/cases/compiler/argumentsObjectIterator02_ES5.ts === +function doubleAndReturnAsArray(x: number, y: number, z: number): [number, number, number] { +>doubleAndReturnAsArray : (x: number, y: number, z: number) => [number, number, number] +>x : number +>y : number +>z : number + + let blah = arguments[Symbol.iterator]; +>blah : any +>arguments[Symbol.iterator] : any +>arguments : IArguments +>Symbol.iterator : any +>Symbol : any +>iterator : any + + let result = []; +>result : any[] +>[] : undefined[] + + for (let arg of blah()) { +>arg : any +>blah() : any +>blah : any + + result.push(arg + arg); +>result.push(arg + arg) : number +>result.push : (...items: any[]) => number +>result : any[] +>push : (...items: any[]) => number +>arg + arg : any +>arg : any +>arg : any + } + return <[any, any, any]>result; +><[any, any, any]>result : [any, any, any] +>result : any[] +} + + diff --git a/tests/baselines/reference/argumentsObjectIterator03_ES5.symbols b/tests/baselines/reference/argumentsObjectIterator03_ES5.symbols new file mode 100644 index 00000000000..ff829062f5e --- /dev/null +++ b/tests/baselines/reference/argumentsObjectIterator03_ES5.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/argumentsObjectIterator03_ES5.ts === +function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] { +>asReversedTuple : Symbol(asReversedTuple, Decl(argumentsObjectIterator03_ES5.ts, 0, 0)) +>a : Symbol(a, Decl(argumentsObjectIterator03_ES5.ts, 0, 25)) +>b : Symbol(b, Decl(argumentsObjectIterator03_ES5.ts, 0, 35)) +>c : Symbol(c, Decl(argumentsObjectIterator03_ES5.ts, 0, 46)) + + let [x, y, z] = arguments; +>x : Symbol(x, Decl(argumentsObjectIterator03_ES5.ts, 1, 9)) +>y : Symbol(y, Decl(argumentsObjectIterator03_ES5.ts, 1, 11)) +>z : Symbol(z, Decl(argumentsObjectIterator03_ES5.ts, 1, 14)) +>arguments : Symbol(arguments) + + return [z, y, x]; +>z : Symbol(z, Decl(argumentsObjectIterator03_ES5.ts, 1, 14)) +>y : Symbol(y, Decl(argumentsObjectIterator03_ES5.ts, 1, 11)) +>x : Symbol(x, Decl(argumentsObjectIterator03_ES5.ts, 1, 9)) +} + + diff --git a/tests/baselines/reference/argumentsObjectIterator03_ES5.types b/tests/baselines/reference/argumentsObjectIterator03_ES5.types new file mode 100644 index 00000000000..cdedc6b01bd --- /dev/null +++ b/tests/baselines/reference/argumentsObjectIterator03_ES5.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/argumentsObjectIterator03_ES5.ts === +function asReversedTuple(a: number, b: string, c: boolean): [boolean, string, number] { +>asReversedTuple : (a: number, b: string, c: boolean) => [boolean, string, number] +>a : number +>b : string +>c : boolean + + let [x, y, z] = arguments; +>x : any +>y : any +>z : any +>arguments : IArguments + + return [z, y, x]; +>[z, y, x] : [any, any, any] +>z : any +>y : any +>x : any +} + + diff --git a/tests/baselines/reference/arithAssignTyping.symbols b/tests/baselines/reference/arithAssignTyping.symbols new file mode 100644 index 00000000000..2b65b6f8132 --- /dev/null +++ b/tests/baselines/reference/arithAssignTyping.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/arithAssignTyping.ts === +class f { } +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f += ''; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f += 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f -= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f *= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f /= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f %= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f &= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f |= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f <<= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f >>= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f >>>= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + +f ^= 1; // error +>f : Symbol(f, Decl(arithAssignTyping.ts, 0, 0)) + diff --git a/tests/baselines/reference/arithAssignTyping.types b/tests/baselines/reference/arithAssignTyping.types new file mode 100644 index 00000000000..ffecb1399de --- /dev/null +++ b/tests/baselines/reference/arithAssignTyping.types @@ -0,0 +1,64 @@ +=== tests/cases/compiler/arithAssignTyping.ts === +class f { } +>f : f + +f += ''; // error +>f += '' : string +>f : any +>'' : "" + +f += 1; // error +>f += 1 : any +>f : any +>1 : 1 + +f -= 1; // error +>f -= 1 : number +>f : any +>1 : 1 + +f *= 1; // error +>f *= 1 : number +>f : any +>1 : 1 + +f /= 1; // error +>f /= 1 : number +>f : any +>1 : 1 + +f %= 1; // error +>f %= 1 : number +>f : any +>1 : 1 + +f &= 1; // error +>f &= 1 : number +>f : any +>1 : 1 + +f |= 1; // error +>f |= 1 : number +>f : any +>1 : 1 + +f <<= 1; // error +>f <<= 1 : number +>f : any +>1 : 1 + +f >>= 1; // error +>f >>= 1 : number +>f : any +>1 : 1 + +f >>>= 1; // error +>f >>>= 1 : number +>f : any +>1 : 1 + +f ^= 1; // error +>f ^= 1 : number +>f : any +>1 : 1 + diff --git a/tests/baselines/reference/arithmeticOnInvalidTypes.symbols b/tests/baselines/reference/arithmeticOnInvalidTypes.symbols new file mode 100644 index 00000000000..d78af458a58 --- /dev/null +++ b/tests/baselines/reference/arithmeticOnInvalidTypes.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/arithmeticOnInvalidTypes.ts === +var x: Number; +>x : Symbol(x, Decl(arithmeticOnInvalidTypes.ts, 0, 3)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var y: Number; +>y : Symbol(y, Decl(arithmeticOnInvalidTypes.ts, 1, 3)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var z = x + y; +>z : Symbol(z, Decl(arithmeticOnInvalidTypes.ts, 2, 3)) +>x : Symbol(x, Decl(arithmeticOnInvalidTypes.ts, 0, 3)) +>y : Symbol(y, Decl(arithmeticOnInvalidTypes.ts, 1, 3)) + +var z2 = x - y; +>z2 : Symbol(z2, Decl(arithmeticOnInvalidTypes.ts, 3, 3)) +>x : Symbol(x, Decl(arithmeticOnInvalidTypes.ts, 0, 3)) +>y : Symbol(y, Decl(arithmeticOnInvalidTypes.ts, 1, 3)) + +var z3 = x * y; +>z3 : Symbol(z3, Decl(arithmeticOnInvalidTypes.ts, 4, 3)) +>x : Symbol(x, Decl(arithmeticOnInvalidTypes.ts, 0, 3)) +>y : Symbol(y, Decl(arithmeticOnInvalidTypes.ts, 1, 3)) + +var z4 = x / y; +>z4 : Symbol(z4, Decl(arithmeticOnInvalidTypes.ts, 5, 3)) +>x : Symbol(x, Decl(arithmeticOnInvalidTypes.ts, 0, 3)) +>y : Symbol(y, Decl(arithmeticOnInvalidTypes.ts, 1, 3)) + diff --git a/tests/baselines/reference/arithmeticOnInvalidTypes.types b/tests/baselines/reference/arithmeticOnInvalidTypes.types new file mode 100644 index 00000000000..330a9c67931 --- /dev/null +++ b/tests/baselines/reference/arithmeticOnInvalidTypes.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/arithmeticOnInvalidTypes.ts === +var x: Number; +>x : Number +>Number : Number + +var y: Number; +>y : Number +>Number : Number + +var z = x + y; +>z : any +>x + y : any +>x : Number +>y : Number + +var z2 = x - y; +>z2 : number +>x - y : number +>x : Number +>y : Number + +var z3 = x * y; +>z3 : number +>x * y : number +>x : Number +>y : Number + +var z4 = x / y; +>z4 : number +>x / y : number +>x : Number +>y : Number + diff --git a/tests/baselines/reference/arithmeticOnInvalidTypes2.symbols b/tests/baselines/reference/arithmeticOnInvalidTypes2.symbols new file mode 100644 index 00000000000..be6784d11f0 --- /dev/null +++ b/tests/baselines/reference/arithmeticOnInvalidTypes2.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/arithmeticOnInvalidTypes2.ts === +var obj = function f(a: T, b: T) { +>obj : Symbol(obj, Decl(arithmeticOnInvalidTypes2.ts, 0, 3)) +>f : Symbol(f, Decl(arithmeticOnInvalidTypes2.ts, 0, 9)) +>T : Symbol(T, Decl(arithmeticOnInvalidTypes2.ts, 0, 21)) +>a : Symbol(a, Decl(arithmeticOnInvalidTypes2.ts, 0, 24)) +>T : Symbol(T, Decl(arithmeticOnInvalidTypes2.ts, 0, 21)) +>b : Symbol(b, Decl(arithmeticOnInvalidTypes2.ts, 0, 29)) +>T : Symbol(T, Decl(arithmeticOnInvalidTypes2.ts, 0, 21)) + + var z1 = a + b; +>z1 : Symbol(z1, Decl(arithmeticOnInvalidTypes2.ts, 1, 7)) +>a : Symbol(a, Decl(arithmeticOnInvalidTypes2.ts, 0, 24)) +>b : Symbol(b, Decl(arithmeticOnInvalidTypes2.ts, 0, 29)) + + var z2 = a - b; +>z2 : Symbol(z2, Decl(arithmeticOnInvalidTypes2.ts, 2, 7)) +>a : Symbol(a, Decl(arithmeticOnInvalidTypes2.ts, 0, 24)) +>b : Symbol(b, Decl(arithmeticOnInvalidTypes2.ts, 0, 29)) + + var z3 = a * b; +>z3 : Symbol(z3, Decl(arithmeticOnInvalidTypes2.ts, 3, 7)) +>a : Symbol(a, Decl(arithmeticOnInvalidTypes2.ts, 0, 24)) +>b : Symbol(b, Decl(arithmeticOnInvalidTypes2.ts, 0, 29)) + + var z4 = a / b; +>z4 : Symbol(z4, Decl(arithmeticOnInvalidTypes2.ts, 4, 7)) +>a : Symbol(a, Decl(arithmeticOnInvalidTypes2.ts, 0, 24)) +>b : Symbol(b, Decl(arithmeticOnInvalidTypes2.ts, 0, 29)) + + return a; +>a : Symbol(a, Decl(arithmeticOnInvalidTypes2.ts, 0, 24)) + +}; diff --git a/tests/baselines/reference/arithmeticOnInvalidTypes2.types b/tests/baselines/reference/arithmeticOnInvalidTypes2.types new file mode 100644 index 00000000000..9608ad171cf --- /dev/null +++ b/tests/baselines/reference/arithmeticOnInvalidTypes2.types @@ -0,0 +1,39 @@ +=== tests/cases/compiler/arithmeticOnInvalidTypes2.ts === +var obj = function f(a: T, b: T) { +>obj : (a: T, b: T) => T +>function f(a: T, b: T) { var z1 = a + b; var z2 = a - b; var z3 = a * b; var z4 = a / b; return a;} : (a: T, b: T) => T +>f : (a: T, b: T) => T +>T : T +>a : T +>T : T +>b : T +>T : T + + var z1 = a + b; +>z1 : any +>a + b : any +>a : T +>b : T + + var z2 = a - b; +>z2 : number +>a - b : number +>a : T +>b : T + + var z3 = a * b; +>z3 : number +>a * b : number +>a : T +>b : T + + var z4 = a / b; +>z4 : number +>a / b : number +>a : T +>b : T + + return a; +>a : T + +}; diff --git a/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.symbols b/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.symbols new file mode 100644 index 00000000000..3b2da85bdbe --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.symbols @@ -0,0 +1,2680 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts === +// these operators require their operands to be of type Any, the Number primitive type, or +// an enum type +enum E { a, b, c } +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>c : Symbol(E.c, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 14)) + +var a: any; +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var b: boolean; +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var c: number; +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var d: string; +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var e: { a: number }; +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 8)) + +var f: Number; +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +// All of the below should be an error unless otherwise noted +// operator * +var r1a1 = a * a; //ok +>r1a1 : Symbol(r1a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 13, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r1a2 = a * b; +>r1a2 : Symbol(r1a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 14, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r1a3 = a * c; //ok +>r1a3 : Symbol(r1a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 15, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r1a4 = a * d; +>r1a4 : Symbol(r1a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 16, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r1a5 = a * e; +>r1a5 : Symbol(r1a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 17, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r1a6 = a * f; +>r1a6 : Symbol(r1a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 18, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r1b1 = b * a; +>r1b1 : Symbol(r1b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 20, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r1b2 = b * b; +>r1b2 : Symbol(r1b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 21, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r1b3 = b * c; +>r1b3 : Symbol(r1b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 22, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r1b4 = b * d; +>r1b4 : Symbol(r1b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 23, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r1b5 = b * e; +>r1b5 : Symbol(r1b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 24, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r1b6 = b * f; +>r1b6 : Symbol(r1b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 25, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r1c1 = c * a; //ok +>r1c1 : Symbol(r1c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 27, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r1c2 = c * b; +>r1c2 : Symbol(r1c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 28, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r1c3 = c * c; //ok +>r1c3 : Symbol(r1c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 29, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r1c4 = c * d; +>r1c4 : Symbol(r1c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 30, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r1c5 = c * e; +>r1c5 : Symbol(r1c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 31, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r1c6 = c * f; +>r1c6 : Symbol(r1c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 32, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r1d1 = d * a; +>r1d1 : Symbol(r1d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 34, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r1d2 = d * b; +>r1d2 : Symbol(r1d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 35, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r1d3 = d * c; +>r1d3 : Symbol(r1d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 36, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r1d4 = d * d; +>r1d4 : Symbol(r1d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 37, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r1d5 = d * e; +>r1d5 : Symbol(r1d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 38, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r1d6 = d * f; +>r1d6 : Symbol(r1d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 39, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r1e1 = e * a; +>r1e1 : Symbol(r1e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 41, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r1e2 = e * b; +>r1e2 : Symbol(r1e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 42, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r1e3 = e * c; +>r1e3 : Symbol(r1e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 43, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r1e4 = e * d; +>r1e4 : Symbol(r1e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 44, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r1e5 = e * e; +>r1e5 : Symbol(r1e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 45, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r1e6 = e * f; +>r1e6 : Symbol(r1e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 46, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r1f1 = f * a; +>r1f1 : Symbol(r1f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 48, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r1f2 = f * b; +>r1f2 : Symbol(r1f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 49, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r1f3 = f * c; +>r1f3 : Symbol(r1f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 50, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r1f4 = f * d; +>r1f4 : Symbol(r1f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 51, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r1f5 = f * e; +>r1f5 : Symbol(r1f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 52, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r1f6 = f * f; +>r1f6 : Symbol(r1f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 53, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r1g1 = E.a * a; //ok +>r1g1 : Symbol(r1g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 55, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r1g2 = E.a * b; +>r1g2 : Symbol(r1g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 56, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r1g3 = E.a * c; //ok +>r1g3 : Symbol(r1g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 57, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r1g4 = E.a * d; +>r1g4 : Symbol(r1g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 58, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r1g5 = E.a * e; +>r1g5 : Symbol(r1g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 59, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r1g6 = E.a * f; +>r1g6 : Symbol(r1g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 60, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r1h1 = a * E.b; //ok +>r1h1 : Symbol(r1h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 62, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r1h2 = b * E.b; +>r1h2 : Symbol(r1h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 63, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r1h3 = c * E.b; //ok +>r1h3 : Symbol(r1h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 64, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r1h4 = d * E.b; +>r1h4 : Symbol(r1h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 65, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r1h5 = e * E.b; +>r1h5 : Symbol(r1h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 66, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r1h6 = f * E.b; +>r1h6 : Symbol(r1h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 67, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator / +var r2a1 = a / a; //ok +>r2a1 : Symbol(r2a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 70, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r2a2 = a / b; +>r2a2 : Symbol(r2a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 71, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r2a3 = a / c; //ok +>r2a3 : Symbol(r2a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 72, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r2a4 = a / d; +>r2a4 : Symbol(r2a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 73, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r2a5 = a / e; +>r2a5 : Symbol(r2a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 74, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r2a6 = a / f; +>r2a6 : Symbol(r2a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 75, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r2b1 = b / a; +>r2b1 : Symbol(r2b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 77, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r2b2 = b / b; +>r2b2 : Symbol(r2b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 78, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r2b3 = b / c; +>r2b3 : Symbol(r2b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 79, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r2b4 = b / d; +>r2b4 : Symbol(r2b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 80, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r2b5 = b / e; +>r2b5 : Symbol(r2b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 81, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r2b6 = b / f; +>r2b6 : Symbol(r2b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 82, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r2c1 = c / a; //ok +>r2c1 : Symbol(r2c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 84, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r2c2 = c / b; +>r2c2 : Symbol(r2c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 85, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r2c3 = c / c; //ok +>r2c3 : Symbol(r2c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 86, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r2c4 = c / d; +>r2c4 : Symbol(r2c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 87, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r2c5 = c / e; +>r2c5 : Symbol(r2c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 88, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r2c6 = c / f; +>r2c6 : Symbol(r2c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 89, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r2d1 = d / a; +>r2d1 : Symbol(r2d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 91, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r2d2 = d / b; +>r2d2 : Symbol(r2d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 92, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r2d3 = d / c; +>r2d3 : Symbol(r2d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 93, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r2d4 = d / d; +>r2d4 : Symbol(r2d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 94, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r2d5 = d / e; +>r2d5 : Symbol(r2d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 95, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r2d6 = d / f; +>r2d6 : Symbol(r2d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 96, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r2e1 = e / a; +>r2e1 : Symbol(r2e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 98, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r2e2 = e / b; +>r2e2 : Symbol(r2e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 99, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r2e3 = e / c; +>r2e3 : Symbol(r2e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 100, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r2e4 = e / d; +>r2e4 : Symbol(r2e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 101, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r2e5 = e / e; +>r2e5 : Symbol(r2e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 102, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r2e6 = e / f; +>r2e6 : Symbol(r2e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 103, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r2f1 = f / a; +>r2f1 : Symbol(r2f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 105, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r2f2 = f / b; +>r2f2 : Symbol(r2f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 106, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r2f3 = f / c; +>r2f3 : Symbol(r2f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 107, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r2f4 = f / d; +>r2f4 : Symbol(r2f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 108, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r2f5 = f / e; +>r2f5 : Symbol(r2f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 109, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r2f6 = f / f; +>r2f6 : Symbol(r2f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 110, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r2g1 = E.a / a; //ok +>r2g1 : Symbol(r2g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 112, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r2g2 = E.a / b; +>r2g2 : Symbol(r2g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 113, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r2g3 = E.a / c; //ok +>r2g3 : Symbol(r2g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 114, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r2g4 = E.a / d; +>r2g4 : Symbol(r2g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 115, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r2g5 = E.a / e; +>r2g5 : Symbol(r2g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 116, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r2g6 = E.a / f; +>r2g6 : Symbol(r2g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 117, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r2h1 = a / E.b; //ok +>r2h1 : Symbol(r2h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 119, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r2h2 = b / E.b; +>r2h2 : Symbol(r2h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 120, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r2h3 = c / E.b; //ok +>r2h3 : Symbol(r2h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 121, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r2h4 = d / E.b; +>r2h4 : Symbol(r2h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 122, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r2h5 = e / E.b; +>r2h5 : Symbol(r2h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 123, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r2h6 = f / E.b; +>r2h6 : Symbol(r2h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 124, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator % +var r3a1 = a % a; //ok +>r3a1 : Symbol(r3a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 127, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r3a2 = a % b; +>r3a2 : Symbol(r3a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 128, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r3a3 = a % c; //ok +>r3a3 : Symbol(r3a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 129, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r3a4 = a % d; +>r3a4 : Symbol(r3a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 130, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r3a5 = a % e; +>r3a5 : Symbol(r3a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 131, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r3a6 = a % f; +>r3a6 : Symbol(r3a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 132, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r3b1 = b % a; +>r3b1 : Symbol(r3b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 134, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r3b2 = b % b; +>r3b2 : Symbol(r3b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 135, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r3b3 = b % c; +>r3b3 : Symbol(r3b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 136, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r3b4 = b % d; +>r3b4 : Symbol(r3b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 137, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r3b5 = b % e; +>r3b5 : Symbol(r3b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 138, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r3b6 = b % f; +>r3b6 : Symbol(r3b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 139, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r3c1 = c % a; //ok +>r3c1 : Symbol(r3c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 141, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r3c2 = c % b; +>r3c2 : Symbol(r3c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 142, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r3c3 = c % c; //ok +>r3c3 : Symbol(r3c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 143, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r3c4 = c % d; +>r3c4 : Symbol(r3c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 144, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r3c5 = c % e; +>r3c5 : Symbol(r3c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 145, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r3c6 = c % f; +>r3c6 : Symbol(r3c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 146, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r3d1 = d % a; +>r3d1 : Symbol(r3d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 148, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r3d2 = d % b; +>r3d2 : Symbol(r3d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 149, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r3d3 = d % c; +>r3d3 : Symbol(r3d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 150, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r3d4 = d % d; +>r3d4 : Symbol(r3d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 151, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r3d5 = d % e; +>r3d5 : Symbol(r3d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 152, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r3d6 = d % f; +>r3d6 : Symbol(r3d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 153, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r3e1 = e % a; +>r3e1 : Symbol(r3e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 155, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r3e2 = e % b; +>r3e2 : Symbol(r3e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 156, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r3e3 = e % c; +>r3e3 : Symbol(r3e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 157, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r3e4 = e % d; +>r3e4 : Symbol(r3e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 158, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r3e5 = e % e; +>r3e5 : Symbol(r3e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 159, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r3e6 = e % f; +>r3e6 : Symbol(r3e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 160, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r3f1 = f % a; +>r3f1 : Symbol(r3f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 162, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r3f2 = f % b; +>r3f2 : Symbol(r3f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 163, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r3f3 = f % c; +>r3f3 : Symbol(r3f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 164, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r3f4 = f % d; +>r3f4 : Symbol(r3f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 165, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r3f5 = f % e; +>r3f5 : Symbol(r3f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 166, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r3f6 = f % f; +>r3f6 : Symbol(r3f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 167, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r3g1 = E.a % a; //ok +>r3g1 : Symbol(r3g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 169, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r3g2 = E.a % b; +>r3g2 : Symbol(r3g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 170, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r3g3 = E.a % c; //ok +>r3g3 : Symbol(r3g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 171, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r3g4 = E.a % d; +>r3g4 : Symbol(r3g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 172, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r3g5 = E.a % e; +>r3g5 : Symbol(r3g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 173, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r3g6 = E.a % f; +>r3g6 : Symbol(r3g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 174, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r3h1 = a % E.b; //ok +>r3h1 : Symbol(r3h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 176, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r3h2 = b % E.b; +>r3h2 : Symbol(r3h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 177, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r3h3 = c % E.b; //ok +>r3h3 : Symbol(r3h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 178, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r3h4 = d % E.b; +>r3h4 : Symbol(r3h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 179, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r3h5 = e % E.b; +>r3h5 : Symbol(r3h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 180, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r3h6 = f % E.b; +>r3h6 : Symbol(r3h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 181, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator - +var r4a1 = a - a; //ok +>r4a1 : Symbol(r4a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 184, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r4a2 = a - b; +>r4a2 : Symbol(r4a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 185, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r4a3 = a - c; //ok +>r4a3 : Symbol(r4a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 186, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r4a4 = a - d; +>r4a4 : Symbol(r4a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 187, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r4a5 = a - e; +>r4a5 : Symbol(r4a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 188, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r4a6 = a - f; +>r4a6 : Symbol(r4a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 189, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r4b1 = b - a; +>r4b1 : Symbol(r4b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 191, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r4b2 = b - b; +>r4b2 : Symbol(r4b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 192, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r4b3 = b - c; +>r4b3 : Symbol(r4b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 193, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r4b4 = b - d; +>r4b4 : Symbol(r4b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 194, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r4b5 = b - e; +>r4b5 : Symbol(r4b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 195, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r4b6 = b - f; +>r4b6 : Symbol(r4b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 196, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r4c1 = c - a; //ok +>r4c1 : Symbol(r4c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 198, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r4c2 = c - b; +>r4c2 : Symbol(r4c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 199, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r4c3 = c - c; //ok +>r4c3 : Symbol(r4c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 200, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r4c4 = c - d; +>r4c4 : Symbol(r4c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 201, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r4c5 = c - e; +>r4c5 : Symbol(r4c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 202, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r4c6 = c - f; +>r4c6 : Symbol(r4c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 203, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r4d1 = d - a; +>r4d1 : Symbol(r4d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 205, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r4d2 = d - b; +>r4d2 : Symbol(r4d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 206, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r4d3 = d - c; +>r4d3 : Symbol(r4d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 207, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r4d4 = d - d; +>r4d4 : Symbol(r4d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 208, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r4d5 = d - e; +>r4d5 : Symbol(r4d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 209, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r4d6 = d - f; +>r4d6 : Symbol(r4d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 210, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r4e1 = e - a; +>r4e1 : Symbol(r4e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 212, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r4e2 = e - b; +>r4e2 : Symbol(r4e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 213, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r4e3 = e - c; +>r4e3 : Symbol(r4e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 214, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r4e4 = e - d; +>r4e4 : Symbol(r4e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 215, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r4e5 = e - e; +>r4e5 : Symbol(r4e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 216, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r4e6 = e - f; +>r4e6 : Symbol(r4e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 217, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r4f1 = f - a; +>r4f1 : Symbol(r4f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 219, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r4f2 = f - b; +>r4f2 : Symbol(r4f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 220, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r4f3 = f - c; +>r4f3 : Symbol(r4f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 221, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r4f4 = f - d; +>r4f4 : Symbol(r4f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 222, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r4f5 = f - e; +>r4f5 : Symbol(r4f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 223, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r4f6 = f - f; +>r4f6 : Symbol(r4f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 224, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r4g1 = E.a - a; //ok +>r4g1 : Symbol(r4g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 226, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r4g2 = E.a - b; +>r4g2 : Symbol(r4g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 227, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r4g3 = E.a - c; //ok +>r4g3 : Symbol(r4g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 228, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r4g4 = E.a - d; +>r4g4 : Symbol(r4g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 229, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r4g5 = E.a - e; +>r4g5 : Symbol(r4g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 230, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r4g6 = E.a - f; +>r4g6 : Symbol(r4g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 231, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r4h1 = a - E.b; //ok +>r4h1 : Symbol(r4h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 233, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r4h2 = b - E.b; +>r4h2 : Symbol(r4h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 234, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r4h3 = c - E.b; //ok +>r4h3 : Symbol(r4h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 235, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r4h4 = d - E.b; +>r4h4 : Symbol(r4h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 236, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r4h5 = e - E.b; +>r4h5 : Symbol(r4h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 237, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r4h6 = f - E.b; +>r4h6 : Symbol(r4h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 238, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator << +var r5a1 = a << a; //ok +>r5a1 : Symbol(r5a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 241, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r5a2 = a << b; +>r5a2 : Symbol(r5a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 242, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r5a3 = a << c; //ok +>r5a3 : Symbol(r5a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 243, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r5a4 = a << d; +>r5a4 : Symbol(r5a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 244, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r5a5 = a << e; +>r5a5 : Symbol(r5a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 245, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r5a6 = a << f; +>r5a6 : Symbol(r5a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 246, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r5b1 = b << a; +>r5b1 : Symbol(r5b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 248, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r5b2 = b << b; +>r5b2 : Symbol(r5b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 249, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r5b3 = b << c; +>r5b3 : Symbol(r5b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 250, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r5b4 = b << d; +>r5b4 : Symbol(r5b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 251, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r5b5 = b << e; +>r5b5 : Symbol(r5b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 252, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r5b6 = b << f; +>r5b6 : Symbol(r5b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 253, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r5c1 = c << a; //ok +>r5c1 : Symbol(r5c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 255, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r5c2 = c << b; +>r5c2 : Symbol(r5c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 256, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r5c3 = c << c; //ok +>r5c3 : Symbol(r5c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 257, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r5c4 = c << d; +>r5c4 : Symbol(r5c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 258, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r5c5 = c << e; +>r5c5 : Symbol(r5c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 259, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r5c6 = c << f; +>r5c6 : Symbol(r5c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 260, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r5d1 = d << a; +>r5d1 : Symbol(r5d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 262, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r5d2 = d << b; +>r5d2 : Symbol(r5d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 263, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r5d3 = d << c; +>r5d3 : Symbol(r5d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 264, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r5d4 = d << d; +>r5d4 : Symbol(r5d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 265, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r5d5 = d << e; +>r5d5 : Symbol(r5d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 266, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r5d6 = d << f; +>r5d6 : Symbol(r5d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 267, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r5e1 = e << a; +>r5e1 : Symbol(r5e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 269, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r5e2 = e << b; +>r5e2 : Symbol(r5e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 270, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r5e3 = e << c; +>r5e3 : Symbol(r5e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 271, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r5e4 = e << d; +>r5e4 : Symbol(r5e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 272, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r5e5 = e << e; +>r5e5 : Symbol(r5e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 273, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r5e6 = e << f; +>r5e6 : Symbol(r5e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 274, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r5f1 = f << a; +>r5f1 : Symbol(r5f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 276, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r5f2 = f << b; +>r5f2 : Symbol(r5f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 277, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r5f3 = f << c; +>r5f3 : Symbol(r5f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 278, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r5f4 = f << d; +>r5f4 : Symbol(r5f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 279, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r5f5 = f << e; +>r5f5 : Symbol(r5f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 280, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r5f6 = f << f; +>r5f6 : Symbol(r5f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 281, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r5g1 = E.a << a; //ok +>r5g1 : Symbol(r5g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 283, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r5g2 = E.a << b; +>r5g2 : Symbol(r5g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 284, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r5g3 = E.a << c; //ok +>r5g3 : Symbol(r5g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 285, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r5g4 = E.a << d; +>r5g4 : Symbol(r5g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 286, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r5g5 = E.a << e; +>r5g5 : Symbol(r5g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 287, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r5g6 = E.a << f; +>r5g6 : Symbol(r5g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 288, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r5h1 = a << E.b; //ok +>r5h1 : Symbol(r5h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 290, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r5h2 = b << E.b; +>r5h2 : Symbol(r5h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 291, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r5h3 = c << E.b; //ok +>r5h3 : Symbol(r5h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 292, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r5h4 = d << E.b; +>r5h4 : Symbol(r5h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 293, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r5h5 = e << E.b; +>r5h5 : Symbol(r5h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 294, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r5h6 = f << E.b; +>r5h6 : Symbol(r5h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 295, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator >> +var r6a1 = a >> a; //ok +>r6a1 : Symbol(r6a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 298, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r6a2 = a >> b; +>r6a2 : Symbol(r6a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 299, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r6a3 = a >> c; //ok +>r6a3 : Symbol(r6a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 300, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r6a4 = a >> d; +>r6a4 : Symbol(r6a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 301, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r6a5 = a >> e; +>r6a5 : Symbol(r6a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 302, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r6a6 = a >> f; +>r6a6 : Symbol(r6a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 303, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r6b1 = b >> a; +>r6b1 : Symbol(r6b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 305, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r6b2 = b >> b; +>r6b2 : Symbol(r6b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 306, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r6b3 = b >> c; +>r6b3 : Symbol(r6b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 307, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r6b4 = b >> d; +>r6b4 : Symbol(r6b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 308, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r6b5 = b >> e; +>r6b5 : Symbol(r6b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 309, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r6b6 = b >> f; +>r6b6 : Symbol(r6b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 310, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r6c1 = c >> a; //ok +>r6c1 : Symbol(r6c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 312, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r6c2 = c >> b; +>r6c2 : Symbol(r6c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 313, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r6c3 = c >> c; //ok +>r6c3 : Symbol(r6c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 314, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r6c4 = c >> d; +>r6c4 : Symbol(r6c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 315, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r6c5 = c >> e; +>r6c5 : Symbol(r6c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 316, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r6c6 = c >> f; +>r6c6 : Symbol(r6c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 317, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r6d1 = d >> a; +>r6d1 : Symbol(r6d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 319, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r6d2 = d >> b; +>r6d2 : Symbol(r6d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 320, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r6d3 = d >> c; +>r6d3 : Symbol(r6d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 321, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r6d4 = d >> d; +>r6d4 : Symbol(r6d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 322, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r6d5 = d >> e; +>r6d5 : Symbol(r6d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 323, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r6d6 = d >> f; +>r6d6 : Symbol(r6d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 324, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r6e1 = e >> a; +>r6e1 : Symbol(r6e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 326, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r6e2 = e >> b; +>r6e2 : Symbol(r6e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 327, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r6e3 = e >> c; +>r6e3 : Symbol(r6e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 328, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r6e4 = e >> d; +>r6e4 : Symbol(r6e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 329, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r6e5 = e >> e; +>r6e5 : Symbol(r6e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 330, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r6e6 = e >> f; +>r6e6 : Symbol(r6e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 331, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r6f1 = f >> a; +>r6f1 : Symbol(r6f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 333, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r6f2 = f >> b; +>r6f2 : Symbol(r6f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 334, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r6f3 = f >> c; +>r6f3 : Symbol(r6f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 335, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r6f4 = f >> d; +>r6f4 : Symbol(r6f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 336, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r6f5 = f >> e; +>r6f5 : Symbol(r6f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 337, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r6f6 = f >> f; +>r6f6 : Symbol(r6f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 338, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r6g1 = E.a >> a; //ok +>r6g1 : Symbol(r6g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 340, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r6g2 = E.a >> b; +>r6g2 : Symbol(r6g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 341, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r6g3 = E.a >> c; //ok +>r6g3 : Symbol(r6g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 342, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r6g4 = E.a >> d; +>r6g4 : Symbol(r6g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 343, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r6g5 = E.a >> e; +>r6g5 : Symbol(r6g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 344, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r6g6 = E.a >> f; +>r6g6 : Symbol(r6g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 345, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r6h1 = a >> E.b; //ok +>r6h1 : Symbol(r6h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 347, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r6h2 = b >> E.b; +>r6h2 : Symbol(r6h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 348, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r6h3 = c >> E.b; //ok +>r6h3 : Symbol(r6h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 349, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r6h4 = d >> E.b; +>r6h4 : Symbol(r6h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 350, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r6h5 = e >> E.b; +>r6h5 : Symbol(r6h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 351, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r6h6 = f >> E.b; +>r6h6 : Symbol(r6h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 352, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator >>> +var r7a1 = a >>> a; //ok +>r7a1 : Symbol(r7a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 355, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r7a2 = a >>> b; +>r7a2 : Symbol(r7a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 356, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r7a3 = a >>> c; //ok +>r7a3 : Symbol(r7a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 357, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r7a4 = a >>> d; +>r7a4 : Symbol(r7a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 358, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r7a5 = a >>> e; +>r7a5 : Symbol(r7a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 359, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r7a6 = a >>> f; +>r7a6 : Symbol(r7a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 360, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r7b1 = b >>> a; +>r7b1 : Symbol(r7b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 362, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r7b2 = b >>> b; +>r7b2 : Symbol(r7b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 363, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r7b3 = b >>> c; +>r7b3 : Symbol(r7b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 364, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r7b4 = b >>> d; +>r7b4 : Symbol(r7b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 365, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r7b5 = b >>> e; +>r7b5 : Symbol(r7b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 366, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r7b6 = b >>> f; +>r7b6 : Symbol(r7b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 367, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r7c1 = c >>> a; //ok +>r7c1 : Symbol(r7c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 369, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r7c2 = c >>> b; +>r7c2 : Symbol(r7c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 370, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r7c3 = c >>> c; //ok +>r7c3 : Symbol(r7c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 371, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r7c4 = c >>> d; +>r7c4 : Symbol(r7c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 372, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r7c5 = c >>> e; +>r7c5 : Symbol(r7c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 373, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r7c6 = c >>> f; +>r7c6 : Symbol(r7c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 374, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r7d1 = d >>> a; +>r7d1 : Symbol(r7d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 376, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r7d2 = d >>> b; +>r7d2 : Symbol(r7d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 377, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r7d3 = d >>> c; +>r7d3 : Symbol(r7d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 378, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r7d4 = d >>> d; +>r7d4 : Symbol(r7d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 379, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r7d5 = d >>> e; +>r7d5 : Symbol(r7d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 380, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r7d6 = d >>> f; +>r7d6 : Symbol(r7d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 381, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r7e1 = e >>> a; +>r7e1 : Symbol(r7e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 383, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r7e2 = e >>> b; +>r7e2 : Symbol(r7e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 384, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r7e3 = e >>> c; +>r7e3 : Symbol(r7e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 385, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r7e4 = e >>> d; +>r7e4 : Symbol(r7e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 386, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r7e5 = e >>> e; +>r7e5 : Symbol(r7e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 387, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r7e6 = e >>> f; +>r7e6 : Symbol(r7e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 388, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r7f1 = f >>> a; +>r7f1 : Symbol(r7f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 390, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r7f2 = f >>> b; +>r7f2 : Symbol(r7f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 391, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r7f3 = f >>> c; +>r7f3 : Symbol(r7f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 392, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r7f4 = f >>> d; +>r7f4 : Symbol(r7f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 393, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r7f5 = f >>> e; +>r7f5 : Symbol(r7f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 394, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r7f6 = f >>> f; +>r7f6 : Symbol(r7f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 395, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r7g1 = E.a >>> a; //ok +>r7g1 : Symbol(r7g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 397, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r7g2 = E.a >>> b; +>r7g2 : Symbol(r7g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 398, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r7g3 = E.a >>> c; //ok +>r7g3 : Symbol(r7g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 399, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r7g4 = E.a >>> d; +>r7g4 : Symbol(r7g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 400, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r7g5 = E.a >>> e; +>r7g5 : Symbol(r7g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 401, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r7g6 = E.a >>> f; +>r7g6 : Symbol(r7g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 402, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r7h1 = a >>> E.b; //ok +>r7h1 : Symbol(r7h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 404, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r7h2 = b >>> E.b; +>r7h2 : Symbol(r7h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 405, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r7h3 = c >>> E.b; //ok +>r7h3 : Symbol(r7h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 406, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r7h4 = d >>> E.b; +>r7h4 : Symbol(r7h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 407, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r7h5 = e >>> E.b; +>r7h5 : Symbol(r7h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 408, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r7h6 = f >>> E.b; +>r7h6 : Symbol(r7h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 409, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator & +var r8a1 = a & a; //ok +>r8a1 : Symbol(r8a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 412, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r8a2 = a & b; +>r8a2 : Symbol(r8a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 413, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r8a3 = a & c; //ok +>r8a3 : Symbol(r8a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 414, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r8a4 = a & d; +>r8a4 : Symbol(r8a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 415, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r8a5 = a & e; +>r8a5 : Symbol(r8a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 416, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r8a6 = a & f; +>r8a6 : Symbol(r8a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 417, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r8b1 = b & a; +>r8b1 : Symbol(r8b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 419, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r8b2 = b & b; +>r8b2 : Symbol(r8b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 420, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r8b3 = b & c; +>r8b3 : Symbol(r8b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 421, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r8b4 = b & d; +>r8b4 : Symbol(r8b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 422, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r8b5 = b & e; +>r8b5 : Symbol(r8b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 423, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r8b6 = b & f; +>r8b6 : Symbol(r8b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 424, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r8c1 = c & a; //ok +>r8c1 : Symbol(r8c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 426, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r8c2 = c & b; +>r8c2 : Symbol(r8c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 427, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r8c3 = c & c; //ok +>r8c3 : Symbol(r8c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 428, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r8c4 = c & d; +>r8c4 : Symbol(r8c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 429, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r8c5 = c & e; +>r8c5 : Symbol(r8c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 430, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r8c6 = c & f; +>r8c6 : Symbol(r8c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 431, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r8d1 = d & a; +>r8d1 : Symbol(r8d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 433, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r8d2 = d & b; +>r8d2 : Symbol(r8d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 434, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r8d3 = d & c; +>r8d3 : Symbol(r8d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 435, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r8d4 = d & d; +>r8d4 : Symbol(r8d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 436, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r8d5 = d & e; +>r8d5 : Symbol(r8d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 437, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r8d6 = d & f; +>r8d6 : Symbol(r8d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 438, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r8e1 = e & a; +>r8e1 : Symbol(r8e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 440, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r8e2 = e & b; +>r8e2 : Symbol(r8e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 441, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r8e3 = e & c; +>r8e3 : Symbol(r8e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 442, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r8e4 = e & d; +>r8e4 : Symbol(r8e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 443, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r8e5 = e & e; +>r8e5 : Symbol(r8e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 444, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r8e6 = e & f; +>r8e6 : Symbol(r8e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 445, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r8f1 = f & a; +>r8f1 : Symbol(r8f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 447, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r8f2 = f & b; +>r8f2 : Symbol(r8f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 448, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r8f3 = f & c; +>r8f3 : Symbol(r8f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 449, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r8f4 = f & d; +>r8f4 : Symbol(r8f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 450, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r8f5 = f & e; +>r8f5 : Symbol(r8f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 451, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r8f6 = f & f; +>r8f6 : Symbol(r8f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 452, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r8g1 = E.a & a; //ok +>r8g1 : Symbol(r8g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 454, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r8g2 = E.a & b; +>r8g2 : Symbol(r8g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 455, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r8g3 = E.a & c; //ok +>r8g3 : Symbol(r8g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 456, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r8g4 = E.a & d; +>r8g4 : Symbol(r8g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 457, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r8g5 = E.a & e; +>r8g5 : Symbol(r8g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 458, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r8g6 = E.a & f; +>r8g6 : Symbol(r8g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 459, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r8h1 = a & E.b; //ok +>r8h1 : Symbol(r8h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 461, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r8h2 = b & E.b; +>r8h2 : Symbol(r8h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 462, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r8h3 = c & E.b; //ok +>r8h3 : Symbol(r8h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 463, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r8h4 = d & E.b; +>r8h4 : Symbol(r8h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 464, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r8h5 = e & E.b; +>r8h5 : Symbol(r8h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 465, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r8h6 = f & E.b; +>r8h6 : Symbol(r8h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 466, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator ^ +var r9a1 = a ^ a; //ok +>r9a1 : Symbol(r9a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 469, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r9a2 = a ^ b; +>r9a2 : Symbol(r9a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 470, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r9a3 = a ^ c; //ok +>r9a3 : Symbol(r9a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 471, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r9a4 = a ^ d; +>r9a4 : Symbol(r9a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 472, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r9a5 = a ^ e; +>r9a5 : Symbol(r9a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 473, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r9a6 = a ^ f; +>r9a6 : Symbol(r9a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 474, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r9b1 = b ^ a; +>r9b1 : Symbol(r9b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 476, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r9b2 = b ^ b; +>r9b2 : Symbol(r9b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 477, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r9b3 = b ^ c; +>r9b3 : Symbol(r9b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 478, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r9b4 = b ^ d; +>r9b4 : Symbol(r9b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 479, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r9b5 = b ^ e; +>r9b5 : Symbol(r9b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 480, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r9b6 = b ^ f; +>r9b6 : Symbol(r9b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 481, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r9c1 = c ^ a; //ok +>r9c1 : Symbol(r9c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 483, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r9c2 = c ^ b; +>r9c2 : Symbol(r9c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 484, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r9c3 = c ^ c; //ok +>r9c3 : Symbol(r9c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 485, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r9c4 = c ^ d; +>r9c4 : Symbol(r9c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 486, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r9c5 = c ^ e; +>r9c5 : Symbol(r9c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 487, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r9c6 = c ^ f; +>r9c6 : Symbol(r9c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 488, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r9d1 = d ^ a; +>r9d1 : Symbol(r9d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 490, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r9d2 = d ^ b; +>r9d2 : Symbol(r9d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 491, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r9d3 = d ^ c; +>r9d3 : Symbol(r9d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 492, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r9d4 = d ^ d; +>r9d4 : Symbol(r9d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 493, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r9d5 = d ^ e; +>r9d5 : Symbol(r9d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 494, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r9d6 = d ^ f; +>r9d6 : Symbol(r9d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 495, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r9e1 = e ^ a; +>r9e1 : Symbol(r9e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 497, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r9e2 = e ^ b; +>r9e2 : Symbol(r9e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 498, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r9e3 = e ^ c; +>r9e3 : Symbol(r9e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 499, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r9e4 = e ^ d; +>r9e4 : Symbol(r9e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 500, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r9e5 = e ^ e; +>r9e5 : Symbol(r9e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 501, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r9e6 = e ^ f; +>r9e6 : Symbol(r9e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 502, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r9f1 = f ^ a; +>r9f1 : Symbol(r9f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 504, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r9f2 = f ^ b; +>r9f2 : Symbol(r9f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 505, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r9f3 = f ^ c; +>r9f3 : Symbol(r9f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 506, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r9f4 = f ^ d; +>r9f4 : Symbol(r9f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 507, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r9f5 = f ^ e; +>r9f5 : Symbol(r9f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 508, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r9f6 = f ^ f; +>r9f6 : Symbol(r9f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 509, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r9g1 = E.a ^ a; //ok +>r9g1 : Symbol(r9g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 511, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r9g2 = E.a ^ b; +>r9g2 : Symbol(r9g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 512, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r9g3 = E.a ^ c; //ok +>r9g3 : Symbol(r9g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 513, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r9g4 = E.a ^ d; +>r9g4 : Symbol(r9g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 514, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r9g5 = E.a ^ e; +>r9g5 : Symbol(r9g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 515, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r9g6 = E.a ^ f; +>r9g6 : Symbol(r9g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 516, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r9h1 = a ^ E.b; //ok +>r9h1 : Symbol(r9h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 518, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r9h2 = b ^ E.b; +>r9h2 : Symbol(r9h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 519, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r9h3 = c ^ E.b; //ok +>r9h3 : Symbol(r9h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 520, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r9h4 = d ^ E.b; +>r9h4 : Symbol(r9h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 521, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r9h5 = e ^ E.b; +>r9h5 : Symbol(r9h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 522, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r9h6 = f ^ E.b; +>r9h6 : Symbol(r9h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 523, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +// operator | +var r10a1 = a | a; //ok +>r10a1 : Symbol(r10a1, Decl(arithmeticOperatorWithInvalidOperands.ts, 526, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r10a2 = a | b; +>r10a2 : Symbol(r10a2, Decl(arithmeticOperatorWithInvalidOperands.ts, 527, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r10a3 = a | c; //ok +>r10a3 : Symbol(r10a3, Decl(arithmeticOperatorWithInvalidOperands.ts, 528, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r10a4 = a | d; +>r10a4 : Symbol(r10a4, Decl(arithmeticOperatorWithInvalidOperands.ts, 529, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r10a5 = a | e; +>r10a5 : Symbol(r10a5, Decl(arithmeticOperatorWithInvalidOperands.ts, 530, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r10a6 = a | f; +>r10a6 : Symbol(r10a6, Decl(arithmeticOperatorWithInvalidOperands.ts, 531, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r10b1 = b | a; +>r10b1 : Symbol(r10b1, Decl(arithmeticOperatorWithInvalidOperands.ts, 533, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r10b2 = b | b; +>r10b2 : Symbol(r10b2, Decl(arithmeticOperatorWithInvalidOperands.ts, 534, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r10b3 = b | c; +>r10b3 : Symbol(r10b3, Decl(arithmeticOperatorWithInvalidOperands.ts, 535, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r10b4 = b | d; +>r10b4 : Symbol(r10b4, Decl(arithmeticOperatorWithInvalidOperands.ts, 536, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r10b5 = b | e; +>r10b5 : Symbol(r10b5, Decl(arithmeticOperatorWithInvalidOperands.ts, 537, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r10b6 = b | f; +>r10b6 : Symbol(r10b6, Decl(arithmeticOperatorWithInvalidOperands.ts, 538, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r10c1 = c | a; //ok +>r10c1 : Symbol(r10c1, Decl(arithmeticOperatorWithInvalidOperands.ts, 540, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r10c2 = c | b; +>r10c2 : Symbol(r10c2, Decl(arithmeticOperatorWithInvalidOperands.ts, 541, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r10c3 = c | c; //ok +>r10c3 : Symbol(r10c3, Decl(arithmeticOperatorWithInvalidOperands.ts, 542, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r10c4 = c | d; +>r10c4 : Symbol(r10c4, Decl(arithmeticOperatorWithInvalidOperands.ts, 543, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r10c5 = c | e; +>r10c5 : Symbol(r10c5, Decl(arithmeticOperatorWithInvalidOperands.ts, 544, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r10c6 = c | f; +>r10c6 : Symbol(r10c6, Decl(arithmeticOperatorWithInvalidOperands.ts, 545, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r10d1 = d | a; +>r10d1 : Symbol(r10d1, Decl(arithmeticOperatorWithInvalidOperands.ts, 547, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r10d2 = d | b; +>r10d2 : Symbol(r10d2, Decl(arithmeticOperatorWithInvalidOperands.ts, 548, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r10d3 = d | c; +>r10d3 : Symbol(r10d3, Decl(arithmeticOperatorWithInvalidOperands.ts, 549, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r10d4 = d | d; +>r10d4 : Symbol(r10d4, Decl(arithmeticOperatorWithInvalidOperands.ts, 550, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r10d5 = d | e; +>r10d5 : Symbol(r10d5, Decl(arithmeticOperatorWithInvalidOperands.ts, 551, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r10d6 = d | f; +>r10d6 : Symbol(r10d6, Decl(arithmeticOperatorWithInvalidOperands.ts, 552, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r10e1 = e | a; +>r10e1 : Symbol(r10e1, Decl(arithmeticOperatorWithInvalidOperands.ts, 554, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r10e2 = e | b; +>r10e2 : Symbol(r10e2, Decl(arithmeticOperatorWithInvalidOperands.ts, 555, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r10e3 = e | c; +>r10e3 : Symbol(r10e3, Decl(arithmeticOperatorWithInvalidOperands.ts, 556, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r10e4 = e | d; +>r10e4 : Symbol(r10e4, Decl(arithmeticOperatorWithInvalidOperands.ts, 557, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r10e5 = e | e; +>r10e5 : Symbol(r10e5, Decl(arithmeticOperatorWithInvalidOperands.ts, 558, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r10e6 = e | f; +>r10e6 : Symbol(r10e6, Decl(arithmeticOperatorWithInvalidOperands.ts, 559, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r10f1 = f | a; +>r10f1 : Symbol(r10f1, Decl(arithmeticOperatorWithInvalidOperands.ts, 561, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r10f2 = f | b; +>r10f2 : Symbol(r10f2, Decl(arithmeticOperatorWithInvalidOperands.ts, 562, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r10f3 = f | c; +>r10f3 : Symbol(r10f3, Decl(arithmeticOperatorWithInvalidOperands.ts, 563, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r10f4 = f | d; +>r10f4 : Symbol(r10f4, Decl(arithmeticOperatorWithInvalidOperands.ts, 564, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r10f5 = f | e; +>r10f5 : Symbol(r10f5, Decl(arithmeticOperatorWithInvalidOperands.ts, 565, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r10f6 = f | f; +>r10f6 : Symbol(r10f6, Decl(arithmeticOperatorWithInvalidOperands.ts, 566, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r10g1 = E.a | a; //ok +>r10g1 : Symbol(r10g1, Decl(arithmeticOperatorWithInvalidOperands.ts, 568, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) + +var r10g2 = E.a | b; +>r10g2 : Symbol(r10g2, Decl(arithmeticOperatorWithInvalidOperands.ts, 569, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) + +var r10g3 = E.a | c; //ok +>r10g3 : Symbol(r10g3, Decl(arithmeticOperatorWithInvalidOperands.ts, 570, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) + +var r10g4 = E.a | d; +>r10g4 : Symbol(r10g4, Decl(arithmeticOperatorWithInvalidOperands.ts, 571, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) + +var r10g5 = E.a | e; +>r10g5 : Symbol(r10g5, Decl(arithmeticOperatorWithInvalidOperands.ts, 572, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) + +var r10g6 = E.a | f; +>r10g6 : Symbol(r10g6, Decl(arithmeticOperatorWithInvalidOperands.ts, 573, 3)) +>E.a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>a : Symbol(E.a, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 8)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) + +var r10h1 = a | E.b; //ok +>r10h1 : Symbol(r10h1, Decl(arithmeticOperatorWithInvalidOperands.ts, 575, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithInvalidOperands.ts, 4, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r10h2 = b | E.b; +>r10h2 : Symbol(r10h2, Decl(arithmeticOperatorWithInvalidOperands.ts, 576, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithInvalidOperands.ts, 5, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r10h3 = c | E.b; //ok +>r10h3 : Symbol(r10h3, Decl(arithmeticOperatorWithInvalidOperands.ts, 577, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithInvalidOperands.ts, 6, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r10h4 = d | E.b; +>r10h4 : Symbol(r10h4, Decl(arithmeticOperatorWithInvalidOperands.ts, 578, 3)) +>d : Symbol(d, Decl(arithmeticOperatorWithInvalidOperands.ts, 7, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r10h5 = e | E.b; +>r10h5 : Symbol(r10h5, Decl(arithmeticOperatorWithInvalidOperands.ts, 579, 3)) +>e : Symbol(e, Decl(arithmeticOperatorWithInvalidOperands.ts, 8, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + +var r10h6 = f | E.b; +>r10h6 : Symbol(r10h6, Decl(arithmeticOperatorWithInvalidOperands.ts, 580, 3)) +>f : Symbol(f, Decl(arithmeticOperatorWithInvalidOperands.ts, 9, 3)) +>E.b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) +>E : Symbol(E, Decl(arithmeticOperatorWithInvalidOperands.ts, 0, 0)) +>b : Symbol(E.b, Decl(arithmeticOperatorWithInvalidOperands.ts, 2, 11)) + diff --git a/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.types b/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.types new file mode 100644 index 00000000000..7bd878e19ff --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithInvalidOperands.types @@ -0,0 +1,3160 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithInvalidOperands.ts === +// these operators require their operands to be of type Any, the Number primitive type, or +// an enum type +enum E { a, b, c } +>E : E +>a : E.a +>b : E.b +>c : E.c + +var a: any; +>a : any + +var b: boolean; +>b : boolean + +var c: number; +>c : number + +var d: string; +>d : string + +var e: { a: number }; +>e : { a: number; } +>a : number + +var f: Number; +>f : Number +>Number : Number + +// All of the below should be an error unless otherwise noted +// operator * +var r1a1 = a * a; //ok +>r1a1 : number +>a * a : number +>a : any +>a : any + +var r1a2 = a * b; +>r1a2 : number +>a * b : number +>a : any +>b : boolean + +var r1a3 = a * c; //ok +>r1a3 : number +>a * c : number +>a : any +>c : number + +var r1a4 = a * d; +>r1a4 : number +>a * d : number +>a : any +>d : string + +var r1a5 = a * e; +>r1a5 : number +>a * e : number +>a : any +>e : { a: number; } + +var r1a6 = a * f; +>r1a6 : number +>a * f : number +>a : any +>f : Number + +var r1b1 = b * a; +>r1b1 : number +>b * a : number +>b : boolean +>a : any + +var r1b2 = b * b; +>r1b2 : number +>b * b : number +>b : boolean +>b : boolean + +var r1b3 = b * c; +>r1b3 : number +>b * c : number +>b : boolean +>c : number + +var r1b4 = b * d; +>r1b4 : number +>b * d : number +>b : boolean +>d : string + +var r1b5 = b * e; +>r1b5 : number +>b * e : number +>b : boolean +>e : { a: number; } + +var r1b6 = b * f; +>r1b6 : number +>b * f : number +>b : boolean +>f : Number + +var r1c1 = c * a; //ok +>r1c1 : number +>c * a : number +>c : number +>a : any + +var r1c2 = c * b; +>r1c2 : number +>c * b : number +>c : number +>b : boolean + +var r1c3 = c * c; //ok +>r1c3 : number +>c * c : number +>c : number +>c : number + +var r1c4 = c * d; +>r1c4 : number +>c * d : number +>c : number +>d : string + +var r1c5 = c * e; +>r1c5 : number +>c * e : number +>c : number +>e : { a: number; } + +var r1c6 = c * f; +>r1c6 : number +>c * f : number +>c : number +>f : Number + +var r1d1 = d * a; +>r1d1 : number +>d * a : number +>d : string +>a : any + +var r1d2 = d * b; +>r1d2 : number +>d * b : number +>d : string +>b : boolean + +var r1d3 = d * c; +>r1d3 : number +>d * c : number +>d : string +>c : number + +var r1d4 = d * d; +>r1d4 : number +>d * d : number +>d : string +>d : string + +var r1d5 = d * e; +>r1d5 : number +>d * e : number +>d : string +>e : { a: number; } + +var r1d6 = d * f; +>r1d6 : number +>d * f : number +>d : string +>f : Number + +var r1e1 = e * a; +>r1e1 : number +>e * a : number +>e : { a: number; } +>a : any + +var r1e2 = e * b; +>r1e2 : number +>e * b : number +>e : { a: number; } +>b : boolean + +var r1e3 = e * c; +>r1e3 : number +>e * c : number +>e : { a: number; } +>c : number + +var r1e4 = e * d; +>r1e4 : number +>e * d : number +>e : { a: number; } +>d : string + +var r1e5 = e * e; +>r1e5 : number +>e * e : number +>e : { a: number; } +>e : { a: number; } + +var r1e6 = e * f; +>r1e6 : number +>e * f : number +>e : { a: number; } +>f : Number + +var r1f1 = f * a; +>r1f1 : number +>f * a : number +>f : Number +>a : any + +var r1f2 = f * b; +>r1f2 : number +>f * b : number +>f : Number +>b : boolean + +var r1f3 = f * c; +>r1f3 : number +>f * c : number +>f : Number +>c : number + +var r1f4 = f * d; +>r1f4 : number +>f * d : number +>f : Number +>d : string + +var r1f5 = f * e; +>r1f5 : number +>f * e : number +>f : Number +>e : { a: number; } + +var r1f6 = f * f; +>r1f6 : number +>f * f : number +>f : Number +>f : Number + +var r1g1 = E.a * a; //ok +>r1g1 : number +>E.a * a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r1g2 = E.a * b; +>r1g2 : number +>E.a * b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r1g3 = E.a * c; //ok +>r1g3 : number +>E.a * c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r1g4 = E.a * d; +>r1g4 : number +>E.a * d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r1g5 = E.a * e; +>r1g5 : number +>E.a * e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r1g6 = E.a * f; +>r1g6 : number +>E.a * f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r1h1 = a * E.b; //ok +>r1h1 : number +>a * E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r1h2 = b * E.b; +>r1h2 : number +>b * E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r1h3 = c * E.b; //ok +>r1h3 : number +>c * E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r1h4 = d * E.b; +>r1h4 : number +>d * E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r1h5 = e * E.b; +>r1h5 : number +>e * E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r1h6 = f * E.b; +>r1h6 : number +>f * E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator / +var r2a1 = a / a; //ok +>r2a1 : number +>a / a : number +>a : any +>a : any + +var r2a2 = a / b; +>r2a2 : number +>a / b : number +>a : any +>b : boolean + +var r2a3 = a / c; //ok +>r2a3 : number +>a / c : number +>a : any +>c : number + +var r2a4 = a / d; +>r2a4 : number +>a / d : number +>a : any +>d : string + +var r2a5 = a / e; +>r2a5 : number +>a / e : number +>a : any +>e : { a: number; } + +var r2a6 = a / f; +>r2a6 : number +>a / f : number +>a : any +>f : Number + +var r2b1 = b / a; +>r2b1 : number +>b / a : number +>b : boolean +>a : any + +var r2b2 = b / b; +>r2b2 : number +>b / b : number +>b : boolean +>b : boolean + +var r2b3 = b / c; +>r2b3 : number +>b / c : number +>b : boolean +>c : number + +var r2b4 = b / d; +>r2b4 : number +>b / d : number +>b : boolean +>d : string + +var r2b5 = b / e; +>r2b5 : number +>b / e : number +>b : boolean +>e : { a: number; } + +var r2b6 = b / f; +>r2b6 : number +>b / f : number +>b : boolean +>f : Number + +var r2c1 = c / a; //ok +>r2c1 : number +>c / a : number +>c : number +>a : any + +var r2c2 = c / b; +>r2c2 : number +>c / b : number +>c : number +>b : boolean + +var r2c3 = c / c; //ok +>r2c3 : number +>c / c : number +>c : number +>c : number + +var r2c4 = c / d; +>r2c4 : number +>c / d : number +>c : number +>d : string + +var r2c5 = c / e; +>r2c5 : number +>c / e : number +>c : number +>e : { a: number; } + +var r2c6 = c / f; +>r2c6 : number +>c / f : number +>c : number +>f : Number + +var r2d1 = d / a; +>r2d1 : number +>d / a : number +>d : string +>a : any + +var r2d2 = d / b; +>r2d2 : number +>d / b : number +>d : string +>b : boolean + +var r2d3 = d / c; +>r2d3 : number +>d / c : number +>d : string +>c : number + +var r2d4 = d / d; +>r2d4 : number +>d / d : number +>d : string +>d : string + +var r2d5 = d / e; +>r2d5 : number +>d / e : number +>d : string +>e : { a: number; } + +var r2d6 = d / f; +>r2d6 : number +>d / f : number +>d : string +>f : Number + +var r2e1 = e / a; +>r2e1 : number +>e / a : number +>e : { a: number; } +>a : any + +var r2e2 = e / b; +>r2e2 : number +>e / b : number +>e : { a: number; } +>b : boolean + +var r2e3 = e / c; +>r2e3 : number +>e / c : number +>e : { a: number; } +>c : number + +var r2e4 = e / d; +>r2e4 : number +>e / d : number +>e : { a: number; } +>d : string + +var r2e5 = e / e; +>r2e5 : number +>e / e : number +>e : { a: number; } +>e : { a: number; } + +var r2e6 = e / f; +>r2e6 : number +>e / f : number +>e : { a: number; } +>f : Number + +var r2f1 = f / a; +>r2f1 : number +>f / a : number +>f : Number +>a : any + +var r2f2 = f / b; +>r2f2 : number +>f / b : number +>f : Number +>b : boolean + +var r2f3 = f / c; +>r2f3 : number +>f / c : number +>f : Number +>c : number + +var r2f4 = f / d; +>r2f4 : number +>f / d : number +>f : Number +>d : string + +var r2f5 = f / e; +>r2f5 : number +>f / e : number +>f : Number +>e : { a: number; } + +var r2f6 = f / f; +>r2f6 : number +>f / f : number +>f : Number +>f : Number + +var r2g1 = E.a / a; //ok +>r2g1 : number +>E.a / a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r2g2 = E.a / b; +>r2g2 : number +>E.a / b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r2g3 = E.a / c; //ok +>r2g3 : number +>E.a / c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r2g4 = E.a / d; +>r2g4 : number +>E.a / d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r2g5 = E.a / e; +>r2g5 : number +>E.a / e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r2g6 = E.a / f; +>r2g6 : number +>E.a / f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r2h1 = a / E.b; //ok +>r2h1 : number +>a / E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r2h2 = b / E.b; +>r2h2 : number +>b / E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r2h3 = c / E.b; //ok +>r2h3 : number +>c / E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r2h4 = d / E.b; +>r2h4 : number +>d / E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r2h5 = e / E.b; +>r2h5 : number +>e / E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r2h6 = f / E.b; +>r2h6 : number +>f / E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator % +var r3a1 = a % a; //ok +>r3a1 : number +>a % a : number +>a : any +>a : any + +var r3a2 = a % b; +>r3a2 : number +>a % b : number +>a : any +>b : boolean + +var r3a3 = a % c; //ok +>r3a3 : number +>a % c : number +>a : any +>c : number + +var r3a4 = a % d; +>r3a4 : number +>a % d : number +>a : any +>d : string + +var r3a5 = a % e; +>r3a5 : number +>a % e : number +>a : any +>e : { a: number; } + +var r3a6 = a % f; +>r3a6 : number +>a % f : number +>a : any +>f : Number + +var r3b1 = b % a; +>r3b1 : number +>b % a : number +>b : boolean +>a : any + +var r3b2 = b % b; +>r3b2 : number +>b % b : number +>b : boolean +>b : boolean + +var r3b3 = b % c; +>r3b3 : number +>b % c : number +>b : boolean +>c : number + +var r3b4 = b % d; +>r3b4 : number +>b % d : number +>b : boolean +>d : string + +var r3b5 = b % e; +>r3b5 : number +>b % e : number +>b : boolean +>e : { a: number; } + +var r3b6 = b % f; +>r3b6 : number +>b % f : number +>b : boolean +>f : Number + +var r3c1 = c % a; //ok +>r3c1 : number +>c % a : number +>c : number +>a : any + +var r3c2 = c % b; +>r3c2 : number +>c % b : number +>c : number +>b : boolean + +var r3c3 = c % c; //ok +>r3c3 : number +>c % c : number +>c : number +>c : number + +var r3c4 = c % d; +>r3c4 : number +>c % d : number +>c : number +>d : string + +var r3c5 = c % e; +>r3c5 : number +>c % e : number +>c : number +>e : { a: number; } + +var r3c6 = c % f; +>r3c6 : number +>c % f : number +>c : number +>f : Number + +var r3d1 = d % a; +>r3d1 : number +>d % a : number +>d : string +>a : any + +var r3d2 = d % b; +>r3d2 : number +>d % b : number +>d : string +>b : boolean + +var r3d3 = d % c; +>r3d3 : number +>d % c : number +>d : string +>c : number + +var r3d4 = d % d; +>r3d4 : number +>d % d : number +>d : string +>d : string + +var r3d5 = d % e; +>r3d5 : number +>d % e : number +>d : string +>e : { a: number; } + +var r3d6 = d % f; +>r3d6 : number +>d % f : number +>d : string +>f : Number + +var r3e1 = e % a; +>r3e1 : number +>e % a : number +>e : { a: number; } +>a : any + +var r3e2 = e % b; +>r3e2 : number +>e % b : number +>e : { a: number; } +>b : boolean + +var r3e3 = e % c; +>r3e3 : number +>e % c : number +>e : { a: number; } +>c : number + +var r3e4 = e % d; +>r3e4 : number +>e % d : number +>e : { a: number; } +>d : string + +var r3e5 = e % e; +>r3e5 : number +>e % e : number +>e : { a: number; } +>e : { a: number; } + +var r3e6 = e % f; +>r3e6 : number +>e % f : number +>e : { a: number; } +>f : Number + +var r3f1 = f % a; +>r3f1 : number +>f % a : number +>f : Number +>a : any + +var r3f2 = f % b; +>r3f2 : number +>f % b : number +>f : Number +>b : boolean + +var r3f3 = f % c; +>r3f3 : number +>f % c : number +>f : Number +>c : number + +var r3f4 = f % d; +>r3f4 : number +>f % d : number +>f : Number +>d : string + +var r3f5 = f % e; +>r3f5 : number +>f % e : number +>f : Number +>e : { a: number; } + +var r3f6 = f % f; +>r3f6 : number +>f % f : number +>f : Number +>f : Number + +var r3g1 = E.a % a; //ok +>r3g1 : number +>E.a % a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r3g2 = E.a % b; +>r3g2 : number +>E.a % b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r3g3 = E.a % c; //ok +>r3g3 : number +>E.a % c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r3g4 = E.a % d; +>r3g4 : number +>E.a % d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r3g5 = E.a % e; +>r3g5 : number +>E.a % e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r3g6 = E.a % f; +>r3g6 : number +>E.a % f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r3h1 = a % E.b; //ok +>r3h1 : number +>a % E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r3h2 = b % E.b; +>r3h2 : number +>b % E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r3h3 = c % E.b; //ok +>r3h3 : number +>c % E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r3h4 = d % E.b; +>r3h4 : number +>d % E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r3h5 = e % E.b; +>r3h5 : number +>e % E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r3h6 = f % E.b; +>r3h6 : number +>f % E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator - +var r4a1 = a - a; //ok +>r4a1 : number +>a - a : number +>a : any +>a : any + +var r4a2 = a - b; +>r4a2 : number +>a - b : number +>a : any +>b : boolean + +var r4a3 = a - c; //ok +>r4a3 : number +>a - c : number +>a : any +>c : number + +var r4a4 = a - d; +>r4a4 : number +>a - d : number +>a : any +>d : string + +var r4a5 = a - e; +>r4a5 : number +>a - e : number +>a : any +>e : { a: number; } + +var r4a6 = a - f; +>r4a6 : number +>a - f : number +>a : any +>f : Number + +var r4b1 = b - a; +>r4b1 : number +>b - a : number +>b : boolean +>a : any + +var r4b2 = b - b; +>r4b2 : number +>b - b : number +>b : boolean +>b : boolean + +var r4b3 = b - c; +>r4b3 : number +>b - c : number +>b : boolean +>c : number + +var r4b4 = b - d; +>r4b4 : number +>b - d : number +>b : boolean +>d : string + +var r4b5 = b - e; +>r4b5 : number +>b - e : number +>b : boolean +>e : { a: number; } + +var r4b6 = b - f; +>r4b6 : number +>b - f : number +>b : boolean +>f : Number + +var r4c1 = c - a; //ok +>r4c1 : number +>c - a : number +>c : number +>a : any + +var r4c2 = c - b; +>r4c2 : number +>c - b : number +>c : number +>b : boolean + +var r4c3 = c - c; //ok +>r4c3 : number +>c - c : number +>c : number +>c : number + +var r4c4 = c - d; +>r4c4 : number +>c - d : number +>c : number +>d : string + +var r4c5 = c - e; +>r4c5 : number +>c - e : number +>c : number +>e : { a: number; } + +var r4c6 = c - f; +>r4c6 : number +>c - f : number +>c : number +>f : Number + +var r4d1 = d - a; +>r4d1 : number +>d - a : number +>d : string +>a : any + +var r4d2 = d - b; +>r4d2 : number +>d - b : number +>d : string +>b : boolean + +var r4d3 = d - c; +>r4d3 : number +>d - c : number +>d : string +>c : number + +var r4d4 = d - d; +>r4d4 : number +>d - d : number +>d : string +>d : string + +var r4d5 = d - e; +>r4d5 : number +>d - e : number +>d : string +>e : { a: number; } + +var r4d6 = d - f; +>r4d6 : number +>d - f : number +>d : string +>f : Number + +var r4e1 = e - a; +>r4e1 : number +>e - a : number +>e : { a: number; } +>a : any + +var r4e2 = e - b; +>r4e2 : number +>e - b : number +>e : { a: number; } +>b : boolean + +var r4e3 = e - c; +>r4e3 : number +>e - c : number +>e : { a: number; } +>c : number + +var r4e4 = e - d; +>r4e4 : number +>e - d : number +>e : { a: number; } +>d : string + +var r4e5 = e - e; +>r4e5 : number +>e - e : number +>e : { a: number; } +>e : { a: number; } + +var r4e6 = e - f; +>r4e6 : number +>e - f : number +>e : { a: number; } +>f : Number + +var r4f1 = f - a; +>r4f1 : number +>f - a : number +>f : Number +>a : any + +var r4f2 = f - b; +>r4f2 : number +>f - b : number +>f : Number +>b : boolean + +var r4f3 = f - c; +>r4f3 : number +>f - c : number +>f : Number +>c : number + +var r4f4 = f - d; +>r4f4 : number +>f - d : number +>f : Number +>d : string + +var r4f5 = f - e; +>r4f5 : number +>f - e : number +>f : Number +>e : { a: number; } + +var r4f6 = f - f; +>r4f6 : number +>f - f : number +>f : Number +>f : Number + +var r4g1 = E.a - a; //ok +>r4g1 : number +>E.a - a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r4g2 = E.a - b; +>r4g2 : number +>E.a - b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r4g3 = E.a - c; //ok +>r4g3 : number +>E.a - c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r4g4 = E.a - d; +>r4g4 : number +>E.a - d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r4g5 = E.a - e; +>r4g5 : number +>E.a - e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r4g6 = E.a - f; +>r4g6 : number +>E.a - f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r4h1 = a - E.b; //ok +>r4h1 : number +>a - E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r4h2 = b - E.b; +>r4h2 : number +>b - E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r4h3 = c - E.b; //ok +>r4h3 : number +>c - E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r4h4 = d - E.b; +>r4h4 : number +>d - E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r4h5 = e - E.b; +>r4h5 : number +>e - E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r4h6 = f - E.b; +>r4h6 : number +>f - E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator << +var r5a1 = a << a; //ok +>r5a1 : number +>a << a : number +>a : any +>a : any + +var r5a2 = a << b; +>r5a2 : number +>a << b : number +>a : any +>b : boolean + +var r5a3 = a << c; //ok +>r5a3 : number +>a << c : number +>a : any +>c : number + +var r5a4 = a << d; +>r5a4 : number +>a << d : number +>a : any +>d : string + +var r5a5 = a << e; +>r5a5 : number +>a << e : number +>a : any +>e : { a: number; } + +var r5a6 = a << f; +>r5a6 : number +>a << f : number +>a : any +>f : Number + +var r5b1 = b << a; +>r5b1 : number +>b << a : number +>b : boolean +>a : any + +var r5b2 = b << b; +>r5b2 : number +>b << b : number +>b : boolean +>b : boolean + +var r5b3 = b << c; +>r5b3 : number +>b << c : number +>b : boolean +>c : number + +var r5b4 = b << d; +>r5b4 : number +>b << d : number +>b : boolean +>d : string + +var r5b5 = b << e; +>r5b5 : number +>b << e : number +>b : boolean +>e : { a: number; } + +var r5b6 = b << f; +>r5b6 : number +>b << f : number +>b : boolean +>f : Number + +var r5c1 = c << a; //ok +>r5c1 : number +>c << a : number +>c : number +>a : any + +var r5c2 = c << b; +>r5c2 : number +>c << b : number +>c : number +>b : boolean + +var r5c3 = c << c; //ok +>r5c3 : number +>c << c : number +>c : number +>c : number + +var r5c4 = c << d; +>r5c4 : number +>c << d : number +>c : number +>d : string + +var r5c5 = c << e; +>r5c5 : number +>c << e : number +>c : number +>e : { a: number; } + +var r5c6 = c << f; +>r5c6 : number +>c << f : number +>c : number +>f : Number + +var r5d1 = d << a; +>r5d1 : number +>d << a : number +>d : string +>a : any + +var r5d2 = d << b; +>r5d2 : number +>d << b : number +>d : string +>b : boolean + +var r5d3 = d << c; +>r5d3 : number +>d << c : number +>d : string +>c : number + +var r5d4 = d << d; +>r5d4 : number +>d << d : number +>d : string +>d : string + +var r5d5 = d << e; +>r5d5 : number +>d << e : number +>d : string +>e : { a: number; } + +var r5d6 = d << f; +>r5d6 : number +>d << f : number +>d : string +>f : Number + +var r5e1 = e << a; +>r5e1 : number +>e << a : number +>e : { a: number; } +>a : any + +var r5e2 = e << b; +>r5e2 : number +>e << b : number +>e : { a: number; } +>b : boolean + +var r5e3 = e << c; +>r5e3 : number +>e << c : number +>e : { a: number; } +>c : number + +var r5e4 = e << d; +>r5e4 : number +>e << d : number +>e : { a: number; } +>d : string + +var r5e5 = e << e; +>r5e5 : number +>e << e : number +>e : { a: number; } +>e : { a: number; } + +var r5e6 = e << f; +>r5e6 : number +>e << f : number +>e : { a: number; } +>f : Number + +var r5f1 = f << a; +>r5f1 : number +>f << a : number +>f : Number +>a : any + +var r5f2 = f << b; +>r5f2 : number +>f << b : number +>f : Number +>b : boolean + +var r5f3 = f << c; +>r5f3 : number +>f << c : number +>f : Number +>c : number + +var r5f4 = f << d; +>r5f4 : number +>f << d : number +>f : Number +>d : string + +var r5f5 = f << e; +>r5f5 : number +>f << e : number +>f : Number +>e : { a: number; } + +var r5f6 = f << f; +>r5f6 : number +>f << f : number +>f : Number +>f : Number + +var r5g1 = E.a << a; //ok +>r5g1 : number +>E.a << a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r5g2 = E.a << b; +>r5g2 : number +>E.a << b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r5g3 = E.a << c; //ok +>r5g3 : number +>E.a << c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r5g4 = E.a << d; +>r5g4 : number +>E.a << d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r5g5 = E.a << e; +>r5g5 : number +>E.a << e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r5g6 = E.a << f; +>r5g6 : number +>E.a << f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r5h1 = a << E.b; //ok +>r5h1 : number +>a << E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r5h2 = b << E.b; +>r5h2 : number +>b << E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r5h3 = c << E.b; //ok +>r5h3 : number +>c << E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r5h4 = d << E.b; +>r5h4 : number +>d << E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r5h5 = e << E.b; +>r5h5 : number +>e << E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r5h6 = f << E.b; +>r5h6 : number +>f << E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator >> +var r6a1 = a >> a; //ok +>r6a1 : number +>a >> a : number +>a : any +>a : any + +var r6a2 = a >> b; +>r6a2 : number +>a >> b : number +>a : any +>b : boolean + +var r6a3 = a >> c; //ok +>r6a3 : number +>a >> c : number +>a : any +>c : number + +var r6a4 = a >> d; +>r6a4 : number +>a >> d : number +>a : any +>d : string + +var r6a5 = a >> e; +>r6a5 : number +>a >> e : number +>a : any +>e : { a: number; } + +var r6a6 = a >> f; +>r6a6 : number +>a >> f : number +>a : any +>f : Number + +var r6b1 = b >> a; +>r6b1 : number +>b >> a : number +>b : boolean +>a : any + +var r6b2 = b >> b; +>r6b2 : number +>b >> b : number +>b : boolean +>b : boolean + +var r6b3 = b >> c; +>r6b3 : number +>b >> c : number +>b : boolean +>c : number + +var r6b4 = b >> d; +>r6b4 : number +>b >> d : number +>b : boolean +>d : string + +var r6b5 = b >> e; +>r6b5 : number +>b >> e : number +>b : boolean +>e : { a: number; } + +var r6b6 = b >> f; +>r6b6 : number +>b >> f : number +>b : boolean +>f : Number + +var r6c1 = c >> a; //ok +>r6c1 : number +>c >> a : number +>c : number +>a : any + +var r6c2 = c >> b; +>r6c2 : number +>c >> b : number +>c : number +>b : boolean + +var r6c3 = c >> c; //ok +>r6c3 : number +>c >> c : number +>c : number +>c : number + +var r6c4 = c >> d; +>r6c4 : number +>c >> d : number +>c : number +>d : string + +var r6c5 = c >> e; +>r6c5 : number +>c >> e : number +>c : number +>e : { a: number; } + +var r6c6 = c >> f; +>r6c6 : number +>c >> f : number +>c : number +>f : Number + +var r6d1 = d >> a; +>r6d1 : number +>d >> a : number +>d : string +>a : any + +var r6d2 = d >> b; +>r6d2 : number +>d >> b : number +>d : string +>b : boolean + +var r6d3 = d >> c; +>r6d3 : number +>d >> c : number +>d : string +>c : number + +var r6d4 = d >> d; +>r6d4 : number +>d >> d : number +>d : string +>d : string + +var r6d5 = d >> e; +>r6d5 : number +>d >> e : number +>d : string +>e : { a: number; } + +var r6d6 = d >> f; +>r6d6 : number +>d >> f : number +>d : string +>f : Number + +var r6e1 = e >> a; +>r6e1 : number +>e >> a : number +>e : { a: number; } +>a : any + +var r6e2 = e >> b; +>r6e2 : number +>e >> b : number +>e : { a: number; } +>b : boolean + +var r6e3 = e >> c; +>r6e3 : number +>e >> c : number +>e : { a: number; } +>c : number + +var r6e4 = e >> d; +>r6e4 : number +>e >> d : number +>e : { a: number; } +>d : string + +var r6e5 = e >> e; +>r6e5 : number +>e >> e : number +>e : { a: number; } +>e : { a: number; } + +var r6e6 = e >> f; +>r6e6 : number +>e >> f : number +>e : { a: number; } +>f : Number + +var r6f1 = f >> a; +>r6f1 : number +>f >> a : number +>f : Number +>a : any + +var r6f2 = f >> b; +>r6f2 : number +>f >> b : number +>f : Number +>b : boolean + +var r6f3 = f >> c; +>r6f3 : number +>f >> c : number +>f : Number +>c : number + +var r6f4 = f >> d; +>r6f4 : number +>f >> d : number +>f : Number +>d : string + +var r6f5 = f >> e; +>r6f5 : number +>f >> e : number +>f : Number +>e : { a: number; } + +var r6f6 = f >> f; +>r6f6 : number +>f >> f : number +>f : Number +>f : Number + +var r6g1 = E.a >> a; //ok +>r6g1 : number +>E.a >> a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r6g2 = E.a >> b; +>r6g2 : number +>E.a >> b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r6g3 = E.a >> c; //ok +>r6g3 : number +>E.a >> c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r6g4 = E.a >> d; +>r6g4 : number +>E.a >> d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r6g5 = E.a >> e; +>r6g5 : number +>E.a >> e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r6g6 = E.a >> f; +>r6g6 : number +>E.a >> f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r6h1 = a >> E.b; //ok +>r6h1 : number +>a >> E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r6h2 = b >> E.b; +>r6h2 : number +>b >> E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r6h3 = c >> E.b; //ok +>r6h3 : number +>c >> E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r6h4 = d >> E.b; +>r6h4 : number +>d >> E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r6h5 = e >> E.b; +>r6h5 : number +>e >> E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r6h6 = f >> E.b; +>r6h6 : number +>f >> E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator >>> +var r7a1 = a >>> a; //ok +>r7a1 : number +>a >>> a : number +>a : any +>a : any + +var r7a2 = a >>> b; +>r7a2 : number +>a >>> b : number +>a : any +>b : boolean + +var r7a3 = a >>> c; //ok +>r7a3 : number +>a >>> c : number +>a : any +>c : number + +var r7a4 = a >>> d; +>r7a4 : number +>a >>> d : number +>a : any +>d : string + +var r7a5 = a >>> e; +>r7a5 : number +>a >>> e : number +>a : any +>e : { a: number; } + +var r7a6 = a >>> f; +>r7a6 : number +>a >>> f : number +>a : any +>f : Number + +var r7b1 = b >>> a; +>r7b1 : number +>b >>> a : number +>b : boolean +>a : any + +var r7b2 = b >>> b; +>r7b2 : number +>b >>> b : number +>b : boolean +>b : boolean + +var r7b3 = b >>> c; +>r7b3 : number +>b >>> c : number +>b : boolean +>c : number + +var r7b4 = b >>> d; +>r7b4 : number +>b >>> d : number +>b : boolean +>d : string + +var r7b5 = b >>> e; +>r7b5 : number +>b >>> e : number +>b : boolean +>e : { a: number; } + +var r7b6 = b >>> f; +>r7b6 : number +>b >>> f : number +>b : boolean +>f : Number + +var r7c1 = c >>> a; //ok +>r7c1 : number +>c >>> a : number +>c : number +>a : any + +var r7c2 = c >>> b; +>r7c2 : number +>c >>> b : number +>c : number +>b : boolean + +var r7c3 = c >>> c; //ok +>r7c3 : number +>c >>> c : number +>c : number +>c : number + +var r7c4 = c >>> d; +>r7c4 : number +>c >>> d : number +>c : number +>d : string + +var r7c5 = c >>> e; +>r7c5 : number +>c >>> e : number +>c : number +>e : { a: number; } + +var r7c6 = c >>> f; +>r7c6 : number +>c >>> f : number +>c : number +>f : Number + +var r7d1 = d >>> a; +>r7d1 : number +>d >>> a : number +>d : string +>a : any + +var r7d2 = d >>> b; +>r7d2 : number +>d >>> b : number +>d : string +>b : boolean + +var r7d3 = d >>> c; +>r7d3 : number +>d >>> c : number +>d : string +>c : number + +var r7d4 = d >>> d; +>r7d4 : number +>d >>> d : number +>d : string +>d : string + +var r7d5 = d >>> e; +>r7d5 : number +>d >>> e : number +>d : string +>e : { a: number; } + +var r7d6 = d >>> f; +>r7d6 : number +>d >>> f : number +>d : string +>f : Number + +var r7e1 = e >>> a; +>r7e1 : number +>e >>> a : number +>e : { a: number; } +>a : any + +var r7e2 = e >>> b; +>r7e2 : number +>e >>> b : number +>e : { a: number; } +>b : boolean + +var r7e3 = e >>> c; +>r7e3 : number +>e >>> c : number +>e : { a: number; } +>c : number + +var r7e4 = e >>> d; +>r7e4 : number +>e >>> d : number +>e : { a: number; } +>d : string + +var r7e5 = e >>> e; +>r7e5 : number +>e >>> e : number +>e : { a: number; } +>e : { a: number; } + +var r7e6 = e >>> f; +>r7e6 : number +>e >>> f : number +>e : { a: number; } +>f : Number + +var r7f1 = f >>> a; +>r7f1 : number +>f >>> a : number +>f : Number +>a : any + +var r7f2 = f >>> b; +>r7f2 : number +>f >>> b : number +>f : Number +>b : boolean + +var r7f3 = f >>> c; +>r7f3 : number +>f >>> c : number +>f : Number +>c : number + +var r7f4 = f >>> d; +>r7f4 : number +>f >>> d : number +>f : Number +>d : string + +var r7f5 = f >>> e; +>r7f5 : number +>f >>> e : number +>f : Number +>e : { a: number; } + +var r7f6 = f >>> f; +>r7f6 : number +>f >>> f : number +>f : Number +>f : Number + +var r7g1 = E.a >>> a; //ok +>r7g1 : number +>E.a >>> a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r7g2 = E.a >>> b; +>r7g2 : number +>E.a >>> b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r7g3 = E.a >>> c; //ok +>r7g3 : number +>E.a >>> c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r7g4 = E.a >>> d; +>r7g4 : number +>E.a >>> d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r7g5 = E.a >>> e; +>r7g5 : number +>E.a >>> e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r7g6 = E.a >>> f; +>r7g6 : number +>E.a >>> f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r7h1 = a >>> E.b; //ok +>r7h1 : number +>a >>> E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r7h2 = b >>> E.b; +>r7h2 : number +>b >>> E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r7h3 = c >>> E.b; //ok +>r7h3 : number +>c >>> E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r7h4 = d >>> E.b; +>r7h4 : number +>d >>> E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r7h5 = e >>> E.b; +>r7h5 : number +>e >>> E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r7h6 = f >>> E.b; +>r7h6 : number +>f >>> E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator & +var r8a1 = a & a; //ok +>r8a1 : number +>a & a : number +>a : any +>a : any + +var r8a2 = a & b; +>r8a2 : number +>a & b : number +>a : any +>b : boolean + +var r8a3 = a & c; //ok +>r8a3 : number +>a & c : number +>a : any +>c : number + +var r8a4 = a & d; +>r8a4 : number +>a & d : number +>a : any +>d : string + +var r8a5 = a & e; +>r8a5 : number +>a & e : number +>a : any +>e : { a: number; } + +var r8a6 = a & f; +>r8a6 : number +>a & f : number +>a : any +>f : Number + +var r8b1 = b & a; +>r8b1 : number +>b & a : number +>b : boolean +>a : any + +var r8b2 = b & b; +>r8b2 : number +>b & b : number +>b : boolean +>b : boolean + +var r8b3 = b & c; +>r8b3 : number +>b & c : number +>b : boolean +>c : number + +var r8b4 = b & d; +>r8b4 : number +>b & d : number +>b : boolean +>d : string + +var r8b5 = b & e; +>r8b5 : number +>b & e : number +>b : boolean +>e : { a: number; } + +var r8b6 = b & f; +>r8b6 : number +>b & f : number +>b : boolean +>f : Number + +var r8c1 = c & a; //ok +>r8c1 : number +>c & a : number +>c : number +>a : any + +var r8c2 = c & b; +>r8c2 : number +>c & b : number +>c : number +>b : boolean + +var r8c3 = c & c; //ok +>r8c3 : number +>c & c : number +>c : number +>c : number + +var r8c4 = c & d; +>r8c4 : number +>c & d : number +>c : number +>d : string + +var r8c5 = c & e; +>r8c5 : number +>c & e : number +>c : number +>e : { a: number; } + +var r8c6 = c & f; +>r8c6 : number +>c & f : number +>c : number +>f : Number + +var r8d1 = d & a; +>r8d1 : number +>d & a : number +>d : string +>a : any + +var r8d2 = d & b; +>r8d2 : number +>d & b : number +>d : string +>b : boolean + +var r8d3 = d & c; +>r8d3 : number +>d & c : number +>d : string +>c : number + +var r8d4 = d & d; +>r8d4 : number +>d & d : number +>d : string +>d : string + +var r8d5 = d & e; +>r8d5 : number +>d & e : number +>d : string +>e : { a: number; } + +var r8d6 = d & f; +>r8d6 : number +>d & f : number +>d : string +>f : Number + +var r8e1 = e & a; +>r8e1 : number +>e & a : number +>e : { a: number; } +>a : any + +var r8e2 = e & b; +>r8e2 : number +>e & b : number +>e : { a: number; } +>b : boolean + +var r8e3 = e & c; +>r8e3 : number +>e & c : number +>e : { a: number; } +>c : number + +var r8e4 = e & d; +>r8e4 : number +>e & d : number +>e : { a: number; } +>d : string + +var r8e5 = e & e; +>r8e5 : number +>e & e : number +>e : { a: number; } +>e : { a: number; } + +var r8e6 = e & f; +>r8e6 : number +>e & f : number +>e : { a: number; } +>f : Number + +var r8f1 = f & a; +>r8f1 : number +>f & a : number +>f : Number +>a : any + +var r8f2 = f & b; +>r8f2 : number +>f & b : number +>f : Number +>b : boolean + +var r8f3 = f & c; +>r8f3 : number +>f & c : number +>f : Number +>c : number + +var r8f4 = f & d; +>r8f4 : number +>f & d : number +>f : Number +>d : string + +var r8f5 = f & e; +>r8f5 : number +>f & e : number +>f : Number +>e : { a: number; } + +var r8f6 = f & f; +>r8f6 : number +>f & f : number +>f : Number +>f : Number + +var r8g1 = E.a & a; //ok +>r8g1 : number +>E.a & a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r8g2 = E.a & b; +>r8g2 : number +>E.a & b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r8g3 = E.a & c; //ok +>r8g3 : number +>E.a & c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r8g4 = E.a & d; +>r8g4 : number +>E.a & d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r8g5 = E.a & e; +>r8g5 : number +>E.a & e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r8g6 = E.a & f; +>r8g6 : number +>E.a & f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r8h1 = a & E.b; //ok +>r8h1 : number +>a & E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r8h2 = b & E.b; +>r8h2 : number +>b & E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r8h3 = c & E.b; //ok +>r8h3 : number +>c & E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r8h4 = d & E.b; +>r8h4 : number +>d & E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r8h5 = e & E.b; +>r8h5 : number +>e & E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r8h6 = f & E.b; +>r8h6 : number +>f & E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator ^ +var r9a1 = a ^ a; //ok +>r9a1 : number +>a ^ a : number +>a : any +>a : any + +var r9a2 = a ^ b; +>r9a2 : number +>a ^ b : number +>a : any +>b : boolean + +var r9a3 = a ^ c; //ok +>r9a3 : number +>a ^ c : number +>a : any +>c : number + +var r9a4 = a ^ d; +>r9a4 : number +>a ^ d : number +>a : any +>d : string + +var r9a5 = a ^ e; +>r9a5 : number +>a ^ e : number +>a : any +>e : { a: number; } + +var r9a6 = a ^ f; +>r9a6 : number +>a ^ f : number +>a : any +>f : Number + +var r9b1 = b ^ a; +>r9b1 : number +>b ^ a : number +>b : boolean +>a : any + +var r9b2 = b ^ b; +>r9b2 : number +>b ^ b : number +>b : boolean +>b : boolean + +var r9b3 = b ^ c; +>r9b3 : number +>b ^ c : number +>b : boolean +>c : number + +var r9b4 = b ^ d; +>r9b4 : number +>b ^ d : number +>b : boolean +>d : string + +var r9b5 = b ^ e; +>r9b5 : number +>b ^ e : number +>b : boolean +>e : { a: number; } + +var r9b6 = b ^ f; +>r9b6 : number +>b ^ f : number +>b : boolean +>f : Number + +var r9c1 = c ^ a; //ok +>r9c1 : number +>c ^ a : number +>c : number +>a : any + +var r9c2 = c ^ b; +>r9c2 : number +>c ^ b : number +>c : number +>b : boolean + +var r9c3 = c ^ c; //ok +>r9c3 : number +>c ^ c : number +>c : number +>c : number + +var r9c4 = c ^ d; +>r9c4 : number +>c ^ d : number +>c : number +>d : string + +var r9c5 = c ^ e; +>r9c5 : number +>c ^ e : number +>c : number +>e : { a: number; } + +var r9c6 = c ^ f; +>r9c6 : number +>c ^ f : number +>c : number +>f : Number + +var r9d1 = d ^ a; +>r9d1 : number +>d ^ a : number +>d : string +>a : any + +var r9d2 = d ^ b; +>r9d2 : number +>d ^ b : number +>d : string +>b : boolean + +var r9d3 = d ^ c; +>r9d3 : number +>d ^ c : number +>d : string +>c : number + +var r9d4 = d ^ d; +>r9d4 : number +>d ^ d : number +>d : string +>d : string + +var r9d5 = d ^ e; +>r9d5 : number +>d ^ e : number +>d : string +>e : { a: number; } + +var r9d6 = d ^ f; +>r9d6 : number +>d ^ f : number +>d : string +>f : Number + +var r9e1 = e ^ a; +>r9e1 : number +>e ^ a : number +>e : { a: number; } +>a : any + +var r9e2 = e ^ b; +>r9e2 : number +>e ^ b : number +>e : { a: number; } +>b : boolean + +var r9e3 = e ^ c; +>r9e3 : number +>e ^ c : number +>e : { a: number; } +>c : number + +var r9e4 = e ^ d; +>r9e4 : number +>e ^ d : number +>e : { a: number; } +>d : string + +var r9e5 = e ^ e; +>r9e5 : number +>e ^ e : number +>e : { a: number; } +>e : { a: number; } + +var r9e6 = e ^ f; +>r9e6 : number +>e ^ f : number +>e : { a: number; } +>f : Number + +var r9f1 = f ^ a; +>r9f1 : number +>f ^ a : number +>f : Number +>a : any + +var r9f2 = f ^ b; +>r9f2 : number +>f ^ b : number +>f : Number +>b : boolean + +var r9f3 = f ^ c; +>r9f3 : number +>f ^ c : number +>f : Number +>c : number + +var r9f4 = f ^ d; +>r9f4 : number +>f ^ d : number +>f : Number +>d : string + +var r9f5 = f ^ e; +>r9f5 : number +>f ^ e : number +>f : Number +>e : { a: number; } + +var r9f6 = f ^ f; +>r9f6 : number +>f ^ f : number +>f : Number +>f : Number + +var r9g1 = E.a ^ a; //ok +>r9g1 : number +>E.a ^ a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r9g2 = E.a ^ b; +>r9g2 : number +>E.a ^ b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r9g3 = E.a ^ c; //ok +>r9g3 : number +>E.a ^ c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r9g4 = E.a ^ d; +>r9g4 : number +>E.a ^ d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r9g5 = E.a ^ e; +>r9g5 : number +>E.a ^ e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r9g6 = E.a ^ f; +>r9g6 : number +>E.a ^ f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r9h1 = a ^ E.b; //ok +>r9h1 : number +>a ^ E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r9h2 = b ^ E.b; +>r9h2 : number +>b ^ E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r9h3 = c ^ E.b; //ok +>r9h3 : number +>c ^ E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r9h4 = d ^ E.b; +>r9h4 : number +>d ^ E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r9h5 = e ^ E.b; +>r9h5 : number +>e ^ E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r9h6 = f ^ E.b; +>r9h6 : number +>f ^ E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + +// operator | +var r10a1 = a | a; //ok +>r10a1 : number +>a | a : number +>a : any +>a : any + +var r10a2 = a | b; +>r10a2 : number +>a | b : number +>a : any +>b : boolean + +var r10a3 = a | c; //ok +>r10a3 : number +>a | c : number +>a : any +>c : number + +var r10a4 = a | d; +>r10a4 : number +>a | d : number +>a : any +>d : string + +var r10a5 = a | e; +>r10a5 : number +>a | e : number +>a : any +>e : { a: number; } + +var r10a6 = a | f; +>r10a6 : number +>a | f : number +>a : any +>f : Number + +var r10b1 = b | a; +>r10b1 : number +>b | a : number +>b : boolean +>a : any + +var r10b2 = b | b; +>r10b2 : number +>b | b : number +>b : boolean +>b : boolean + +var r10b3 = b | c; +>r10b3 : number +>b | c : number +>b : boolean +>c : number + +var r10b4 = b | d; +>r10b4 : number +>b | d : number +>b : boolean +>d : string + +var r10b5 = b | e; +>r10b5 : number +>b | e : number +>b : boolean +>e : { a: number; } + +var r10b6 = b | f; +>r10b6 : number +>b | f : number +>b : boolean +>f : Number + +var r10c1 = c | a; //ok +>r10c1 : number +>c | a : number +>c : number +>a : any + +var r10c2 = c | b; +>r10c2 : number +>c | b : number +>c : number +>b : boolean + +var r10c3 = c | c; //ok +>r10c3 : number +>c | c : number +>c : number +>c : number + +var r10c4 = c | d; +>r10c4 : number +>c | d : number +>c : number +>d : string + +var r10c5 = c | e; +>r10c5 : number +>c | e : number +>c : number +>e : { a: number; } + +var r10c6 = c | f; +>r10c6 : number +>c | f : number +>c : number +>f : Number + +var r10d1 = d | a; +>r10d1 : number +>d | a : number +>d : string +>a : any + +var r10d2 = d | b; +>r10d2 : number +>d | b : number +>d : string +>b : boolean + +var r10d3 = d | c; +>r10d3 : number +>d | c : number +>d : string +>c : number + +var r10d4 = d | d; +>r10d4 : number +>d | d : number +>d : string +>d : string + +var r10d5 = d | e; +>r10d5 : number +>d | e : number +>d : string +>e : { a: number; } + +var r10d6 = d | f; +>r10d6 : number +>d | f : number +>d : string +>f : Number + +var r10e1 = e | a; +>r10e1 : number +>e | a : number +>e : { a: number; } +>a : any + +var r10e2 = e | b; +>r10e2 : number +>e | b : number +>e : { a: number; } +>b : boolean + +var r10e3 = e | c; +>r10e3 : number +>e | c : number +>e : { a: number; } +>c : number + +var r10e4 = e | d; +>r10e4 : number +>e | d : number +>e : { a: number; } +>d : string + +var r10e5 = e | e; +>r10e5 : number +>e | e : number +>e : { a: number; } +>e : { a: number; } + +var r10e6 = e | f; +>r10e6 : number +>e | f : number +>e : { a: number; } +>f : Number + +var r10f1 = f | a; +>r10f1 : number +>f | a : number +>f : Number +>a : any + +var r10f2 = f | b; +>r10f2 : number +>f | b : number +>f : Number +>b : boolean + +var r10f3 = f | c; +>r10f3 : number +>f | c : number +>f : Number +>c : number + +var r10f4 = f | d; +>r10f4 : number +>f | d : number +>f : Number +>d : string + +var r10f5 = f | e; +>r10f5 : number +>f | e : number +>f : Number +>e : { a: number; } + +var r10f6 = f | f; +>r10f6 : number +>f | f : number +>f : Number +>f : Number + +var r10g1 = E.a | a; //ok +>r10g1 : number +>E.a | a : number +>E.a : E.a +>E : typeof E +>a : E.a +>a : any + +var r10g2 = E.a | b; +>r10g2 : number +>E.a | b : number +>E.a : E.a +>E : typeof E +>a : E.a +>b : boolean + +var r10g3 = E.a | c; //ok +>r10g3 : number +>E.a | c : number +>E.a : E.a +>E : typeof E +>a : E.a +>c : number + +var r10g4 = E.a | d; +>r10g4 : number +>E.a | d : number +>E.a : E.a +>E : typeof E +>a : E.a +>d : string + +var r10g5 = E.a | e; +>r10g5 : number +>E.a | e : number +>E.a : E.a +>E : typeof E +>a : E.a +>e : { a: number; } + +var r10g6 = E.a | f; +>r10g6 : number +>E.a | f : number +>E.a : E.a +>E : typeof E +>a : E.a +>f : Number + +var r10h1 = a | E.b; //ok +>r10h1 : number +>a | E.b : number +>a : any +>E.b : E.b +>E : typeof E +>b : E.b + +var r10h2 = b | E.b; +>r10h2 : number +>b | E.b : number +>b : boolean +>E.b : E.b +>E : typeof E +>b : E.b + +var r10h3 = c | E.b; //ok +>r10h3 : number +>c | E.b : number +>c : number +>E.b : E.b +>E : typeof E +>b : E.b + +var r10h4 = d | E.b; +>r10h4 : number +>d | E.b : number +>d : string +>E.b : E.b +>E : typeof E +>b : E.b + +var r10h5 = e | E.b; +>r10h5 : number +>e | E.b : number +>e : { a: number; } +>E.b : E.b +>E : typeof E +>b : E.b + +var r10h6 = f | E.b; +>r10h6 : number +>f | E.b : number +>f : Number +>E.b : E.b +>E : typeof E +>b : E.b + diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.symbols b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.symbols new file mode 100644 index 00000000000..7e55e3c0052 --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.symbols @@ -0,0 +1,444 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts === +// If one operand is the null or undefined value, it is treated as having the type of the +// other operand. + +var a: boolean; +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var b: string; +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var c: Object; +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +// operator * +var r1a1 = null * a; +>r1a1 : Symbol(r1a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 8, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r1a2 = null * b; +>r1a2 : Symbol(r1a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 9, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r1a3 = null * c; +>r1a3 : Symbol(r1a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 10, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r1b1 = a * null; +>r1b1 : Symbol(r1b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 12, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r1b2 = b * null; +>r1b2 : Symbol(r1b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 13, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r1b3 = c * null; +>r1b3 : Symbol(r1b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 14, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r1c1 = null * true; +>r1c1 : Symbol(r1c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 16, 3)) + +var r1c2 = null * ''; +>r1c2 : Symbol(r1c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 17, 3)) + +var r1c3 = null * {}; +>r1c3 : Symbol(r1c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 18, 3)) + +var r1d1 = true * null; +>r1d1 : Symbol(r1d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 20, 3)) + +var r1d2 = '' * null; +>r1d2 : Symbol(r1d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 21, 3)) + +var r1d3 = {} * null; +>r1d3 : Symbol(r1d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 22, 3)) + +// operator / +var r2a1 = null / a; +>r2a1 : Symbol(r2a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 25, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r2a2 = null / b; +>r2a2 : Symbol(r2a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 26, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r2a3 = null / c; +>r2a3 : Symbol(r2a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 27, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r2b1 = a / null; +>r2b1 : Symbol(r2b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 29, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r2b2 = b / null; +>r2b2 : Symbol(r2b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 30, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r2b3 = c / null; +>r2b3 : Symbol(r2b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 31, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r2c1 = null / true; +>r2c1 : Symbol(r2c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 33, 3)) + +var r2c2 = null / ''; +>r2c2 : Symbol(r2c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 34, 3)) + +var r2c3 = null / {}; +>r2c3 : Symbol(r2c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 35, 3)) + +var r2d1 = true / null; +>r2d1 : Symbol(r2d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 37, 3)) + +var r2d2 = '' / null; +>r2d2 : Symbol(r2d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 38, 3)) + +var r2d3 = {} / null; +>r2d3 : Symbol(r2d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 39, 3)) + +// operator % +var r3a1 = null % a; +>r3a1 : Symbol(r3a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 42, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r3a2 = null % b; +>r3a2 : Symbol(r3a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 43, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r3a3 = null % c; +>r3a3 : Symbol(r3a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 44, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r3b1 = a % null; +>r3b1 : Symbol(r3b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 46, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r3b2 = b % null; +>r3b2 : Symbol(r3b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 47, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r3b3 = c % null; +>r3b3 : Symbol(r3b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 48, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r3c1 = null % true; +>r3c1 : Symbol(r3c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 50, 3)) + +var r3c2 = null % ''; +>r3c2 : Symbol(r3c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 51, 3)) + +var r3c3 = null % {}; +>r3c3 : Symbol(r3c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 52, 3)) + +var r3d1 = true % null; +>r3d1 : Symbol(r3d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 54, 3)) + +var r3d2 = '' % null; +>r3d2 : Symbol(r3d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 55, 3)) + +var r3d3 = {} % null; +>r3d3 : Symbol(r3d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 56, 3)) + +// operator - +var r4a1 = null - a; +>r4a1 : Symbol(r4a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 59, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r4a2 = null - b; +>r4a2 : Symbol(r4a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 60, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r4a3 = null - c; +>r4a3 : Symbol(r4a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 61, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r4b1 = a - null; +>r4b1 : Symbol(r4b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 63, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r4b2 = b - null; +>r4b2 : Symbol(r4b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 64, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r4b3 = c - null; +>r4b3 : Symbol(r4b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 65, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r4c1 = null - true; +>r4c1 : Symbol(r4c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 67, 3)) + +var r4c2 = null - ''; +>r4c2 : Symbol(r4c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 68, 3)) + +var r4c3 = null - {}; +>r4c3 : Symbol(r4c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 69, 3)) + +var r4d1 = true - null; +>r4d1 : Symbol(r4d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 71, 3)) + +var r4d2 = '' - null; +>r4d2 : Symbol(r4d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 72, 3)) + +var r4d3 = {} - null; +>r4d3 : Symbol(r4d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 73, 3)) + +// operator << +var r5a1 = null << a; +>r5a1 : Symbol(r5a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 76, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r5a2 = null << b; +>r5a2 : Symbol(r5a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 77, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r5a3 = null << c; +>r5a3 : Symbol(r5a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 78, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r5b1 = a << null; +>r5b1 : Symbol(r5b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 80, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r5b2 = b << null; +>r5b2 : Symbol(r5b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 81, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r5b3 = c << null; +>r5b3 : Symbol(r5b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 82, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r5c1 = null << true; +>r5c1 : Symbol(r5c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 84, 3)) + +var r5c2 = null << ''; +>r5c2 : Symbol(r5c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 85, 3)) + +var r5c3 = null << {}; +>r5c3 : Symbol(r5c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 86, 3)) + +var r5d1 = true << null; +>r5d1 : Symbol(r5d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 88, 3)) + +var r5d2 = '' << null; +>r5d2 : Symbol(r5d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 89, 3)) + +var r5d3 = {} << null; +>r5d3 : Symbol(r5d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 90, 3)) + +// operator >> +var r6a1 = null >> a; +>r6a1 : Symbol(r6a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 93, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r6a2 = null >> b; +>r6a2 : Symbol(r6a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 94, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r6a3 = null >> c; +>r6a3 : Symbol(r6a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 95, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r6b1 = a >> null; +>r6b1 : Symbol(r6b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 97, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r6b2 = b >> null; +>r6b2 : Symbol(r6b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 98, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r6b3 = c >> null; +>r6b3 : Symbol(r6b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 99, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r6c1 = null >> true; +>r6c1 : Symbol(r6c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 101, 3)) + +var r6c2 = null >> ''; +>r6c2 : Symbol(r6c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 102, 3)) + +var r6c3 = null >> {}; +>r6c3 : Symbol(r6c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 103, 3)) + +var r6d1 = true >> null; +>r6d1 : Symbol(r6d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 105, 3)) + +var r6d2 = '' >> null; +>r6d2 : Symbol(r6d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 106, 3)) + +var r6d3 = {} >> null; +>r6d3 : Symbol(r6d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 107, 3)) + +// operator >>> +var r7a1 = null >>> a; +>r7a1 : Symbol(r7a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 110, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r7a2 = null >>> b; +>r7a2 : Symbol(r7a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 111, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r7a3 = null >>> c; +>r7a3 : Symbol(r7a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 112, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r7b1 = a >>> null; +>r7b1 : Symbol(r7b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 114, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r7b2 = b >>> null; +>r7b2 : Symbol(r7b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 115, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r7b3 = c >>> null; +>r7b3 : Symbol(r7b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 116, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r7c1 = null >>> true; +>r7c1 : Symbol(r7c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 118, 3)) + +var r7c2 = null >>> ''; +>r7c2 : Symbol(r7c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 119, 3)) + +var r7c3 = null >>> {}; +>r7c3 : Symbol(r7c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 120, 3)) + +var r7d1 = true >>> null; +>r7d1 : Symbol(r7d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 122, 3)) + +var r7d2 = '' >>> null; +>r7d2 : Symbol(r7d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 123, 3)) + +var r7d3 = {} >>> null; +>r7d3 : Symbol(r7d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 124, 3)) + +// operator & +var r8a1 = null & a; +>r8a1 : Symbol(r8a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 127, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r8a2 = null & b; +>r8a2 : Symbol(r8a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 128, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r8a3 = null & c; +>r8a3 : Symbol(r8a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 129, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r8b1 = a & null; +>r8b1 : Symbol(r8b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 131, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r8b2 = b & null; +>r8b2 : Symbol(r8b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 132, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r8b3 = c & null; +>r8b3 : Symbol(r8b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 133, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r8c1 = null & true; +>r8c1 : Symbol(r8c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 135, 3)) + +var r8c2 = null & ''; +>r8c2 : Symbol(r8c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 136, 3)) + +var r8c3 = null & {}; +>r8c3 : Symbol(r8c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 137, 3)) + +var r8d1 = true & null; +>r8d1 : Symbol(r8d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 139, 3)) + +var r8d2 = '' & null; +>r8d2 : Symbol(r8d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 140, 3)) + +var r8d3 = {} & null; +>r8d3 : Symbol(r8d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 141, 3)) + +// operator ^ +var r9a1 = null ^ a; +>r9a1 : Symbol(r9a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 144, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r9a2 = null ^ b; +>r9a2 : Symbol(r9a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 145, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r9a3 = null ^ c; +>r9a3 : Symbol(r9a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 146, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r9b1 = a ^ null; +>r9b1 : Symbol(r9b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 148, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r9b2 = b ^ null; +>r9b2 : Symbol(r9b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 149, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r9b3 = c ^ null; +>r9b3 : Symbol(r9b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 150, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r9c1 = null ^ true; +>r9c1 : Symbol(r9c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 152, 3)) + +var r9c2 = null ^ ''; +>r9c2 : Symbol(r9c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 153, 3)) + +var r9c3 = null ^ {}; +>r9c3 : Symbol(r9c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 154, 3)) + +var r9d1 = true ^ null; +>r9d1 : Symbol(r9d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 156, 3)) + +var r9d2 = '' ^ null; +>r9d2 : Symbol(r9d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 157, 3)) + +var r9d3 = {} ^ null; +>r9d3 : Symbol(r9d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 158, 3)) + +// operator | +var r10a1 = null | a; +>r10a1 : Symbol(r10a1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 161, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r10a2 = null | b; +>r10a2 : Symbol(r10a2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 162, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r10a3 = null | c; +>r10a3 : Symbol(r10a3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 163, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r10b1 = a | null; +>r10b1 : Symbol(r10b1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 165, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 3, 3)) + +var r10b2 = b | null; +>r10b2 : Symbol(r10b2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 166, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 4, 3)) + +var r10b3 = c | null; +>r10b3 : Symbol(r10b3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 167, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 5, 3)) + +var r10c1 = null | true; +>r10c1 : Symbol(r10c1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 169, 3)) + +var r10c2 = null | ''; +>r10c2 : Symbol(r10c2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 170, 3)) + +var r10c3 = null | {}; +>r10c3 : Symbol(r10c3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 171, 3)) + +var r10d1 = true | null; +>r10d1 : Symbol(r10d1, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 173, 3)) + +var r10d2 = '' | null; +>r10d2 : Symbol(r10d2, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 174, 3)) + +var r10d3 = {} | null; +>r10d3 : Symbol(r10d3, Decl(arithmeticOperatorWithNullValueAndInvalidOperands.ts, 175, 3)) + diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.types b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.types new file mode 100644 index 00000000000..2a0fb6d9239 --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndInvalidOperands.types @@ -0,0 +1,744 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithNullValueAndInvalidOperands.ts === +// If one operand is the null or undefined value, it is treated as having the type of the +// other operand. + +var a: boolean; +>a : boolean + +var b: string; +>b : string + +var c: Object; +>c : Object +>Object : Object + +// operator * +var r1a1 = null * a; +>r1a1 : number +>null * a : number +>null : null +>a : boolean + +var r1a2 = null * b; +>r1a2 : number +>null * b : number +>null : null +>b : string + +var r1a3 = null * c; +>r1a3 : number +>null * c : number +>null : null +>c : Object + +var r1b1 = a * null; +>r1b1 : number +>a * null : number +>a : boolean +>null : null + +var r1b2 = b * null; +>r1b2 : number +>b * null : number +>b : string +>null : null + +var r1b3 = c * null; +>r1b3 : number +>c * null : number +>c : Object +>null : null + +var r1c1 = null * true; +>r1c1 : number +>null * true : number +>null : null +>true : true + +var r1c2 = null * ''; +>r1c2 : number +>null * '' : number +>null : null +>'' : "" + +var r1c3 = null * {}; +>r1c3 : number +>null * {} : number +>null : null +>{} : {} + +var r1d1 = true * null; +>r1d1 : number +>true * null : number +>true : true +>null : null + +var r1d2 = '' * null; +>r1d2 : number +>'' * null : number +>'' : "" +>null : null + +var r1d3 = {} * null; +>r1d3 : number +>{} * null : number +>{} : {} +>null : null + +// operator / +var r2a1 = null / a; +>r2a1 : number +>null / a : number +>null : null +>a : boolean + +var r2a2 = null / b; +>r2a2 : number +>null / b : number +>null : null +>b : string + +var r2a3 = null / c; +>r2a3 : number +>null / c : number +>null : null +>c : Object + +var r2b1 = a / null; +>r2b1 : number +>a / null : number +>a : boolean +>null : null + +var r2b2 = b / null; +>r2b2 : number +>b / null : number +>b : string +>null : null + +var r2b3 = c / null; +>r2b3 : number +>c / null : number +>c : Object +>null : null + +var r2c1 = null / true; +>r2c1 : number +>null / true : number +>null : null +>true : true + +var r2c2 = null / ''; +>r2c2 : number +>null / '' : number +>null : null +>'' : "" + +var r2c3 = null / {}; +>r2c3 : number +>null / {} : number +>null : null +>{} : {} + +var r2d1 = true / null; +>r2d1 : number +>true / null : number +>true : true +>null : null + +var r2d2 = '' / null; +>r2d2 : number +>'' / null : number +>'' : "" +>null : null + +var r2d3 = {} / null; +>r2d3 : number +>{} / null : number +>{} : {} +>null : null + +// operator % +var r3a1 = null % a; +>r3a1 : number +>null % a : number +>null : null +>a : boolean + +var r3a2 = null % b; +>r3a2 : number +>null % b : number +>null : null +>b : string + +var r3a3 = null % c; +>r3a3 : number +>null % c : number +>null : null +>c : Object + +var r3b1 = a % null; +>r3b1 : number +>a % null : number +>a : boolean +>null : null + +var r3b2 = b % null; +>r3b2 : number +>b % null : number +>b : string +>null : null + +var r3b3 = c % null; +>r3b3 : number +>c % null : number +>c : Object +>null : null + +var r3c1 = null % true; +>r3c1 : number +>null % true : number +>null : null +>true : true + +var r3c2 = null % ''; +>r3c2 : number +>null % '' : number +>null : null +>'' : "" + +var r3c3 = null % {}; +>r3c3 : number +>null % {} : number +>null : null +>{} : {} + +var r3d1 = true % null; +>r3d1 : number +>true % null : number +>true : true +>null : null + +var r3d2 = '' % null; +>r3d2 : number +>'' % null : number +>'' : "" +>null : null + +var r3d3 = {} % null; +>r3d3 : number +>{} % null : number +>{} : {} +>null : null + +// operator - +var r4a1 = null - a; +>r4a1 : number +>null - a : number +>null : null +>a : boolean + +var r4a2 = null - b; +>r4a2 : number +>null - b : number +>null : null +>b : string + +var r4a3 = null - c; +>r4a3 : number +>null - c : number +>null : null +>c : Object + +var r4b1 = a - null; +>r4b1 : number +>a - null : number +>a : boolean +>null : null + +var r4b2 = b - null; +>r4b2 : number +>b - null : number +>b : string +>null : null + +var r4b3 = c - null; +>r4b3 : number +>c - null : number +>c : Object +>null : null + +var r4c1 = null - true; +>r4c1 : number +>null - true : number +>null : null +>true : true + +var r4c2 = null - ''; +>r4c2 : number +>null - '' : number +>null : null +>'' : "" + +var r4c3 = null - {}; +>r4c3 : number +>null - {} : number +>null : null +>{} : {} + +var r4d1 = true - null; +>r4d1 : number +>true - null : number +>true : true +>null : null + +var r4d2 = '' - null; +>r4d2 : number +>'' - null : number +>'' : "" +>null : null + +var r4d3 = {} - null; +>r4d3 : number +>{} - null : number +>{} : {} +>null : null + +// operator << +var r5a1 = null << a; +>r5a1 : number +>null << a : number +>null : null +>a : boolean + +var r5a2 = null << b; +>r5a2 : number +>null << b : number +>null : null +>b : string + +var r5a3 = null << c; +>r5a3 : number +>null << c : number +>null : null +>c : Object + +var r5b1 = a << null; +>r5b1 : number +>a << null : number +>a : boolean +>null : null + +var r5b2 = b << null; +>r5b2 : number +>b << null : number +>b : string +>null : null + +var r5b3 = c << null; +>r5b3 : number +>c << null : number +>c : Object +>null : null + +var r5c1 = null << true; +>r5c1 : number +>null << true : number +>null : null +>true : true + +var r5c2 = null << ''; +>r5c2 : number +>null << '' : number +>null : null +>'' : "" + +var r5c3 = null << {}; +>r5c3 : number +>null << {} : number +>null : null +>{} : {} + +var r5d1 = true << null; +>r5d1 : number +>true << null : number +>true : true +>null : null + +var r5d2 = '' << null; +>r5d2 : number +>'' << null : number +>'' : "" +>null : null + +var r5d3 = {} << null; +>r5d3 : number +>{} << null : number +>{} : {} +>null : null + +// operator >> +var r6a1 = null >> a; +>r6a1 : number +>null >> a : number +>null : null +>a : boolean + +var r6a2 = null >> b; +>r6a2 : number +>null >> b : number +>null : null +>b : string + +var r6a3 = null >> c; +>r6a3 : number +>null >> c : number +>null : null +>c : Object + +var r6b1 = a >> null; +>r6b1 : number +>a >> null : number +>a : boolean +>null : null + +var r6b2 = b >> null; +>r6b2 : number +>b >> null : number +>b : string +>null : null + +var r6b3 = c >> null; +>r6b3 : number +>c >> null : number +>c : Object +>null : null + +var r6c1 = null >> true; +>r6c1 : number +>null >> true : number +>null : null +>true : true + +var r6c2 = null >> ''; +>r6c2 : number +>null >> '' : number +>null : null +>'' : "" + +var r6c3 = null >> {}; +>r6c3 : number +>null >> {} : number +>null : null +>{} : {} + +var r6d1 = true >> null; +>r6d1 : number +>true >> null : number +>true : true +>null : null + +var r6d2 = '' >> null; +>r6d2 : number +>'' >> null : number +>'' : "" +>null : null + +var r6d3 = {} >> null; +>r6d3 : number +>{} >> null : number +>{} : {} +>null : null + +// operator >>> +var r7a1 = null >>> a; +>r7a1 : number +>null >>> a : number +>null : null +>a : boolean + +var r7a2 = null >>> b; +>r7a2 : number +>null >>> b : number +>null : null +>b : string + +var r7a3 = null >>> c; +>r7a3 : number +>null >>> c : number +>null : null +>c : Object + +var r7b1 = a >>> null; +>r7b1 : number +>a >>> null : number +>a : boolean +>null : null + +var r7b2 = b >>> null; +>r7b2 : number +>b >>> null : number +>b : string +>null : null + +var r7b3 = c >>> null; +>r7b3 : number +>c >>> null : number +>c : Object +>null : null + +var r7c1 = null >>> true; +>r7c1 : number +>null >>> true : number +>null : null +>true : true + +var r7c2 = null >>> ''; +>r7c2 : number +>null >>> '' : number +>null : null +>'' : "" + +var r7c3 = null >>> {}; +>r7c3 : number +>null >>> {} : number +>null : null +>{} : {} + +var r7d1 = true >>> null; +>r7d1 : number +>true >>> null : number +>true : true +>null : null + +var r7d2 = '' >>> null; +>r7d2 : number +>'' >>> null : number +>'' : "" +>null : null + +var r7d3 = {} >>> null; +>r7d3 : number +>{} >>> null : number +>{} : {} +>null : null + +// operator & +var r8a1 = null & a; +>r8a1 : number +>null & a : number +>null : null +>a : boolean + +var r8a2 = null & b; +>r8a2 : number +>null & b : number +>null : null +>b : string + +var r8a3 = null & c; +>r8a3 : number +>null & c : number +>null : null +>c : Object + +var r8b1 = a & null; +>r8b1 : number +>a & null : number +>a : boolean +>null : null + +var r8b2 = b & null; +>r8b2 : number +>b & null : number +>b : string +>null : null + +var r8b3 = c & null; +>r8b3 : number +>c & null : number +>c : Object +>null : null + +var r8c1 = null & true; +>r8c1 : number +>null & true : number +>null : null +>true : true + +var r8c2 = null & ''; +>r8c2 : number +>null & '' : number +>null : null +>'' : "" + +var r8c3 = null & {}; +>r8c3 : number +>null & {} : number +>null : null +>{} : {} + +var r8d1 = true & null; +>r8d1 : number +>true & null : number +>true : true +>null : null + +var r8d2 = '' & null; +>r8d2 : number +>'' & null : number +>'' : "" +>null : null + +var r8d3 = {} & null; +>r8d3 : number +>{} & null : number +>{} : {} +>null : null + +// operator ^ +var r9a1 = null ^ a; +>r9a1 : number +>null ^ a : number +>null : null +>a : boolean + +var r9a2 = null ^ b; +>r9a2 : number +>null ^ b : number +>null : null +>b : string + +var r9a3 = null ^ c; +>r9a3 : number +>null ^ c : number +>null : null +>c : Object + +var r9b1 = a ^ null; +>r9b1 : number +>a ^ null : number +>a : boolean +>null : null + +var r9b2 = b ^ null; +>r9b2 : number +>b ^ null : number +>b : string +>null : null + +var r9b3 = c ^ null; +>r9b3 : number +>c ^ null : number +>c : Object +>null : null + +var r9c1 = null ^ true; +>r9c1 : number +>null ^ true : number +>null : null +>true : true + +var r9c2 = null ^ ''; +>r9c2 : number +>null ^ '' : number +>null : null +>'' : "" + +var r9c3 = null ^ {}; +>r9c3 : number +>null ^ {} : number +>null : null +>{} : {} + +var r9d1 = true ^ null; +>r9d1 : number +>true ^ null : number +>true : true +>null : null + +var r9d2 = '' ^ null; +>r9d2 : number +>'' ^ null : number +>'' : "" +>null : null + +var r9d3 = {} ^ null; +>r9d3 : number +>{} ^ null : number +>{} : {} +>null : null + +// operator | +var r10a1 = null | a; +>r10a1 : number +>null | a : number +>null : null +>a : boolean + +var r10a2 = null | b; +>r10a2 : number +>null | b : number +>null : null +>b : string + +var r10a3 = null | c; +>r10a3 : number +>null | c : number +>null : null +>c : Object + +var r10b1 = a | null; +>r10b1 : number +>a | null : number +>a : boolean +>null : null + +var r10b2 = b | null; +>r10b2 : number +>b | null : number +>b : string +>null : null + +var r10b3 = c | null; +>r10b3 : number +>c | null : number +>c : Object +>null : null + +var r10c1 = null | true; +>r10c1 : number +>null | true : number +>null : null +>true : true + +var r10c2 = null | ''; +>r10c2 : number +>null | '' : number +>null : null +>'' : "" + +var r10c3 = null | {}; +>r10c3 : number +>null | {} : number +>null : null +>{} : {} + +var r10d1 = true | null; +>r10d1 : number +>true | null : number +>true : true +>null : null + +var r10d2 = '' | null; +>r10d2 : number +>'' | null : number +>'' : "" +>null : null + +var r10d3 = {} | null; +>r10d3 : number +>{} | null : number +>{} : {} +>null : null + diff --git a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.symbols b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.symbols new file mode 100644 index 00000000000..4ee959cef79 --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.symbols @@ -0,0 +1,171 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts === +// operator * +var ra1 = null * null; +>ra1 : Symbol(ra1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 1, 3)) + +var ra2 = null * undefined; +>ra2 : Symbol(ra2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 2, 3)) +>undefined : Symbol(undefined) + +var ra3 = undefined * null; +>ra3 : Symbol(ra3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 3, 3)) +>undefined : Symbol(undefined) + +var ra4 = undefined * undefined; +>ra4 : Symbol(ra4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 4, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator / +var rb1 = null / null; +>rb1 : Symbol(rb1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 7, 3)) + +var rb2 = null / undefined; +>rb2 : Symbol(rb2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 8, 3)) +>undefined : Symbol(undefined) + +var rb3 = undefined / null; +>rb3 : Symbol(rb3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 9, 3)) +>undefined : Symbol(undefined) + +var rb4 = undefined / undefined; +>rb4 : Symbol(rb4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 10, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator % +var rc1 = null % null; +>rc1 : Symbol(rc1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 13, 3)) + +var rc2 = null % undefined; +>rc2 : Symbol(rc2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 14, 3)) +>undefined : Symbol(undefined) + +var rc3 = undefined % null; +>rc3 : Symbol(rc3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 15, 3)) +>undefined : Symbol(undefined) + +var rc4 = undefined % undefined; +>rc4 : Symbol(rc4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 16, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator - +var rd1 = null - null; +>rd1 : Symbol(rd1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 19, 3)) + +var rd2 = null - undefined; +>rd2 : Symbol(rd2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 20, 3)) +>undefined : Symbol(undefined) + +var rd3 = undefined - null; +>rd3 : Symbol(rd3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 21, 3)) +>undefined : Symbol(undefined) + +var rd4 = undefined - undefined; +>rd4 : Symbol(rd4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 22, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator << +var re1 = null << null; +>re1 : Symbol(re1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 25, 3)) + +var re2 = null << undefined; +>re2 : Symbol(re2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 26, 3)) +>undefined : Symbol(undefined) + +var re3 = undefined << null; +>re3 : Symbol(re3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 27, 3)) +>undefined : Symbol(undefined) + +var re4 = undefined << undefined; +>re4 : Symbol(re4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 28, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator >> +var rf1 = null >> null; +>rf1 : Symbol(rf1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 31, 3)) + +var rf2 = null >> undefined; +>rf2 : Symbol(rf2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 32, 3)) +>undefined : Symbol(undefined) + +var rf3 = undefined >> null; +>rf3 : Symbol(rf3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 33, 3)) +>undefined : Symbol(undefined) + +var rf4 = undefined >> undefined; +>rf4 : Symbol(rf4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 34, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator >>> +var rg1 = null >>> null; +>rg1 : Symbol(rg1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 37, 3)) + +var rg2 = null >>> undefined; +>rg2 : Symbol(rg2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 38, 3)) +>undefined : Symbol(undefined) + +var rg3 = undefined >>> null; +>rg3 : Symbol(rg3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 39, 3)) +>undefined : Symbol(undefined) + +var rg4 = undefined >>> undefined; +>rg4 : Symbol(rg4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 40, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator & +var rh1 = null & null; +>rh1 : Symbol(rh1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 43, 3)) + +var rh2 = null & undefined; +>rh2 : Symbol(rh2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 44, 3)) +>undefined : Symbol(undefined) + +var rh3 = undefined & null; +>rh3 : Symbol(rh3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 45, 3)) +>undefined : Symbol(undefined) + +var rh4 = undefined & undefined; +>rh4 : Symbol(rh4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 46, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator ^ +var ri1 = null ^ null; +>ri1 : Symbol(ri1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 49, 3)) + +var ri2 = null ^ undefined; +>ri2 : Symbol(ri2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 50, 3)) +>undefined : Symbol(undefined) + +var ri3 = undefined ^ null; +>ri3 : Symbol(ri3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 51, 3)) +>undefined : Symbol(undefined) + +var ri4 = undefined ^ undefined; +>ri4 : Symbol(ri4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 52, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// operator | +var rj1 = null | null; +>rj1 : Symbol(rj1, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 55, 3)) + +var rj2 = null | undefined; +>rj2 : Symbol(rj2, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 56, 3)) +>undefined : Symbol(undefined) + +var rj3 = undefined | null; +>rj3 : Symbol(rj3, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 57, 3)) +>undefined : Symbol(undefined) + +var rj4 = undefined | undefined; +>rj4 : Symbol(rj4, Decl(arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts, 58, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.types b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.types new file mode 100644 index 00000000000..7b8963f4003 --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.types @@ -0,0 +1,251 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithOnlyNullValueOrUndefinedValue.ts === +// operator * +var ra1 = null * null; +>ra1 : number +>null * null : number +>null : null +>null : null + +var ra2 = null * undefined; +>ra2 : number +>null * undefined : number +>null : null +>undefined : undefined + +var ra3 = undefined * null; +>ra3 : number +>undefined * null : number +>undefined : undefined +>null : null + +var ra4 = undefined * undefined; +>ra4 : number +>undefined * undefined : number +>undefined : undefined +>undefined : undefined + +// operator / +var rb1 = null / null; +>rb1 : number +>null / null : number +>null : null +>null : null + +var rb2 = null / undefined; +>rb2 : number +>null / undefined : number +>null : null +>undefined : undefined + +var rb3 = undefined / null; +>rb3 : number +>undefined / null : number +>undefined : undefined +>null : null + +var rb4 = undefined / undefined; +>rb4 : number +>undefined / undefined : number +>undefined : undefined +>undefined : undefined + +// operator % +var rc1 = null % null; +>rc1 : number +>null % null : number +>null : null +>null : null + +var rc2 = null % undefined; +>rc2 : number +>null % undefined : number +>null : null +>undefined : undefined + +var rc3 = undefined % null; +>rc3 : number +>undefined % null : number +>undefined : undefined +>null : null + +var rc4 = undefined % undefined; +>rc4 : number +>undefined % undefined : number +>undefined : undefined +>undefined : undefined + +// operator - +var rd1 = null - null; +>rd1 : number +>null - null : number +>null : null +>null : null + +var rd2 = null - undefined; +>rd2 : number +>null - undefined : number +>null : null +>undefined : undefined + +var rd3 = undefined - null; +>rd3 : number +>undefined - null : number +>undefined : undefined +>null : null + +var rd4 = undefined - undefined; +>rd4 : number +>undefined - undefined : number +>undefined : undefined +>undefined : undefined + +// operator << +var re1 = null << null; +>re1 : number +>null << null : number +>null : null +>null : null + +var re2 = null << undefined; +>re2 : number +>null << undefined : number +>null : null +>undefined : undefined + +var re3 = undefined << null; +>re3 : number +>undefined << null : number +>undefined : undefined +>null : null + +var re4 = undefined << undefined; +>re4 : number +>undefined << undefined : number +>undefined : undefined +>undefined : undefined + +// operator >> +var rf1 = null >> null; +>rf1 : number +>null >> null : number +>null : null +>null : null + +var rf2 = null >> undefined; +>rf2 : number +>null >> undefined : number +>null : null +>undefined : undefined + +var rf3 = undefined >> null; +>rf3 : number +>undefined >> null : number +>undefined : undefined +>null : null + +var rf4 = undefined >> undefined; +>rf4 : number +>undefined >> undefined : number +>undefined : undefined +>undefined : undefined + +// operator >>> +var rg1 = null >>> null; +>rg1 : number +>null >>> null : number +>null : null +>null : null + +var rg2 = null >>> undefined; +>rg2 : number +>null >>> undefined : number +>null : null +>undefined : undefined + +var rg3 = undefined >>> null; +>rg3 : number +>undefined >>> null : number +>undefined : undefined +>null : null + +var rg4 = undefined >>> undefined; +>rg4 : number +>undefined >>> undefined : number +>undefined : undefined +>undefined : undefined + +// operator & +var rh1 = null & null; +>rh1 : number +>null & null : number +>null : null +>null : null + +var rh2 = null & undefined; +>rh2 : number +>null & undefined : number +>null : null +>undefined : undefined + +var rh3 = undefined & null; +>rh3 : number +>undefined & null : number +>undefined : undefined +>null : null + +var rh4 = undefined & undefined; +>rh4 : number +>undefined & undefined : number +>undefined : undefined +>undefined : undefined + +// operator ^ +var ri1 = null ^ null; +>ri1 : number +>null ^ null : number +>null : null +>null : null + +var ri2 = null ^ undefined; +>ri2 : number +>null ^ undefined : number +>null : null +>undefined : undefined + +var ri3 = undefined ^ null; +>ri3 : number +>undefined ^ null : number +>undefined : undefined +>null : null + +var ri4 = undefined ^ undefined; +>ri4 : number +>undefined ^ undefined : number +>undefined : undefined +>undefined : undefined + +// operator | +var rj1 = null | null; +>rj1 : number +>null | null : number +>null : null +>null : null + +var rj2 = null | undefined; +>rj2 : number +>null | undefined : number +>null : null +>undefined : undefined + +var rj3 = undefined | null; +>rj3 : number +>undefined | null : number +>undefined : undefined +>null : null + +var rj4 = undefined | undefined; +>rj4 : number +>undefined | undefined : number +>undefined : undefined +>undefined : undefined + diff --git a/tests/baselines/reference/arithmeticOperatorWithTypeParameter.symbols b/tests/baselines/reference/arithmeticOperatorWithTypeParameter.symbols new file mode 100644 index 00000000000..24f058e530e --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithTypeParameter.symbols @@ -0,0 +1,573 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithTypeParameter.ts === +// type parameter type is not valid for arithmetic operand +function foo(t: T) { +>foo : Symbol(foo, Decl(arithmeticOperatorWithTypeParameter.ts, 0, 0)) +>T : Symbol(T, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 13)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>T : Symbol(T, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 13)) + + var a: any; +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var b: boolean; +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var c: number; +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var d: string; +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var e: {}; +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r1a1 = a * t; +>r1a1 : Symbol(r1a1, Decl(arithmeticOperatorWithTypeParameter.ts, 8, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a2 = a / t; +>r1a2 : Symbol(r1a2, Decl(arithmeticOperatorWithTypeParameter.ts, 9, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a3 = a % t; +>r1a3 : Symbol(r1a3, Decl(arithmeticOperatorWithTypeParameter.ts, 10, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a4 = a - t; +>r1a4 : Symbol(r1a4, Decl(arithmeticOperatorWithTypeParameter.ts, 11, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a5 = a << t; +>r1a5 : Symbol(r1a5, Decl(arithmeticOperatorWithTypeParameter.ts, 12, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a6 = a >> t; +>r1a6 : Symbol(r1a6, Decl(arithmeticOperatorWithTypeParameter.ts, 13, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a7 = a >>> t; +>r1a7 : Symbol(r1a7, Decl(arithmeticOperatorWithTypeParameter.ts, 14, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a8 = a & t; +>r1a8 : Symbol(r1a8, Decl(arithmeticOperatorWithTypeParameter.ts, 15, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a9 = a ^ t; +>r1a9 : Symbol(r1a9, Decl(arithmeticOperatorWithTypeParameter.ts, 16, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1a10 = a | t; +>r1a10 : Symbol(r1a10, Decl(arithmeticOperatorWithTypeParameter.ts, 17, 7)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r2a1 = t * a; +>r2a1 : Symbol(r2a1, Decl(arithmeticOperatorWithTypeParameter.ts, 19, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a2 = t / a; +>r2a2 : Symbol(r2a2, Decl(arithmeticOperatorWithTypeParameter.ts, 20, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a3 = t % a; +>r2a3 : Symbol(r2a3, Decl(arithmeticOperatorWithTypeParameter.ts, 21, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a4 = t - a; +>r2a4 : Symbol(r2a4, Decl(arithmeticOperatorWithTypeParameter.ts, 22, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a5 = t << a; +>r2a5 : Symbol(r2a5, Decl(arithmeticOperatorWithTypeParameter.ts, 23, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a6 = t >> a; +>r2a6 : Symbol(r2a6, Decl(arithmeticOperatorWithTypeParameter.ts, 24, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a7 = t >>> a; +>r2a7 : Symbol(r2a7, Decl(arithmeticOperatorWithTypeParameter.ts, 25, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a8 = t & a; +>r2a8 : Symbol(r2a8, Decl(arithmeticOperatorWithTypeParameter.ts, 26, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a9 = t ^ a; +>r2a9 : Symbol(r2a9, Decl(arithmeticOperatorWithTypeParameter.ts, 27, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r2a10 = t | a; +>r2a10 : Symbol(r2a10, Decl(arithmeticOperatorWithTypeParameter.ts, 28, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>a : Symbol(a, Decl(arithmeticOperatorWithTypeParameter.ts, 2, 7)) + + var r1b1 = b * t; +>r1b1 : Symbol(r1b1, Decl(arithmeticOperatorWithTypeParameter.ts, 30, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b2 = b / t; +>r1b2 : Symbol(r1b2, Decl(arithmeticOperatorWithTypeParameter.ts, 31, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b3 = b % t; +>r1b3 : Symbol(r1b3, Decl(arithmeticOperatorWithTypeParameter.ts, 32, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b4 = b - t; +>r1b4 : Symbol(r1b4, Decl(arithmeticOperatorWithTypeParameter.ts, 33, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b5 = b << t; +>r1b5 : Symbol(r1b5, Decl(arithmeticOperatorWithTypeParameter.ts, 34, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b6 = b >> t; +>r1b6 : Symbol(r1b6, Decl(arithmeticOperatorWithTypeParameter.ts, 35, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b7 = b >>> t; +>r1b7 : Symbol(r1b7, Decl(arithmeticOperatorWithTypeParameter.ts, 36, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b8 = b & t; +>r1b8 : Symbol(r1b8, Decl(arithmeticOperatorWithTypeParameter.ts, 37, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b9 = b ^ t; +>r1b9 : Symbol(r1b9, Decl(arithmeticOperatorWithTypeParameter.ts, 38, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1b10 = b | t; +>r1b10 : Symbol(r1b10, Decl(arithmeticOperatorWithTypeParameter.ts, 39, 7)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r2b1 = t * b; +>r2b1 : Symbol(r2b1, Decl(arithmeticOperatorWithTypeParameter.ts, 41, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b2 = t / b; +>r2b2 : Symbol(r2b2, Decl(arithmeticOperatorWithTypeParameter.ts, 42, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b3 = t % b; +>r2b3 : Symbol(r2b3, Decl(arithmeticOperatorWithTypeParameter.ts, 43, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b4 = t - b; +>r2b4 : Symbol(r2b4, Decl(arithmeticOperatorWithTypeParameter.ts, 44, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b5 = t << b; +>r2b5 : Symbol(r2b5, Decl(arithmeticOperatorWithTypeParameter.ts, 45, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b6 = t >> b; +>r2b6 : Symbol(r2b6, Decl(arithmeticOperatorWithTypeParameter.ts, 46, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b7 = t >>> b; +>r2b7 : Symbol(r2b7, Decl(arithmeticOperatorWithTypeParameter.ts, 47, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b8 = t & b; +>r2b8 : Symbol(r2b8, Decl(arithmeticOperatorWithTypeParameter.ts, 48, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b9 = t ^ b; +>r2b9 : Symbol(r2b9, Decl(arithmeticOperatorWithTypeParameter.ts, 49, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r2b10 = t | b; +>r2b10 : Symbol(r2b10, Decl(arithmeticOperatorWithTypeParameter.ts, 50, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>b : Symbol(b, Decl(arithmeticOperatorWithTypeParameter.ts, 3, 7)) + + var r1c1 = c * t; +>r1c1 : Symbol(r1c1, Decl(arithmeticOperatorWithTypeParameter.ts, 52, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c2 = c / t; +>r1c2 : Symbol(r1c2, Decl(arithmeticOperatorWithTypeParameter.ts, 53, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c3 = c % t; +>r1c3 : Symbol(r1c3, Decl(arithmeticOperatorWithTypeParameter.ts, 54, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c4 = c - t; +>r1c4 : Symbol(r1c4, Decl(arithmeticOperatorWithTypeParameter.ts, 55, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c5 = c << t; +>r1c5 : Symbol(r1c5, Decl(arithmeticOperatorWithTypeParameter.ts, 56, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c6 = c >> t; +>r1c6 : Symbol(r1c6, Decl(arithmeticOperatorWithTypeParameter.ts, 57, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c7 = c >>> t; +>r1c7 : Symbol(r1c7, Decl(arithmeticOperatorWithTypeParameter.ts, 58, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c8 = c & t; +>r1c8 : Symbol(r1c8, Decl(arithmeticOperatorWithTypeParameter.ts, 59, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c9 = c ^ t; +>r1c9 : Symbol(r1c9, Decl(arithmeticOperatorWithTypeParameter.ts, 60, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1c10 = c | t; +>r1c10 : Symbol(r1c10, Decl(arithmeticOperatorWithTypeParameter.ts, 61, 7)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r2c1 = t * c; +>r2c1 : Symbol(r2c1, Decl(arithmeticOperatorWithTypeParameter.ts, 63, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c2 = t / c; +>r2c2 : Symbol(r2c2, Decl(arithmeticOperatorWithTypeParameter.ts, 64, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c3 = t % c; +>r2c3 : Symbol(r2c3, Decl(arithmeticOperatorWithTypeParameter.ts, 65, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c4 = t - c; +>r2c4 : Symbol(r2c4, Decl(arithmeticOperatorWithTypeParameter.ts, 66, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c5 = t << c; +>r2c5 : Symbol(r2c5, Decl(arithmeticOperatorWithTypeParameter.ts, 67, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c6 = t >> c; +>r2c6 : Symbol(r2c6, Decl(arithmeticOperatorWithTypeParameter.ts, 68, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c7 = t >>> c; +>r2c7 : Symbol(r2c7, Decl(arithmeticOperatorWithTypeParameter.ts, 69, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c8 = t & c; +>r2c8 : Symbol(r2c8, Decl(arithmeticOperatorWithTypeParameter.ts, 70, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c9 = t ^ c; +>r2c9 : Symbol(r2c9, Decl(arithmeticOperatorWithTypeParameter.ts, 71, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r2c10 = t | c; +>r2c10 : Symbol(r2c10, Decl(arithmeticOperatorWithTypeParameter.ts, 72, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>c : Symbol(c, Decl(arithmeticOperatorWithTypeParameter.ts, 4, 7)) + + var r1d1 = d * t; +>r1d1 : Symbol(r1d1, Decl(arithmeticOperatorWithTypeParameter.ts, 74, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d2 = d / t; +>r1d2 : Symbol(r1d2, Decl(arithmeticOperatorWithTypeParameter.ts, 75, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d3 = d % t; +>r1d3 : Symbol(r1d3, Decl(arithmeticOperatorWithTypeParameter.ts, 76, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d4 = d - t; +>r1d4 : Symbol(r1d4, Decl(arithmeticOperatorWithTypeParameter.ts, 77, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d5 = d << t; +>r1d5 : Symbol(r1d5, Decl(arithmeticOperatorWithTypeParameter.ts, 78, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d6 = d >> t; +>r1d6 : Symbol(r1d6, Decl(arithmeticOperatorWithTypeParameter.ts, 79, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d7 = d >>> t; +>r1d7 : Symbol(r1d7, Decl(arithmeticOperatorWithTypeParameter.ts, 80, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d8 = d & t; +>r1d8 : Symbol(r1d8, Decl(arithmeticOperatorWithTypeParameter.ts, 81, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d9 = d ^ t; +>r1d9 : Symbol(r1d9, Decl(arithmeticOperatorWithTypeParameter.ts, 82, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1d10 = d | t; +>r1d10 : Symbol(r1d10, Decl(arithmeticOperatorWithTypeParameter.ts, 83, 7)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r2d1 = t * d; +>r2d1 : Symbol(r2d1, Decl(arithmeticOperatorWithTypeParameter.ts, 85, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d2 = t / d; +>r2d2 : Symbol(r2d2, Decl(arithmeticOperatorWithTypeParameter.ts, 86, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d3 = t % d; +>r2d3 : Symbol(r2d3, Decl(arithmeticOperatorWithTypeParameter.ts, 87, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d4 = t - d; +>r2d4 : Symbol(r2d4, Decl(arithmeticOperatorWithTypeParameter.ts, 88, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d5 = t << d; +>r2d5 : Symbol(r2d5, Decl(arithmeticOperatorWithTypeParameter.ts, 89, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d6 = t >> d; +>r2d6 : Symbol(r2d6, Decl(arithmeticOperatorWithTypeParameter.ts, 90, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d7 = t >>> d; +>r2d7 : Symbol(r2d7, Decl(arithmeticOperatorWithTypeParameter.ts, 91, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d8 = t & d; +>r2d8 : Symbol(r2d8, Decl(arithmeticOperatorWithTypeParameter.ts, 92, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d9 = t ^ d; +>r2d9 : Symbol(r2d9, Decl(arithmeticOperatorWithTypeParameter.ts, 93, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r2d10 = t | d; +>r2d10 : Symbol(r2d10, Decl(arithmeticOperatorWithTypeParameter.ts, 94, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>d : Symbol(d, Decl(arithmeticOperatorWithTypeParameter.ts, 5, 7)) + + var r1e1 = e * t; +>r1e1 : Symbol(r1e1, Decl(arithmeticOperatorWithTypeParameter.ts, 96, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e2 = e / t; +>r1e2 : Symbol(r1e2, Decl(arithmeticOperatorWithTypeParameter.ts, 97, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e3 = e % t; +>r1e3 : Symbol(r1e3, Decl(arithmeticOperatorWithTypeParameter.ts, 98, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e4 = e - t; +>r1e4 : Symbol(r1e4, Decl(arithmeticOperatorWithTypeParameter.ts, 99, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e5 = e << t; +>r1e5 : Symbol(r1e5, Decl(arithmeticOperatorWithTypeParameter.ts, 100, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e6 = e >> t; +>r1e6 : Symbol(r1e6, Decl(arithmeticOperatorWithTypeParameter.ts, 101, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e7 = e >>> t; +>r1e7 : Symbol(r1e7, Decl(arithmeticOperatorWithTypeParameter.ts, 102, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e8 = e & t; +>r1e8 : Symbol(r1e8, Decl(arithmeticOperatorWithTypeParameter.ts, 103, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e9 = e ^ t; +>r1e9 : Symbol(r1e9, Decl(arithmeticOperatorWithTypeParameter.ts, 104, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1e10 = e | t; +>r1e10 : Symbol(r1e10, Decl(arithmeticOperatorWithTypeParameter.ts, 105, 7)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r2e1 = t * e; +>r2e1 : Symbol(r2e1, Decl(arithmeticOperatorWithTypeParameter.ts, 107, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e2 = t / e; +>r2e2 : Symbol(r2e2, Decl(arithmeticOperatorWithTypeParameter.ts, 108, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e3 = t % e; +>r2e3 : Symbol(r2e3, Decl(arithmeticOperatorWithTypeParameter.ts, 109, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e4 = t - e; +>r2e4 : Symbol(r2e4, Decl(arithmeticOperatorWithTypeParameter.ts, 110, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e5 = t << e; +>r2e5 : Symbol(r2e5, Decl(arithmeticOperatorWithTypeParameter.ts, 111, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e6 = t >> e; +>r2e6 : Symbol(r2e6, Decl(arithmeticOperatorWithTypeParameter.ts, 112, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e7 = t >>> e; +>r2e7 : Symbol(r2e7, Decl(arithmeticOperatorWithTypeParameter.ts, 113, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e8 = t & e; +>r2e8 : Symbol(r2e8, Decl(arithmeticOperatorWithTypeParameter.ts, 114, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e9 = t ^ e; +>r2e9 : Symbol(r2e9, Decl(arithmeticOperatorWithTypeParameter.ts, 115, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r2e10 = t | e; +>r2e10 : Symbol(r2e10, Decl(arithmeticOperatorWithTypeParameter.ts, 116, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>e : Symbol(e, Decl(arithmeticOperatorWithTypeParameter.ts, 6, 7)) + + var r1f1 = t * t; +>r1f1 : Symbol(r1f1, Decl(arithmeticOperatorWithTypeParameter.ts, 118, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f2 = t / t; +>r1f2 : Symbol(r1f2, Decl(arithmeticOperatorWithTypeParameter.ts, 119, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f3 = t % t; +>r1f3 : Symbol(r1f3, Decl(arithmeticOperatorWithTypeParameter.ts, 120, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f4 = t - t; +>r1f4 : Symbol(r1f4, Decl(arithmeticOperatorWithTypeParameter.ts, 121, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f5 = t << t; +>r1f5 : Symbol(r1f5, Decl(arithmeticOperatorWithTypeParameter.ts, 122, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f6 = t >> t; +>r1f6 : Symbol(r1f6, Decl(arithmeticOperatorWithTypeParameter.ts, 123, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f7 = t >>> t; +>r1f7 : Symbol(r1f7, Decl(arithmeticOperatorWithTypeParameter.ts, 124, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f8 = t & t; +>r1f8 : Symbol(r1f8, Decl(arithmeticOperatorWithTypeParameter.ts, 125, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f9 = t ^ t; +>r1f9 : Symbol(r1f9, Decl(arithmeticOperatorWithTypeParameter.ts, 126, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) + + var r1f10 = t | t; +>r1f10 : Symbol(r1f10, Decl(arithmeticOperatorWithTypeParameter.ts, 127, 7)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +>t : Symbol(t, Decl(arithmeticOperatorWithTypeParameter.ts, 1, 16)) +} diff --git a/tests/baselines/reference/arithmeticOperatorWithTypeParameter.types b/tests/baselines/reference/arithmeticOperatorWithTypeParameter.types new file mode 100644 index 00000000000..0fc72d5dc0f --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithTypeParameter.types @@ -0,0 +1,683 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithTypeParameter.ts === +// type parameter type is not valid for arithmetic operand +function foo(t: T) { +>foo : (t: T) => void +>T : T +>t : T +>T : T + + var a: any; +>a : any + + var b: boolean; +>b : boolean + + var c: number; +>c : number + + var d: string; +>d : string + + var e: {}; +>e : {} + + var r1a1 = a * t; +>r1a1 : number +>a * t : number +>a : any +>t : T + + var r1a2 = a / t; +>r1a2 : number +>a / t : number +>a : any +>t : T + + var r1a3 = a % t; +>r1a3 : number +>a % t : number +>a : any +>t : T + + var r1a4 = a - t; +>r1a4 : number +>a - t : number +>a : any +>t : T + + var r1a5 = a << t; +>r1a5 : number +>a << t : number +>a : any +>t : T + + var r1a6 = a >> t; +>r1a6 : number +>a >> t : number +>a : any +>t : T + + var r1a7 = a >>> t; +>r1a7 : number +>a >>> t : number +>a : any +>t : T + + var r1a8 = a & t; +>r1a8 : number +>a & t : number +>a : any +>t : T + + var r1a9 = a ^ t; +>r1a9 : number +>a ^ t : number +>a : any +>t : T + + var r1a10 = a | t; +>r1a10 : number +>a | t : number +>a : any +>t : T + + var r2a1 = t * a; +>r2a1 : number +>t * a : number +>t : T +>a : any + + var r2a2 = t / a; +>r2a2 : number +>t / a : number +>t : T +>a : any + + var r2a3 = t % a; +>r2a3 : number +>t % a : number +>t : T +>a : any + + var r2a4 = t - a; +>r2a4 : number +>t - a : number +>t : T +>a : any + + var r2a5 = t << a; +>r2a5 : number +>t << a : number +>t : T +>a : any + + var r2a6 = t >> a; +>r2a6 : number +>t >> a : number +>t : T +>a : any + + var r2a7 = t >>> a; +>r2a7 : number +>t >>> a : number +>t : T +>a : any + + var r2a8 = t & a; +>r2a8 : number +>t & a : number +>t : T +>a : any + + var r2a9 = t ^ a; +>r2a9 : number +>t ^ a : number +>t : T +>a : any + + var r2a10 = t | a; +>r2a10 : number +>t | a : number +>t : T +>a : any + + var r1b1 = b * t; +>r1b1 : number +>b * t : number +>b : boolean +>t : T + + var r1b2 = b / t; +>r1b2 : number +>b / t : number +>b : boolean +>t : T + + var r1b3 = b % t; +>r1b3 : number +>b % t : number +>b : boolean +>t : T + + var r1b4 = b - t; +>r1b4 : number +>b - t : number +>b : boolean +>t : T + + var r1b5 = b << t; +>r1b5 : number +>b << t : number +>b : boolean +>t : T + + var r1b6 = b >> t; +>r1b6 : number +>b >> t : number +>b : boolean +>t : T + + var r1b7 = b >>> t; +>r1b7 : number +>b >>> t : number +>b : boolean +>t : T + + var r1b8 = b & t; +>r1b8 : number +>b & t : number +>b : boolean +>t : T + + var r1b9 = b ^ t; +>r1b9 : number +>b ^ t : number +>b : boolean +>t : T + + var r1b10 = b | t; +>r1b10 : number +>b | t : number +>b : boolean +>t : T + + var r2b1 = t * b; +>r2b1 : number +>t * b : number +>t : T +>b : boolean + + var r2b2 = t / b; +>r2b2 : number +>t / b : number +>t : T +>b : boolean + + var r2b3 = t % b; +>r2b3 : number +>t % b : number +>t : T +>b : boolean + + var r2b4 = t - b; +>r2b4 : number +>t - b : number +>t : T +>b : boolean + + var r2b5 = t << b; +>r2b5 : number +>t << b : number +>t : T +>b : boolean + + var r2b6 = t >> b; +>r2b6 : number +>t >> b : number +>t : T +>b : boolean + + var r2b7 = t >>> b; +>r2b7 : number +>t >>> b : number +>t : T +>b : boolean + + var r2b8 = t & b; +>r2b8 : number +>t & b : number +>t : T +>b : boolean + + var r2b9 = t ^ b; +>r2b9 : number +>t ^ b : number +>t : T +>b : boolean + + var r2b10 = t | b; +>r2b10 : number +>t | b : number +>t : T +>b : boolean + + var r1c1 = c * t; +>r1c1 : number +>c * t : number +>c : number +>t : T + + var r1c2 = c / t; +>r1c2 : number +>c / t : number +>c : number +>t : T + + var r1c3 = c % t; +>r1c3 : number +>c % t : number +>c : number +>t : T + + var r1c4 = c - t; +>r1c4 : number +>c - t : number +>c : number +>t : T + + var r1c5 = c << t; +>r1c5 : number +>c << t : number +>c : number +>t : T + + var r1c6 = c >> t; +>r1c6 : number +>c >> t : number +>c : number +>t : T + + var r1c7 = c >>> t; +>r1c7 : number +>c >>> t : number +>c : number +>t : T + + var r1c8 = c & t; +>r1c8 : number +>c & t : number +>c : number +>t : T + + var r1c9 = c ^ t; +>r1c9 : number +>c ^ t : number +>c : number +>t : T + + var r1c10 = c | t; +>r1c10 : number +>c | t : number +>c : number +>t : T + + var r2c1 = t * c; +>r2c1 : number +>t * c : number +>t : T +>c : number + + var r2c2 = t / c; +>r2c2 : number +>t / c : number +>t : T +>c : number + + var r2c3 = t % c; +>r2c3 : number +>t % c : number +>t : T +>c : number + + var r2c4 = t - c; +>r2c4 : number +>t - c : number +>t : T +>c : number + + var r2c5 = t << c; +>r2c5 : number +>t << c : number +>t : T +>c : number + + var r2c6 = t >> c; +>r2c6 : number +>t >> c : number +>t : T +>c : number + + var r2c7 = t >>> c; +>r2c7 : number +>t >>> c : number +>t : T +>c : number + + var r2c8 = t & c; +>r2c8 : number +>t & c : number +>t : T +>c : number + + var r2c9 = t ^ c; +>r2c9 : number +>t ^ c : number +>t : T +>c : number + + var r2c10 = t | c; +>r2c10 : number +>t | c : number +>t : T +>c : number + + var r1d1 = d * t; +>r1d1 : number +>d * t : number +>d : string +>t : T + + var r1d2 = d / t; +>r1d2 : number +>d / t : number +>d : string +>t : T + + var r1d3 = d % t; +>r1d3 : number +>d % t : number +>d : string +>t : T + + var r1d4 = d - t; +>r1d4 : number +>d - t : number +>d : string +>t : T + + var r1d5 = d << t; +>r1d5 : number +>d << t : number +>d : string +>t : T + + var r1d6 = d >> t; +>r1d6 : number +>d >> t : number +>d : string +>t : T + + var r1d7 = d >>> t; +>r1d7 : number +>d >>> t : number +>d : string +>t : T + + var r1d8 = d & t; +>r1d8 : number +>d & t : number +>d : string +>t : T + + var r1d9 = d ^ t; +>r1d9 : number +>d ^ t : number +>d : string +>t : T + + var r1d10 = d | t; +>r1d10 : number +>d | t : number +>d : string +>t : T + + var r2d1 = t * d; +>r2d1 : number +>t * d : number +>t : T +>d : string + + var r2d2 = t / d; +>r2d2 : number +>t / d : number +>t : T +>d : string + + var r2d3 = t % d; +>r2d3 : number +>t % d : number +>t : T +>d : string + + var r2d4 = t - d; +>r2d4 : number +>t - d : number +>t : T +>d : string + + var r2d5 = t << d; +>r2d5 : number +>t << d : number +>t : T +>d : string + + var r2d6 = t >> d; +>r2d6 : number +>t >> d : number +>t : T +>d : string + + var r2d7 = t >>> d; +>r2d7 : number +>t >>> d : number +>t : T +>d : string + + var r2d8 = t & d; +>r2d8 : number +>t & d : number +>t : T +>d : string + + var r2d9 = t ^ d; +>r2d9 : number +>t ^ d : number +>t : T +>d : string + + var r2d10 = t | d; +>r2d10 : number +>t | d : number +>t : T +>d : string + + var r1e1 = e * t; +>r1e1 : number +>e * t : number +>e : {} +>t : T + + var r1e2 = e / t; +>r1e2 : number +>e / t : number +>e : {} +>t : T + + var r1e3 = e % t; +>r1e3 : number +>e % t : number +>e : {} +>t : T + + var r1e4 = e - t; +>r1e4 : number +>e - t : number +>e : {} +>t : T + + var r1e5 = e << t; +>r1e5 : number +>e << t : number +>e : {} +>t : T + + var r1e6 = e >> t; +>r1e6 : number +>e >> t : number +>e : {} +>t : T + + var r1e7 = e >>> t; +>r1e7 : number +>e >>> t : number +>e : {} +>t : T + + var r1e8 = e & t; +>r1e8 : number +>e & t : number +>e : {} +>t : T + + var r1e9 = e ^ t; +>r1e9 : number +>e ^ t : number +>e : {} +>t : T + + var r1e10 = e | t; +>r1e10 : number +>e | t : number +>e : {} +>t : T + + var r2e1 = t * e; +>r2e1 : number +>t * e : number +>t : T +>e : {} + + var r2e2 = t / e; +>r2e2 : number +>t / e : number +>t : T +>e : {} + + var r2e3 = t % e; +>r2e3 : number +>t % e : number +>t : T +>e : {} + + var r2e4 = t - e; +>r2e4 : number +>t - e : number +>t : T +>e : {} + + var r2e5 = t << e; +>r2e5 : number +>t << e : number +>t : T +>e : {} + + var r2e6 = t >> e; +>r2e6 : number +>t >> e : number +>t : T +>e : {} + + var r2e7 = t >>> e; +>r2e7 : number +>t >>> e : number +>t : T +>e : {} + + var r2e8 = t & e; +>r2e8 : number +>t & e : number +>t : T +>e : {} + + var r2e9 = t ^ e; +>r2e9 : number +>t ^ e : number +>t : T +>e : {} + + var r2e10 = t | e; +>r2e10 : number +>t | e : number +>t : T +>e : {} + + var r1f1 = t * t; +>r1f1 : number +>t * t : number +>t : T +>t : T + + var r1f2 = t / t; +>r1f2 : number +>t / t : number +>t : T +>t : T + + var r1f3 = t % t; +>r1f3 : number +>t % t : number +>t : T +>t : T + + var r1f4 = t - t; +>r1f4 : number +>t - t : number +>t : T +>t : T + + var r1f5 = t << t; +>r1f5 : number +>t << t : number +>t : T +>t : T + + var r1f6 = t >> t; +>r1f6 : number +>t >> t : number +>t : T +>t : T + + var r1f7 = t >>> t; +>r1f7 : number +>t >>> t : number +>t : T +>t : T + + var r1f8 = t & t; +>r1f8 : number +>t & t : number +>t : T +>t : T + + var r1f9 = t ^ t; +>r1f9 : number +>t ^ t : number +>t : T +>t : T + + var r1f10 = t | t; +>r1f10 : number +>t | t : number +>t : T +>t : T +} diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.symbols b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.symbols new file mode 100644 index 00000000000..8275cc2fed4 --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.symbols @@ -0,0 +1,564 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts === +// If one operand is the undefined or undefined value, it is treated as having the type of the +// other operand. + +var a: boolean; +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var b: string; +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var c: Object; +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +// operator * +var r1a1 = undefined * a; +>r1a1 : Symbol(r1a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 8, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r1a2 = undefined * b; +>r1a2 : Symbol(r1a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 9, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r1a3 = undefined * c; +>r1a3 : Symbol(r1a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 10, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r1b1 = a * undefined; +>r1b1 : Symbol(r1b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 12, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r1b2 = b * undefined; +>r1b2 : Symbol(r1b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 13, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r1b3 = c * undefined; +>r1b3 : Symbol(r1b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 14, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r1c1 = undefined * true; +>r1c1 : Symbol(r1c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 16, 3)) +>undefined : Symbol(undefined) + +var r1c2 = undefined * ''; +>r1c2 : Symbol(r1c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 17, 3)) +>undefined : Symbol(undefined) + +var r1c3 = undefined * {}; +>r1c3 : Symbol(r1c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 18, 3)) +>undefined : Symbol(undefined) + +var r1d1 = true * undefined; +>r1d1 : Symbol(r1d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 20, 3)) +>undefined : Symbol(undefined) + +var r1d2 = '' * undefined; +>r1d2 : Symbol(r1d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 21, 3)) +>undefined : Symbol(undefined) + +var r1d3 = {} * undefined; +>r1d3 : Symbol(r1d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 22, 3)) +>undefined : Symbol(undefined) + +// operator / +var r2a1 = undefined / a; +>r2a1 : Symbol(r2a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 25, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r2a2 = undefined / b; +>r2a2 : Symbol(r2a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 26, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r2a3 = undefined / c; +>r2a3 : Symbol(r2a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 27, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r2b1 = a / undefined; +>r2b1 : Symbol(r2b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 29, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r2b2 = b / undefined; +>r2b2 : Symbol(r2b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 30, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r2b3 = c / undefined; +>r2b3 : Symbol(r2b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 31, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r2c1 = undefined / true; +>r2c1 : Symbol(r2c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 33, 3)) +>undefined : Symbol(undefined) + +var r2c2 = undefined / ''; +>r2c2 : Symbol(r2c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 34, 3)) +>undefined : Symbol(undefined) + +var r2c3 = undefined / {}; +>r2c3 : Symbol(r2c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 35, 3)) +>undefined : Symbol(undefined) + +var r2d1 = true / undefined; +>r2d1 : Symbol(r2d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 37, 3)) +>undefined : Symbol(undefined) + +var r2d2 = '' / undefined; +>r2d2 : Symbol(r2d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 38, 3)) +>undefined : Symbol(undefined) + +var r2d3 = {} / undefined; +>r2d3 : Symbol(r2d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 39, 3)) +>undefined : Symbol(undefined) + +// operator % +var r3a1 = undefined % a; +>r3a1 : Symbol(r3a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 42, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r3a2 = undefined % b; +>r3a2 : Symbol(r3a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 43, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r3a3 = undefined % c; +>r3a3 : Symbol(r3a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 44, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r3b1 = a % undefined; +>r3b1 : Symbol(r3b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 46, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r3b2 = b % undefined; +>r3b2 : Symbol(r3b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 47, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r3b3 = c % undefined; +>r3b3 : Symbol(r3b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 48, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r3c1 = undefined % true; +>r3c1 : Symbol(r3c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 50, 3)) +>undefined : Symbol(undefined) + +var r3c2 = undefined % ''; +>r3c2 : Symbol(r3c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 51, 3)) +>undefined : Symbol(undefined) + +var r3c3 = undefined % {}; +>r3c3 : Symbol(r3c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 52, 3)) +>undefined : Symbol(undefined) + +var r3d1 = true % undefined; +>r3d1 : Symbol(r3d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 54, 3)) +>undefined : Symbol(undefined) + +var r3d2 = '' % undefined; +>r3d2 : Symbol(r3d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 55, 3)) +>undefined : Symbol(undefined) + +var r3d3 = {} % undefined; +>r3d3 : Symbol(r3d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 56, 3)) +>undefined : Symbol(undefined) + +// operator - +var r4a1 = undefined - a; +>r4a1 : Symbol(r4a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 59, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r4a2 = undefined - b; +>r4a2 : Symbol(r4a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 60, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r4a3 = undefined - c; +>r4a3 : Symbol(r4a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 61, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r4b1 = a - undefined; +>r4b1 : Symbol(r4b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 63, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r4b2 = b - undefined; +>r4b2 : Symbol(r4b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 64, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r4b3 = c - undefined; +>r4b3 : Symbol(r4b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 65, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r4c1 = undefined - true; +>r4c1 : Symbol(r4c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 67, 3)) +>undefined : Symbol(undefined) + +var r4c2 = undefined - ''; +>r4c2 : Symbol(r4c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 68, 3)) +>undefined : Symbol(undefined) + +var r4c3 = undefined - {}; +>r4c3 : Symbol(r4c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 69, 3)) +>undefined : Symbol(undefined) + +var r4d1 = true - undefined; +>r4d1 : Symbol(r4d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 71, 3)) +>undefined : Symbol(undefined) + +var r4d2 = '' - undefined; +>r4d2 : Symbol(r4d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 72, 3)) +>undefined : Symbol(undefined) + +var r4d3 = {} - undefined; +>r4d3 : Symbol(r4d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 73, 3)) +>undefined : Symbol(undefined) + +// operator << +var r5a1 = undefined << a; +>r5a1 : Symbol(r5a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 76, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r5a2 = undefined << b; +>r5a2 : Symbol(r5a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 77, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r5a3 = undefined << c; +>r5a3 : Symbol(r5a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 78, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r5b1 = a << undefined; +>r5b1 : Symbol(r5b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 80, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r5b2 = b << undefined; +>r5b2 : Symbol(r5b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 81, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r5b3 = c << undefined; +>r5b3 : Symbol(r5b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 82, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r5c1 = undefined << true; +>r5c1 : Symbol(r5c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 84, 3)) +>undefined : Symbol(undefined) + +var r5c2 = undefined << ''; +>r5c2 : Symbol(r5c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 85, 3)) +>undefined : Symbol(undefined) + +var r5c3 = undefined << {}; +>r5c3 : Symbol(r5c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 86, 3)) +>undefined : Symbol(undefined) + +var r5d1 = true << undefined; +>r5d1 : Symbol(r5d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 88, 3)) +>undefined : Symbol(undefined) + +var r5d2 = '' << undefined; +>r5d2 : Symbol(r5d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 89, 3)) +>undefined : Symbol(undefined) + +var r5d3 = {} << undefined; +>r5d3 : Symbol(r5d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 90, 3)) +>undefined : Symbol(undefined) + +// operator >> +var r6a1 = undefined >> a; +>r6a1 : Symbol(r6a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 93, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r6a2 = undefined >> b; +>r6a2 : Symbol(r6a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 94, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r6a3 = undefined >> c; +>r6a3 : Symbol(r6a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 95, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r6b1 = a >> undefined; +>r6b1 : Symbol(r6b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 97, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r6b2 = b >> undefined; +>r6b2 : Symbol(r6b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 98, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r6b3 = c >> undefined; +>r6b3 : Symbol(r6b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 99, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r6c1 = undefined >> true; +>r6c1 : Symbol(r6c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 101, 3)) +>undefined : Symbol(undefined) + +var r6c2 = undefined >> ''; +>r6c2 : Symbol(r6c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 102, 3)) +>undefined : Symbol(undefined) + +var r6c3 = undefined >> {}; +>r6c3 : Symbol(r6c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 103, 3)) +>undefined : Symbol(undefined) + +var r6d1 = true >> undefined; +>r6d1 : Symbol(r6d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 105, 3)) +>undefined : Symbol(undefined) + +var r6d2 = '' >> undefined; +>r6d2 : Symbol(r6d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 106, 3)) +>undefined : Symbol(undefined) + +var r6d3 = {} >> undefined; +>r6d3 : Symbol(r6d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 107, 3)) +>undefined : Symbol(undefined) + +// operator >>> +var r7a1 = undefined >>> a; +>r7a1 : Symbol(r7a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 110, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r7a2 = undefined >>> b; +>r7a2 : Symbol(r7a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 111, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r7a3 = undefined >>> c; +>r7a3 : Symbol(r7a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 112, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r7b1 = a >>> undefined; +>r7b1 : Symbol(r7b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 114, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r7b2 = b >>> undefined; +>r7b2 : Symbol(r7b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 115, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r7b3 = c >>> undefined; +>r7b3 : Symbol(r7b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 116, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r7c1 = undefined >>> true; +>r7c1 : Symbol(r7c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 118, 3)) +>undefined : Symbol(undefined) + +var r7c2 = undefined >>> ''; +>r7c2 : Symbol(r7c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 119, 3)) +>undefined : Symbol(undefined) + +var r7c3 = undefined >>> {}; +>r7c3 : Symbol(r7c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 120, 3)) +>undefined : Symbol(undefined) + +var r7d1 = true >>> undefined; +>r7d1 : Symbol(r7d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 122, 3)) +>undefined : Symbol(undefined) + +var r7d2 = '' >>> undefined; +>r7d2 : Symbol(r7d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 123, 3)) +>undefined : Symbol(undefined) + +var r7d3 = {} >>> undefined; +>r7d3 : Symbol(r7d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 124, 3)) +>undefined : Symbol(undefined) + +// operator & +var r8a1 = undefined & a; +>r8a1 : Symbol(r8a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 127, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r8a2 = undefined & b; +>r8a2 : Symbol(r8a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 128, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r8a3 = undefined & c; +>r8a3 : Symbol(r8a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 129, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r8b1 = a & undefined; +>r8b1 : Symbol(r8b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 131, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r8b2 = b & undefined; +>r8b2 : Symbol(r8b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 132, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r8b3 = c & undefined; +>r8b3 : Symbol(r8b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 133, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r8c1 = undefined & true; +>r8c1 : Symbol(r8c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 135, 3)) +>undefined : Symbol(undefined) + +var r8c2 = undefined & ''; +>r8c2 : Symbol(r8c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 136, 3)) +>undefined : Symbol(undefined) + +var r8c3 = undefined & {}; +>r8c3 : Symbol(r8c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 137, 3)) +>undefined : Symbol(undefined) + +var r8d1 = true & undefined; +>r8d1 : Symbol(r8d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 139, 3)) +>undefined : Symbol(undefined) + +var r8d2 = '' & undefined; +>r8d2 : Symbol(r8d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 140, 3)) +>undefined : Symbol(undefined) + +var r8d3 = {} & undefined; +>r8d3 : Symbol(r8d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 141, 3)) +>undefined : Symbol(undefined) + +// operator ^ +var r9a1 = undefined ^ a; +>r9a1 : Symbol(r9a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 144, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r9a2 = undefined ^ b; +>r9a2 : Symbol(r9a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 145, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r9a3 = undefined ^ c; +>r9a3 : Symbol(r9a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 146, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r9b1 = a ^ undefined; +>r9b1 : Symbol(r9b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 148, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r9b2 = b ^ undefined; +>r9b2 : Symbol(r9b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 149, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r9b3 = c ^ undefined; +>r9b3 : Symbol(r9b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 150, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r9c1 = undefined ^ true; +>r9c1 : Symbol(r9c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 152, 3)) +>undefined : Symbol(undefined) + +var r9c2 = undefined ^ ''; +>r9c2 : Symbol(r9c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 153, 3)) +>undefined : Symbol(undefined) + +var r9c3 = undefined ^ {}; +>r9c3 : Symbol(r9c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 154, 3)) +>undefined : Symbol(undefined) + +var r9d1 = true ^ undefined; +>r9d1 : Symbol(r9d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 156, 3)) +>undefined : Symbol(undefined) + +var r9d2 = '' ^ undefined; +>r9d2 : Symbol(r9d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 157, 3)) +>undefined : Symbol(undefined) + +var r9d3 = {} ^ undefined; +>r9d3 : Symbol(r9d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 158, 3)) +>undefined : Symbol(undefined) + +// operator | +var r10a1 = undefined | a; +>r10a1 : Symbol(r10a1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 161, 3)) +>undefined : Symbol(undefined) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) + +var r10a2 = undefined | b; +>r10a2 : Symbol(r10a2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 162, 3)) +>undefined : Symbol(undefined) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) + +var r10a3 = undefined | c; +>r10a3 : Symbol(r10a3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 163, 3)) +>undefined : Symbol(undefined) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) + +var r10b1 = a | undefined; +>r10b1 : Symbol(r10b1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 165, 3)) +>a : Symbol(a, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 3, 3)) +>undefined : Symbol(undefined) + +var r10b2 = b | undefined; +>r10b2 : Symbol(r10b2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 166, 3)) +>b : Symbol(b, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 4, 3)) +>undefined : Symbol(undefined) + +var r10b3 = c | undefined; +>r10b3 : Symbol(r10b3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 167, 3)) +>c : Symbol(c, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 5, 3)) +>undefined : Symbol(undefined) + +var r10c1 = undefined | true; +>r10c1 : Symbol(r10c1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 169, 3)) +>undefined : Symbol(undefined) + +var r10c2 = undefined | ''; +>r10c2 : Symbol(r10c2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 170, 3)) +>undefined : Symbol(undefined) + +var r10c3 = undefined | {}; +>r10c3 : Symbol(r10c3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 171, 3)) +>undefined : Symbol(undefined) + +var r10d1 = true | undefined; +>r10d1 : Symbol(r10d1, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 173, 3)) +>undefined : Symbol(undefined) + +var r10d2 = '' | undefined; +>r10d2 : Symbol(r10d2, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 174, 3)) +>undefined : Symbol(undefined) + +var r10d3 = {} | undefined; +>r10d3 : Symbol(r10d3, Decl(arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts, 175, 3)) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.types b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.types new file mode 100644 index 00000000000..3211250146b --- /dev/null +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndInvalidOperands.types @@ -0,0 +1,744 @@ +=== tests/cases/conformance/expressions/binaryOperators/arithmeticOperator/arithmeticOperatorWithUndefinedValueAndInvalidOperands.ts === +// If one operand is the undefined or undefined value, it is treated as having the type of the +// other operand. + +var a: boolean; +>a : boolean + +var b: string; +>b : string + +var c: Object; +>c : Object +>Object : Object + +// operator * +var r1a1 = undefined * a; +>r1a1 : number +>undefined * a : number +>undefined : undefined +>a : boolean + +var r1a2 = undefined * b; +>r1a2 : number +>undefined * b : number +>undefined : undefined +>b : string + +var r1a3 = undefined * c; +>r1a3 : number +>undefined * c : number +>undefined : undefined +>c : Object + +var r1b1 = a * undefined; +>r1b1 : number +>a * undefined : number +>a : boolean +>undefined : undefined + +var r1b2 = b * undefined; +>r1b2 : number +>b * undefined : number +>b : string +>undefined : undefined + +var r1b3 = c * undefined; +>r1b3 : number +>c * undefined : number +>c : Object +>undefined : undefined + +var r1c1 = undefined * true; +>r1c1 : number +>undefined * true : number +>undefined : undefined +>true : true + +var r1c2 = undefined * ''; +>r1c2 : number +>undefined * '' : number +>undefined : undefined +>'' : "" + +var r1c3 = undefined * {}; +>r1c3 : number +>undefined * {} : number +>undefined : undefined +>{} : {} + +var r1d1 = true * undefined; +>r1d1 : number +>true * undefined : number +>true : true +>undefined : undefined + +var r1d2 = '' * undefined; +>r1d2 : number +>'' * undefined : number +>'' : "" +>undefined : undefined + +var r1d3 = {} * undefined; +>r1d3 : number +>{} * undefined : number +>{} : {} +>undefined : undefined + +// operator / +var r2a1 = undefined / a; +>r2a1 : number +>undefined / a : number +>undefined : undefined +>a : boolean + +var r2a2 = undefined / b; +>r2a2 : number +>undefined / b : number +>undefined : undefined +>b : string + +var r2a3 = undefined / c; +>r2a3 : number +>undefined / c : number +>undefined : undefined +>c : Object + +var r2b1 = a / undefined; +>r2b1 : number +>a / undefined : number +>a : boolean +>undefined : undefined + +var r2b2 = b / undefined; +>r2b2 : number +>b / undefined : number +>b : string +>undefined : undefined + +var r2b3 = c / undefined; +>r2b3 : number +>c / undefined : number +>c : Object +>undefined : undefined + +var r2c1 = undefined / true; +>r2c1 : number +>undefined / true : number +>undefined : undefined +>true : true + +var r2c2 = undefined / ''; +>r2c2 : number +>undefined / '' : number +>undefined : undefined +>'' : "" + +var r2c3 = undefined / {}; +>r2c3 : number +>undefined / {} : number +>undefined : undefined +>{} : {} + +var r2d1 = true / undefined; +>r2d1 : number +>true / undefined : number +>true : true +>undefined : undefined + +var r2d2 = '' / undefined; +>r2d2 : number +>'' / undefined : number +>'' : "" +>undefined : undefined + +var r2d3 = {} / undefined; +>r2d3 : number +>{} / undefined : number +>{} : {} +>undefined : undefined + +// operator % +var r3a1 = undefined % a; +>r3a1 : number +>undefined % a : number +>undefined : undefined +>a : boolean + +var r3a2 = undefined % b; +>r3a2 : number +>undefined % b : number +>undefined : undefined +>b : string + +var r3a3 = undefined % c; +>r3a3 : number +>undefined % c : number +>undefined : undefined +>c : Object + +var r3b1 = a % undefined; +>r3b1 : number +>a % undefined : number +>a : boolean +>undefined : undefined + +var r3b2 = b % undefined; +>r3b2 : number +>b % undefined : number +>b : string +>undefined : undefined + +var r3b3 = c % undefined; +>r3b3 : number +>c % undefined : number +>c : Object +>undefined : undefined + +var r3c1 = undefined % true; +>r3c1 : number +>undefined % true : number +>undefined : undefined +>true : true + +var r3c2 = undefined % ''; +>r3c2 : number +>undefined % '' : number +>undefined : undefined +>'' : "" + +var r3c3 = undefined % {}; +>r3c3 : number +>undefined % {} : number +>undefined : undefined +>{} : {} + +var r3d1 = true % undefined; +>r3d1 : number +>true % undefined : number +>true : true +>undefined : undefined + +var r3d2 = '' % undefined; +>r3d2 : number +>'' % undefined : number +>'' : "" +>undefined : undefined + +var r3d3 = {} % undefined; +>r3d3 : number +>{} % undefined : number +>{} : {} +>undefined : undefined + +// operator - +var r4a1 = undefined - a; +>r4a1 : number +>undefined - a : number +>undefined : undefined +>a : boolean + +var r4a2 = undefined - b; +>r4a2 : number +>undefined - b : number +>undefined : undefined +>b : string + +var r4a3 = undefined - c; +>r4a3 : number +>undefined - c : number +>undefined : undefined +>c : Object + +var r4b1 = a - undefined; +>r4b1 : number +>a - undefined : number +>a : boolean +>undefined : undefined + +var r4b2 = b - undefined; +>r4b2 : number +>b - undefined : number +>b : string +>undefined : undefined + +var r4b3 = c - undefined; +>r4b3 : number +>c - undefined : number +>c : Object +>undefined : undefined + +var r4c1 = undefined - true; +>r4c1 : number +>undefined - true : number +>undefined : undefined +>true : true + +var r4c2 = undefined - ''; +>r4c2 : number +>undefined - '' : number +>undefined : undefined +>'' : "" + +var r4c3 = undefined - {}; +>r4c3 : number +>undefined - {} : number +>undefined : undefined +>{} : {} + +var r4d1 = true - undefined; +>r4d1 : number +>true - undefined : number +>true : true +>undefined : undefined + +var r4d2 = '' - undefined; +>r4d2 : number +>'' - undefined : number +>'' : "" +>undefined : undefined + +var r4d3 = {} - undefined; +>r4d3 : number +>{} - undefined : number +>{} : {} +>undefined : undefined + +// operator << +var r5a1 = undefined << a; +>r5a1 : number +>undefined << a : number +>undefined : undefined +>a : boolean + +var r5a2 = undefined << b; +>r5a2 : number +>undefined << b : number +>undefined : undefined +>b : string + +var r5a3 = undefined << c; +>r5a3 : number +>undefined << c : number +>undefined : undefined +>c : Object + +var r5b1 = a << undefined; +>r5b1 : number +>a << undefined : number +>a : boolean +>undefined : undefined + +var r5b2 = b << undefined; +>r5b2 : number +>b << undefined : number +>b : string +>undefined : undefined + +var r5b3 = c << undefined; +>r5b3 : number +>c << undefined : number +>c : Object +>undefined : undefined + +var r5c1 = undefined << true; +>r5c1 : number +>undefined << true : number +>undefined : undefined +>true : true + +var r5c2 = undefined << ''; +>r5c2 : number +>undefined << '' : number +>undefined : undefined +>'' : "" + +var r5c3 = undefined << {}; +>r5c3 : number +>undefined << {} : number +>undefined : undefined +>{} : {} + +var r5d1 = true << undefined; +>r5d1 : number +>true << undefined : number +>true : true +>undefined : undefined + +var r5d2 = '' << undefined; +>r5d2 : number +>'' << undefined : number +>'' : "" +>undefined : undefined + +var r5d3 = {} << undefined; +>r5d3 : number +>{} << undefined : number +>{} : {} +>undefined : undefined + +// operator >> +var r6a1 = undefined >> a; +>r6a1 : number +>undefined >> a : number +>undefined : undefined +>a : boolean + +var r6a2 = undefined >> b; +>r6a2 : number +>undefined >> b : number +>undefined : undefined +>b : string + +var r6a3 = undefined >> c; +>r6a3 : number +>undefined >> c : number +>undefined : undefined +>c : Object + +var r6b1 = a >> undefined; +>r6b1 : number +>a >> undefined : number +>a : boolean +>undefined : undefined + +var r6b2 = b >> undefined; +>r6b2 : number +>b >> undefined : number +>b : string +>undefined : undefined + +var r6b3 = c >> undefined; +>r6b3 : number +>c >> undefined : number +>c : Object +>undefined : undefined + +var r6c1 = undefined >> true; +>r6c1 : number +>undefined >> true : number +>undefined : undefined +>true : true + +var r6c2 = undefined >> ''; +>r6c2 : number +>undefined >> '' : number +>undefined : undefined +>'' : "" + +var r6c3 = undefined >> {}; +>r6c3 : number +>undefined >> {} : number +>undefined : undefined +>{} : {} + +var r6d1 = true >> undefined; +>r6d1 : number +>true >> undefined : number +>true : true +>undefined : undefined + +var r6d2 = '' >> undefined; +>r6d2 : number +>'' >> undefined : number +>'' : "" +>undefined : undefined + +var r6d3 = {} >> undefined; +>r6d3 : number +>{} >> undefined : number +>{} : {} +>undefined : undefined + +// operator >>> +var r7a1 = undefined >>> a; +>r7a1 : number +>undefined >>> a : number +>undefined : undefined +>a : boolean + +var r7a2 = undefined >>> b; +>r7a2 : number +>undefined >>> b : number +>undefined : undefined +>b : string + +var r7a3 = undefined >>> c; +>r7a3 : number +>undefined >>> c : number +>undefined : undefined +>c : Object + +var r7b1 = a >>> undefined; +>r7b1 : number +>a >>> undefined : number +>a : boolean +>undefined : undefined + +var r7b2 = b >>> undefined; +>r7b2 : number +>b >>> undefined : number +>b : string +>undefined : undefined + +var r7b3 = c >>> undefined; +>r7b3 : number +>c >>> undefined : number +>c : Object +>undefined : undefined + +var r7c1 = undefined >>> true; +>r7c1 : number +>undefined >>> true : number +>undefined : undefined +>true : true + +var r7c2 = undefined >>> ''; +>r7c2 : number +>undefined >>> '' : number +>undefined : undefined +>'' : "" + +var r7c3 = undefined >>> {}; +>r7c3 : number +>undefined >>> {} : number +>undefined : undefined +>{} : {} + +var r7d1 = true >>> undefined; +>r7d1 : number +>true >>> undefined : number +>true : true +>undefined : undefined + +var r7d2 = '' >>> undefined; +>r7d2 : number +>'' >>> undefined : number +>'' : "" +>undefined : undefined + +var r7d3 = {} >>> undefined; +>r7d3 : number +>{} >>> undefined : number +>{} : {} +>undefined : undefined + +// operator & +var r8a1 = undefined & a; +>r8a1 : number +>undefined & a : number +>undefined : undefined +>a : boolean + +var r8a2 = undefined & b; +>r8a2 : number +>undefined & b : number +>undefined : undefined +>b : string + +var r8a3 = undefined & c; +>r8a3 : number +>undefined & c : number +>undefined : undefined +>c : Object + +var r8b1 = a & undefined; +>r8b1 : number +>a & undefined : number +>a : boolean +>undefined : undefined + +var r8b2 = b & undefined; +>r8b2 : number +>b & undefined : number +>b : string +>undefined : undefined + +var r8b3 = c & undefined; +>r8b3 : number +>c & undefined : number +>c : Object +>undefined : undefined + +var r8c1 = undefined & true; +>r8c1 : number +>undefined & true : number +>undefined : undefined +>true : true + +var r8c2 = undefined & ''; +>r8c2 : number +>undefined & '' : number +>undefined : undefined +>'' : "" + +var r8c3 = undefined & {}; +>r8c3 : number +>undefined & {} : number +>undefined : undefined +>{} : {} + +var r8d1 = true & undefined; +>r8d1 : number +>true & undefined : number +>true : true +>undefined : undefined + +var r8d2 = '' & undefined; +>r8d2 : number +>'' & undefined : number +>'' : "" +>undefined : undefined + +var r8d3 = {} & undefined; +>r8d3 : number +>{} & undefined : number +>{} : {} +>undefined : undefined + +// operator ^ +var r9a1 = undefined ^ a; +>r9a1 : number +>undefined ^ a : number +>undefined : undefined +>a : boolean + +var r9a2 = undefined ^ b; +>r9a2 : number +>undefined ^ b : number +>undefined : undefined +>b : string + +var r9a3 = undefined ^ c; +>r9a3 : number +>undefined ^ c : number +>undefined : undefined +>c : Object + +var r9b1 = a ^ undefined; +>r9b1 : number +>a ^ undefined : number +>a : boolean +>undefined : undefined + +var r9b2 = b ^ undefined; +>r9b2 : number +>b ^ undefined : number +>b : string +>undefined : undefined + +var r9b3 = c ^ undefined; +>r9b3 : number +>c ^ undefined : number +>c : Object +>undefined : undefined + +var r9c1 = undefined ^ true; +>r9c1 : number +>undefined ^ true : number +>undefined : undefined +>true : true + +var r9c2 = undefined ^ ''; +>r9c2 : number +>undefined ^ '' : number +>undefined : undefined +>'' : "" + +var r9c3 = undefined ^ {}; +>r9c3 : number +>undefined ^ {} : number +>undefined : undefined +>{} : {} + +var r9d1 = true ^ undefined; +>r9d1 : number +>true ^ undefined : number +>true : true +>undefined : undefined + +var r9d2 = '' ^ undefined; +>r9d2 : number +>'' ^ undefined : number +>'' : "" +>undefined : undefined + +var r9d3 = {} ^ undefined; +>r9d3 : number +>{} ^ undefined : number +>{} : {} +>undefined : undefined + +// operator | +var r10a1 = undefined | a; +>r10a1 : number +>undefined | a : number +>undefined : undefined +>a : boolean + +var r10a2 = undefined | b; +>r10a2 : number +>undefined | b : number +>undefined : undefined +>b : string + +var r10a3 = undefined | c; +>r10a3 : number +>undefined | c : number +>undefined : undefined +>c : Object + +var r10b1 = a | undefined; +>r10b1 : number +>a | undefined : number +>a : boolean +>undefined : undefined + +var r10b2 = b | undefined; +>r10b2 : number +>b | undefined : number +>b : string +>undefined : undefined + +var r10b3 = c | undefined; +>r10b3 : number +>c | undefined : number +>c : Object +>undefined : undefined + +var r10c1 = undefined | true; +>r10c1 : number +>undefined | true : number +>undefined : undefined +>true : true + +var r10c2 = undefined | ''; +>r10c2 : number +>undefined | '' : number +>undefined : undefined +>'' : "" + +var r10c3 = undefined | {}; +>r10c3 : number +>undefined | {} : number +>undefined : undefined +>{} : {} + +var r10d1 = true | undefined; +>r10d1 : number +>true | undefined : number +>true : true +>undefined : undefined + +var r10d2 = '' | undefined; +>r10d2 : number +>'' | undefined : number +>'' : "" +>undefined : undefined + +var r10d3 = {} | undefined; +>r10d3 : number +>{} | undefined : number +>{} : {} +>undefined : undefined + diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.symbols b/tests/baselines/reference/arityAndOrderCompatibility01.symbols new file mode 100644 index 00000000000..c6ef08a845b --- /dev/null +++ b/tests/baselines/reference/arityAndOrderCompatibility01.symbols @@ -0,0 +1,113 @@ +=== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts === +interface StrNum extends Array { +>StrNum : Symbol(StrNum, Decl(arityAndOrderCompatibility01.ts, 0, 0)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + 0: string; + 1: number; +} + +var x: [string, number]; +>x : Symbol(x, Decl(arityAndOrderCompatibility01.ts, 5, 3)) + +var y: StrNum +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) +>StrNum : Symbol(StrNum, Decl(arityAndOrderCompatibility01.ts, 0, 0)) + +var z: { +>z : Symbol(z, Decl(arityAndOrderCompatibility01.ts, 7, 3)) + + 0: string; + 1: number; +} + +var [a, b, c] = x; +>a : Symbol(a, Decl(arityAndOrderCompatibility01.ts, 12, 5)) +>b : Symbol(b, Decl(arityAndOrderCompatibility01.ts, 12, 7)) +>c : Symbol(c, Decl(arityAndOrderCompatibility01.ts, 12, 10)) +>x : Symbol(x, Decl(arityAndOrderCompatibility01.ts, 5, 3)) + +var [d, e, f] = y; +>d : Symbol(d, Decl(arityAndOrderCompatibility01.ts, 13, 5)) +>e : Symbol(e, Decl(arityAndOrderCompatibility01.ts, 13, 7)) +>f : Symbol(f, Decl(arityAndOrderCompatibility01.ts, 13, 10)) +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) + +var [g, h, i] = z; +>g : Symbol(g, Decl(arityAndOrderCompatibility01.ts, 14, 5)) +>h : Symbol(h, Decl(arityAndOrderCompatibility01.ts, 14, 7)) +>i : Symbol(i, Decl(arityAndOrderCompatibility01.ts, 14, 10)) +>z : Symbol(z, Decl(arityAndOrderCompatibility01.ts, 7, 3)) + +var j1: [number, number, number] = x; +>j1 : Symbol(j1, Decl(arityAndOrderCompatibility01.ts, 15, 3)) +>x : Symbol(x, Decl(arityAndOrderCompatibility01.ts, 5, 3)) + +var j2: [number, number, number] = y; +>j2 : Symbol(j2, Decl(arityAndOrderCompatibility01.ts, 16, 3)) +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) + +var j3: [number, number, number] = z; +>j3 : Symbol(j3, Decl(arityAndOrderCompatibility01.ts, 17, 3)) +>z : Symbol(z, Decl(arityAndOrderCompatibility01.ts, 7, 3)) + +var k1: [string, number, number] = x; +>k1 : Symbol(k1, Decl(arityAndOrderCompatibility01.ts, 18, 3)) +>x : Symbol(x, Decl(arityAndOrderCompatibility01.ts, 5, 3)) + +var k2: [string, number, number] = y; +>k2 : Symbol(k2, Decl(arityAndOrderCompatibility01.ts, 19, 3)) +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) + +var k3: [string, number, number] = z; +>k3 : Symbol(k3, Decl(arityAndOrderCompatibility01.ts, 20, 3)) +>z : Symbol(z, Decl(arityAndOrderCompatibility01.ts, 7, 3)) + +var l1: [number] = x; +>l1 : Symbol(l1, Decl(arityAndOrderCompatibility01.ts, 21, 3)) +>x : Symbol(x, Decl(arityAndOrderCompatibility01.ts, 5, 3)) + +var l2: [number] = y; +>l2 : Symbol(l2, Decl(arityAndOrderCompatibility01.ts, 22, 3)) +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) + +var l3: [number] = z; +>l3 : Symbol(l3, Decl(arityAndOrderCompatibility01.ts, 23, 3)) +>z : Symbol(z, Decl(arityAndOrderCompatibility01.ts, 7, 3)) + +var m1: [string] = x; +>m1 : Symbol(m1, Decl(arityAndOrderCompatibility01.ts, 24, 3)) +>x : Symbol(x, Decl(arityAndOrderCompatibility01.ts, 5, 3)) + +var m2: [string] = y; +>m2 : Symbol(m2, Decl(arityAndOrderCompatibility01.ts, 25, 3)) +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) + +var m3: [string] = z; +>m3 : Symbol(m3, Decl(arityAndOrderCompatibility01.ts, 26, 3)) +>z : Symbol(z, Decl(arityAndOrderCompatibility01.ts, 7, 3)) + +var n1: [number, string] = x; +>n1 : Symbol(n1, Decl(arityAndOrderCompatibility01.ts, 27, 3)) +>x : Symbol(x, Decl(arityAndOrderCompatibility01.ts, 5, 3)) + +var n2: [number, string] = y; +>n2 : Symbol(n2, Decl(arityAndOrderCompatibility01.ts, 28, 3)) +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) + +var n3: [number, string] = z; +>n3 : Symbol(n3, Decl(arityAndOrderCompatibility01.ts, 29, 3)) +>z : Symbol(z, Decl(arityAndOrderCompatibility01.ts, 7, 3)) + +var o1: [string, number] = x; +>o1 : Symbol(o1, Decl(arityAndOrderCompatibility01.ts, 30, 3)) +>x : Symbol(x, Decl(arityAndOrderCompatibility01.ts, 5, 3)) + +var o2: [string, number] = y; +>o2 : Symbol(o2, Decl(arityAndOrderCompatibility01.ts, 31, 3)) +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) + +var o3: [string, number] = y; +>o3 : Symbol(o3, Decl(arityAndOrderCompatibility01.ts, 32, 3)) +>y : Symbol(y, Decl(arityAndOrderCompatibility01.ts, 6, 3)) + diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.types b/tests/baselines/reference/arityAndOrderCompatibility01.types new file mode 100644 index 00000000000..934c5c6966d --- /dev/null +++ b/tests/baselines/reference/arityAndOrderCompatibility01.types @@ -0,0 +1,113 @@ +=== tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts === +interface StrNum extends Array { +>StrNum : StrNum +>Array : T[] + + 0: string; + 1: number; +} + +var x: [string, number]; +>x : [string, number] + +var y: StrNum +>y : StrNum +>StrNum : StrNum + +var z: { +>z : { 0: string; 1: number; } + + 0: string; + 1: number; +} + +var [a, b, c] = x; +>a : string +>b : number +>c : any +>x : [string, number] + +var [d, e, f] = y; +>d : string +>e : number +>f : any +>y : StrNum + +var [g, h, i] = z; +>g : string +>h : number +>i : any +>z : { 0: string; 1: number; } + +var j1: [number, number, number] = x; +>j1 : [number, number, number] +>x : [string, number] + +var j2: [number, number, number] = y; +>j2 : [number, number, number] +>y : StrNum + +var j3: [number, number, number] = z; +>j3 : [number, number, number] +>z : { 0: string; 1: number; } + +var k1: [string, number, number] = x; +>k1 : [string, number, number] +>x : [string, number] + +var k2: [string, number, number] = y; +>k2 : [string, number, number] +>y : StrNum + +var k3: [string, number, number] = z; +>k3 : [string, number, number] +>z : { 0: string; 1: number; } + +var l1: [number] = x; +>l1 : [number] +>x : [string, number] + +var l2: [number] = y; +>l2 : [number] +>y : StrNum + +var l3: [number] = z; +>l3 : [number] +>z : { 0: string; 1: number; } + +var m1: [string] = x; +>m1 : [string] +>x : [string, number] + +var m2: [string] = y; +>m2 : [string] +>y : StrNum + +var m3: [string] = z; +>m3 : [string] +>z : { 0: string; 1: number; } + +var n1: [number, string] = x; +>n1 : [number, string] +>x : [string, number] + +var n2: [number, string] = y; +>n2 : [number, string] +>y : StrNum + +var n3: [number, string] = z; +>n3 : [number, string] +>z : { 0: string; 1: number; } + +var o1: [string, number] = x; +>o1 : [string, number] +>x : [string, number] + +var o2: [string, number] = y; +>o2 : [string, number] +>y : StrNum + +var o3: [string, number] = y; +>o3 : [string, number] +>y : StrNum + diff --git a/tests/baselines/reference/arrayAssignmentTest1.symbols b/tests/baselines/reference/arrayAssignmentTest1.symbols new file mode 100644 index 00000000000..8f9445fd56c --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest1.symbols @@ -0,0 +1,233 @@ +=== tests/cases/compiler/arrayAssignmentTest1.ts === +interface I1 { +>I1 : Symbol(I1, Decl(arrayAssignmentTest1.ts, 0, 0)) + + IM1():void[]; +>IM1 : Symbol(I1.IM1, Decl(arrayAssignmentTest1.ts, 0, 14)) +} + +class C1 implements I1 { +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest1.ts, 0, 0)) + + IM1():void[] {return null;} +>IM1 : Symbol(C1.IM1, Decl(arrayAssignmentTest1.ts, 4, 24)) + + C1M1():C1[] {return null;} +>C1M1 : Symbol(C1.C1M1, Decl(arrayAssignmentTest1.ts, 5, 28)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) + } +class C2 extends C1 { +>C2 : Symbol(C2, Decl(arrayAssignmentTest1.ts, 7, 2)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) + + C2M1():C2[] { return null;} +>C2M1 : Symbol(C2.C2M1, Decl(arrayAssignmentTest1.ts, 8, 21)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest1.ts, 7, 2)) +} + +class C3 { +>C3 : Symbol(C3, Decl(arrayAssignmentTest1.ts, 10, 1)) + + CM3M1() { return 3;} +>CM3M1 : Symbol(C3.CM3M1, Decl(arrayAssignmentTest1.ts, 12, 10)) +} + + +/* + +This behaves unexpectedly with the following types: + +Type 1 of any[]: + +* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[]. + +* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass. + +*/ +var a1 : any = null; +>a1 : Symbol(a1, Decl(arrayAssignmentTest1.ts, 28, 3)) + +var c1 : C1 = new C1(); +>c1 : Symbol(c1, Decl(arrayAssignmentTest1.ts, 29, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) + +var i1 : I1 = c1; +>i1 : Symbol(i1, Decl(arrayAssignmentTest1.ts, 30, 3)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest1.ts, 0, 0)) +>c1 : Symbol(c1, Decl(arrayAssignmentTest1.ts, 29, 3)) + +var c2 : C2 = new C2(); +>c2 : Symbol(c2, Decl(arrayAssignmentTest1.ts, 31, 3)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest1.ts, 7, 2)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest1.ts, 7, 2)) + +var c3 : C3 = new C3(); +>c3 : Symbol(c3, Decl(arrayAssignmentTest1.ts, 32, 3)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest1.ts, 10, 1)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest1.ts, 10, 1)) + +var o1 = {one : 1}; +>o1 : Symbol(o1, Decl(arrayAssignmentTest1.ts, 33, 3)) +>one : Symbol(one, Decl(arrayAssignmentTest1.ts, 33, 10)) + +var f1 = function () { return new C1();} +>f1 : Symbol(f1, Decl(arrayAssignmentTest1.ts, 34, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) + +var arr_any: any[] = []; +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) + +var arr_i1: I1[] = []; +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest1.ts, 0, 0)) + +var arr_c1: C1[] = []; +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) + +var arr_c2: C2[] = []; +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest1.ts, 7, 2)) + +var arr_i1_2: I1[] = []; +>arr_i1_2 : Symbol(arr_i1_2, Decl(arrayAssignmentTest1.ts, 40, 3)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest1.ts, 0, 0)) + +var arr_c1_2: C1[] = []; +>arr_c1_2 : Symbol(arr_c1_2, Decl(arrayAssignmentTest1.ts, 41, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) + +var arr_c2_2: C2[] = []; +>arr_c2_2 : Symbol(arr_c2_2, Decl(arrayAssignmentTest1.ts, 42, 3)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest1.ts, 7, 2)) + +var arr_c3: C3[] = []; +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest1.ts, 43, 3)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest1.ts, 10, 1)) + +var i1_error: I1 = []; // should be an error - is +>i1_error : Symbol(i1_error, Decl(arrayAssignmentTest1.ts, 45, 3)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest1.ts, 0, 0)) + +var c1_error: C1 = []; // should be an error - is +>c1_error : Symbol(c1_error, Decl(arrayAssignmentTest1.ts, 46, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest1.ts, 2, 1)) + +var c2_error: C2 = []; // should be an error - is +>c2_error : Symbol(c2_error, Decl(arrayAssignmentTest1.ts, 47, 3)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest1.ts, 7, 2)) + +var c3_error: C3 = []; // should be an error - is +>c3_error : Symbol(c3_error, Decl(arrayAssignmentTest1.ts, 48, 3)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest1.ts, 10, 1)) + + +arr_any = arr_i1; // should be ok - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) + +arr_any = arr_c1; // should be ok - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) + +arr_any = arr_c2; // should be ok - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) + +arr_any = arr_c3; // should be ok - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest1.ts, 43, 3)) + +arr_i1 = arr_i1; // should be ok - subtype relationship - is +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) + +arr_i1 = arr_c1; // should be ok - subtype relationship - is +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) + +arr_i1 = arr_c2; // should be ok - subtype relationship - is +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) + +arr_i1 = arr_c3; // should be an error - is +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest1.ts, 43, 3)) + +arr_c1 = arr_c1; // should be ok - subtype relationship - is +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) + +arr_c1 = arr_c2; // should be ok - subtype relationship - is +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) + +arr_c1 = arr_i1; // should be an error - is +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) + +arr_c1 = arr_c3; // should be an error - is +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest1.ts, 43, 3)) + +arr_c2 = arr_c2; // should be ok - subtype relationship - is +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) + +arr_c2 = arr_c1; // should be an error - subtype relationship - is +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest1.ts, 38, 3)) + +arr_c2 = arr_i1; // should be an error - subtype relationship - is +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest1.ts, 37, 3)) + +arr_c2 = arr_c3; // should be an error - is +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest1.ts, 39, 3)) +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest1.ts, 43, 3)) + +// "clean up bug" occurs at this point +// if you move these three expressions to another file, they raise an error +// something to do with state from the above propagating forward? +arr_c3 = arr_c2_2; // should be an error - is +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest1.ts, 43, 3)) +>arr_c2_2 : Symbol(arr_c2_2, Decl(arrayAssignmentTest1.ts, 42, 3)) + +arr_c3 = arr_c1_2; // should be an error - is +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest1.ts, 43, 3)) +>arr_c1_2 : Symbol(arr_c1_2, Decl(arrayAssignmentTest1.ts, 41, 3)) + +arr_c3 = arr_i1_2; // should be an error - is +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest1.ts, 43, 3)) +>arr_i1_2 : Symbol(arr_i1_2, Decl(arrayAssignmentTest1.ts, 40, 3)) + +arr_any = f1; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>f1 : Symbol(f1, Decl(arrayAssignmentTest1.ts, 34, 3)) + +arr_any = o1; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>o1 : Symbol(o1, Decl(arrayAssignmentTest1.ts, 33, 3)) + +arr_any = a1; // should be ok - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>a1 : Symbol(a1, Decl(arrayAssignmentTest1.ts, 28, 3)) + +arr_any = c1; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>c1 : Symbol(c1, Decl(arrayAssignmentTest1.ts, 29, 3)) + +arr_any = c2; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>c2 : Symbol(c2, Decl(arrayAssignmentTest1.ts, 31, 3)) + +arr_any = c3; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>c3 : Symbol(c3, Decl(arrayAssignmentTest1.ts, 32, 3)) + +arr_any = i1; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest1.ts, 36, 3)) +>i1 : Symbol(i1, Decl(arrayAssignmentTest1.ts, 30, 3)) + diff --git a/tests/baselines/reference/arrayAssignmentTest1.types b/tests/baselines/reference/arrayAssignmentTest1.types new file mode 100644 index 00000000000..c46d6971eec --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest1.types @@ -0,0 +1,283 @@ +=== tests/cases/compiler/arrayAssignmentTest1.ts === +interface I1 { +>I1 : I1 + + IM1():void[]; +>IM1 : () => void[] +} + +class C1 implements I1 { +>C1 : C1 +>I1 : I1 + + IM1():void[] {return null;} +>IM1 : () => void[] +>null : null + + C1M1():C1[] {return null;} +>C1M1 : () => C1[] +>C1 : C1 +>null : null + } +class C2 extends C1 { +>C2 : C2 +>C1 : C1 + + C2M1():C2[] { return null;} +>C2M1 : () => C2[] +>C2 : C2 +>null : null +} + +class C3 { +>C3 : C3 + + CM3M1() { return 3;} +>CM3M1 : () => number +>3 : 3 +} + + +/* + +This behaves unexpectedly with the following types: + +Type 1 of any[]: + +* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[]. + +* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass. + +*/ +var a1 : any = null; +>a1 : any +>null : null + +var c1 : C1 = new C1(); +>c1 : C1 +>C1 : C1 +>new C1() : C1 +>C1 : typeof C1 + +var i1 : I1 = c1; +>i1 : I1 +>I1 : I1 +>c1 : C1 + +var c2 : C2 = new C2(); +>c2 : C2 +>C2 : C2 +>new C2() : C2 +>C2 : typeof C2 + +var c3 : C3 = new C3(); +>c3 : C3 +>C3 : C3 +>new C3() : C3 +>C3 : typeof C3 + +var o1 = {one : 1}; +>o1 : { one: number; } +>{one : 1} : { one: number; } +>one : number +>1 : 1 + +var f1 = function () { return new C1();} +>f1 : () => C1 +>function () { return new C1();} : () => C1 +>new C1() : C1 +>C1 : typeof C1 + +var arr_any: any[] = []; +>arr_any : any[] +>[] : undefined[] + +var arr_i1: I1[] = []; +>arr_i1 : I1[] +>I1 : I1 +>[] : undefined[] + +var arr_c1: C1[] = []; +>arr_c1 : C1[] +>C1 : C1 +>[] : undefined[] + +var arr_c2: C2[] = []; +>arr_c2 : C2[] +>C2 : C2 +>[] : undefined[] + +var arr_i1_2: I1[] = []; +>arr_i1_2 : I1[] +>I1 : I1 +>[] : undefined[] + +var arr_c1_2: C1[] = []; +>arr_c1_2 : C1[] +>C1 : C1 +>[] : undefined[] + +var arr_c2_2: C2[] = []; +>arr_c2_2 : C2[] +>C2 : C2 +>[] : undefined[] + +var arr_c3: C3[] = []; +>arr_c3 : C3[] +>C3 : C3 +>[] : undefined[] + +var i1_error: I1 = []; // should be an error - is +>i1_error : I1 +>I1 : I1 +>[] : undefined[] + +var c1_error: C1 = []; // should be an error - is +>c1_error : C1 +>C1 : C1 +>[] : undefined[] + +var c2_error: C2 = []; // should be an error - is +>c2_error : C2 +>C2 : C2 +>[] : undefined[] + +var c3_error: C3 = []; // should be an error - is +>c3_error : C3 +>C3 : C3 +>[] : undefined[] + + +arr_any = arr_i1; // should be ok - is +>arr_any = arr_i1 : I1[] +>arr_any : any[] +>arr_i1 : I1[] + +arr_any = arr_c1; // should be ok - is +>arr_any = arr_c1 : C1[] +>arr_any : any[] +>arr_c1 : C1[] + +arr_any = arr_c2; // should be ok - is +>arr_any = arr_c2 : C2[] +>arr_any : any[] +>arr_c2 : C2[] + +arr_any = arr_c3; // should be ok - is +>arr_any = arr_c3 : C3[] +>arr_any : any[] +>arr_c3 : C3[] + +arr_i1 = arr_i1; // should be ok - subtype relationship - is +>arr_i1 = arr_i1 : I1[] +>arr_i1 : I1[] +>arr_i1 : I1[] + +arr_i1 = arr_c1; // should be ok - subtype relationship - is +>arr_i1 = arr_c1 : C1[] +>arr_i1 : I1[] +>arr_c1 : C1[] + +arr_i1 = arr_c2; // should be ok - subtype relationship - is +>arr_i1 = arr_c2 : C2[] +>arr_i1 : I1[] +>arr_c2 : C2[] + +arr_i1 = arr_c3; // should be an error - is +>arr_i1 = arr_c3 : C3[] +>arr_i1 : I1[] +>arr_c3 : C3[] + +arr_c1 = arr_c1; // should be ok - subtype relationship - is +>arr_c1 = arr_c1 : C1[] +>arr_c1 : C1[] +>arr_c1 : C1[] + +arr_c1 = arr_c2; // should be ok - subtype relationship - is +>arr_c1 = arr_c2 : C2[] +>arr_c1 : C1[] +>arr_c2 : C2[] + +arr_c1 = arr_i1; // should be an error - is +>arr_c1 = arr_i1 : I1[] +>arr_c1 : C1[] +>arr_i1 : I1[] + +arr_c1 = arr_c3; // should be an error - is +>arr_c1 = arr_c3 : C3[] +>arr_c1 : C1[] +>arr_c3 : C3[] + +arr_c2 = arr_c2; // should be ok - subtype relationship - is +>arr_c2 = arr_c2 : C2[] +>arr_c2 : C2[] +>arr_c2 : C2[] + +arr_c2 = arr_c1; // should be an error - subtype relationship - is +>arr_c2 = arr_c1 : C1[] +>arr_c2 : C2[] +>arr_c1 : C1[] + +arr_c2 = arr_i1; // should be an error - subtype relationship - is +>arr_c2 = arr_i1 : I1[] +>arr_c2 : C2[] +>arr_i1 : I1[] + +arr_c2 = arr_c3; // should be an error - is +>arr_c2 = arr_c3 : C3[] +>arr_c2 : C2[] +>arr_c3 : C3[] + +// "clean up bug" occurs at this point +// if you move these three expressions to another file, they raise an error +// something to do with state from the above propagating forward? +arr_c3 = arr_c2_2; // should be an error - is +>arr_c3 = arr_c2_2 : C2[] +>arr_c3 : C3[] +>arr_c2_2 : C2[] + +arr_c3 = arr_c1_2; // should be an error - is +>arr_c3 = arr_c1_2 : C1[] +>arr_c3 : C3[] +>arr_c1_2 : C1[] + +arr_c3 = arr_i1_2; // should be an error - is +>arr_c3 = arr_i1_2 : I1[] +>arr_c3 : C3[] +>arr_i1_2 : I1[] + +arr_any = f1; // should be an error - is +>arr_any = f1 : () => C1 +>arr_any : any[] +>f1 : () => C1 + +arr_any = o1; // should be an error - is +>arr_any = o1 : { one: number; } +>arr_any : any[] +>o1 : { one: number; } + +arr_any = a1; // should be ok - is +>arr_any = a1 : any +>arr_any : any[] +>a1 : any + +arr_any = c1; // should be an error - is +>arr_any = c1 : C1 +>arr_any : any[] +>c1 : C1 + +arr_any = c2; // should be an error - is +>arr_any = c2 : C2 +>arr_any : any[] +>c2 : C2 + +arr_any = c3; // should be an error - is +>arr_any = c3 : C3 +>arr_any : any[] +>c3 : C3 + +arr_any = i1; // should be an error - is +>arr_any = i1 : I1 +>arr_any : any[] +>i1 : I1 + diff --git a/tests/baselines/reference/arrayAssignmentTest2.symbols b/tests/baselines/reference/arrayAssignmentTest2.symbols new file mode 100644 index 00000000000..e96f15fb5b1 --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest2.symbols @@ -0,0 +1,153 @@ +=== tests/cases/compiler/arrayAssignmentTest2.ts === +interface I1 { +>I1 : Symbol(I1, Decl(arrayAssignmentTest2.ts, 0, 0)) + + IM1():void[]; +>IM1 : Symbol(I1.IM1, Decl(arrayAssignmentTest2.ts, 0, 14)) +} + +class C1 implements I1 { +>C1 : Symbol(C1, Decl(arrayAssignmentTest2.ts, 2, 1)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest2.ts, 0, 0)) + + IM1():void[] {return null;} +>IM1 : Symbol(C1.IM1, Decl(arrayAssignmentTest2.ts, 4, 24)) + + C1M1():C1[] {return null;} +>C1M1 : Symbol(C1.C1M1, Decl(arrayAssignmentTest2.ts, 5, 28)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest2.ts, 2, 1)) + } +class C2 extends C1 { +>C2 : Symbol(C2, Decl(arrayAssignmentTest2.ts, 7, 2)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest2.ts, 2, 1)) + + C2M1():C2[] { return null;} +>C2M1 : Symbol(C2.C2M1, Decl(arrayAssignmentTest2.ts, 8, 21)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest2.ts, 7, 2)) +} + +class C3 { +>C3 : Symbol(C3, Decl(arrayAssignmentTest2.ts, 10, 1)) + + CM3M1() { return 3;} +>CM3M1 : Symbol(C3.CM3M1, Decl(arrayAssignmentTest2.ts, 12, 10)) +} + + +/* + +This behaves unexpectedly with the following types: + +Type 1 of any[]: + +* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[]. + +* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass. + +*/ +var a1 : any = null; +>a1 : Symbol(a1, Decl(arrayAssignmentTest2.ts, 28, 3)) + +var c1 : C1 = new C1(); +>c1 : Symbol(c1, Decl(arrayAssignmentTest2.ts, 29, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest2.ts, 2, 1)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest2.ts, 2, 1)) + +var i1 : I1 = c1; +>i1 : Symbol(i1, Decl(arrayAssignmentTest2.ts, 30, 3)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest2.ts, 0, 0)) +>c1 : Symbol(c1, Decl(arrayAssignmentTest2.ts, 29, 3)) + +var c2 : C2 = new C2(); +>c2 : Symbol(c2, Decl(arrayAssignmentTest2.ts, 31, 3)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest2.ts, 7, 2)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest2.ts, 7, 2)) + +var c3 : C3 = new C3(); +>c3 : Symbol(c3, Decl(arrayAssignmentTest2.ts, 32, 3)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest2.ts, 10, 1)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest2.ts, 10, 1)) + +var o1 = {one : 1}; +>o1 : Symbol(o1, Decl(arrayAssignmentTest2.ts, 33, 3)) +>one : Symbol(one, Decl(arrayAssignmentTest2.ts, 33, 10)) + +var f1 = function () { return new C1();} +>f1 : Symbol(f1, Decl(arrayAssignmentTest2.ts, 34, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest2.ts, 2, 1)) + +var arr_any: any[] = []; +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) + +var arr_i1: I1[] = []; +>arr_i1 : Symbol(arr_i1, Decl(arrayAssignmentTest2.ts, 37, 3)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest2.ts, 0, 0)) + +var arr_c1: C1[] = []; +>arr_c1 : Symbol(arr_c1, Decl(arrayAssignmentTest2.ts, 38, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest2.ts, 2, 1)) + +var arr_c2: C2[] = []; +>arr_c2 : Symbol(arr_c2, Decl(arrayAssignmentTest2.ts, 39, 3)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest2.ts, 7, 2)) + +var arr_i1_2: I1[] = []; +>arr_i1_2 : Symbol(arr_i1_2, Decl(arrayAssignmentTest2.ts, 40, 3)) +>I1 : Symbol(I1, Decl(arrayAssignmentTest2.ts, 0, 0)) + +var arr_c1_2: C1[] = []; +>arr_c1_2 : Symbol(arr_c1_2, Decl(arrayAssignmentTest2.ts, 41, 3)) +>C1 : Symbol(C1, Decl(arrayAssignmentTest2.ts, 2, 1)) + +var arr_c2_2: C2[] = []; +>arr_c2_2 : Symbol(arr_c2_2, Decl(arrayAssignmentTest2.ts, 42, 3)) +>C2 : Symbol(C2, Decl(arrayAssignmentTest2.ts, 7, 2)) + +var arr_c3: C3[] = []; +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest2.ts, 43, 3)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest2.ts, 10, 1)) + +// "clean up error" occurs at this point +arr_c3 = arr_c2_2; // should be an error - is +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest2.ts, 43, 3)) +>arr_c2_2 : Symbol(arr_c2_2, Decl(arrayAssignmentTest2.ts, 42, 3)) + +arr_c3 = arr_c1_2; // should be an error - is +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest2.ts, 43, 3)) +>arr_c1_2 : Symbol(arr_c1_2, Decl(arrayAssignmentTest2.ts, 41, 3)) + +arr_c3 = arr_i1_2; // should be an error - is +>arr_c3 : Symbol(arr_c3, Decl(arrayAssignmentTest2.ts, 43, 3)) +>arr_i1_2 : Symbol(arr_i1_2, Decl(arrayAssignmentTest2.ts, 40, 3)) + +arr_any = f1; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) +>f1 : Symbol(f1, Decl(arrayAssignmentTest2.ts, 34, 3)) + +arr_any = function () { return null;} // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) + +arr_any = o1; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) +>o1 : Symbol(o1, Decl(arrayAssignmentTest2.ts, 33, 3)) + +arr_any = a1; // should be ok - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) +>a1 : Symbol(a1, Decl(arrayAssignmentTest2.ts, 28, 3)) + +arr_any = c1; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) +>c1 : Symbol(c1, Decl(arrayAssignmentTest2.ts, 29, 3)) + +arr_any = c2; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) +>c2 : Symbol(c2, Decl(arrayAssignmentTest2.ts, 31, 3)) + +arr_any = c3; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) +>c3 : Symbol(c3, Decl(arrayAssignmentTest2.ts, 32, 3)) + +arr_any = i1; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest2.ts, 36, 3)) +>i1 : Symbol(i1, Decl(arrayAssignmentTest2.ts, 30, 3)) + diff --git a/tests/baselines/reference/arrayAssignmentTest2.types b/tests/baselines/reference/arrayAssignmentTest2.types new file mode 100644 index 00000000000..86d35b06d07 --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest2.types @@ -0,0 +1,186 @@ +=== tests/cases/compiler/arrayAssignmentTest2.ts === +interface I1 { +>I1 : I1 + + IM1():void[]; +>IM1 : () => void[] +} + +class C1 implements I1 { +>C1 : C1 +>I1 : I1 + + IM1():void[] {return null;} +>IM1 : () => void[] +>null : null + + C1M1():C1[] {return null;} +>C1M1 : () => C1[] +>C1 : C1 +>null : null + } +class C2 extends C1 { +>C2 : C2 +>C1 : C1 + + C2M1():C2[] { return null;} +>C2M1 : () => C2[] +>C2 : C2 +>null : null +} + +class C3 { +>C3 : C3 + + CM3M1() { return 3;} +>CM3M1 : () => number +>3 : 3 +} + + +/* + +This behaves unexpectedly with the following types: + +Type 1 of any[]: + +* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[]. + +* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass. + +*/ +var a1 : any = null; +>a1 : any +>null : null + +var c1 : C1 = new C1(); +>c1 : C1 +>C1 : C1 +>new C1() : C1 +>C1 : typeof C1 + +var i1 : I1 = c1; +>i1 : I1 +>I1 : I1 +>c1 : C1 + +var c2 : C2 = new C2(); +>c2 : C2 +>C2 : C2 +>new C2() : C2 +>C2 : typeof C2 + +var c3 : C3 = new C3(); +>c3 : C3 +>C3 : C3 +>new C3() : C3 +>C3 : typeof C3 + +var o1 = {one : 1}; +>o1 : { one: number; } +>{one : 1} : { one: number; } +>one : number +>1 : 1 + +var f1 = function () { return new C1();} +>f1 : () => C1 +>function () { return new C1();} : () => C1 +>new C1() : C1 +>C1 : typeof C1 + +var arr_any: any[] = []; +>arr_any : any[] +>[] : undefined[] + +var arr_i1: I1[] = []; +>arr_i1 : I1[] +>I1 : I1 +>[] : undefined[] + +var arr_c1: C1[] = []; +>arr_c1 : C1[] +>C1 : C1 +>[] : undefined[] + +var arr_c2: C2[] = []; +>arr_c2 : C2[] +>C2 : C2 +>[] : undefined[] + +var arr_i1_2: I1[] = []; +>arr_i1_2 : I1[] +>I1 : I1 +>[] : undefined[] + +var arr_c1_2: C1[] = []; +>arr_c1_2 : C1[] +>C1 : C1 +>[] : undefined[] + +var arr_c2_2: C2[] = []; +>arr_c2_2 : C2[] +>C2 : C2 +>[] : undefined[] + +var arr_c3: C3[] = []; +>arr_c3 : C3[] +>C3 : C3 +>[] : undefined[] + +// "clean up error" occurs at this point +arr_c3 = arr_c2_2; // should be an error - is +>arr_c3 = arr_c2_2 : C2[] +>arr_c3 : C3[] +>arr_c2_2 : C2[] + +arr_c3 = arr_c1_2; // should be an error - is +>arr_c3 = arr_c1_2 : C1[] +>arr_c3 : C3[] +>arr_c1_2 : C1[] + +arr_c3 = arr_i1_2; // should be an error - is +>arr_c3 = arr_i1_2 : I1[] +>arr_c3 : C3[] +>arr_i1_2 : I1[] + +arr_any = f1; // should be an error - is +>arr_any = f1 : () => C1 +>arr_any : any[] +>f1 : () => C1 + +arr_any = function () { return null;} // should be an error - is +>arr_any = function () { return null;} : () => any +>arr_any : any[] +>function () { return null;} : () => any +>null : null + +arr_any = o1; // should be an error - is +>arr_any = o1 : { one: number; } +>arr_any : any[] +>o1 : { one: number; } + +arr_any = a1; // should be ok - is +>arr_any = a1 : any +>arr_any : any[] +>a1 : any + +arr_any = c1; // should be an error - is +>arr_any = c1 : C1 +>arr_any : any[] +>c1 : C1 + +arr_any = c2; // should be an error - is +>arr_any = c2 : C2 +>arr_any : any[] +>c2 : C2 + +arr_any = c3; // should be an error - is +>arr_any = c3 : C3 +>arr_any : any[] +>c3 : C3 + +arr_any = i1; // should be an error - is +>arr_any = i1 : I1 +>arr_any : any[] +>i1 : I1 + diff --git a/tests/baselines/reference/arrayAssignmentTest3.symbols b/tests/baselines/reference/arrayAssignmentTest3.symbols new file mode 100644 index 00000000000..7b0907f94eb --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest3.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/arrayAssignmentTest3.ts === +// The following gives no error +// Michal saw no error if he used number instead of B, +// but I do... +class B {} +>B : Symbol(B, Decl(arrayAssignmentTest3.ts, 0, 0)) + +class a { +>a : Symbol(a, Decl(arrayAssignmentTest3.ts, 3, 10)) + + constructor(public x: string, public y: number, z: B[]) { } +>x : Symbol(a.x, Decl(arrayAssignmentTest3.ts, 6, 16)) +>y : Symbol(a.y, Decl(arrayAssignmentTest3.ts, 6, 33)) +>z : Symbol(z, Decl(arrayAssignmentTest3.ts, 6, 51)) +>B : Symbol(B, Decl(arrayAssignmentTest3.ts, 0, 0)) +} + + + +var xx = new a(null, 7, new B()); +>xx : Symbol(xx, Decl(arrayAssignmentTest3.ts, 11, 3)) +>a : Symbol(a, Decl(arrayAssignmentTest3.ts, 3, 10)) +>B : Symbol(B, Decl(arrayAssignmentTest3.ts, 0, 0)) + + diff --git a/tests/baselines/reference/arrayAssignmentTest3.types b/tests/baselines/reference/arrayAssignmentTest3.types new file mode 100644 index 00000000000..1a3e1e3805e --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest3.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/arrayAssignmentTest3.ts === +// The following gives no error +// Michal saw no error if he used number instead of B, +// but I do... +class B {} +>B : B + +class a { +>a : a + + constructor(public x: string, public y: number, z: B[]) { } +>x : string +>y : number +>z : B[] +>B : B +} + + + +var xx = new a(null, 7, new B()); +>xx : any +>new a(null, 7, new B()) : any +>a : typeof a +>null : null +>7 : 7 +>new B() : B +>B : typeof B + + diff --git a/tests/baselines/reference/arrayAssignmentTest4.symbols b/tests/baselines/reference/arrayAssignmentTest4.symbols new file mode 100644 index 00000000000..f8928f4ae9c --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest4.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/arrayAssignmentTest4.ts === +class C3 { +>C3 : Symbol(C3, Decl(arrayAssignmentTest4.ts, 0, 0)) + + CM3M1() { return 3;} +>CM3M1 : Symbol(C3.CM3M1, Decl(arrayAssignmentTest4.ts, 0, 10)) +} + + +/* + +This behaves unexpectedly with teh following types: + +Type 1 of any[]: + +* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[]. + +* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass. + +*/ +var c3 : C3 = new C3(); +>c3 : Symbol(c3, Decl(arrayAssignmentTest4.ts, 16, 3)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest4.ts, 0, 0)) +>C3 : Symbol(C3, Decl(arrayAssignmentTest4.ts, 0, 0)) + +var o1 = {one : 1}; +>o1 : Symbol(o1, Decl(arrayAssignmentTest4.ts, 17, 3)) +>one : Symbol(one, Decl(arrayAssignmentTest4.ts, 17, 10)) + +var arr_any: any[] = []; +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest4.ts, 19, 3)) + +arr_any = function () { return null;} // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest4.ts, 19, 3)) + +arr_any = c3; // should be an error - is +>arr_any : Symbol(arr_any, Decl(arrayAssignmentTest4.ts, 19, 3)) +>c3 : Symbol(c3, Decl(arrayAssignmentTest4.ts, 16, 3)) + diff --git a/tests/baselines/reference/arrayAssignmentTest4.types b/tests/baselines/reference/arrayAssignmentTest4.types new file mode 100644 index 00000000000..c80591a8b1f --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest4.types @@ -0,0 +1,48 @@ +=== tests/cases/compiler/arrayAssignmentTest4.ts === +class C3 { +>C3 : C3 + + CM3M1() { return 3;} +>CM3M1 : () => number +>3 : 3 +} + + +/* + +This behaves unexpectedly with teh following types: + +Type 1 of any[]: + +* Type 2 of the following throws an error but shouldn't: () => void[], SomeClass[], and {one: 1}[]. + +* Type 2 of the following doesn't throw an error but should: {one: 1}, new() => SomeClass, SomeClass. + +*/ +var c3 : C3 = new C3(); +>c3 : C3 +>C3 : C3 +>new C3() : C3 +>C3 : typeof C3 + +var o1 = {one : 1}; +>o1 : { one: number; } +>{one : 1} : { one: number; } +>one : number +>1 : 1 + +var arr_any: any[] = []; +>arr_any : any[] +>[] : undefined[] + +arr_any = function () { return null;} // should be an error - is +>arr_any = function () { return null;} : () => any +>arr_any : any[] +>function () { return null;} : () => any +>null : null + +arr_any = c3; // should be an error - is +>arr_any = c3 : C3 +>arr_any : any[] +>c3 : C3 + diff --git a/tests/baselines/reference/arrayAssignmentTest5.symbols b/tests/baselines/reference/arrayAssignmentTest5.symbols new file mode 100644 index 00000000000..b85fa17ee1e --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest5.symbols @@ -0,0 +1,109 @@ +=== tests/cases/compiler/arrayAssignmentTest5.ts === +module Test { +>Test : Symbol(Test, Decl(arrayAssignmentTest5.ts, 0, 0)) + + interface IState { +>IState : Symbol(IState, Decl(arrayAssignmentTest5.ts, 0, 13)) + } + interface IToken { +>IToken : Symbol(IToken, Decl(arrayAssignmentTest5.ts, 2, 5)) + + startIndex: number; +>startIndex : Symbol(IToken.startIndex, Decl(arrayAssignmentTest5.ts, 3, 22)) + } + interface IStateToken extends IToken { +>IStateToken : Symbol(IStateToken, Decl(arrayAssignmentTest5.ts, 5, 5)) +>IToken : Symbol(IToken, Decl(arrayAssignmentTest5.ts, 2, 5)) + + state: IState; +>state : Symbol(IStateToken.state, Decl(arrayAssignmentTest5.ts, 6, 42)) +>IState : Symbol(IState, Decl(arrayAssignmentTest5.ts, 0, 13)) + } + interface ILineTokens { +>ILineTokens : Symbol(ILineTokens, Decl(arrayAssignmentTest5.ts, 8, 5)) + + tokens: IToken[]; +>tokens : Symbol(ILineTokens.tokens, Decl(arrayAssignmentTest5.ts, 9, 27)) +>IToken : Symbol(IToken, Decl(arrayAssignmentTest5.ts, 2, 5)) + + endState: IState; +>endState : Symbol(ILineTokens.endState, Decl(arrayAssignmentTest5.ts, 10, 25)) +>IState : Symbol(IState, Decl(arrayAssignmentTest5.ts, 0, 13)) + } + interface IAction { +>IAction : Symbol(IAction, Decl(arrayAssignmentTest5.ts, 12, 5)) + } + interface IMode { +>IMode : Symbol(IMode, Decl(arrayAssignmentTest5.ts, 14, 5)) + + onEnter(line:string, state:IState, offset:number):IAction; +>onEnter : Symbol(IMode.onEnter, Decl(arrayAssignmentTest5.ts, 15, 21)) +>line : Symbol(line, Decl(arrayAssignmentTest5.ts, 16, 16)) +>state : Symbol(state, Decl(arrayAssignmentTest5.ts, 16, 28)) +>IState : Symbol(IState, Decl(arrayAssignmentTest5.ts, 0, 13)) +>offset : Symbol(offset, Decl(arrayAssignmentTest5.ts, 16, 42)) +>IAction : Symbol(IAction, Decl(arrayAssignmentTest5.ts, 12, 5)) + + tokenize(line:string, state:IState, includeStates:boolean):ILineTokens; +>tokenize : Symbol(IMode.tokenize, Decl(arrayAssignmentTest5.ts, 16, 66)) +>line : Symbol(line, Decl(arrayAssignmentTest5.ts, 17, 17)) +>state : Symbol(state, Decl(arrayAssignmentTest5.ts, 17, 29)) +>IState : Symbol(IState, Decl(arrayAssignmentTest5.ts, 0, 13)) +>includeStates : Symbol(includeStates, Decl(arrayAssignmentTest5.ts, 17, 43)) +>ILineTokens : Symbol(ILineTokens, Decl(arrayAssignmentTest5.ts, 8, 5)) + } + export class Bug implements IMode { +>Bug : Symbol(Bug, Decl(arrayAssignmentTest5.ts, 18, 5)) +>IMode : Symbol(IMode, Decl(arrayAssignmentTest5.ts, 14, 5)) + + public onEnter(line:string, state:IState, offset:number):IAction { +>onEnter : Symbol(Bug.onEnter, Decl(arrayAssignmentTest5.ts, 19, 39)) +>line : Symbol(line, Decl(arrayAssignmentTest5.ts, 20, 23)) +>state : Symbol(state, Decl(arrayAssignmentTest5.ts, 20, 35)) +>IState : Symbol(IState, Decl(arrayAssignmentTest5.ts, 0, 13)) +>offset : Symbol(offset, Decl(arrayAssignmentTest5.ts, 20, 49)) +>IAction : Symbol(IAction, Decl(arrayAssignmentTest5.ts, 12, 5)) + + var lineTokens:ILineTokens= this.tokenize(line, state, true); +>lineTokens : Symbol(lineTokens, Decl(arrayAssignmentTest5.ts, 21, 15)) +>ILineTokens : Symbol(ILineTokens, Decl(arrayAssignmentTest5.ts, 8, 5)) +>this.tokenize : Symbol(Bug.tokenize, Decl(arrayAssignmentTest5.ts, 26, 9)) +>this : Symbol(Bug, Decl(arrayAssignmentTest5.ts, 18, 5)) +>tokenize : Symbol(Bug.tokenize, Decl(arrayAssignmentTest5.ts, 26, 9)) +>line : Symbol(line, Decl(arrayAssignmentTest5.ts, 20, 23)) +>state : Symbol(state, Decl(arrayAssignmentTest5.ts, 20, 35)) + + var tokens:IStateToken[]= lineTokens.tokens; +>tokens : Symbol(tokens, Decl(arrayAssignmentTest5.ts, 22, 15)) +>IStateToken : Symbol(IStateToken, Decl(arrayAssignmentTest5.ts, 5, 5)) +>lineTokens.tokens : Symbol(ILineTokens.tokens, Decl(arrayAssignmentTest5.ts, 9, 27)) +>lineTokens : Symbol(lineTokens, Decl(arrayAssignmentTest5.ts, 21, 15)) +>tokens : Symbol(ILineTokens.tokens, Decl(arrayAssignmentTest5.ts, 9, 27)) + + if (tokens.length === 0) { +>tokens.length : Symbol(Array.length, Decl(lib.d.ts, --, --)) +>tokens : Symbol(tokens, Decl(arrayAssignmentTest5.ts, 22, 15)) +>length : Symbol(Array.length, Decl(lib.d.ts, --, --)) + + return this.onEnter(line, tokens, offset); // <== this should produce an error since onEnter can not be called with (string, IStateToken[], offset) +>this.onEnter : Symbol(Bug.onEnter, Decl(arrayAssignmentTest5.ts, 19, 39)) +>this : Symbol(Bug, Decl(arrayAssignmentTest5.ts, 18, 5)) +>onEnter : Symbol(Bug.onEnter, Decl(arrayAssignmentTest5.ts, 19, 39)) +>line : Symbol(line, Decl(arrayAssignmentTest5.ts, 20, 23)) +>tokens : Symbol(tokens, Decl(arrayAssignmentTest5.ts, 22, 15)) +>offset : Symbol(offset, Decl(arrayAssignmentTest5.ts, 20, 49)) + } + } + public tokenize(line:string, state:IState, includeStates:boolean):ILineTokens { +>tokenize : Symbol(Bug.tokenize, Decl(arrayAssignmentTest5.ts, 26, 9)) +>line : Symbol(line, Decl(arrayAssignmentTest5.ts, 27, 24)) +>state : Symbol(state, Decl(arrayAssignmentTest5.ts, 27, 36)) +>IState : Symbol(IState, Decl(arrayAssignmentTest5.ts, 0, 13)) +>includeStates : Symbol(includeStates, Decl(arrayAssignmentTest5.ts, 27, 50)) +>ILineTokens : Symbol(ILineTokens, Decl(arrayAssignmentTest5.ts, 8, 5)) + + return null; + } + } +} + diff --git a/tests/baselines/reference/arrayAssignmentTest5.types b/tests/baselines/reference/arrayAssignmentTest5.types new file mode 100644 index 00000000000..7e8d2e0d39b --- /dev/null +++ b/tests/baselines/reference/arrayAssignmentTest5.types @@ -0,0 +1,115 @@ +=== tests/cases/compiler/arrayAssignmentTest5.ts === +module Test { +>Test : typeof Test + + interface IState { +>IState : IState + } + interface IToken { +>IToken : IToken + + startIndex: number; +>startIndex : number + } + interface IStateToken extends IToken { +>IStateToken : IStateToken +>IToken : IToken + + state: IState; +>state : IState +>IState : IState + } + interface ILineTokens { +>ILineTokens : ILineTokens + + tokens: IToken[]; +>tokens : IToken[] +>IToken : IToken + + endState: IState; +>endState : IState +>IState : IState + } + interface IAction { +>IAction : IAction + } + interface IMode { +>IMode : IMode + + onEnter(line:string, state:IState, offset:number):IAction; +>onEnter : (line: string, state: IState, offset: number) => IAction +>line : string +>state : IState +>IState : IState +>offset : number +>IAction : IAction + + tokenize(line:string, state:IState, includeStates:boolean):ILineTokens; +>tokenize : (line: string, state: IState, includeStates: boolean) => ILineTokens +>line : string +>state : IState +>IState : IState +>includeStates : boolean +>ILineTokens : ILineTokens + } + export class Bug implements IMode { +>Bug : Bug +>IMode : IMode + + public onEnter(line:string, state:IState, offset:number):IAction { +>onEnter : (line: string, state: IState, offset: number) => IAction +>line : string +>state : IState +>IState : IState +>offset : number +>IAction : IAction + + var lineTokens:ILineTokens= this.tokenize(line, state, true); +>lineTokens : ILineTokens +>ILineTokens : ILineTokens +>this.tokenize(line, state, true) : ILineTokens +>this.tokenize : (line: string, state: IState, includeStates: boolean) => ILineTokens +>this : this +>tokenize : (line: string, state: IState, includeStates: boolean) => ILineTokens +>line : string +>state : IState +>true : true + + var tokens:IStateToken[]= lineTokens.tokens; +>tokens : IStateToken[] +>IStateToken : IStateToken +>lineTokens.tokens : IToken[] +>lineTokens : ILineTokens +>tokens : IToken[] + + if (tokens.length === 0) { +>tokens.length === 0 : boolean +>tokens.length : number +>tokens : IStateToken[] +>length : number +>0 : 0 + + return this.onEnter(line, tokens, offset); // <== this should produce an error since onEnter can not be called with (string, IStateToken[], offset) +>this.onEnter(line, tokens, offset) : IAction +>this.onEnter : (line: string, state: IState, offset: number) => IAction +>this : this +>onEnter : (line: string, state: IState, offset: number) => IAction +>line : string +>tokens : IStateToken[] +>offset : number + } + } + public tokenize(line:string, state:IState, includeStates:boolean):ILineTokens { +>tokenize : (line: string, state: IState, includeStates: boolean) => ILineTokens +>line : string +>state : IState +>IState : IState +>includeStates : boolean +>ILineTokens : ILineTokens + + return null; +>null : null + } + } +} + diff --git a/tests/baselines/reference/arrayCast.symbols b/tests/baselines/reference/arrayCast.symbols new file mode 100644 index 00000000000..668ca3a79d5 --- /dev/null +++ b/tests/baselines/reference/arrayCast.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/arrayCast.ts === +// Should fail. Even though the array is contextually typed with { id: number }[], it still +// has type { foo: string }[], which is not assignable to { id: number }[]. +<{ id: number; }[]>[{ foo: "s" }]; +>id : Symbol(id, Decl(arrayCast.ts, 2, 2)) +>foo : Symbol(foo, Decl(arrayCast.ts, 2, 21)) + +// Should succeed, as the {} element causes the type of the array to be {}[] +<{ id: number; }[]>[{ foo: "s" }, {}]; +>id : Symbol(id, Decl(arrayCast.ts, 5, 2)) +>foo : Symbol(foo, Decl(arrayCast.ts, 5, 21)) + diff --git a/tests/baselines/reference/arrayCast.types b/tests/baselines/reference/arrayCast.types new file mode 100644 index 00000000000..ed536d0a60a --- /dev/null +++ b/tests/baselines/reference/arrayCast.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/arrayCast.ts === +// Should fail. Even though the array is contextually typed with { id: number }[], it still +// has type { foo: string }[], which is not assignable to { id: number }[]. +<{ id: number; }[]>[{ foo: "s" }]; +><{ id: number; }[]>[{ foo: "s" }] : { id: number; }[] +>id : number +>[{ foo: "s" }] : { foo: string; }[] +>{ foo: "s" } : { foo: string; } +>foo : string +>"s" : "s" + +// Should succeed, as the {} element causes the type of the array to be {}[] +<{ id: number; }[]>[{ foo: "s" }, {}]; +><{ id: number; }[]>[{ foo: "s" }, {}] : { id: number; }[] +>id : number +>[{ foo: "s" }, {}] : ({ foo: string; } | {})[] +>{ foo: "s" } : { foo: string; } +>foo : string +>"s" : "s" +>{} : {} + diff --git a/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.symbols b/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.symbols new file mode 100644 index 00000000000..dbe484bcf0f --- /dev/null +++ b/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.symbols @@ -0,0 +1,41 @@ +=== tests/cases/compiler/arrayLiteralAndArrayConstructorEquivalence1.ts === +var myCars=new Array(); +>myCars : Symbol(myCars, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 0, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var myCars3 = new Array({}); +>myCars3 : Symbol(myCars3, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 1, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var myCars4: Array; // error +>myCars4 : Symbol(myCars4, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 2, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var myCars5: Array[]; +>myCars5 : Symbol(myCars5, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 3, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +myCars = myCars3; +>myCars : Symbol(myCars, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 0, 3)) +>myCars3 : Symbol(myCars3, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 1, 3)) + +myCars = myCars4; +>myCars : Symbol(myCars, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 0, 3)) +>myCars4 : Symbol(myCars4, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 2, 3)) + +myCars = myCars5; +>myCars : Symbol(myCars, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 0, 3)) +>myCars5 : Symbol(myCars5, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 3, 3)) + +myCars3 = myCars; +>myCars3 : Symbol(myCars3, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 1, 3)) +>myCars : Symbol(myCars, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 0, 3)) + +myCars3 = myCars4; +>myCars3 : Symbol(myCars3, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 1, 3)) +>myCars4 : Symbol(myCars4, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 2, 3)) + +myCars3 = myCars5; +>myCars3 : Symbol(myCars3, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 1, 3)) +>myCars5 : Symbol(myCars5, Decl(arrayLiteralAndArrayConstructorEquivalence1.ts, 3, 3)) + diff --git a/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.types b/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.types new file mode 100644 index 00000000000..ea4803c0244 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralAndArrayConstructorEquivalence1.types @@ -0,0 +1,50 @@ +=== tests/cases/compiler/arrayLiteralAndArrayConstructorEquivalence1.ts === +var myCars=new Array(); +>myCars : any[] +>new Array() : any[] +>Array : ArrayConstructor + +var myCars3 = new Array({}); +>myCars3 : {}[] +>new Array({}) : {}[] +>Array : ArrayConstructor +>{} : {} + +var myCars4: Array; // error +>myCars4 : any +>Array : T[] + +var myCars5: Array[]; +>myCars5 : any[][] +>Array : T[] + +myCars = myCars3; +>myCars = myCars3 : {}[] +>myCars : any[] +>myCars3 : {}[] + +myCars = myCars4; +>myCars = myCars4 : any +>myCars : any[] +>myCars4 : any + +myCars = myCars5; +>myCars = myCars5 : any[][] +>myCars : any[] +>myCars5 : any[][] + +myCars3 = myCars; +>myCars3 = myCars : any[] +>myCars3 : {}[] +>myCars : any[] + +myCars3 = myCars4; +>myCars3 = myCars4 : any +>myCars3 : {}[] +>myCars4 : any + +myCars3 = myCars5; +>myCars3 = myCars5 : any[][] +>myCars3 : {}[] +>myCars5 : any[][] + diff --git a/tests/baselines/reference/arrayLiteralExpressionContextualTyping.symbols b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.symbols new file mode 100644 index 00000000000..23458bf3636 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts === +// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by +// the type of the property with the numeric name N in the contextual type, if any, or otherwise +// the numeric index type of the contextual type, if any. +var array = [1, 2, 3]; +>array : Symbol(array, Decl(arrayLiteralExpressionContextualTyping.ts, 3, 3)) + +var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type +>array1 : Symbol(array1, Decl(arrayLiteralExpressionContextualTyping.ts, 4, 3)) + +var tup: [number, number, number] = [1, 2, 3, 4]; +>tup : Symbol(tup, Decl(arrayLiteralExpressionContextualTyping.ts, 5, 3)) + +var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"]; +>tup1 : Symbol(tup1, Decl(arrayLiteralExpressionContextualTyping.ts, 6, 3)) + +var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error +>tup2 : Symbol(tup2, Decl(arrayLiteralExpressionContextualTyping.ts, 7, 3)) + +// In a contextually typed array literal expression containing one or more spread elements, +// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. +var spr = [1, 2, 3, ...array]; +>spr : Symbol(spr, Decl(arrayLiteralExpressionContextualTyping.ts, 11, 3)) +>array : Symbol(array, Decl(arrayLiteralExpressionContextualTyping.ts, 3, 3)) + +var spr1 = [1, 2, 3, ...tup]; +>spr1 : Symbol(spr1, Decl(arrayLiteralExpressionContextualTyping.ts, 12, 3)) +>tup : Symbol(tup, Decl(arrayLiteralExpressionContextualTyping.ts, 5, 3)) + +var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error +>spr2 : Symbol(spr2, Decl(arrayLiteralExpressionContextualTyping.ts, 13, 3)) +>tup : Symbol(tup, Decl(arrayLiteralExpressionContextualTyping.ts, 5, 3)) + diff --git a/tests/baselines/reference/arrayLiteralExpressionContextualTyping.types b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.types new file mode 100644 index 00000000000..5954448c984 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralExpressionContextualTyping.types @@ -0,0 +1,71 @@ +=== tests/cases/conformance/expressions/contextualTyping/arrayLiteralExpressionContextualTyping.ts === +// In a contextually typed array literal expression containing no spread elements, an element expression at index N is contextually typed by +// the type of the property with the numeric name N in the contextual type, if any, or otherwise +// the numeric index type of the contextual type, if any. +var array = [1, 2, 3]; +>array : number[] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + +var array1 = [true, 2, 3]; // Contextual type by the numeric index type of the contextual type +>array1 : (number | boolean)[] +>[true, 2, 3] : (number | boolean)[] +>true : true +>2 : 2 +>3 : 3 + +var tup: [number, number, number] = [1, 2, 3, 4]; +>tup : [number, number, number] +>[1, 2, 3, 4] : [number, number, number, number] +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + +var tup1: [number|string, number|string, number|string] = [1, 2, 3, "string"]; +>tup1 : [string | number, string | number, string | number] +>[1, 2, 3, "string"] : [number, number, number, string] +>1 : 1 +>2 : 2 +>3 : 3 +>"string" : "string" + +var tup2: [number, number, number] = [1, 2, 3, "string"]; // Error +>tup2 : [number, number, number] +>[1, 2, 3, "string"] : [number, number, number, string] +>1 : 1 +>2 : 2 +>3 : 3 +>"string" : "string" + +// In a contextually typed array literal expression containing one or more spread elements, +// an element expression at index N is contextually typed by the numeric index type of the contextual type, if any. +var spr = [1, 2, 3, ...array]; +>spr : number[] +>[1, 2, 3, ...array] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>...array : number +>array : number[] + +var spr1 = [1, 2, 3, ...tup]; +>spr1 : number[] +>[1, 2, 3, ...tup] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>...tup : number +>tup : [number, number, number] + +var spr2:[number, number, number] = [1, 2, 3, ...tup]; // Error +>spr2 : [number, number, number] +>[1, 2, 3, ...tup] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>...tup : number +>tup : [number, number, number] + diff --git a/tests/baselines/reference/arrayLiteralTypeInference.symbols b/tests/baselines/reference/arrayLiteralTypeInference.symbols new file mode 100644 index 00000000000..9f95dec0aaa --- /dev/null +++ b/tests/baselines/reference/arrayLiteralTypeInference.symbols @@ -0,0 +1,113 @@ +=== tests/cases/compiler/arrayLiteralTypeInference.ts === +class Action { +>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) + + id: number; +>id : Symbol(Action.id, Decl(arrayLiteralTypeInference.ts, 0, 14)) +} + +class ActionA extends Action { +>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) +>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) + + value: string; +>value : Symbol(ActionA.value, Decl(arrayLiteralTypeInference.ts, 4, 30)) +} + +class ActionB extends Action { +>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) +>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) + + trueNess: boolean; +>trueNess : Symbol(ActionB.trueNess, Decl(arrayLiteralTypeInference.ts, 8, 30)) +} + +var x1: Action[] = [ +>x1 : Symbol(x1, Decl(arrayLiteralTypeInference.ts, 12, 3)) +>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) + + { id: 2, trueness: false }, +>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 13, 5)) +>trueness : Symbol(trueness, Decl(arrayLiteralTypeInference.ts, 13, 12)) + + { id: 3, name: "three" } +>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 14, 5)) +>name : Symbol(name, Decl(arrayLiteralTypeInference.ts, 14, 12)) + +] + +var x2: Action[] = [ +>x2 : Symbol(x2, Decl(arrayLiteralTypeInference.ts, 17, 3)) +>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) + + new ActionA(), +>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) + + new ActionB() +>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) + +] + +var x3: Action[] = [ +>x3 : Symbol(x3, Decl(arrayLiteralTypeInference.ts, 22, 3)) +>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) + + new Action(), +>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) + + new ActionA(), +>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) + + new ActionB() +>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) + +] + +var z1: { id: number }[] = +>z1 : Symbol(z1, Decl(arrayLiteralTypeInference.ts, 28, 3)) +>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 28, 9)) + + [ + { id: 2, trueness: false }, +>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 30, 9)) +>trueness : Symbol(trueness, Decl(arrayLiteralTypeInference.ts, 30, 16)) + + { id: 3, name: "three" } +>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 31, 9)) +>name : Symbol(name, Decl(arrayLiteralTypeInference.ts, 31, 16)) + + ] + +var z2: { id: number }[] = +>z2 : Symbol(z2, Decl(arrayLiteralTypeInference.ts, 34, 3)) +>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 34, 9)) + + [ + new ActionA(), +>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) + + new ActionB() +>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) + + ] + +var z3: { id: number }[] = +>z3 : Symbol(z3, Decl(arrayLiteralTypeInference.ts, 40, 3)) +>id : Symbol(id, Decl(arrayLiteralTypeInference.ts, 40, 9)) + + [ + new Action(), +>Action : Symbol(Action, Decl(arrayLiteralTypeInference.ts, 0, 0)) + + new ActionA(), +>ActionA : Symbol(ActionA, Decl(arrayLiteralTypeInference.ts, 2, 1)) + + new ActionB() +>ActionB : Symbol(ActionB, Decl(arrayLiteralTypeInference.ts, 6, 1)) + + ] + + + + + diff --git a/tests/baselines/reference/arrayLiteralTypeInference.types b/tests/baselines/reference/arrayLiteralTypeInference.types new file mode 100644 index 00000000000..bb3c8b0b7de --- /dev/null +++ b/tests/baselines/reference/arrayLiteralTypeInference.types @@ -0,0 +1,144 @@ +=== tests/cases/compiler/arrayLiteralTypeInference.ts === +class Action { +>Action : Action + + id: number; +>id : number +} + +class ActionA extends Action { +>ActionA : ActionA +>Action : Action + + value: string; +>value : string +} + +class ActionB extends Action { +>ActionB : ActionB +>Action : Action + + trueNess: boolean; +>trueNess : boolean +} + +var x1: Action[] = [ +>x1 : Action[] +>Action : Action +>[ { id: 2, trueness: false }, { id: 3, name: "three" }] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[] + + { id: 2, trueness: false }, +>{ id: 2, trueness: false } : { id: number; trueness: boolean; } +>id : number +>2 : 2 +>trueness : boolean +>false : false + + { id: 3, name: "three" } +>{ id: 3, name: "three" } : { id: number; name: string; } +>id : number +>3 : 3 +>name : string +>"three" : "three" + +] + +var x2: Action[] = [ +>x2 : Action[] +>Action : Action +>[ new ActionA(), new ActionB()] : (ActionA | ActionB)[] + + new ActionA(), +>new ActionA() : ActionA +>ActionA : typeof ActionA + + new ActionB() +>new ActionB() : ActionB +>ActionB : typeof ActionB + +] + +var x3: Action[] = [ +>x3 : Action[] +>Action : Action +>[ new Action(), new ActionA(), new ActionB()] : Action[] + + new Action(), +>new Action() : Action +>Action : typeof Action + + new ActionA(), +>new ActionA() : ActionA +>ActionA : typeof ActionA + + new ActionB() +>new ActionB() : ActionB +>ActionB : typeof ActionB + +] + +var z1: { id: number }[] = +>z1 : { id: number; }[] +>id : number + + [ +>[ { id: 2, trueness: false }, { id: 3, name: "three" } ] : ({ id: number; trueness: boolean; } | { id: number; name: string; })[] + + { id: 2, trueness: false }, +>{ id: 2, trueness: false } : { id: number; trueness: boolean; } +>id : number +>2 : 2 +>trueness : boolean +>false : false + + { id: 3, name: "three" } +>{ id: 3, name: "three" } : { id: number; name: string; } +>id : number +>3 : 3 +>name : string +>"three" : "three" + + ] + +var z2: { id: number }[] = +>z2 : { id: number; }[] +>id : number + + [ +>[ new ActionA(), new ActionB() ] : (ActionA | ActionB)[] + + new ActionA(), +>new ActionA() : ActionA +>ActionA : typeof ActionA + + new ActionB() +>new ActionB() : ActionB +>ActionB : typeof ActionB + + ] + +var z3: { id: number }[] = +>z3 : { id: number; }[] +>id : number + + [ +>[ new Action(), new ActionA(), new ActionB() ] : Action[] + + new Action(), +>new Action() : Action +>Action : typeof Action + + new ActionA(), +>new ActionA() : ActionA +>ActionA : typeof ActionA + + new ActionB() +>new ActionB() : ActionB +>ActionB : typeof ActionB + + ] + + + + + diff --git a/tests/baselines/reference/arrayLiterals.symbols b/tests/baselines/reference/arrayLiterals.symbols new file mode 100644 index 00000000000..0e45eaf54cf --- /dev/null +++ b/tests/baselines/reference/arrayLiterals.symbols @@ -0,0 +1,94 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts === +// Empty array literal with no contextual type has type Undefined[] + +var arr1= [[], [1], ['']]; +>arr1 : Symbol(arr1, Decl(arrayLiterals.ts, 2, 3)) + +var arr2 = [[null], [1], ['']]; +>arr2 : Symbol(arr2, Decl(arrayLiterals.ts, 4, 3)) + + +// Array literal with elements of only EveryType E has type E[] +var stringArrArr = [[''], [""]]; +>stringArrArr : Symbol(stringArrArr, Decl(arrayLiterals.ts, 8, 3)) + +var stringArr = ['', ""]; +>stringArr : Symbol(stringArr, Decl(arrayLiterals.ts, 10, 3)) + +var numberArr = [0, 0.0, 0x00, 1e1]; +>numberArr : Symbol(numberArr, Decl(arrayLiterals.ts, 12, 3)) + +var boolArr = [false, true, false, true]; +>boolArr : Symbol(boolArr, Decl(arrayLiterals.ts, 14, 3)) + +class C { private p; } +>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) +>p : Symbol(C.p, Decl(arrayLiterals.ts, 16, 9)) + +var classArr = [new C(), new C()]; +>classArr : Symbol(classArr, Decl(arrayLiterals.ts, 17, 3)) +>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) +>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) + +var classTypeArray = [C, C, C]; +>classTypeArray : Symbol(classTypeArray, Decl(arrayLiterals.ts, 19, 3), Decl(arrayLiterals.ts, 20, 3)) +>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) +>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) +>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) + +var classTypeArray: Array; // Should OK, not be a parse error +>classTypeArray : Symbol(classTypeArray, Decl(arrayLiterals.ts, 19, 3), Decl(arrayLiterals.ts, 20, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>C : Symbol(C, Decl(arrayLiterals.ts, 14, 41)) + +// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] +var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; +>context1 : Symbol(context1, Decl(arrayLiterals.ts, 23, 3)) +>n : Symbol(n, Decl(arrayLiterals.ts, 23, 17)) +>a : Symbol(a, Decl(arrayLiterals.ts, 23, 30)) +>b : Symbol(b, Decl(arrayLiterals.ts, 23, 41)) +>a : Symbol(a, Decl(arrayLiterals.ts, 23, 62)) +>b : Symbol(b, Decl(arrayLiterals.ts, 23, 69)) +>c : Symbol(c, Decl(arrayLiterals.ts, 23, 75)) +>a : Symbol(a, Decl(arrayLiterals.ts, 23, 86)) +>b : Symbol(b, Decl(arrayLiterals.ts, 23, 93)) +>c : Symbol(c, Decl(arrayLiterals.ts, 23, 99)) + +var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; +>context2 : Symbol(context2, Decl(arrayLiterals.ts, 24, 3)) +>a : Symbol(a, Decl(arrayLiterals.ts, 24, 17)) +>b : Symbol(b, Decl(arrayLiterals.ts, 24, 24)) +>c : Symbol(c, Decl(arrayLiterals.ts, 24, 30)) +>a : Symbol(a, Decl(arrayLiterals.ts, 24, 41)) +>b : Symbol(b, Decl(arrayLiterals.ts, 24, 48)) +>c : Symbol(c, Decl(arrayLiterals.ts, 24, 54)) + +// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] +class Base { private p; } +>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) +>p : Symbol(Base.p, Decl(arrayLiterals.ts, 27, 12)) + +class Derived1 extends Base { private m }; +>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25)) +>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) +>m : Symbol(Derived1.m, Decl(arrayLiterals.ts, 28, 29)) + +class Derived2 extends Base { private n }; +>Derived2 : Symbol(Derived2, Decl(arrayLiterals.ts, 28, 42)) +>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) +>n : Symbol(Derived2.n, Decl(arrayLiterals.ts, 29, 29)) + +var context3: Base[] = [new Derived1(), new Derived2()]; +>context3 : Symbol(context3, Decl(arrayLiterals.ts, 30, 3)) +>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) +>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25)) +>Derived2 : Symbol(Derived2, Decl(arrayLiterals.ts, 28, 42)) + +// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[] +var context4: Base[] = [new Derived1(), new Derived1()]; +>context4 : Symbol(context4, Decl(arrayLiterals.ts, 33, 3)) +>Base : Symbol(Base, Decl(arrayLiterals.ts, 24, 63)) +>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25)) +>Derived1 : Symbol(Derived1, Decl(arrayLiterals.ts, 27, 25)) + + diff --git a/tests/baselines/reference/arrayLiterals.types b/tests/baselines/reference/arrayLiterals.types new file mode 100644 index 00000000000..02dec0c8ecd --- /dev/null +++ b/tests/baselines/reference/arrayLiterals.types @@ -0,0 +1,153 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals.ts === +// Empty array literal with no contextual type has type Undefined[] + +var arr1= [[], [1], ['']]; +>arr1 : (number[] | string[])[] +>[[], [1], ['']] : (number[] | string[])[] +>[] : undefined[] +>[1] : number[] +>1 : 1 +>[''] : string[] +>'' : "" + +var arr2 = [[null], [1], ['']]; +>arr2 : (number[] | string[])[] +>[[null], [1], ['']] : (number[] | string[])[] +>[null] : null[] +>null : null +>[1] : number[] +>1 : 1 +>[''] : string[] +>'' : "" + + +// Array literal with elements of only EveryType E has type E[] +var stringArrArr = [[''], [""]]; +>stringArrArr : string[][] +>[[''], [""]] : string[][] +>[''] : string[] +>'' : "" +>[""] : string[] +>"" : "" + +var stringArr = ['', ""]; +>stringArr : string[] +>['', ""] : string[] +>'' : "" +>"" : "" + +var numberArr = [0, 0.0, 0x00, 1e1]; +>numberArr : number[] +>[0, 0.0, 0x00, 1e1] : number[] +>0 : 0 +>0.0 : 0 +>0x00 : 0 +>1e1 : 10 + +var boolArr = [false, true, false, true]; +>boolArr : boolean[] +>[false, true, false, true] : boolean[] +>false : false +>true : true +>false : false +>true : true + +class C { private p; } +>C : C +>p : any + +var classArr = [new C(), new C()]; +>classArr : C[] +>[new C(), new C()] : C[] +>new C() : C +>C : typeof C +>new C() : C +>C : typeof C + +var classTypeArray = [C, C, C]; +>classTypeArray : (typeof C)[] +>[C, C, C] : (typeof C)[] +>C : typeof C +>C : typeof C +>C : typeof C + +var classTypeArray: Array; // Should OK, not be a parse error +>classTypeArray : (typeof C)[] +>Array : T[] +>C : typeof C + +// Contextual type C with numeric index signature makes array literal of EveryType E of type BCT(E,C)[] +var context1: { [n: number]: { a: string; b: number; }; } = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; +>context1 : { [n: number]: { a: string; b: number; }; } +>n : number +>a : string +>b : number +>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] +>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; } +>a : string +>'' : "" +>b : number +>0 : 0 +>c : string +>'' : "" +>{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; } +>a : string +>"" : "" +>b : number +>3 : 3 +>c : number +>0 : 0 + +var context2 = [{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }]; +>context2 : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] +>[{ a: '', b: 0, c: '' }, { a: "", b: 3, c: 0 }] : ({ a: string; b: number; c: string; } | { a: string; b: number; c: number; })[] +>{ a: '', b: 0, c: '' } : { a: string; b: number; c: string; } +>a : string +>'' : "" +>b : number +>0 : 0 +>c : string +>'' : "" +>{ a: "", b: 3, c: 0 } : { a: string; b: number; c: number; } +>a : string +>"" : "" +>b : number +>3 : 3 +>c : number +>0 : 0 + +// Contextual type C with numeric index signature of type Base makes array literal of Derived have type Base[] +class Base { private p; } +>Base : Base +>p : any + +class Derived1 extends Base { private m }; +>Derived1 : Derived1 +>Base : Base +>m : any + +class Derived2 extends Base { private n }; +>Derived2 : Derived2 +>Base : Base +>n : any + +var context3: Base[] = [new Derived1(), new Derived2()]; +>context3 : Base[] +>Base : Base +>[new Derived1(), new Derived2()] : (Derived1 | Derived2)[] +>new Derived1() : Derived1 +>Derived1 : typeof Derived1 +>new Derived2() : Derived2 +>Derived2 : typeof Derived2 + +// Contextual type C with numeric index signature of type Base makes array literal of Derived1 and Derived2 have type Base[] +var context4: Base[] = [new Derived1(), new Derived1()]; +>context4 : Base[] +>Base : Base +>[new Derived1(), new Derived1()] : Derived1[] +>new Derived1() : Derived1 +>Derived1 : typeof Derived1 +>new Derived1() : Derived1 +>Derived1 : typeof Derived1 + + diff --git a/tests/baselines/reference/arrayLiterals2ES6.symbols b/tests/baselines/reference/arrayLiterals2ES6.symbols index 8202cb16df9..da256ba2238 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.symbols +++ b/tests/baselines/reference/arrayLiterals2ES6.symbols @@ -79,7 +79,7 @@ interface myArray2 extends Array { } >myArray2 : Symbol(myArray2, Decl(arrayLiterals2ES6.ts, 42, 43)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >Number : Symbol(Number, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) ->String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>String : Symbol(String, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --) ... and 1 more) var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : Symbol(d0, Decl(arrayLiterals2ES6.ts, 44, 3)) diff --git a/tests/baselines/reference/arrayLiterals3.symbols b/tests/baselines/reference/arrayLiterals3.symbols new file mode 100644 index 00000000000..8a94e9ee462 --- /dev/null +++ b/tests/baselines/reference/arrayLiterals3.symbols @@ -0,0 +1,68 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts === +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var a0: [any, any, any] = []; // Error +>a0 : Symbol(a0, Decl(arrayLiterals3.ts, 9, 3)) + +var a1: [boolean, string, number] = ["string", 1, true]; // Error +>a1 : Symbol(a1, Decl(arrayLiterals3.ts, 10, 3)) + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [b1, b2]: [number, number] = [1, 2, "string", true]; +>b1 : Symbol(b1, Decl(arrayLiterals3.ts, 16, 5)) +>b2 : Symbol(b2, Decl(arrayLiterals3.ts, 16, 8)) + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +>temp : Symbol(temp, Decl(arrayLiterals3.ts, 21, 3)) + +var temp1 = [1, 2, 3]; +>temp1 : Symbol(temp1, Decl(arrayLiterals3.ts, 22, 3)) + +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>temp2 : Symbol(temp2, Decl(arrayLiterals3.ts, 23, 3)) + +interface tup { +>tup : Symbol(tup, Decl(arrayLiterals3.ts, 23, 67)) + + 0: number[]|string[]; + 1: number[]|string[]; +} +interface myArray extends Array { } +>myArray : Symbol(myArray, Decl(arrayLiterals3.ts, 28, 1)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +interface myArray2 extends Array { } +>myArray2 : Symbol(myArray2, Decl(arrayLiterals3.ts, 29, 43)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var c0: tup = [...temp2]; // Error +>c0 : Symbol(c0, Decl(arrayLiterals3.ts, 31, 3)) +>tup : Symbol(tup, Decl(arrayLiterals3.ts, 23, 67)) +>temp2 : Symbol(temp2, Decl(arrayLiterals3.ts, 23, 3)) + +var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number] +>c1 : Symbol(c1, Decl(arrayLiterals3.ts, 32, 3)) +>temp1 : Symbol(temp1, Decl(arrayLiterals3.ts, 22, 3)) + +var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[] +>c2 : Symbol(c2, Decl(arrayLiterals3.ts, 33, 3)) +>myArray : Symbol(myArray, Decl(arrayLiterals3.ts, 28, 1)) +>temp1 : Symbol(temp1, Decl(arrayLiterals3.ts, 22, 3)) +>temp : Symbol(temp, Decl(arrayLiterals3.ts, 21, 3)) + diff --git a/tests/baselines/reference/arrayLiterals3.types b/tests/baselines/reference/arrayLiterals3.types new file mode 100644 index 00000000000..827f35ead8c --- /dev/null +++ b/tests/baselines/reference/arrayLiterals3.types @@ -0,0 +1,101 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts === +// Each element expression in a non-empty array literal is processed as follows: +// - If the array literal contains no spread elements, and if the array literal is contextually typed (section 4.19) +// by a type T and T has a property with the numeric name N, where N is the index of the element expression in the array literal, +// the element expression is contextually typed by the type of that property. + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is contextually typed by a tuple-like type, +// the resulting type is a tuple type constructed from the types of the element expressions. + +var a0: [any, any, any] = []; // Error +>a0 : [any, any, any] +>[] : undefined[] + +var a1: [boolean, string, number] = ["string", 1, true]; // Error +>a1 : [boolean, string, number] +>["string", 1, true] : ["string", number, boolean] +>"string" : "string" +>1 : 1 +>true : true + +// The resulting type an array literal expression is determined as follows: +// - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), +// the resulting type is a tuple type constructed from the types of the element expressions. + +var [b1, b2]: [number, number] = [1, 2, "string", true]; +>b1 : number +>b2 : number +>[1, 2, "string", true] : [number, number, string, boolean] +>1 : 1 +>2 : 2 +>"string" : "string" +>true : true + +// The resulting type an array literal expression is determined as follows: +// - the resulting type is an array type with an element type that is the union of the types of the +// non - spread element expressions and the numeric index signature types of the spread element expressions +var temp = ["s", "t", "r"]; +>temp : string[] +>["s", "t", "r"] : string[] +>"s" : "s" +>"t" : "t" +>"r" : "r" + +var temp1 = [1, 2, 3]; +>temp1 : number[] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 + +var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; +>temp2 : [number[], string[]] +>[[1, 2, 3], ["hello", "string"]] : [number[], string[]] +>[1, 2, 3] : number[] +>1 : 1 +>2 : 2 +>3 : 3 +>["hello", "string"] : string[] +>"hello" : "hello" +>"string" : "string" + +interface tup { +>tup : tup + + 0: number[]|string[]; + 1: number[]|string[]; +} +interface myArray extends Array { } +>myArray : myArray +>Array : T[] +>Number : Number + +interface myArray2 extends Array { } +>myArray2 : myArray2 +>Array : T[] +>Number : Number +>String : String + +var c0: tup = [...temp2]; // Error +>c0 : tup +>tup : tup +>[...temp2] : (number[] | string[])[] +>...temp2 : number[] | string[] +>temp2 : [number[], string[]] + +var c1: [number, number, number] = [...temp1]; // Error cannot assign number[] to [number, number, number] +>c1 : [number, number, number] +>[...temp1] : number[] +>...temp1 : number +>temp1 : number[] + +var c2: myArray = [...temp1, ...temp]; // Error cannot assign (number|string)[] to number[] +>c2 : myArray +>myArray : myArray +>[...temp1, ...temp] : (string | number)[] +>...temp1 : number +>temp1 : number[] +>...temp : string +>temp : string[] + diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.symbols b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.symbols new file mode 100644 index 00000000000..4c466f029ef --- /dev/null +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.symbols @@ -0,0 +1,77 @@ +=== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts === +class A { a } +>A : Symbol(A, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 0)) +>a : Symbol(A.a, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 9)) + +class B extends A { b } +>B : Symbol(B, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 13)) +>A : Symbol(A, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 0)) +>b : Symbol(B.b, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 1, 19)) + +class C extends Array { c } +>C : Symbol(C, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 1, 23)) +>T : Symbol(T, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 2, 8)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>T : Symbol(T, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 2, 8)) +>c : Symbol(C.c, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 2, 29)) + +declare var ara: A[]; +>ara : Symbol(ara, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 3, 11)) +>A : Symbol(A, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 0)) + +declare var arb: B[]; +>arb : Symbol(arb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 4, 11)) +>B : Symbol(B, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 13)) + +declare var cra: C; +>cra : Symbol(cra, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 5, 11)) +>C : Symbol(C, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 1, 23)) +>A : Symbol(A, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 0)) + +declare var crb: C; +>crb : Symbol(crb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 6, 11)) +>C : Symbol(C, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 1, 23)) +>B : Symbol(B, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 13)) + +declare var rra: ReadonlyArray; +>rra : Symbol(rra, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 7, 11)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.d.ts, --, --)) +>A : Symbol(A, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 0)) + +declare var rrb: ReadonlyArray; +>rrb : Symbol(rrb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 8, 11)) +>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.d.ts, --, --)) +>B : Symbol(B, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 0, 13)) + +rra = ara; +>rra : Symbol(rra, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 7, 11)) +>ara : Symbol(ara, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 3, 11)) + +rrb = arb; // OK, Array is assignable to ReadonlyArray +>rrb : Symbol(rrb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 8, 11)) +>arb : Symbol(arb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 4, 11)) + +rra = arb; +>rra : Symbol(rra, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 7, 11)) +>arb : Symbol(arb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 4, 11)) + +rrb = ara; // error: 'A' is not assignable to 'B' +>rrb : Symbol(rrb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 8, 11)) +>ara : Symbol(ara, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 3, 11)) + +rra = cra; +>rra : Symbol(rra, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 7, 11)) +>cra : Symbol(cra, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 5, 11)) + +rra = crb; // OK, C is assignable to ReadonlyArray +>rra : Symbol(rra, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 7, 11)) +>crb : Symbol(crb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 6, 11)) + +rrb = crb; +>rrb : Symbol(rrb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 8, 11)) +>crb : Symbol(crb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 6, 11)) + +rrb = cra; // error: 'A' is not assignable to 'B' +>rrb : Symbol(rrb, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 8, 11)) +>cra : Symbol(cra, Decl(arrayOfSubtypeIsAssignableToReadonlyArray.ts, 5, 11)) + diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.types b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.types new file mode 100644 index 00000000000..dea89276a58 --- /dev/null +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.types @@ -0,0 +1,85 @@ +=== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts === +class A { a } +>A : A +>a : any + +class B extends A { b } +>B : B +>A : A +>b : any + +class C extends Array { c } +>C : C +>T : T +>Array : T[] +>T : T +>c : any + +declare var ara: A[]; +>ara : A[] +>A : A + +declare var arb: B[]; +>arb : B[] +>B : B + +declare var cra: C; +>cra : C +>C : C +>A : A + +declare var crb: C; +>crb : C +>C : C +>B : B + +declare var rra: ReadonlyArray; +>rra : ReadonlyArray +>ReadonlyArray : ReadonlyArray +>A : A + +declare var rrb: ReadonlyArray; +>rrb : ReadonlyArray +>ReadonlyArray : ReadonlyArray +>B : B + +rra = ara; +>rra = ara : A[] +>rra : ReadonlyArray +>ara : A[] + +rrb = arb; // OK, Array is assignable to ReadonlyArray +>rrb = arb : B[] +>rrb : ReadonlyArray +>arb : B[] + +rra = arb; +>rra = arb : B[] +>rra : ReadonlyArray +>arb : B[] + +rrb = ara; // error: 'A' is not assignable to 'B' +>rrb = ara : A[] +>rrb : ReadonlyArray +>ara : A[] + +rra = cra; +>rra = cra : C +>rra : ReadonlyArray +>cra : C + +rra = crb; // OK, C is assignable to ReadonlyArray +>rra = crb : C +>rra : ReadonlyArray +>crb : C + +rrb = crb; +>rrb = crb : C +>rrb : ReadonlyArray +>crb : C + +rrb = cra; // error: 'A' is not assignable to 'B' +>rrb = cra : C +>rrb : ReadonlyArray +>cra : C + diff --git a/tests/baselines/reference/arrayReferenceWithoutTypeArgs.symbols b/tests/baselines/reference/arrayReferenceWithoutTypeArgs.symbols new file mode 100644 index 00000000000..b4f845f52e0 --- /dev/null +++ b/tests/baselines/reference/arrayReferenceWithoutTypeArgs.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/arrayReferenceWithoutTypeArgs.ts === +class X { +>X : Symbol(X, Decl(arrayReferenceWithoutTypeArgs.ts, 0, 0)) + + public f(a: Array) { } +>f : Symbol(X.f, Decl(arrayReferenceWithoutTypeArgs.ts, 0, 9)) +>a : Symbol(a, Decl(arrayReferenceWithoutTypeArgs.ts, 1, 13)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} diff --git a/tests/baselines/reference/arrayReferenceWithoutTypeArgs.types b/tests/baselines/reference/arrayReferenceWithoutTypeArgs.types new file mode 100644 index 00000000000..a4931c1c2cc --- /dev/null +++ b/tests/baselines/reference/arrayReferenceWithoutTypeArgs.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/arrayReferenceWithoutTypeArgs.ts === +class X { +>X : X + + public f(a: Array) { } +>f : (a: any) => void +>a : any +>Array : T[] +} diff --git a/tests/baselines/reference/arraySigChecking.symbols b/tests/baselines/reference/arraySigChecking.symbols new file mode 100644 index 00000000000..a692f78c53a --- /dev/null +++ b/tests/baselines/reference/arraySigChecking.symbols @@ -0,0 +1,76 @@ +=== tests/cases/compiler/arraySigChecking.ts === +declare module M { +>M : Symbol(M, Decl(arraySigChecking.ts, 0, 0)) + + interface iBar { t: any; } +>iBar : Symbol(iBar, Decl(arraySigChecking.ts, 0, 18)) +>t : Symbol(iBar.t, Decl(arraySigChecking.ts, 1, 20)) + + interface iFoo extends iBar { +>iFoo : Symbol(iFoo, Decl(arraySigChecking.ts, 1, 30)) +>iBar : Symbol(iBar, Decl(arraySigChecking.ts, 0, 18)) + + s: any; +>s : Symbol(iFoo.s, Decl(arraySigChecking.ts, 2, 33)) + } + + class cFoo { +>cFoo : Symbol(cFoo, Decl(arraySigChecking.ts, 4, 5)) + + t: any; +>t : Symbol(cFoo.t, Decl(arraySigChecking.ts, 6, 16)) + } + + var foo: { [index: any]; }; // expect an error here +>foo : Symbol(foo, Decl(arraySigChecking.ts, 10, 7)) +>index : Symbol(index, Decl(arraySigChecking.ts, 10, 16)) +} + +interface myInt { +>myInt : Symbol(myInt, Decl(arraySigChecking.ts, 11, 1)) + + voidFn(): void; +>voidFn : Symbol(myInt.voidFn, Decl(arraySigChecking.ts, 13, 17)) +} +var myVar: myInt; +>myVar : Symbol(myVar, Decl(arraySigChecking.ts, 16, 3)) +>myInt : Symbol(myInt, Decl(arraySigChecking.ts, 11, 1)) + +var strArray: string[] = [myVar.voidFn()]; +>strArray : Symbol(strArray, Decl(arraySigChecking.ts, 17, 3)) +>myVar.voidFn : Symbol(myInt.voidFn, Decl(arraySigChecking.ts, 13, 17)) +>myVar : Symbol(myVar, Decl(arraySigChecking.ts, 16, 3)) +>voidFn : Symbol(myInt.voidFn, Decl(arraySigChecking.ts, 13, 17)) + + +var myArray: number[][][]; +>myArray : Symbol(myArray, Decl(arraySigChecking.ts, 20, 3)) + +myArray = [[1, 2]]; +>myArray : Symbol(myArray, Decl(arraySigChecking.ts, 20, 3)) + +function isEmpty(l: { length: number }) { +>isEmpty : Symbol(isEmpty, Decl(arraySigChecking.ts, 21, 19)) +>l : Symbol(l, Decl(arraySigChecking.ts, 23, 17)) +>length : Symbol(length, Decl(arraySigChecking.ts, 23, 21)) + + return l.length === 0; +>l.length : Symbol(length, Decl(arraySigChecking.ts, 23, 21)) +>l : Symbol(l, Decl(arraySigChecking.ts, 23, 17)) +>length : Symbol(length, Decl(arraySigChecking.ts, 23, 21)) +} + +isEmpty([]); +>isEmpty : Symbol(isEmpty, Decl(arraySigChecking.ts, 21, 19)) + +isEmpty(new Array(3)); +>isEmpty : Symbol(isEmpty, Decl(arraySigChecking.ts, 21, 19)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +isEmpty(new Array(3)); +>isEmpty : Symbol(isEmpty, Decl(arraySigChecking.ts, 21, 19)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +isEmpty(['a']); +>isEmpty : Symbol(isEmpty, Decl(arraySigChecking.ts, 21, 19)) + diff --git a/tests/baselines/reference/arraySigChecking.types b/tests/baselines/reference/arraySigChecking.types new file mode 100644 index 00000000000..470e721d1bb --- /dev/null +++ b/tests/baselines/reference/arraySigChecking.types @@ -0,0 +1,96 @@ +=== tests/cases/compiler/arraySigChecking.ts === +declare module M { +>M : typeof M + + interface iBar { t: any; } +>iBar : iBar +>t : any + + interface iFoo extends iBar { +>iFoo : iFoo +>iBar : iBar + + s: any; +>s : any + } + + class cFoo { +>cFoo : cFoo + + t: any; +>t : any + } + + var foo: { [index: any]; }; // expect an error here +>foo : {} +>index : any +} + +interface myInt { +>myInt : myInt + + voidFn(): void; +>voidFn : () => void +} +var myVar: myInt; +>myVar : myInt +>myInt : myInt + +var strArray: string[] = [myVar.voidFn()]; +>strArray : string[] +>[myVar.voidFn()] : void[] +>myVar.voidFn() : void +>myVar.voidFn : () => void +>myVar : myInt +>voidFn : () => void + + +var myArray: number[][][]; +>myArray : number[][][] + +myArray = [[1, 2]]; +>myArray = [[1, 2]] : number[][] +>myArray : number[][][] +>[[1, 2]] : number[][] +>[1, 2] : number[] +>1 : 1 +>2 : 2 + +function isEmpty(l: { length: number }) { +>isEmpty : (l: { length: number; }) => boolean +>l : { length: number; } +>length : number + + return l.length === 0; +>l.length === 0 : boolean +>l.length : number +>l : { length: number; } +>length : number +>0 : 0 +} + +isEmpty([]); +>isEmpty([]) : boolean +>isEmpty : (l: { length: number; }) => boolean +>[] : undefined[] + +isEmpty(new Array(3)); +>isEmpty(new Array(3)) : boolean +>isEmpty : (l: { length: number; }) => boolean +>new Array(3) : any[] +>Array : ArrayConstructor +>3 : 3 + +isEmpty(new Array(3)); +>isEmpty(new Array(3)) : boolean +>isEmpty : (l: { length: number; }) => boolean +>new Array(3) : string[] +>Array : ArrayConstructor +>3 : 3 + +isEmpty(['a']); +>isEmpty(['a']) : boolean +>isEmpty : (l: { length: number; }) => boolean +>['a'] : string[] +>'a' : "a" + diff --git a/tests/baselines/reference/arrayTypeOfFunctionTypes.symbols b/tests/baselines/reference/arrayTypeOfFunctionTypes.symbols new file mode 100644 index 00000000000..ecd1501c662 --- /dev/null +++ b/tests/baselines/reference/arrayTypeOfFunctionTypes.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfFunctionTypes.ts === +// valid uses of arrays of function types + +var x: () => string[]; +>x : Symbol(x, Decl(arrayTypeOfFunctionTypes.ts, 2, 3)) + +var r = x[1]; +>r : Symbol(r, Decl(arrayTypeOfFunctionTypes.ts, 3, 3)) +>x : Symbol(x, Decl(arrayTypeOfFunctionTypes.ts, 2, 3)) + +var r2 = r(); +>r2 : Symbol(r2, Decl(arrayTypeOfFunctionTypes.ts, 4, 3)) +>r : Symbol(r, Decl(arrayTypeOfFunctionTypes.ts, 3, 3)) + +var r2b = new r(); +>r2b : Symbol(r2b, Decl(arrayTypeOfFunctionTypes.ts, 5, 3)) +>r : Symbol(r, Decl(arrayTypeOfFunctionTypes.ts, 3, 3)) + +var x2: { (): string }[]; +>x2 : Symbol(x2, Decl(arrayTypeOfFunctionTypes.ts, 7, 3)) + +var r3 = x2[1]; +>r3 : Symbol(r3, Decl(arrayTypeOfFunctionTypes.ts, 8, 3)) +>x2 : Symbol(x2, Decl(arrayTypeOfFunctionTypes.ts, 7, 3)) + +var r4 = r3(); +>r4 : Symbol(r4, Decl(arrayTypeOfFunctionTypes.ts, 9, 3)) +>r3 : Symbol(r3, Decl(arrayTypeOfFunctionTypes.ts, 8, 3)) + +var r4b = new r3(); // error +>r4b : Symbol(r4b, Decl(arrayTypeOfFunctionTypes.ts, 10, 3)) +>r3 : Symbol(r3, Decl(arrayTypeOfFunctionTypes.ts, 8, 3)) + +var x3: Array<() => string>; +>x3 : Symbol(x3, Decl(arrayTypeOfFunctionTypes.ts, 12, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var r5 = x2[1]; +>r5 : Symbol(r5, Decl(arrayTypeOfFunctionTypes.ts, 13, 3)) +>x2 : Symbol(x2, Decl(arrayTypeOfFunctionTypes.ts, 7, 3)) + +var r6 = r5(); +>r6 : Symbol(r6, Decl(arrayTypeOfFunctionTypes.ts, 14, 3)) +>r5 : Symbol(r5, Decl(arrayTypeOfFunctionTypes.ts, 13, 3)) + +var r6b = new r5(); // error +>r6b : Symbol(r6b, Decl(arrayTypeOfFunctionTypes.ts, 15, 3)) +>r5 : Symbol(r5, Decl(arrayTypeOfFunctionTypes.ts, 13, 3)) + diff --git a/tests/baselines/reference/arrayTypeOfFunctionTypes.types b/tests/baselines/reference/arrayTypeOfFunctionTypes.types new file mode 100644 index 00000000000..5248c6731c0 --- /dev/null +++ b/tests/baselines/reference/arrayTypeOfFunctionTypes.types @@ -0,0 +1,61 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfFunctionTypes.ts === +// valid uses of arrays of function types + +var x: () => string[]; +>x : () => string[] + +var r = x[1]; +>r : any +>x[1] : any +>x : () => string[] +>1 : 1 + +var r2 = r(); +>r2 : any +>r() : any +>r : any + +var r2b = new r(); +>r2b : any +>new r() : any +>r : any + +var x2: { (): string }[]; +>x2 : (() => string)[] + +var r3 = x2[1]; +>r3 : () => string +>x2[1] : () => string +>x2 : (() => string)[] +>1 : 1 + +var r4 = r3(); +>r4 : string +>r3() : string +>r3 : () => string + +var r4b = new r3(); // error +>r4b : any +>new r3() : any +>r3 : () => string + +var x3: Array<() => string>; +>x3 : (() => string)[] +>Array : T[] + +var r5 = x2[1]; +>r5 : () => string +>x2[1] : () => string +>x2 : (() => string)[] +>1 : 1 + +var r6 = r5(); +>r6 : string +>r5() : string +>r5 : () => string + +var r6b = new r5(); // error +>r6b : any +>new r5() : any +>r5 : () => string + diff --git a/tests/baselines/reference/arrayTypeOfFunctionTypes2.symbols b/tests/baselines/reference/arrayTypeOfFunctionTypes2.symbols new file mode 100644 index 00000000000..545546dd849 --- /dev/null +++ b/tests/baselines/reference/arrayTypeOfFunctionTypes2.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfFunctionTypes2.ts === +// valid uses of arrays of function types + +var x: new () => string[]; +>x : Symbol(x, Decl(arrayTypeOfFunctionTypes2.ts, 2, 3)) + +var r = x[1]; +>r : Symbol(r, Decl(arrayTypeOfFunctionTypes2.ts, 3, 3)) +>x : Symbol(x, Decl(arrayTypeOfFunctionTypes2.ts, 2, 3)) + +var r2 = new r(); +>r2 : Symbol(r2, Decl(arrayTypeOfFunctionTypes2.ts, 4, 3)) +>r : Symbol(r, Decl(arrayTypeOfFunctionTypes2.ts, 3, 3)) + +var r2b = r(); +>r2b : Symbol(r2b, Decl(arrayTypeOfFunctionTypes2.ts, 5, 3)) +>r : Symbol(r, Decl(arrayTypeOfFunctionTypes2.ts, 3, 3)) + +var x2: { new(): string }[]; +>x2 : Symbol(x2, Decl(arrayTypeOfFunctionTypes2.ts, 7, 3)) + +var r3 = x[1]; +>r3 : Symbol(r3, Decl(arrayTypeOfFunctionTypes2.ts, 8, 3)) +>x : Symbol(x, Decl(arrayTypeOfFunctionTypes2.ts, 2, 3)) + +var r4 = new r3(); +>r4 : Symbol(r4, Decl(arrayTypeOfFunctionTypes2.ts, 9, 3)) +>r3 : Symbol(r3, Decl(arrayTypeOfFunctionTypes2.ts, 8, 3)) + +var r4b = new r3(); +>r4b : Symbol(r4b, Decl(arrayTypeOfFunctionTypes2.ts, 10, 3)) +>r3 : Symbol(r3, Decl(arrayTypeOfFunctionTypes2.ts, 8, 3)) + +var x3: Array string>; +>x3 : Symbol(x3, Decl(arrayTypeOfFunctionTypes2.ts, 12, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var r5 = x2[1]; +>r5 : Symbol(r5, Decl(arrayTypeOfFunctionTypes2.ts, 13, 3)) +>x2 : Symbol(x2, Decl(arrayTypeOfFunctionTypes2.ts, 7, 3)) + +var r6 = new r5(); +>r6 : Symbol(r6, Decl(arrayTypeOfFunctionTypes2.ts, 14, 3)) +>r5 : Symbol(r5, Decl(arrayTypeOfFunctionTypes2.ts, 13, 3)) + +var r6b = r5(); +>r6b : Symbol(r6b, Decl(arrayTypeOfFunctionTypes2.ts, 15, 3)) +>r5 : Symbol(r5, Decl(arrayTypeOfFunctionTypes2.ts, 13, 3)) + diff --git a/tests/baselines/reference/arrayTypeOfFunctionTypes2.types b/tests/baselines/reference/arrayTypeOfFunctionTypes2.types new file mode 100644 index 00000000000..8ca385a71ba --- /dev/null +++ b/tests/baselines/reference/arrayTypeOfFunctionTypes2.types @@ -0,0 +1,61 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfFunctionTypes2.ts === +// valid uses of arrays of function types + +var x: new () => string[]; +>x : new () => string[] + +var r = x[1]; +>r : any +>x[1] : any +>x : new () => string[] +>1 : 1 + +var r2 = new r(); +>r2 : any +>new r() : any +>r : any + +var r2b = r(); +>r2b : any +>r() : any +>r : any + +var x2: { new(): string }[]; +>x2 : (new () => string)[] + +var r3 = x[1]; +>r3 : any +>x[1] : any +>x : new () => string[] +>1 : 1 + +var r4 = new r3(); +>r4 : any +>new r3() : any +>r3 : any + +var r4b = new r3(); +>r4b : any +>new r3() : any +>r3 : any + +var x3: Array string>; +>x3 : (new () => string)[] +>Array : T[] + +var r5 = x2[1]; +>r5 : new () => string +>x2[1] : new () => string +>x2 : (new () => string)[] +>1 : 1 + +var r6 = new r5(); +>r6 : string +>new r5() : string +>r5 : new () => string + +var r6b = r5(); +>r6b : any +>r5() : any +>r5 : new () => string + diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.symbols b/tests/baselines/reference/arrayTypeOfTypeOf.symbols new file mode 100644 index 00000000000..b86f680b80d --- /dev/null +++ b/tests/baselines/reference/arrayTypeOfTypeOf.symbols @@ -0,0 +1,23 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts === +// array type cannot use typeof. + +var x = 1; +>x : Symbol(x, Decl(arrayTypeOfTypeOf.ts, 2, 3)) + +var xs: typeof x[]; // Not an error. This is equivalent to Array +>xs : Symbol(xs, Decl(arrayTypeOfTypeOf.ts, 3, 3)) +>x : Symbol(x, Decl(arrayTypeOfTypeOf.ts, 2, 3)) + +var xs2: typeof Array; +>xs2 : Symbol(xs2, Decl(arrayTypeOfTypeOf.ts, 4, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var xs3: typeof Array; +>xs3 : Symbol(xs3, Decl(arrayTypeOfTypeOf.ts, 5, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var xs4: typeof Array; +>xs4 : Symbol(xs4, Decl(arrayTypeOfTypeOf.ts, 6, 3)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(arrayTypeOfTypeOf.ts, 2, 3)) + diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.types b/tests/baselines/reference/arrayTypeOfTypeOf.types new file mode 100644 index 00000000000..398cbb759a5 --- /dev/null +++ b/tests/baselines/reference/arrayTypeOfTypeOf.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts === +// array type cannot use typeof. + +var x = 1; +>x : number +>1 : 1 + +var xs: typeof x[]; // Not an error. This is equivalent to Array +>xs : number[] +>x : number + +var xs2: typeof Array; +>xs2 : ArrayConstructor +>Array : ArrayConstructor + +var xs3: typeof Array; +>xs3 : ArrayConstructor +>Array : ArrayConstructor +> : number +> : any + +var xs4: typeof Array; +>xs4 : ArrayConstructor +>Array : ArrayConstructor +> : number +>x : number +> : any + diff --git a/tests/baselines/reference/arrowFunctionContexts.symbols b/tests/baselines/reference/arrowFunctionContexts.symbols new file mode 100644 index 00000000000..44b9aaedec4 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionContexts.symbols @@ -0,0 +1,198 @@ +=== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts === +// Arrow function used in with statement +with (window) { + var p = () => this; +} + +// Arrow function as argument to super call +class Base { +>Base : Symbol(Base, Decl(arrowFunctionContexts.ts, 3, 1)) + + constructor(n: any) { } +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 7, 16)) +} + +class Derived extends Base { +>Derived : Symbol(Derived, Decl(arrowFunctionContexts.ts, 8, 1)) +>Base : Symbol(Base, Decl(arrowFunctionContexts.ts, 3, 1)) + + constructor() { + super(() => this); +>super : Symbol(Base, Decl(arrowFunctionContexts.ts, 3, 1)) +>this : Symbol(Derived, Decl(arrowFunctionContexts.ts, 8, 1)) + } +} + +// Arrow function as function argument +window.setTimeout(() => null, 100); + +// Arrow function as value in array literal + +var obj = (n: number) => ''; +>obj : Symbol(obj, Decl(arrowFunctionContexts.ts, 21, 3), Decl(arrowFunctionContexts.ts, 22, 3)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 21, 11)) + +var obj: { (n: number): string; }; // OK +>obj : Symbol(obj, Decl(arrowFunctionContexts.ts, 21, 3), Decl(arrowFunctionContexts.ts, 22, 3)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 22, 12)) + +var arr = [(n: number) => '']; +>arr : Symbol(arr, Decl(arrowFunctionContexts.ts, 24, 3), Decl(arrowFunctionContexts.ts, 25, 3)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 24, 12)) + +var arr: { (n: number): string; }[]; // Incorrect error here (bug 829597) +>arr : Symbol(arr, Decl(arrowFunctionContexts.ts, 24, 3), Decl(arrowFunctionContexts.ts, 25, 3)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 25, 12)) + +// Arrow function as enum value +enum E { +>E : Symbol(E, Decl(arrowFunctionContexts.ts, 25, 36)) + + x = () => 4, // Error expected +>x : Symbol(E.x, Decl(arrowFunctionContexts.ts, 28, 8)) + + y = (() => this).length // error, can't use this in enum +>y : Symbol(E.y, Decl(arrowFunctionContexts.ts, 29, 16)) +>(() => this).length : Symbol(Function.length, Decl(lib.d.ts, --, --)) +>length : Symbol(Function.length, Decl(lib.d.ts, --, --)) +} + +// Arrow function as module variable initializer +module M { +>M : Symbol(M, Decl(arrowFunctionContexts.ts, 31, 1)) + + export var a = (s) => ''; +>a : Symbol(a, Decl(arrowFunctionContexts.ts, 35, 14)) +>s : Symbol(s, Decl(arrowFunctionContexts.ts, 35, 20)) + + var b = (s) => s; +>b : Symbol(b, Decl(arrowFunctionContexts.ts, 36, 7)) +>s : Symbol(s, Decl(arrowFunctionContexts.ts, 36, 13)) +>s : Symbol(s, Decl(arrowFunctionContexts.ts, 36, 13)) +} + +// Repeat above for module members that are functions? (necessary to redo all of them?) +module M2 { +>M2 : Symbol(M2, Decl(arrowFunctionContexts.ts, 37, 1)) + + // Arrow function used in with statement + with (window) { + var p = () => this; + } + + // Arrow function as argument to super call + class Base { +>Base : Symbol(Base, Decl(arrowFunctionContexts.ts, 44, 5)) + + constructor(n: any) { } +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 48, 20)) + } + + class Derived extends Base { +>Derived : Symbol(Derived, Decl(arrowFunctionContexts.ts, 49, 5)) +>Base : Symbol(Base, Decl(arrowFunctionContexts.ts, 44, 5)) + + constructor() { + super(() => this); +>super : Symbol(Base, Decl(arrowFunctionContexts.ts, 44, 5)) +>this : Symbol(Derived, Decl(arrowFunctionContexts.ts, 49, 5)) + } + } + + // Arrow function as function argument + window.setTimeout(() => null, 100); + + // Arrow function as value in array literal + + var obj = (n: number) => ''; +>obj : Symbol(obj, Decl(arrowFunctionContexts.ts, 62, 7), Decl(arrowFunctionContexts.ts, 63, 7)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 62, 15)) + + var obj: { (n: number): string; }; // OK +>obj : Symbol(obj, Decl(arrowFunctionContexts.ts, 62, 7), Decl(arrowFunctionContexts.ts, 63, 7)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 63, 16)) + + var arr = [(n: number) => '']; +>arr : Symbol(arr, Decl(arrowFunctionContexts.ts, 65, 7), Decl(arrowFunctionContexts.ts, 66, 7)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 65, 16)) + + var arr: { (n: number): string; }[]; // Incorrect error here (bug 829597) +>arr : Symbol(arr, Decl(arrowFunctionContexts.ts, 65, 7), Decl(arrowFunctionContexts.ts, 66, 7)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 66, 16)) + + // Arrow function as enum value + enum E { +>E : Symbol(E, Decl(arrowFunctionContexts.ts, 66, 40)) + + x = () => 4, // Error expected +>x : Symbol(E.x, Decl(arrowFunctionContexts.ts, 69, 12)) + + y = (() => this).length +>y : Symbol(E.y, Decl(arrowFunctionContexts.ts, 70, 20)) +>(() => this).length : Symbol(Function.length, Decl(lib.d.ts, --, --)) +>length : Symbol(Function.length, Decl(lib.d.ts, --, --)) + } + + // Arrow function as module variable initializer + module M { +>M : Symbol(M, Decl(arrowFunctionContexts.ts, 72, 5)) + + export var a = (s) => ''; +>a : Symbol(a, Decl(arrowFunctionContexts.ts, 76, 18)) +>s : Symbol(s, Decl(arrowFunctionContexts.ts, 76, 24)) + + var b = (s) => s; +>b : Symbol(b, Decl(arrowFunctionContexts.ts, 77, 11)) +>s : Symbol(s, Decl(arrowFunctionContexts.ts, 77, 17)) +>s : Symbol(s, Decl(arrowFunctionContexts.ts, 77, 17)) + } + +} + +// (ParamList) => { ... } is a generic arrow function +var generic1 = (n: T) => [n]; +>generic1 : Symbol(generic1, Decl(arrowFunctionContexts.ts, 83, 3), Decl(arrowFunctionContexts.ts, 84, 3)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 83, 16)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 83, 19)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 83, 16)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 83, 19)) + +var generic1: { (n: T): T[] }; // Incorrect error, Bug 829597 +>generic1 : Symbol(generic1, Decl(arrowFunctionContexts.ts, 83, 3), Decl(arrowFunctionContexts.ts, 84, 3)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 84, 17)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 84, 20)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 84, 17)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 84, 17)) + +var generic2 = (n: T) => { return [n]; }; +>generic2 : Symbol(generic2, Decl(arrowFunctionContexts.ts, 85, 3), Decl(arrowFunctionContexts.ts, 86, 3)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 85, 16)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 85, 19)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 85, 16)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 85, 19)) + +var generic2: { (n: T): T[] }; +>generic2 : Symbol(generic2, Decl(arrowFunctionContexts.ts, 85, 3), Decl(arrowFunctionContexts.ts, 86, 3)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 86, 17)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 86, 20)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 86, 17)) +>T : Symbol(T, Decl(arrowFunctionContexts.ts, 86, 17)) + +// ((ParamList) => { ... } ) is a type assertion to an arrow function +var asserted1 = ((n) => [n]); +>asserted1 : Symbol(asserted1, Decl(arrowFunctionContexts.ts, 89, 3), Decl(arrowFunctionContexts.ts, 90, 3)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 89, 23)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 89, 23)) + +var asserted1: any; +>asserted1 : Symbol(asserted1, Decl(arrowFunctionContexts.ts, 89, 3), Decl(arrowFunctionContexts.ts, 90, 3)) + +var asserted2 = ((n) => { return n; }); +>asserted2 : Symbol(asserted2, Decl(arrowFunctionContexts.ts, 91, 3), Decl(arrowFunctionContexts.ts, 92, 3)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 91, 23)) +>n : Symbol(n, Decl(arrowFunctionContexts.ts, 91, 23)) + +var asserted2: any; +>asserted2 : Symbol(asserted2, Decl(arrowFunctionContexts.ts, 91, 3), Decl(arrowFunctionContexts.ts, 92, 3)) + + diff --git a/tests/baselines/reference/arrowFunctionContexts.types b/tests/baselines/reference/arrowFunctionContexts.types new file mode 100644 index 00000000000..80c310a8cd4 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionContexts.types @@ -0,0 +1,263 @@ +=== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts === +// Arrow function used in with statement +with (window) { +>window : any + + var p = () => this; +>p : any +>() => this : any +>this : any +} + +// Arrow function as argument to super call +class Base { +>Base : Base + + constructor(n: any) { } +>n : any +} + +class Derived extends Base { +>Derived : Derived +>Base : Base + + constructor() { + super(() => this); +>super(() => this) : void +>super : typeof Base +>() => this : () => this +>this : this + } +} + +// Arrow function as function argument +window.setTimeout(() => null, 100); +>window.setTimeout(() => null, 100) : any +>window.setTimeout : any +>window : any +>setTimeout : any +>() => null : () => any +>null : null +>100 : 100 + +// Arrow function as value in array literal + +var obj = (n: number) => ''; +>obj : (n: number) => string +>(n: number) => '' : (n: number) => string +>n : number +>'' : "" + +var obj: { (n: number): string; }; // OK +>obj : (n: number) => string +>n : number + +var arr = [(n: number) => '']; +>arr : ((n: number) => string)[] +>[(n: number) => ''] : ((n: number) => string)[] +>(n: number) => '' : (n: number) => string +>n : number +>'' : "" + +var arr: { (n: number): string; }[]; // Incorrect error here (bug 829597) +>arr : ((n: number) => string)[] +>n : number + +// Arrow function as enum value +enum E { +>E : E + + x = () => 4, // Error expected +>x : E +>() => 4 : () => number +>4 : 4 + + y = (() => this).length // error, can't use this in enum +>y : E +>(() => this).length : number +>(() => this) : () => any +>() => this : () => any +>this : any +>length : number +} + +// Arrow function as module variable initializer +module M { +>M : typeof M + + export var a = (s) => ''; +>a : (s: any) => string +>(s) => '' : (s: any) => string +>s : any +>'' : "" + + var b = (s) => s; +>b : (s: any) => any +>(s) => s : (s: any) => any +>s : any +>s : any +} + +// Repeat above for module members that are functions? (necessary to redo all of them?) +module M2 { +>M2 : typeof M2 + + // Arrow function used in with statement + with (window) { +>window : any + + var p = () => this; +>p : any +>() => this : any +>this : any + } + + // Arrow function as argument to super call + class Base { +>Base : Base + + constructor(n: any) { } +>n : any + } + + class Derived extends Base { +>Derived : Derived +>Base : Base + + constructor() { + super(() => this); +>super(() => this) : void +>super : typeof Base +>() => this : () => this +>this : this + } + } + + // Arrow function as function argument + window.setTimeout(() => null, 100); +>window.setTimeout(() => null, 100) : any +>window.setTimeout : any +>window : any +>setTimeout : any +>() => null : () => any +>null : null +>100 : 100 + + // Arrow function as value in array literal + + var obj = (n: number) => ''; +>obj : (n: number) => string +>(n: number) => '' : (n: number) => string +>n : number +>'' : "" + + var obj: { (n: number): string; }; // OK +>obj : (n: number) => string +>n : number + + var arr = [(n: number) => '']; +>arr : ((n: number) => string)[] +>[(n: number) => ''] : ((n: number) => string)[] +>(n: number) => '' : (n: number) => string +>n : number +>'' : "" + + var arr: { (n: number): string; }[]; // Incorrect error here (bug 829597) +>arr : ((n: number) => string)[] +>n : number + + // Arrow function as enum value + enum E { +>E : E + + x = () => 4, // Error expected +>x : E +>() => 4 : () => number +>4 : 4 + + y = (() => this).length +>y : E +>(() => this).length : number +>(() => this) : () => any +>() => this : () => any +>this : any +>length : number + } + + // Arrow function as module variable initializer + module M { +>M : typeof M + + export var a = (s) => ''; +>a : (s: any) => string +>(s) => '' : (s: any) => string +>s : any +>'' : "" + + var b = (s) => s; +>b : (s: any) => any +>(s) => s : (s: any) => any +>s : any +>s : any + } + +} + +// (ParamList) => { ... } is a generic arrow function +var generic1 = (n: T) => [n]; +>generic1 : (n: T) => T[] +>(n: T) => [n] : (n: T) => T[] +>T : T +>n : T +>T : T +>[n] : T[] +>n : T + +var generic1: { (n: T): T[] }; // Incorrect error, Bug 829597 +>generic1 : (n: T) => T[] +>T : T +>n : T +>T : T +>T : T + +var generic2 = (n: T) => { return [n]; }; +>generic2 : (n: T) => T[] +>(n: T) => { return [n]; } : (n: T) => T[] +>T : T +>n : T +>T : T +>[n] : T[] +>n : T + +var generic2: { (n: T): T[] }; +>generic2 : (n: T) => T[] +>T : T +>n : T +>T : T +>T : T + +// ((ParamList) => { ... } ) is a type assertion to an arrow function +var asserted1 = ((n) => [n]); +>asserted1 : any +>((n) => [n]) : any +>((n) => [n]) : (n: any) => any[] +>(n) => [n] : (n: any) => any[] +>n : any +>[n] : any[] +>n : any + +var asserted1: any; +>asserted1 : any + +var asserted2 = ((n) => { return n; }); +>asserted2 : any +>((n) => { return n; }) : any +>((n) => { return n; }) : (n: any) => any +>(n) => { return n; } : (n: any) => any +>n : any +>n : any + +var asserted2: any; +>asserted2 : any + + diff --git a/tests/baselines/reference/arrowFunctionErrorSpan.symbols b/tests/baselines/reference/arrowFunctionErrorSpan.symbols new file mode 100644 index 00000000000..c5adb1da8f8 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionErrorSpan.symbols @@ -0,0 +1,81 @@ +=== tests/cases/compiler/arrowFunctionErrorSpan.ts === +function f(a: () => number) { } +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) +>a : Symbol(a, Decl(arrowFunctionErrorSpan.ts, 0, 11)) + +// oneliner +f(() => { }); +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) + +// multiline, body +f(() => { +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) + +}); + +// multiline 2, body +f(() => { +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) + +}); + +// multiline 3, arrow on a new line +f(() +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) + + => { }); + +// multiline 4, arguments +f((a, +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) +>a : Symbol(a, Decl(arrowFunctionErrorSpan.ts, 20, 3)) + + b, +>b : Symbol(b, Decl(arrowFunctionErrorSpan.ts, 20, 5)) + + c, +>c : Symbol(c, Decl(arrowFunctionErrorSpan.ts, 21, 6)) + + d) => { }); +>d : Symbol(d, Decl(arrowFunctionErrorSpan.ts, 22, 6)) + +// single line with a comment +f(/* +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) + + */() => { }); + +// multi line with a comment +f(/* +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) + + */() => { }); + +// multi line with a comment 2 +f(/* +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) + + */() => { + + }); + +// multi line with a comment 3 +f( // comment 1 +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) + + // comment 2 + () => + // comment 3 + { + // comment 4 + } + // comment 5 +); + +// body is not a block +f(_ => 1 + +>f : Symbol(f, Decl(arrowFunctionErrorSpan.ts, 0, 0)) +>_ : Symbol(_, Decl(arrowFunctionErrorSpan.ts, 51, 2)) + + 2); + diff --git a/tests/baselines/reference/arrowFunctionErrorSpan.types b/tests/baselines/reference/arrowFunctionErrorSpan.types new file mode 100644 index 00000000000..1d5bde951cd --- /dev/null +++ b/tests/baselines/reference/arrowFunctionErrorSpan.types @@ -0,0 +1,105 @@ +=== tests/cases/compiler/arrowFunctionErrorSpan.ts === +function f(a: () => number) { } +>f : (a: () => number) => void +>a : () => number + +// oneliner +f(() => { }); +>f(() => { }) : void +>f : (a: () => number) => void +>() => { } : () => void + +// multiline, body +f(() => { +>f(() => {}) : void +>f : (a: () => number) => void +>() => {} : () => void + +}); + +// multiline 2, body +f(() => { +>f(() => {}) : void +>f : (a: () => number) => void +>() => {} : () => void + +}); + +// multiline 3, arrow on a new line +f(() +>f(() => { }) : void +>f : (a: () => number) => void +>() => { } : () => void + + => { }); + +// multiline 4, arguments +f((a, +>f((a, b, c, d) => { }) : void +>f : (a: () => number) => void +>(a, b, c, d) => { } : (a: any, b: any, c: any, d: any) => void +>a : any + + b, +>b : any + + c, +>c : any + + d) => { }); +>d : any + +// single line with a comment +f(/* +>f(/* */() => { }) : void +>f : (a: () => number) => void + + */() => { }); +>() => { } : () => void + +// multi line with a comment +f(/* +>f(/* */() => { }) : void +>f : (a: () => number) => void + + */() => { }); +>() => { } : () => void + +// multi line with a comment 2 +f(/* +>f(/* */() => { }) : void +>f : (a: () => number) => void + + */() => { +>() => { } : () => void + + }); + +// multi line with a comment 3 +f( // comment 1 +>f( // comment 1 // comment 2 () => // comment 3 { // comment 4 } // comment 5) : void +>f : (a: () => number) => void + + // comment 2 + () => +>() => // comment 3 { // comment 4 } : () => void + + // comment 3 + { + // comment 4 + } + // comment 5 +); + +// body is not a block +f(_ => 1 + +>f(_ => 1 + 2) : void +>f : (a: () => number) => void +>_ => 1 + 2 : (_: any) => number +>_ : any +>1 + 2 : number +>1 : 1 + + 2); +>2 : 2 + diff --git a/tests/baselines/reference/arrowFunctionInConstructorArgument1.symbols b/tests/baselines/reference/arrowFunctionInConstructorArgument1.symbols new file mode 100644 index 00000000000..2991e8ace27 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionInConstructorArgument1.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/arrowFunctionInConstructorArgument1.ts === +class C { +>C : Symbol(C, Decl(arrowFunctionInConstructorArgument1.ts, 0, 0)) + + constructor(x: () => void) { } +>x : Symbol(x, Decl(arrowFunctionInConstructorArgument1.ts, 1, 16)) +} +var c = new C(() => { return asdf; } ) // should error +>c : Symbol(c, Decl(arrowFunctionInConstructorArgument1.ts, 3, 3)) +>C : Symbol(C, Decl(arrowFunctionInConstructorArgument1.ts, 0, 0)) + diff --git a/tests/baselines/reference/arrowFunctionInConstructorArgument1.types b/tests/baselines/reference/arrowFunctionInConstructorArgument1.types new file mode 100644 index 00000000000..bea39c33b10 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionInConstructorArgument1.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/arrowFunctionInConstructorArgument1.ts === +class C { +>C : C + + constructor(x: () => void) { } +>x : () => void +} +var c = new C(() => { return asdf; } ) // should error +>c : C +>new C(() => { return asdf; } ) : C +>C : typeof C +>() => { return asdf; } : () => any +>asdf : any + diff --git a/tests/baselines/reference/arrowFunctionMissingCurlyWithSemicolon.symbols b/tests/baselines/reference/arrowFunctionMissingCurlyWithSemicolon.symbols new file mode 100644 index 00000000000..af4ae1b5976 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionMissingCurlyWithSemicolon.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/arrowFunctionMissingCurlyWithSemicolon.ts === +// Should error at semicolon. +var f = () => ; +>f : Symbol(f, Decl(arrowFunctionMissingCurlyWithSemicolon.ts, 1, 3)) + +var b = 1 * 2 * 3 * 4; +>b : Symbol(b, Decl(arrowFunctionMissingCurlyWithSemicolon.ts, 2, 3)) + +var square = (x: number) => x * x; +>square : Symbol(square, Decl(arrowFunctionMissingCurlyWithSemicolon.ts, 3, 3)) +>x : Symbol(x, Decl(arrowFunctionMissingCurlyWithSemicolon.ts, 3, 14)) +>x : Symbol(x, Decl(arrowFunctionMissingCurlyWithSemicolon.ts, 3, 14)) +>x : Symbol(x, Decl(arrowFunctionMissingCurlyWithSemicolon.ts, 3, 14)) + diff --git a/tests/baselines/reference/arrowFunctionMissingCurlyWithSemicolon.types b/tests/baselines/reference/arrowFunctionMissingCurlyWithSemicolon.types new file mode 100644 index 00000000000..90dc0011b79 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionMissingCurlyWithSemicolon.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/arrowFunctionMissingCurlyWithSemicolon.ts === +// Should error at semicolon. +var f = () => ; +>f : () => any +>() => : () => any +> : any + +var b = 1 * 2 * 3 * 4; +>b : number +>1 * 2 * 3 * 4 : number +>1 * 2 * 3 : number +>1 * 2 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 + +var square = (x: number) => x * x; +>square : (x: number) => number +>(x: number) => x * x : (x: number) => number +>x : number +>x * x : number +>x : number +>x : number + diff --git a/tests/baselines/reference/arrowFunctionsMissingTokens.symbols b/tests/baselines/reference/arrowFunctionsMissingTokens.symbols new file mode 100644 index 00000000000..31d91f71960 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionsMissingTokens.symbols @@ -0,0 +1,135 @@ +=== tests/cases/compiler/arrowFunctionsMissingTokens.ts === +module missingArrowsWithCurly { +>missingArrowsWithCurly : Symbol(missingArrowsWithCurly, Decl(arrowFunctionsMissingTokens.ts, 0, 0)) + + var a = () { }; +>a : Symbol(a, Decl(arrowFunctionsMissingTokens.ts, 1, 7)) + + var b = (): void { } +>b : Symbol(b, Decl(arrowFunctionsMissingTokens.ts, 3, 7)) + + var c = (x) { }; +>c : Symbol(c, Decl(arrowFunctionsMissingTokens.ts, 5, 7)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 5, 13)) + + var d = (x: number, y: string) { }; +>d : Symbol(d, Decl(arrowFunctionsMissingTokens.ts, 7, 7)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 7, 13)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 7, 23)) + + var e = (x: number, y: string): void { }; +>e : Symbol(e, Decl(arrowFunctionsMissingTokens.ts, 9, 7)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 9, 13)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 9, 23)) +} + +module missingCurliesWithArrow { +>missingCurliesWithArrow : Symbol(missingCurliesWithArrow, Decl(arrowFunctionsMissingTokens.ts, 10, 1)) + + module withStatement { +>withStatement : Symbol(withStatement, Decl(arrowFunctionsMissingTokens.ts, 12, 32)) + + var a = () => var k = 10;}; +>a : Symbol(a, Decl(arrowFunctionsMissingTokens.ts, 14, 11)) +>k : Symbol(k, Decl(arrowFunctionsMissingTokens.ts, 14, 25)) + + var b = (): void => var k = 10;} +>b : Symbol(b, Decl(arrowFunctionsMissingTokens.ts, 16, 11)) +>k : Symbol(k, Decl(arrowFunctionsMissingTokens.ts, 16, 31)) + + var c = (x) => var k = 10;}; +>c : Symbol(c, Decl(arrowFunctionsMissingTokens.ts, 18, 11)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 18, 17)) +>k : Symbol(k, Decl(arrowFunctionsMissingTokens.ts, 18, 26)) + + var d = (x: number, y: string) => var k = 10;}; +>d : Symbol(d, Decl(arrowFunctionsMissingTokens.ts, 20, 11)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 20, 17)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 20, 27)) +>k : Symbol(k, Decl(arrowFunctionsMissingTokens.ts, 20, 45)) + + var e = (x: number, y: string): void => var k = 10;}; +>e : Symbol(e, Decl(arrowFunctionsMissingTokens.ts, 22, 11)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 22, 17)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 22, 27)) +>k : Symbol(k, Decl(arrowFunctionsMissingTokens.ts, 22, 51)) + + var f = () => var k = 10;} +>f : Symbol(f, Decl(arrowFunctionsMissingTokens.ts, 24, 11)) +>k : Symbol(k, Decl(arrowFunctionsMissingTokens.ts, 24, 25)) + } + + module withoutStatement { +>withoutStatement : Symbol(withoutStatement, Decl(arrowFunctionsMissingTokens.ts, 25, 5)) + + var a = () => }; +>a : Symbol(a, Decl(arrowFunctionsMissingTokens.ts, 28, 11)) + + var b = (): void => } +>b : Symbol(b, Decl(arrowFunctionsMissingTokens.ts, 30, 11)) + + var c = (x) => }; +>c : Symbol(c, Decl(arrowFunctionsMissingTokens.ts, 32, 11)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 32, 17)) + + var d = (x: number, y: string) => }; +>d : Symbol(d, Decl(arrowFunctionsMissingTokens.ts, 34, 11)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 34, 17)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 34, 27)) + + var e = (x: number, y: string): void => }; +>e : Symbol(e, Decl(arrowFunctionsMissingTokens.ts, 36, 11)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 36, 17)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 36, 27)) + + var f = () => } +>f : Symbol(f, Decl(arrowFunctionsMissingTokens.ts, 38, 11)) + } +} + +module ce_nEst_pas_une_arrow_function { +>ce_nEst_pas_une_arrow_function : Symbol(ce_nEst_pas_une_arrow_function, Decl(arrowFunctionsMissingTokens.ts, 40, 1)) + + var a = (); +>a : Symbol(a, Decl(arrowFunctionsMissingTokens.ts, 43, 7)) + + var b = (): void; +>b : Symbol(b, Decl(arrowFunctionsMissingTokens.ts, 45, 7)) + + var c = (x); +>c : Symbol(c, Decl(arrowFunctionsMissingTokens.ts, 47, 7)) + + var d = (x: number, y: string); +>d : Symbol(d, Decl(arrowFunctionsMissingTokens.ts, 49, 7)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 49, 13)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 49, 23)) + + var e = (x: number, y: string): void; +>e : Symbol(e, Decl(arrowFunctionsMissingTokens.ts, 51, 7)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 51, 13)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 51, 23)) +} + +module okay { +>okay : Symbol(okay, Decl(arrowFunctionsMissingTokens.ts, 52, 1)) + + var a = () => { }; +>a : Symbol(a, Decl(arrowFunctionsMissingTokens.ts, 55, 7)) + + var b = (): void => { } +>b : Symbol(b, Decl(arrowFunctionsMissingTokens.ts, 57, 7)) + + var c = (x) => { }; +>c : Symbol(c, Decl(arrowFunctionsMissingTokens.ts, 59, 7)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 59, 13)) + + var d = (x: number, y: string) => { }; +>d : Symbol(d, Decl(arrowFunctionsMissingTokens.ts, 61, 7)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 61, 13)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 61, 23)) + + var e = (x: number, y: string): void => { }; +>e : Symbol(e, Decl(arrowFunctionsMissingTokens.ts, 63, 7)) +>x : Symbol(x, Decl(arrowFunctionsMissingTokens.ts, 63, 13)) +>y : Symbol(y, Decl(arrowFunctionsMissingTokens.ts, 63, 23)) +} diff --git a/tests/baselines/reference/arrowFunctionsMissingTokens.types b/tests/baselines/reference/arrowFunctionsMissingTokens.types new file mode 100644 index 00000000000..ab067bb1415 --- /dev/null +++ b/tests/baselines/reference/arrowFunctionsMissingTokens.types @@ -0,0 +1,179 @@ +=== tests/cases/compiler/arrowFunctionsMissingTokens.ts === +module missingArrowsWithCurly { +>missingArrowsWithCurly : typeof missingArrowsWithCurly + + var a = () { }; +>a : () => void +>() { } : () => void + + var b = (): void { } +>b : () => void +>(): void { } : () => void + + var c = (x) { }; +>c : (x: any) => void +>(x) { } : (x: any) => void +>x : any + + var d = (x: number, y: string) { }; +>d : (x: number, y: string) => void +>(x: number, y: string) { } : (x: number, y: string) => void +>x : number +>y : string + + var e = (x: number, y: string): void { }; +>e : (x: number, y: string) => void +>(x: number, y: string): void { } : (x: number, y: string) => void +>x : number +>y : string +} + +module missingCurliesWithArrow { +>missingCurliesWithArrow : typeof missingCurliesWithArrow + + module withStatement { +>withStatement : typeof withStatement + + var a = () => var k = 10;}; +>a : () => void +>() => var k = 10;} : () => void +>k : number +>10 : 10 + + var b = (): void => var k = 10;} +>b : () => void +>(): void => var k = 10;} : () => void +>k : number +>10 : 10 + + var c = (x) => var k = 10;}; +>c : (x: any) => void +>(x) => var k = 10;} : (x: any) => void +>x : any +>k : number +>10 : 10 + + var d = (x: number, y: string) => var k = 10;}; +>d : (x: number, y: string) => void +>(x: number, y: string) => var k = 10;} : (x: number, y: string) => void +>x : number +>y : string +>k : number +>10 : 10 + + var e = (x: number, y: string): void => var k = 10;}; +>e : (x: number, y: string) => void +>(x: number, y: string): void => var k = 10;} : (x: number, y: string) => void +>x : number +>y : string +>k : number +>10 : 10 + + var f = () => var k = 10;} +>f : () => void +>() => var k = 10;} : () => void +>k : number +>10 : 10 + } + + module withoutStatement { +>withoutStatement : typeof withoutStatement + + var a = () => }; +>a : () => any +>() => : () => any +> : any + + var b = (): void => } +>b : () => void +>(): void => : () => void +> : any + + var c = (x) => }; +>c : (x: any) => any +>(x) => : (x: any) => any +>x : any +> : any + + var d = (x: number, y: string) => }; +>d : (x: number, y: string) => any +>(x: number, y: string) => : (x: number, y: string) => any +>x : number +>y : string +> : any + + var e = (x: number, y: string): void => }; +>e : (x: number, y: string) => void +>(x: number, y: string): void => : (x: number, y: string) => void +>x : number +>y : string +> : any + + var f = () => } +>f : () => any +>() => : () => any +> : any + } +} + +module ce_nEst_pas_une_arrow_function { +>ce_nEst_pas_une_arrow_function : typeof ce_nEst_pas_une_arrow_function + + var a = (); +>a : any +>() : any +> : any + + var b = (): void; +>b : () => void +>(): void : () => void +> : any + + var c = (x); +>c : any +>(x) : any +>x : any + + var d = (x: number, y: string); +>d : (x: number, y: string) => any +>(x: number, y: string) : (x: number, y: string) => any +>x : number +>y : string +> : any + + var e = (x: number, y: string): void; +>e : (x: number, y: string) => void +>(x: number, y: string): void : (x: number, y: string) => void +>x : number +>y : string +> : any +} + +module okay { +>okay : typeof okay + + var a = () => { }; +>a : () => void +>() => { } : () => void + + var b = (): void => { } +>b : () => void +>(): void => { } : () => void + + var c = (x) => { }; +>c : (x: any) => void +>(x) => { } : (x: any) => void +>x : any + + var d = (x: number, y: string) => { }; +>d : (x: number, y: string) => void +>(x: number, y: string) => { } : (x: number, y: string) => void +>x : number +>y : string + + var e = (x: number, y: string): void => { }; +>e : (x: number, y: string) => void +>(x: number, y: string): void => { } : (x: number, y: string) => void +>x : number +>y : string +} diff --git a/tests/baselines/reference/asOperator2.symbols b/tests/baselines/reference/asOperator2.symbols new file mode 100644 index 00000000000..52ddf48e2e7 --- /dev/null +++ b/tests/baselines/reference/asOperator2.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator2.ts === +var x = 23 as string; +>x : Symbol(x, Decl(asOperator2.ts, 0, 3)) + diff --git a/tests/baselines/reference/asOperator2.types b/tests/baselines/reference/asOperator2.types new file mode 100644 index 00000000000..108b97a1d85 --- /dev/null +++ b/tests/baselines/reference/asOperator2.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/expressions/asOperator/asOperator2.ts === +var x = 23 as string; +>x : string +>23 as string : string +>23 : 23 + diff --git a/tests/baselines/reference/asOperatorAmbiguity.symbols b/tests/baselines/reference/asOperatorAmbiguity.symbols new file mode 100644 index 00000000000..d191f110b3b --- /dev/null +++ b/tests/baselines/reference/asOperatorAmbiguity.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts === +interface A { x: T; } +>A : Symbol(A, Decl(asOperatorAmbiguity.ts, 0, 0)) +>T : Symbol(T, Decl(asOperatorAmbiguity.ts, 0, 12)) +>x : Symbol(A.x, Decl(asOperatorAmbiguity.ts, 0, 16)) +>T : Symbol(T, Decl(asOperatorAmbiguity.ts, 0, 12)) + +interface B { m: string; } +>B : Symbol(B, Decl(asOperatorAmbiguity.ts, 0, 24)) +>m : Symbol(B.m, Decl(asOperatorAmbiguity.ts, 1, 13)) + +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x: any; +>x : Symbol(x, Decl(asOperatorAmbiguity.ts, 4, 3)) + +var y = x as A[]; +>y : Symbol(y, Decl(asOperatorAmbiguity.ts, 5, 3)) +>x : Symbol(x, Decl(asOperatorAmbiguity.ts, 4, 3)) +>A : Symbol(A, Decl(asOperatorAmbiguity.ts, 0, 0)) +>B : Symbol(B, Decl(asOperatorAmbiguity.ts, 0, 24)) + +var z = y[0].m; // z should be string +>z : Symbol(z, Decl(asOperatorAmbiguity.ts, 6, 3)) +>y : Symbol(y, Decl(asOperatorAmbiguity.ts, 5, 3)) + + diff --git a/tests/baselines/reference/asOperatorAmbiguity.types b/tests/baselines/reference/asOperatorAmbiguity.types new file mode 100644 index 00000000000..61aa0f00e66 --- /dev/null +++ b/tests/baselines/reference/asOperatorAmbiguity.types @@ -0,0 +1,31 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorAmbiguity.ts === +interface A { x: T; } +>A : A +>T : T +>x : T +>T : T + +interface B { m: string; } +>B : B +>m : string + +// Make sure this is a type assertion to an array type, and not nested comparison operators. +var x: any; +>x : any + +var y = x as A[]; +>y : A[] +>x as A[] : A[] +>x : any +>A : A +>B : B + +var z = y[0].m; // z should be string +>z : any +>y[0].m : any +>y[0] : A +>y : A[] +>0 : 0 +>m : any + + diff --git a/tests/baselines/reference/asOperatorContextualType.symbols b/tests/baselines/reference/asOperatorContextualType.symbols new file mode 100644 index 00000000000..b32284b5393 --- /dev/null +++ b/tests/baselines/reference/asOperatorContextualType.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts === +// should error +var x = (v => v) as (x: number) => string; +>x : Symbol(x, Decl(asOperatorContextualType.ts, 1, 3)) +>v : Symbol(v, Decl(asOperatorContextualType.ts, 1, 9)) +>v : Symbol(v, Decl(asOperatorContextualType.ts, 1, 9)) +>x : Symbol(x, Decl(asOperatorContextualType.ts, 1, 21)) + diff --git a/tests/baselines/reference/asOperatorContextualType.types b/tests/baselines/reference/asOperatorContextualType.types new file mode 100644 index 00000000000..b318dd4878b --- /dev/null +++ b/tests/baselines/reference/asOperatorContextualType.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorContextualType.ts === +// should error +var x = (v => v) as (x: number) => string; +>x : (x: number) => string +>(v => v) as (x: number) => string : (x: number) => string +>(v => v) : (v: number) => number +>v => v : (v: number) => number +>v : number +>v : number +>x : number + diff --git a/tests/baselines/reference/asOperatorNames.symbols b/tests/baselines/reference/asOperatorNames.symbols new file mode 100644 index 00000000000..eda84b98c24 --- /dev/null +++ b/tests/baselines/reference/asOperatorNames.symbols @@ -0,0 +1,15 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorNames.ts === +var a = 20; +>a : Symbol(a, Decl(asOperatorNames.ts, 0, 3)) + +var b = a as string; +>b : Symbol(b, Decl(asOperatorNames.ts, 1, 3)) +>a : Symbol(a, Decl(asOperatorNames.ts, 0, 3)) + +var as = "hello"; +>as : Symbol(as, Decl(asOperatorNames.ts, 2, 3)) + +var as1 = as as string; +>as1 : Symbol(as1, Decl(asOperatorNames.ts, 3, 3)) +>as : Symbol(as, Decl(asOperatorNames.ts, 2, 3)) + diff --git a/tests/baselines/reference/asOperatorNames.types b/tests/baselines/reference/asOperatorNames.types new file mode 100644 index 00000000000..0caa81d1f8d --- /dev/null +++ b/tests/baselines/reference/asOperatorNames.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/expressions/asOperator/asOperatorNames.ts === +var a = 20; +>a : number +>20 : 20 + +var b = a as string; +>b : string +>a as string : string +>a : number + +var as = "hello"; +>as : string +>"hello" : "hello" + +var as1 = as as string; +>as1 : string +>as as string : string +>as : string + diff --git a/tests/baselines/reference/asiAbstract.symbols b/tests/baselines/reference/asiAbstract.symbols new file mode 100644 index 00000000000..d7781af6495 --- /dev/null +++ b/tests/baselines/reference/asiAbstract.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/asiAbstract.ts === +abstract +class NonAbstractClass { +>NonAbstractClass : Symbol(NonAbstractClass, Decl(asiAbstract.ts, 0, 8)) + + abstract s(); +>s : Symbol(NonAbstractClass.s, Decl(asiAbstract.ts, 1, 24)) +} + +class C2 { +>C2 : Symbol(C2, Decl(asiAbstract.ts, 3, 1)) + + abstract +>abstract : Symbol(C2.abstract, Decl(asiAbstract.ts, 5, 10)) + + nonAbstractFunction() { +>nonAbstractFunction : Symbol(C2.nonAbstractFunction, Decl(asiAbstract.ts, 6, 12)) + } +} + +class C3 { +>C3 : Symbol(C3, Decl(asiAbstract.ts, 9, 1)) + + abstract +>abstract : Symbol(C3.abstract, Decl(asiAbstract.ts, 11, 10)) +} + diff --git a/tests/baselines/reference/asiAbstract.types b/tests/baselines/reference/asiAbstract.types new file mode 100644 index 00000000000..d1ac88d5373 --- /dev/null +++ b/tests/baselines/reference/asiAbstract.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/asiAbstract.ts === +abstract +>abstract : any + +class NonAbstractClass { +>NonAbstractClass : NonAbstractClass + + abstract s(); +>s : () => any +} + +class C2 { +>C2 : C2 + + abstract +>abstract : any + + nonAbstractFunction() { +>nonAbstractFunction : () => void + } +} + +class C3 { +>C3 : C3 + + abstract +>abstract : any +} + diff --git a/tests/baselines/reference/asiPreventsParsingAsInterface05.symbols b/tests/baselines/reference/asiPreventsParsingAsInterface05.symbols new file mode 100644 index 00000000000..08eddcb1d78 --- /dev/null +++ b/tests/baselines/reference/asiPreventsParsingAsInterface05.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface05.ts === +"use strict" + +var interface: number; +>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface05.ts, 2, 3)) + +// 'interface' is a strict mode reserved word, and so it would be permissible +// to allow 'interface' and the name of the interface to be on separate lines; +// however, this complicates things, and so it is preferable to restrict interface +// declarations such that their identifier must follow 'interface' on the same line. + +interface // This should be the identifier 'interface' +>interface : Symbol(interface, Decl(asiPreventsParsingAsInterface05.ts, 2, 3)) + +I // This should be the identifier 'I' +{ } // This should be a block body diff --git a/tests/baselines/reference/asiPreventsParsingAsInterface05.types b/tests/baselines/reference/asiPreventsParsingAsInterface05.types new file mode 100644 index 00000000000..3cd12ce04b3 --- /dev/null +++ b/tests/baselines/reference/asiPreventsParsingAsInterface05.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/interfaces/interfaceDeclarations/asiPreventsParsingAsInterface05.ts === +"use strict" +>"use strict" : "use strict" + +var interface: number; +>interface : number + +// 'interface' is a strict mode reserved word, and so it would be permissible +// to allow 'interface' and the name of the interface to be on separate lines; +// however, this complicates things, and so it is preferable to restrict interface +// declarations such that their identifier must follow 'interface' on the same line. + +interface // This should be the identifier 'interface' +>interface : number + +I // This should be the identifier 'I' +>I : any + +{ } // This should be a block body diff --git a/tests/baselines/reference/asiPublicPrivateProtected.symbols b/tests/baselines/reference/asiPublicPrivateProtected.symbols new file mode 100644 index 00000000000..987849a329a --- /dev/null +++ b/tests/baselines/reference/asiPublicPrivateProtected.symbols @@ -0,0 +1,72 @@ +=== tests/cases/compiler/asiPublicPrivateProtected.ts === +public +class NonPublicClass { +>NonPublicClass : Symbol(NonPublicClass, Decl(asiPublicPrivateProtected.ts, 0, 6)) + + public s() { +>s : Symbol(NonPublicClass.s, Decl(asiPublicPrivateProtected.ts, 1, 22)) + } +} + +class NonPublicClass2 { +>NonPublicClass2 : Symbol(NonPublicClass2, Decl(asiPublicPrivateProtected.ts, 4, 1)) + + public +>public : Symbol(NonPublicClass2.public, Decl(asiPublicPrivateProtected.ts, 6, 23)) + + private nonPublicFunction() { +>nonPublicFunction : Symbol(NonPublicClass2.nonPublicFunction, Decl(asiPublicPrivateProtected.ts, 7, 10)) + } +} +private +class NonPrivateClass { +>NonPrivateClass : Symbol(NonPrivateClass, Decl(asiPublicPrivateProtected.ts, 11, 7)) + + private s() { +>s : Symbol(NonPrivateClass.s, Decl(asiPublicPrivateProtected.ts, 12, 23)) + } +} + +class NonPrivateClass2 { +>NonPrivateClass2 : Symbol(NonPrivateClass2, Decl(asiPublicPrivateProtected.ts, 15, 1)) + + private +>private : Symbol(NonPrivateClass2.private, Decl(asiPublicPrivateProtected.ts, 17, 24)) + + public nonPrivateFunction() { +>nonPrivateFunction : Symbol(NonPrivateClass2.nonPrivateFunction, Decl(asiPublicPrivateProtected.ts, 18, 11)) + } +} +protected +class NonProtectedClass { +>NonProtectedClass : Symbol(NonProtectedClass, Decl(asiPublicPrivateProtected.ts, 22, 9)) + + protected s() { +>s : Symbol(NonProtectedClass.s, Decl(asiPublicPrivateProtected.ts, 23, 25)) + } +} + +class NonProtectedClass2 { +>NonProtectedClass2 : Symbol(NonProtectedClass2, Decl(asiPublicPrivateProtected.ts, 26, 1)) + + protected +>protected : Symbol(NonProtectedClass2.protected, Decl(asiPublicPrivateProtected.ts, 28, 26)) + + public nonProtectedFunction() { +>nonProtectedFunction : Symbol(NonProtectedClass2.nonProtectedFunction, Decl(asiPublicPrivateProtected.ts, 29, 13)) + } +} + +class ClassWithThreeMembers { +>ClassWithThreeMembers : Symbol(ClassWithThreeMembers, Decl(asiPublicPrivateProtected.ts, 32, 1)) + + public +>public : Symbol(ClassWithThreeMembers.public, Decl(asiPublicPrivateProtected.ts, 34, 29)) + + private +>private : Symbol(ClassWithThreeMembers.private, Decl(asiPublicPrivateProtected.ts, 35, 10)) + + protected +>protected : Symbol(ClassWithThreeMembers.protected, Decl(asiPublicPrivateProtected.ts, 36, 11)) +} + diff --git a/tests/baselines/reference/asiPublicPrivateProtected.types b/tests/baselines/reference/asiPublicPrivateProtected.types new file mode 100644 index 00000000000..c1734d8488d --- /dev/null +++ b/tests/baselines/reference/asiPublicPrivateProtected.types @@ -0,0 +1,78 @@ +=== tests/cases/compiler/asiPublicPrivateProtected.ts === +public +>public : any + +class NonPublicClass { +>NonPublicClass : NonPublicClass + + public s() { +>s : () => void + } +} + +class NonPublicClass2 { +>NonPublicClass2 : NonPublicClass2 + + public +>public : any + + private nonPublicFunction() { +>nonPublicFunction : () => void + } +} +private +>private : any + +class NonPrivateClass { +>NonPrivateClass : NonPrivateClass + + private s() { +>s : () => void + } +} + +class NonPrivateClass2 { +>NonPrivateClass2 : NonPrivateClass2 + + private +>private : any + + public nonPrivateFunction() { +>nonPrivateFunction : () => void + } +} +protected +>protected : any + +class NonProtectedClass { +>NonProtectedClass : NonProtectedClass + + protected s() { +>s : () => void + } +} + +class NonProtectedClass2 { +>NonProtectedClass2 : NonProtectedClass2 + + protected +>protected : any + + public nonProtectedFunction() { +>nonProtectedFunction : () => void + } +} + +class ClassWithThreeMembers { +>ClassWithThreeMembers : ClassWithThreeMembers + + public +>public : any + + private +>private : any + + protected +>protected : any +} + diff --git a/tests/baselines/reference/asiReturn.symbols b/tests/baselines/reference/asiReturn.symbols new file mode 100644 index 00000000000..da206e8577b --- /dev/null +++ b/tests/baselines/reference/asiReturn.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/asiReturn.ts === +// This should be an error for using a return outside a function, but ASI should work properly +No type information for this code.return +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/asiReturn.types b/tests/baselines/reference/asiReturn.types new file mode 100644 index 00000000000..da206e8577b --- /dev/null +++ b/tests/baselines/reference/asiReturn.types @@ -0,0 +1,4 @@ +=== tests/cases/compiler/asiReturn.ts === +// This should be an error for using a return outside a function, but ASI should work properly +No type information for this code.return +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/assertInWrapSomeTypeParameter.symbols b/tests/baselines/reference/assertInWrapSomeTypeParameter.symbols new file mode 100644 index 00000000000..c2079508930 --- /dev/null +++ b/tests/baselines/reference/assertInWrapSomeTypeParameter.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/assertInWrapSomeTypeParameter.ts === +class C> { +>C : Symbol(C, Decl(assertInWrapSomeTypeParameter.ts, 0, 0)) +>T : Symbol(T, Decl(assertInWrapSomeTypeParameter.ts, 0, 8)) +>C : Symbol(C, Decl(assertInWrapSomeTypeParameter.ts, 0, 0)) +>T : Symbol(T, Decl(assertInWrapSomeTypeParameter.ts, 0, 8)) + + foo>(x: U) { +>foo : Symbol(C.foo, Decl(assertInWrapSomeTypeParameter.ts, 0, 25)) +>U : Symbol(U, Decl(assertInWrapSomeTypeParameter.ts, 1, 8)) +>C : Symbol(C, Decl(assertInWrapSomeTypeParameter.ts, 0, 0)) +>C : Symbol(C, Decl(assertInWrapSomeTypeParameter.ts, 0, 0)) +>T : Symbol(T, Decl(assertInWrapSomeTypeParameter.ts, 0, 8)) +>x : Symbol(x, Decl(assertInWrapSomeTypeParameter.ts, 1, 26)) +>U : Symbol(U, Decl(assertInWrapSomeTypeParameter.ts, 1, 8)) + + return null; + } +} diff --git a/tests/baselines/reference/assertInWrapSomeTypeParameter.types b/tests/baselines/reference/assertInWrapSomeTypeParameter.types new file mode 100644 index 00000000000..289001b6c3a --- /dev/null +++ b/tests/baselines/reference/assertInWrapSomeTypeParameter.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/assertInWrapSomeTypeParameter.ts === +class C> { +>C : C +>T : T +>C : C +>T : T + + foo>(x: U) { +>foo : >>(x: U) => any +>U : U +>C : C +>C : C +>T : T +>x : U +>U : U + + return null; +>null : null + } +} diff --git a/tests/baselines/reference/assignAnyToEveryType.symbols b/tests/baselines/reference/assignAnyToEveryType.symbols new file mode 100644 index 00000000000..c5f6addb2fa --- /dev/null +++ b/tests/baselines/reference/assignAnyToEveryType.symbols @@ -0,0 +1,115 @@ +=== tests/cases/conformance/types/any/assignAnyToEveryType.ts === +// all of these are valid + +var x: any; +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var a: number = x; +>a : Symbol(a, Decl(assignAnyToEveryType.ts, 4, 3)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var b: boolean = x; +>b : Symbol(b, Decl(assignAnyToEveryType.ts, 5, 3)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var c: string = x; +>c : Symbol(c, Decl(assignAnyToEveryType.ts, 6, 3)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var d: void = x; +>d : Symbol(d, Decl(assignAnyToEveryType.ts, 7, 3)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var e = null; +>e : Symbol(e, Decl(assignAnyToEveryType.ts, 8, 3)) + +e = x; +>e : Symbol(e, Decl(assignAnyToEveryType.ts, 8, 3)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var f = undefined; +>f : Symbol(f, Decl(assignAnyToEveryType.ts, 10, 3)) +>undefined : Symbol(undefined) + +f = x; +>f : Symbol(f, Decl(assignAnyToEveryType.ts, 10, 3)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +enum E { +>E : Symbol(E, Decl(assignAnyToEveryType.ts, 11, 6)) + + A +>A : Symbol(E.A, Decl(assignAnyToEveryType.ts, 13, 8)) +} + +var g: E = x; +>g : Symbol(g, Decl(assignAnyToEveryType.ts, 17, 3)) +>E : Symbol(E, Decl(assignAnyToEveryType.ts, 11, 6)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var g2 = E.A; +>g2 : Symbol(g2, Decl(assignAnyToEveryType.ts, 18, 3)) +>E.A : Symbol(E.A, Decl(assignAnyToEveryType.ts, 13, 8)) +>E : Symbol(E, Decl(assignAnyToEveryType.ts, 11, 6)) +>A : Symbol(E.A, Decl(assignAnyToEveryType.ts, 13, 8)) + +g2 = x; +>g2 : Symbol(g2, Decl(assignAnyToEveryType.ts, 18, 3)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +class C { +>C : Symbol(C, Decl(assignAnyToEveryType.ts, 19, 7)) + + foo: string; +>foo : Symbol(C.foo, Decl(assignAnyToEveryType.ts, 21, 9)) +} + +var h: C = x; +>h : Symbol(h, Decl(assignAnyToEveryType.ts, 25, 3)) +>C : Symbol(C, Decl(assignAnyToEveryType.ts, 19, 7)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +interface I { +>I : Symbol(I, Decl(assignAnyToEveryType.ts, 25, 13)) + + foo: string; +>foo : Symbol(I.foo, Decl(assignAnyToEveryType.ts, 27, 13)) +} + +var i: I = x; +>i : Symbol(i, Decl(assignAnyToEveryType.ts, 31, 3)) +>I : Symbol(I, Decl(assignAnyToEveryType.ts, 25, 13)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var j: { (): string } = x; +>j : Symbol(j, Decl(assignAnyToEveryType.ts, 33, 3)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +var j2: { (x: T): string } = x; +>j2 : Symbol(j2, Decl(assignAnyToEveryType.ts, 34, 3)) +>T : Symbol(T, Decl(assignAnyToEveryType.ts, 34, 11)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 34, 14)) +>T : Symbol(T, Decl(assignAnyToEveryType.ts, 34, 11)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +module M { +>M : Symbol(M, Decl(assignAnyToEveryType.ts, 34, 34)) + + export var foo = 1; +>foo : Symbol(foo, Decl(assignAnyToEveryType.ts, 37, 14)) +} + +M = x; +>M : Symbol(M, Decl(assignAnyToEveryType.ts, 34, 34)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) + +function k(a: T) { +>k : Symbol(k, Decl(assignAnyToEveryType.ts, 40, 6)) +>T : Symbol(T, Decl(assignAnyToEveryType.ts, 42, 11)) +>a : Symbol(a, Decl(assignAnyToEveryType.ts, 42, 14)) +>T : Symbol(T, Decl(assignAnyToEveryType.ts, 42, 11)) + + a = x; +>a : Symbol(a, Decl(assignAnyToEveryType.ts, 42, 14)) +>x : Symbol(x, Decl(assignAnyToEveryType.ts, 2, 3)) +} diff --git a/tests/baselines/reference/assignAnyToEveryType.types b/tests/baselines/reference/assignAnyToEveryType.types new file mode 100644 index 00000000000..c3f475d058d --- /dev/null +++ b/tests/baselines/reference/assignAnyToEveryType.types @@ -0,0 +1,122 @@ +=== tests/cases/conformance/types/any/assignAnyToEveryType.ts === +// all of these are valid + +var x: any; +>x : any + +var a: number = x; +>a : number +>x : any + +var b: boolean = x; +>b : boolean +>x : any + +var c: string = x; +>c : string +>x : any + +var d: void = x; +>d : void +>x : any + +var e = null; +>e : any +>null : null + +e = x; +>e = x : any +>e : any +>x : any + +var f = undefined; +>f : any +>undefined : undefined + +f = x; +>f = x : any +>f : any +>x : any + +enum E { +>E : E + + A +>A : E +} + +var g: E = x; +>g : E +>E : E +>x : any + +var g2 = E.A; +>g2 : E +>E.A : E +>E : typeof E +>A : E + +g2 = x; +>g2 = x : any +>g2 : E +>x : any + +class C { +>C : C + + foo: string; +>foo : string +} + +var h: C = x; +>h : C +>C : C +>x : any + +interface I { +>I : I + + foo: string; +>foo : string +} + +var i: I = x; +>i : I +>I : I +>x : any + +var j: { (): string } = x; +>j : () => string +>x : any + +var j2: { (x: T): string } = x; +>j2 : (x: T) => string +>T : T +>x : T +>T : T +>x : any + +module M { +>M : typeof M + + export var foo = 1; +>foo : number +>1 : 1 +} + +M = x; +>M = x : any +>M : any +>x : any + +function k(a: T) { +>k : (a: T) => void +>T : T +>a : T +>T : T + + a = x; +>a = x : any +>a : T +>x : any +} diff --git a/tests/baselines/reference/assignFromBooleanInterface.symbols b/tests/baselines/reference/assignFromBooleanInterface.symbols new file mode 100644 index 00000000000..a9f747cab0b --- /dev/null +++ b/tests/baselines/reference/assignFromBooleanInterface.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts === +var x = true; +>x : Symbol(x, Decl(assignFromBooleanInterface.ts, 0, 3)) + +var a: Boolean; +>a : Symbol(a, Decl(assignFromBooleanInterface.ts, 1, 3)) +>Boolean : Symbol(Boolean, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +x = a; +>x : Symbol(x, Decl(assignFromBooleanInterface.ts, 0, 3)) +>a : Symbol(a, Decl(assignFromBooleanInterface.ts, 1, 3)) + +a = x; +>a : Symbol(a, Decl(assignFromBooleanInterface.ts, 1, 3)) +>x : Symbol(x, Decl(assignFromBooleanInterface.ts, 0, 3)) + diff --git a/tests/baselines/reference/assignFromBooleanInterface.types b/tests/baselines/reference/assignFromBooleanInterface.types new file mode 100644 index 00000000000..598f89bc2a4 --- /dev/null +++ b/tests/baselines/reference/assignFromBooleanInterface.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts === +var x = true; +>x : boolean +>true : true + +var a: Boolean; +>a : Boolean +>Boolean : Boolean + +x = a; +>x = a : Boolean +>x : boolean +>a : Boolean + +a = x; +>a = x : boolean +>a : Boolean +>x : boolean + diff --git a/tests/baselines/reference/assignFromBooleanInterface2.symbols b/tests/baselines/reference/assignFromBooleanInterface2.symbols new file mode 100644 index 00000000000..2bc7c3cf289 --- /dev/null +++ b/tests/baselines/reference/assignFromBooleanInterface2.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts === +interface Boolean { +>Boolean : Symbol(Boolean, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(assignFromBooleanInterface2.ts, 0, 0)) + + doStuff(): string; +>doStuff : Symbol(Boolean.doStuff, Decl(assignFromBooleanInterface2.ts, 0, 19)) +} + +interface NotBoolean { +>NotBoolean : Symbol(NotBoolean, Decl(assignFromBooleanInterface2.ts, 2, 1)) + + doStuff(): string; +>doStuff : Symbol(NotBoolean.doStuff, Decl(assignFromBooleanInterface2.ts, 4, 22)) +} + +var x = true; +>x : Symbol(x, Decl(assignFromBooleanInterface2.ts, 8, 3)) + +var a: Boolean; +>a : Symbol(a, Decl(assignFromBooleanInterface2.ts, 9, 3)) +>Boolean : Symbol(Boolean, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(assignFromBooleanInterface2.ts, 0, 0)) + +var b: NotBoolean; +>b : Symbol(b, Decl(assignFromBooleanInterface2.ts, 10, 3)) +>NotBoolean : Symbol(NotBoolean, Decl(assignFromBooleanInterface2.ts, 2, 1)) + +a = x; +>a : Symbol(a, Decl(assignFromBooleanInterface2.ts, 9, 3)) +>x : Symbol(x, Decl(assignFromBooleanInterface2.ts, 8, 3)) + +a = b; +>a : Symbol(a, Decl(assignFromBooleanInterface2.ts, 9, 3)) +>b : Symbol(b, Decl(assignFromBooleanInterface2.ts, 10, 3)) + +b = a; +>b : Symbol(b, Decl(assignFromBooleanInterface2.ts, 10, 3)) +>a : Symbol(a, Decl(assignFromBooleanInterface2.ts, 9, 3)) + +b = x; +>b : Symbol(b, Decl(assignFromBooleanInterface2.ts, 10, 3)) +>x : Symbol(x, Decl(assignFromBooleanInterface2.ts, 8, 3)) + +x = a; // expected error +>x : Symbol(x, Decl(assignFromBooleanInterface2.ts, 8, 3)) +>a : Symbol(a, Decl(assignFromBooleanInterface2.ts, 9, 3)) + +x = b; // expected error +>x : Symbol(x, Decl(assignFromBooleanInterface2.ts, 8, 3)) +>b : Symbol(b, Decl(assignFromBooleanInterface2.ts, 10, 3)) + + diff --git a/tests/baselines/reference/assignFromBooleanInterface2.types b/tests/baselines/reference/assignFromBooleanInterface2.types new file mode 100644 index 00000000000..7472fec421a --- /dev/null +++ b/tests/baselines/reference/assignFromBooleanInterface2.types @@ -0,0 +1,58 @@ +=== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts === +interface Boolean { +>Boolean : Boolean + + doStuff(): string; +>doStuff : () => string +} + +interface NotBoolean { +>NotBoolean : NotBoolean + + doStuff(): string; +>doStuff : () => string +} + +var x = true; +>x : boolean +>true : true + +var a: Boolean; +>a : Boolean +>Boolean : Boolean + +var b: NotBoolean; +>b : NotBoolean +>NotBoolean : NotBoolean + +a = x; +>a = x : true +>a : Boolean +>x : true + +a = b; +>a = b : NotBoolean +>a : Boolean +>b : NotBoolean + +b = a; +>b = a : Boolean +>b : NotBoolean +>a : Boolean + +b = x; +>b = x : true +>b : NotBoolean +>x : true + +x = a; // expected error +>x = a : Boolean +>x : boolean +>a : Boolean + +x = b; // expected error +>x = b : NotBoolean +>x : boolean +>b : NotBoolean + + diff --git a/tests/baselines/reference/assignFromNumberInterface.symbols b/tests/baselines/reference/assignFromNumberInterface.symbols new file mode 100644 index 00000000000..06485958aab --- /dev/null +++ b/tests/baselines/reference/assignFromNumberInterface.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts === +var x = 1; +>x : Symbol(x, Decl(assignFromNumberInterface.ts, 0, 3)) + +var a: Number; +>a : Symbol(a, Decl(assignFromNumberInterface.ts, 1, 3)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +x = a; +>x : Symbol(x, Decl(assignFromNumberInterface.ts, 0, 3)) +>a : Symbol(a, Decl(assignFromNumberInterface.ts, 1, 3)) + +a = x; +>a : Symbol(a, Decl(assignFromNumberInterface.ts, 1, 3)) +>x : Symbol(x, Decl(assignFromNumberInterface.ts, 0, 3)) + diff --git a/tests/baselines/reference/assignFromNumberInterface.types b/tests/baselines/reference/assignFromNumberInterface.types new file mode 100644 index 00000000000..d37023d8a53 --- /dev/null +++ b/tests/baselines/reference/assignFromNumberInterface.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts === +var x = 1; +>x : number +>1 : 1 + +var a: Number; +>a : Number +>Number : Number + +x = a; +>x = a : Number +>x : number +>a : Number + +a = x; +>a = x : number +>a : Number +>x : number + diff --git a/tests/baselines/reference/assignFromNumberInterface2.symbols b/tests/baselines/reference/assignFromNumberInterface2.symbols new file mode 100644 index 00000000000..45bc0762b30 --- /dev/null +++ b/tests/baselines/reference/assignFromNumberInterface2.symbols @@ -0,0 +1,70 @@ +=== tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts === +interface Number { +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(assignFromNumberInterface2.ts, 0, 0)) + + doStuff(): string; +>doStuff : Symbol(Number.doStuff, Decl(assignFromNumberInterface2.ts, 0, 18)) +} + +interface NotNumber { +>NotNumber : Symbol(NotNumber, Decl(assignFromNumberInterface2.ts, 2, 1)) + + toString(radix?: number): string; +>toString : Symbol(NotNumber.toString, Decl(assignFromNumberInterface2.ts, 4, 21)) +>radix : Symbol(radix, Decl(assignFromNumberInterface2.ts, 5, 13)) + + toFixed(fractionDigits?: number): string; +>toFixed : Symbol(NotNumber.toFixed, Decl(assignFromNumberInterface2.ts, 5, 37)) +>fractionDigits : Symbol(fractionDigits, Decl(assignFromNumberInterface2.ts, 6, 12)) + + toExponential(fractionDigits?: number): string; +>toExponential : Symbol(NotNumber.toExponential, Decl(assignFromNumberInterface2.ts, 6, 45)) +>fractionDigits : Symbol(fractionDigits, Decl(assignFromNumberInterface2.ts, 7, 18)) + + toPrecision(precision?: number): string; +>toPrecision : Symbol(NotNumber.toPrecision, Decl(assignFromNumberInterface2.ts, 7, 51)) +>precision : Symbol(precision, Decl(assignFromNumberInterface2.ts, 8, 16)) + + valueOf(): number; +>valueOf : Symbol(NotNumber.valueOf, Decl(assignFromNumberInterface2.ts, 8, 44)) + + doStuff(): string; +>doStuff : Symbol(NotNumber.doStuff, Decl(assignFromNumberInterface2.ts, 9, 22)) +} + +var x = 1; +>x : Symbol(x, Decl(assignFromNumberInterface2.ts, 13, 3)) + +var a: Number; +>a : Symbol(a, Decl(assignFromNumberInterface2.ts, 14, 3)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(assignFromNumberInterface2.ts, 0, 0)) + +var b: NotNumber; +>b : Symbol(b, Decl(assignFromNumberInterface2.ts, 15, 3)) +>NotNumber : Symbol(NotNumber, Decl(assignFromNumberInterface2.ts, 2, 1)) + +a = x; +>a : Symbol(a, Decl(assignFromNumberInterface2.ts, 14, 3)) +>x : Symbol(x, Decl(assignFromNumberInterface2.ts, 13, 3)) + +a = b; +>a : Symbol(a, Decl(assignFromNumberInterface2.ts, 14, 3)) +>b : Symbol(b, Decl(assignFromNumberInterface2.ts, 15, 3)) + +b = a; +>b : Symbol(b, Decl(assignFromNumberInterface2.ts, 15, 3)) +>a : Symbol(a, Decl(assignFromNumberInterface2.ts, 14, 3)) + +b = x; +>b : Symbol(b, Decl(assignFromNumberInterface2.ts, 15, 3)) +>x : Symbol(x, Decl(assignFromNumberInterface2.ts, 13, 3)) + +x = a; // expected error +>x : Symbol(x, Decl(assignFromNumberInterface2.ts, 13, 3)) +>a : Symbol(a, Decl(assignFromNumberInterface2.ts, 14, 3)) + +x = b; // expected error +>x : Symbol(x, Decl(assignFromNumberInterface2.ts, 13, 3)) +>b : Symbol(b, Decl(assignFromNumberInterface2.ts, 15, 3)) + + diff --git a/tests/baselines/reference/assignFromNumberInterface2.types b/tests/baselines/reference/assignFromNumberInterface2.types new file mode 100644 index 00000000000..d2c4fc04658 --- /dev/null +++ b/tests/baselines/reference/assignFromNumberInterface2.types @@ -0,0 +1,77 @@ +=== tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts === +interface Number { +>Number : Number + + doStuff(): string; +>doStuff : () => string +} + +interface NotNumber { +>NotNumber : NotNumber + + toString(radix?: number): string; +>toString : (radix?: number) => string +>radix : number + + toFixed(fractionDigits?: number): string; +>toFixed : (fractionDigits?: number) => string +>fractionDigits : number + + toExponential(fractionDigits?: number): string; +>toExponential : (fractionDigits?: number) => string +>fractionDigits : number + + toPrecision(precision?: number): string; +>toPrecision : (precision?: number) => string +>precision : number + + valueOf(): number; +>valueOf : () => number + + doStuff(): string; +>doStuff : () => string +} + +var x = 1; +>x : number +>1 : 1 + +var a: Number; +>a : Number +>Number : Number + +var b: NotNumber; +>b : NotNumber +>NotNumber : NotNumber + +a = x; +>a = x : number +>a : Number +>x : number + +a = b; +>a = b : NotNumber +>a : Number +>b : NotNumber + +b = a; +>b = a : Number +>b : NotNumber +>a : Number + +b = x; +>b = x : number +>b : NotNumber +>x : number + +x = a; // expected error +>x = a : Number +>x : number +>a : Number + +x = b; // expected error +>x = b : NotNumber +>x : number +>b : NotNumber + + diff --git a/tests/baselines/reference/assignFromStringInterface.symbols b/tests/baselines/reference/assignFromStringInterface.symbols new file mode 100644 index 00000000000..348c237ca1f --- /dev/null +++ b/tests/baselines/reference/assignFromStringInterface.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts === +var x = ''; +>x : Symbol(x, Decl(assignFromStringInterface.ts, 0, 3)) + +var a: String; +>a : Symbol(a, Decl(assignFromStringInterface.ts, 1, 3)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +x = a; +>x : Symbol(x, Decl(assignFromStringInterface.ts, 0, 3)) +>a : Symbol(a, Decl(assignFromStringInterface.ts, 1, 3)) + +a = x; +>a : Symbol(a, Decl(assignFromStringInterface.ts, 1, 3)) +>x : Symbol(x, Decl(assignFromStringInterface.ts, 0, 3)) + diff --git a/tests/baselines/reference/assignFromStringInterface.types b/tests/baselines/reference/assignFromStringInterface.types new file mode 100644 index 00000000000..07c2433e586 --- /dev/null +++ b/tests/baselines/reference/assignFromStringInterface.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts === +var x = ''; +>x : string +>'' : "" + +var a: String; +>a : String +>String : String + +x = a; +>x = a : String +>x : string +>a : String + +a = x; +>a = x : string +>a : String +>x : string + diff --git a/tests/baselines/reference/assignFromStringInterface2.symbols b/tests/baselines/reference/assignFromStringInterface2.symbols new file mode 100644 index 00000000000..88fd673c708 --- /dev/null +++ b/tests/baselines/reference/assignFromStringInterface2.symbols @@ -0,0 +1,174 @@ +=== tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts === +interface String { +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(assignFromStringInterface2.ts, 0, 0)) + + doStuff(): string; +>doStuff : Symbol(String.doStuff, Decl(assignFromStringInterface2.ts, 0, 18)) +} + +interface NotString { +>NotString : Symbol(NotString, Decl(assignFromStringInterface2.ts, 2, 1)) + + doStuff(): string; +>doStuff : Symbol(NotString.doStuff, Decl(assignFromStringInterface2.ts, 4, 21)) + + toString(): string; +>toString : Symbol(NotString.toString, Decl(assignFromStringInterface2.ts, 5, 22)) + + charAt(pos: number): string; +>charAt : Symbol(NotString.charAt, Decl(assignFromStringInterface2.ts, 6, 23)) +>pos : Symbol(pos, Decl(assignFromStringInterface2.ts, 7, 11)) + + charCodeAt(index: number): number; +>charCodeAt : Symbol(NotString.charCodeAt, Decl(assignFromStringInterface2.ts, 7, 32)) +>index : Symbol(index, Decl(assignFromStringInterface2.ts, 8, 15)) + + concat(...strings: string[]): string; +>concat : Symbol(NotString.concat, Decl(assignFromStringInterface2.ts, 8, 38)) +>strings : Symbol(strings, Decl(assignFromStringInterface2.ts, 9, 11)) + + indexOf(searchString: string, position?: number): number; +>indexOf : Symbol(NotString.indexOf, Decl(assignFromStringInterface2.ts, 9, 41)) +>searchString : Symbol(searchString, Decl(assignFromStringInterface2.ts, 10, 12)) +>position : Symbol(position, Decl(assignFromStringInterface2.ts, 10, 33)) + + lastIndexOf(searchString: string, position?: number): number; +>lastIndexOf : Symbol(NotString.lastIndexOf, Decl(assignFromStringInterface2.ts, 10, 61)) +>searchString : Symbol(searchString, Decl(assignFromStringInterface2.ts, 11, 16)) +>position : Symbol(position, Decl(assignFromStringInterface2.ts, 11, 37)) + + localeCompare(that: string): number; +>localeCompare : Symbol(NotString.localeCompare, Decl(assignFromStringInterface2.ts, 11, 65)) +>that : Symbol(that, Decl(assignFromStringInterface2.ts, 12, 18)) + + match(regexp: string): string[]; +>match : Symbol(NotString.match, Decl(assignFromStringInterface2.ts, 12, 40), Decl(assignFromStringInterface2.ts, 13, 36)) +>regexp : Symbol(regexp, Decl(assignFromStringInterface2.ts, 13, 10)) + + match(regexp: RegExp): string[]; +>match : Symbol(NotString.match, Decl(assignFromStringInterface2.ts, 12, 40), Decl(assignFromStringInterface2.ts, 13, 36)) +>regexp : Symbol(regexp, Decl(assignFromStringInterface2.ts, 14, 10)) +>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + replace(searchValue: string, replaceValue: string): string; +>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 36), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63)) +>searchValue : Symbol(searchValue, Decl(assignFromStringInterface2.ts, 15, 12)) +>replaceValue : Symbol(replaceValue, Decl(assignFromStringInterface2.ts, 15, 32)) + + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; +>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 36), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63)) +>searchValue : Symbol(searchValue, Decl(assignFromStringInterface2.ts, 16, 12)) +>replaceValue : Symbol(replaceValue, Decl(assignFromStringInterface2.ts, 16, 32)) +>substring : Symbol(substring, Decl(assignFromStringInterface2.ts, 16, 48)) +>args : Symbol(args, Decl(assignFromStringInterface2.ts, 16, 66)) + + replace(searchValue: RegExp, replaceValue: string): string; +>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 36), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63)) +>searchValue : Symbol(searchValue, Decl(assignFromStringInterface2.ts, 17, 12)) +>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replaceValue : Symbol(replaceValue, Decl(assignFromStringInterface2.ts, 17, 32)) + + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; +>replace : Symbol(NotString.replace, Decl(assignFromStringInterface2.ts, 14, 36), Decl(assignFromStringInterface2.ts, 15, 63), Decl(assignFromStringInterface2.ts, 16, 102), Decl(assignFromStringInterface2.ts, 17, 63)) +>searchValue : Symbol(searchValue, Decl(assignFromStringInterface2.ts, 18, 12)) +>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>replaceValue : Symbol(replaceValue, Decl(assignFromStringInterface2.ts, 18, 32)) +>substring : Symbol(substring, Decl(assignFromStringInterface2.ts, 18, 48)) +>args : Symbol(args, Decl(assignFromStringInterface2.ts, 18, 66)) + + search(regexp: string): number; +>search : Symbol(NotString.search, Decl(assignFromStringInterface2.ts, 18, 102), Decl(assignFromStringInterface2.ts, 19, 35)) +>regexp : Symbol(regexp, Decl(assignFromStringInterface2.ts, 19, 11)) + + search(regexp: RegExp): number; +>search : Symbol(NotString.search, Decl(assignFromStringInterface2.ts, 18, 102), Decl(assignFromStringInterface2.ts, 19, 35)) +>regexp : Symbol(regexp, Decl(assignFromStringInterface2.ts, 20, 11)) +>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + slice(start?: number, end?: number): string; +>slice : Symbol(NotString.slice, Decl(assignFromStringInterface2.ts, 20, 35)) +>start : Symbol(start, Decl(assignFromStringInterface2.ts, 21, 10)) +>end : Symbol(end, Decl(assignFromStringInterface2.ts, 21, 25)) + + split(separator: string, limit?: number): string[]; +>split : Symbol(NotString.split, Decl(assignFromStringInterface2.ts, 21, 48), Decl(assignFromStringInterface2.ts, 22, 55)) +>separator : Symbol(separator, Decl(assignFromStringInterface2.ts, 22, 10)) +>limit : Symbol(limit, Decl(assignFromStringInterface2.ts, 22, 28)) + + split(separator: RegExp, limit?: number): string[]; +>split : Symbol(NotString.split, Decl(assignFromStringInterface2.ts, 21, 48), Decl(assignFromStringInterface2.ts, 22, 55)) +>separator : Symbol(separator, Decl(assignFromStringInterface2.ts, 23, 10)) +>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>limit : Symbol(limit, Decl(assignFromStringInterface2.ts, 23, 28)) + + substring(start: number, end?: number): string; +>substring : Symbol(NotString.substring, Decl(assignFromStringInterface2.ts, 23, 55)) +>start : Symbol(start, Decl(assignFromStringInterface2.ts, 24, 14)) +>end : Symbol(end, Decl(assignFromStringInterface2.ts, 24, 28)) + + toLowerCase(): string; +>toLowerCase : Symbol(NotString.toLowerCase, Decl(assignFromStringInterface2.ts, 24, 51)) + + toLocaleLowerCase(): string; +>toLocaleLowerCase : Symbol(NotString.toLocaleLowerCase, Decl(assignFromStringInterface2.ts, 25, 26)) + + toUpperCase(): string; +>toUpperCase : Symbol(NotString.toUpperCase, Decl(assignFromStringInterface2.ts, 26, 32)) + + toLocaleUpperCase(): string; +>toLocaleUpperCase : Symbol(NotString.toLocaleUpperCase, Decl(assignFromStringInterface2.ts, 27, 26)) + + trim(): string; +>trim : Symbol(NotString.trim, Decl(assignFromStringInterface2.ts, 28, 32)) + + length: number; +>length : Symbol(NotString.length, Decl(assignFromStringInterface2.ts, 29, 19)) + + substr(from: number, length?: number): string; +>substr : Symbol(NotString.substr, Decl(assignFromStringInterface2.ts, 30, 19)) +>from : Symbol(from, Decl(assignFromStringInterface2.ts, 31, 11)) +>length : Symbol(length, Decl(assignFromStringInterface2.ts, 31, 24)) + + valueOf(): string; +>valueOf : Symbol(NotString.valueOf, Decl(assignFromStringInterface2.ts, 31, 50)) + + [index: number]: string; +>index : Symbol(index, Decl(assignFromStringInterface2.ts, 33, 5)) +} + +var x = ''; +>x : Symbol(x, Decl(assignFromStringInterface2.ts, 36, 3)) + +var a: String; +>a : Symbol(a, Decl(assignFromStringInterface2.ts, 37, 3)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(assignFromStringInterface2.ts, 0, 0)) + +var b: NotString; +>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3)) +>NotString : Symbol(NotString, Decl(assignFromStringInterface2.ts, 2, 1)) + +a = x; +>a : Symbol(a, Decl(assignFromStringInterface2.ts, 37, 3)) +>x : Symbol(x, Decl(assignFromStringInterface2.ts, 36, 3)) + +a = b; +>a : Symbol(a, Decl(assignFromStringInterface2.ts, 37, 3)) +>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3)) + +b = a; +>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3)) +>a : Symbol(a, Decl(assignFromStringInterface2.ts, 37, 3)) + +b = x; +>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3)) +>x : Symbol(x, Decl(assignFromStringInterface2.ts, 36, 3)) + +x = a; // expected error +>x : Symbol(x, Decl(assignFromStringInterface2.ts, 36, 3)) +>a : Symbol(a, Decl(assignFromStringInterface2.ts, 37, 3)) + +x = b; // expected error +>x : Symbol(x, Decl(assignFromStringInterface2.ts, 36, 3)) +>b : Symbol(b, Decl(assignFromStringInterface2.ts, 38, 3)) + + diff --git a/tests/baselines/reference/assignFromStringInterface2.types b/tests/baselines/reference/assignFromStringInterface2.types new file mode 100644 index 00000000000..8ec212babce --- /dev/null +++ b/tests/baselines/reference/assignFromStringInterface2.types @@ -0,0 +1,181 @@ +=== tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts === +interface String { +>String : String + + doStuff(): string; +>doStuff : () => string +} + +interface NotString { +>NotString : NotString + + doStuff(): string; +>doStuff : () => string + + toString(): string; +>toString : () => string + + charAt(pos: number): string; +>charAt : (pos: number) => string +>pos : number + + charCodeAt(index: number): number; +>charCodeAt : (index: number) => number +>index : number + + concat(...strings: string[]): string; +>concat : (...strings: string[]) => string +>strings : string[] + + indexOf(searchString: string, position?: number): number; +>indexOf : (searchString: string, position?: number) => number +>searchString : string +>position : number + + lastIndexOf(searchString: string, position?: number): number; +>lastIndexOf : (searchString: string, position?: number) => number +>searchString : string +>position : number + + localeCompare(that: string): number; +>localeCompare : (that: string) => number +>that : string + + match(regexp: string): string[]; +>match : { (regexp: string): string[]; (regexp: RegExp): string[]; } +>regexp : string + + match(regexp: RegExp): string[]; +>match : { (regexp: string): string[]; (regexp: RegExp): string[]; } +>regexp : RegExp +>RegExp : RegExp + + replace(searchValue: string, replaceValue: string): string; +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>searchValue : string +>replaceValue : string + + replace(searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>searchValue : string +>replaceValue : (substring: string, ...args: any[]) => string +>substring : string +>args : any[] + + replace(searchValue: RegExp, replaceValue: string): string; +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>searchValue : RegExp +>RegExp : RegExp +>replaceValue : string + + replace(searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; +>replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replaceValue: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replaceValue: (substring: string, ...args: any[]) => string): string; } +>searchValue : RegExp +>RegExp : RegExp +>replaceValue : (substring: string, ...args: any[]) => string +>substring : string +>args : any[] + + search(regexp: string): number; +>search : { (regexp: string): number; (regexp: RegExp): number; } +>regexp : string + + search(regexp: RegExp): number; +>search : { (regexp: string): number; (regexp: RegExp): number; } +>regexp : RegExp +>RegExp : RegExp + + slice(start?: number, end?: number): string; +>slice : (start?: number, end?: number) => string +>start : number +>end : number + + split(separator: string, limit?: number): string[]; +>split : { (separator: string, limit?: number): string[]; (separator: RegExp, limit?: number): string[]; } +>separator : string +>limit : number + + split(separator: RegExp, limit?: number): string[]; +>split : { (separator: string, limit?: number): string[]; (separator: RegExp, limit?: number): string[]; } +>separator : RegExp +>RegExp : RegExp +>limit : number + + substring(start: number, end?: number): string; +>substring : (start: number, end?: number) => string +>start : number +>end : number + + toLowerCase(): string; +>toLowerCase : () => string + + toLocaleLowerCase(): string; +>toLocaleLowerCase : () => string + + toUpperCase(): string; +>toUpperCase : () => string + + toLocaleUpperCase(): string; +>toLocaleUpperCase : () => string + + trim(): string; +>trim : () => string + + length: number; +>length : number + + substr(from: number, length?: number): string; +>substr : (from: number, length?: number) => string +>from : number +>length : number + + valueOf(): string; +>valueOf : () => string + + [index: number]: string; +>index : number +} + +var x = ''; +>x : string +>'' : "" + +var a: String; +>a : String +>String : String + +var b: NotString; +>b : NotString +>NotString : NotString + +a = x; +>a = x : string +>a : String +>x : string + +a = b; +>a = b : NotString +>a : String +>b : NotString + +b = a; +>b = a : String +>b : NotString +>a : String + +b = x; +>b = x : string +>b : NotString +>x : string + +x = a; // expected error +>x = a : String +>x : string +>a : String + +x = b; // expected error +>x = b : NotString +>x : string +>b : NotString + + diff --git a/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.symbols b/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.symbols new file mode 100644 index 00000000000..19dac44b30c --- /dev/null +++ b/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts === +interface IResultCallback extends Function { +>IResultCallback : Symbol(IResultCallback, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 0, 0)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + x: number; +>x : Symbol(IResultCallback.x, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 0, 44)) +} + +function fn(cb: IResultCallback) { } +>fn : Symbol(fn, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 2, 1)) +>cb : Symbol(cb, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 4, 12)) +>IResultCallback : Symbol(IResultCallback, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 0, 0)) + +fn((a, b) => true); +>fn : Symbol(fn, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 2, 1)) +>a : Symbol(a, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 6, 4)) +>b : Symbol(b, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 6, 6)) + +fn(function (a, b) { return true; }) +>fn : Symbol(fn, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 2, 1)) +>a : Symbol(a, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 7, 13)) +>b : Symbol(b, Decl(assignLambdaToNominalSubtypeOfFunction.ts, 7, 15)) + diff --git a/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.types b/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.types new file mode 100644 index 00000000000..bff7fe98da4 --- /dev/null +++ b/tests/baselines/reference/assignLambdaToNominalSubtypeOfFunction.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/assignLambdaToNominalSubtypeOfFunction.ts === +interface IResultCallback extends Function { +>IResultCallback : IResultCallback +>Function : Function + + x: number; +>x : number +} + +function fn(cb: IResultCallback) { } +>fn : (cb: IResultCallback) => void +>cb : IResultCallback +>IResultCallback : IResultCallback + +fn((a, b) => true); +>fn((a, b) => true) : void +>fn : (cb: IResultCallback) => void +>(a, b) => true : (a: any, b: any) => boolean +>a : any +>b : any +>true : true + +fn(function (a, b) { return true; }) +>fn(function (a, b) { return true; }) : void +>fn : (cb: IResultCallback) => void +>function (a, b) { return true; } : (a: any, b: any) => boolean +>a : any +>b : any +>true : true + diff --git a/tests/baselines/reference/assignToEnum.symbols b/tests/baselines/reference/assignToEnum.symbols new file mode 100644 index 00000000000..8abccb32ce4 --- /dev/null +++ b/tests/baselines/reference/assignToEnum.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/assignToEnum.ts === +enum A { foo, bar } +>A : Symbol(A, Decl(assignToEnum.ts, 0, 0)) +>foo : Symbol(A.foo, Decl(assignToEnum.ts, 0, 8)) +>bar : Symbol(A.bar, Decl(assignToEnum.ts, 0, 13)) + +A = undefined; // invalid LHS +>A : Symbol(A, Decl(assignToEnum.ts, 0, 0)) +>undefined : Symbol(undefined) + +A = A.bar; // invalid LHS +>A : Symbol(A, Decl(assignToEnum.ts, 0, 0)) +>A.bar : Symbol(A.bar, Decl(assignToEnum.ts, 0, 13)) +>A : Symbol(A, Decl(assignToEnum.ts, 0, 0)) +>bar : Symbol(A.bar, Decl(assignToEnum.ts, 0, 13)) + +A.foo = 1; // invalid LHS +>A.foo : Symbol(A.foo, Decl(assignToEnum.ts, 0, 8)) +>A : Symbol(A, Decl(assignToEnum.ts, 0, 0)) +>foo : Symbol(A.foo, Decl(assignToEnum.ts, 0, 8)) + +A.foo = A.bar; // invalid LHS +>A.foo : Symbol(A.foo, Decl(assignToEnum.ts, 0, 8)) +>A : Symbol(A, Decl(assignToEnum.ts, 0, 0)) +>foo : Symbol(A.foo, Decl(assignToEnum.ts, 0, 8)) +>A.bar : Symbol(A.bar, Decl(assignToEnum.ts, 0, 13)) +>A : Symbol(A, Decl(assignToEnum.ts, 0, 0)) +>bar : Symbol(A.bar, Decl(assignToEnum.ts, 0, 13)) + + diff --git a/tests/baselines/reference/assignToEnum.types b/tests/baselines/reference/assignToEnum.types new file mode 100644 index 00000000000..a4301d113ab --- /dev/null +++ b/tests/baselines/reference/assignToEnum.types @@ -0,0 +1,35 @@ +=== tests/cases/compiler/assignToEnum.ts === +enum A { foo, bar } +>A : A +>foo : A.foo +>bar : A.bar + +A = undefined; // invalid LHS +>A = undefined : undefined +>A : any +>undefined : undefined + +A = A.bar; // invalid LHS +>A = A.bar : A.bar +>A : any +>A.bar : A.bar +>A : typeof A +>bar : A.bar + +A.foo = 1; // invalid LHS +>A.foo = 1 : 1 +>A.foo : any +>A : typeof A +>foo : any +>1 : 1 + +A.foo = A.bar; // invalid LHS +>A.foo = A.bar : A.bar +>A.foo : any +>A : typeof A +>foo : any +>A.bar : A.bar +>A : typeof A +>bar : A.bar + + diff --git a/tests/baselines/reference/assignToExistingClass.symbols b/tests/baselines/reference/assignToExistingClass.symbols new file mode 100644 index 00000000000..9d170e9e30c --- /dev/null +++ b/tests/baselines/reference/assignToExistingClass.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/assignToExistingClass.ts === +module Test { +>Test : Symbol(Test, Decl(assignToExistingClass.ts, 0, 0)) + + class Mocked { +>Mocked : Symbol(Mocked, Decl(assignToExistingClass.ts, 0, 13)) + + myProp: string; +>myProp : Symbol(Mocked.myProp, Decl(assignToExistingClass.ts, 1, 18)) + } + + class Tester { +>Tester : Symbol(Tester, Decl(assignToExistingClass.ts, 3, 5)) + + willThrowError() { +>willThrowError : Symbol(Tester.willThrowError, Decl(assignToExistingClass.ts, 5, 18)) + + Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression. +>Mocked : Symbol(Mocked, Decl(assignToExistingClass.ts, 0, 13)) +>Mocked : Symbol(Mocked, Decl(assignToExistingClass.ts, 0, 13)) + + return { myProp: "test" }; +>myProp : Symbol(myProp, Decl(assignToExistingClass.ts, 8, 24)) + + }; + } + } + +} + diff --git a/tests/baselines/reference/assignToExistingClass.types b/tests/baselines/reference/assignToExistingClass.types new file mode 100644 index 00000000000..9894347c20f --- /dev/null +++ b/tests/baselines/reference/assignToExistingClass.types @@ -0,0 +1,35 @@ +=== tests/cases/compiler/assignToExistingClass.ts === +module Test { +>Test : typeof Test + + class Mocked { +>Mocked : Mocked + + myProp: string; +>myProp : string + } + + class Tester { +>Tester : Tester + + willThrowError() { +>willThrowError : () => void + + Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression. +>Mocked = Mocked || function () { // => Error: Invalid left-hand side of assignment expression. return { myProp: "test" }; } : typeof Mocked | (() => { myProp: string; }) +>Mocked : any +>Mocked || function () { // => Error: Invalid left-hand side of assignment expression. return { myProp: "test" }; } : typeof Mocked | (() => { myProp: string; }) +>Mocked : typeof Mocked +>function () { // => Error: Invalid left-hand side of assignment expression. return { myProp: "test" }; } : () => { myProp: string; } + + return { myProp: "test" }; +>{ myProp: "test" } : { myProp: string; } +>myProp : string +>"test" : "test" + + }; + } + } + +} + diff --git a/tests/baselines/reference/assignToFn.symbols b/tests/baselines/reference/assignToFn.symbols new file mode 100644 index 00000000000..497515eec99 --- /dev/null +++ b/tests/baselines/reference/assignToFn.symbols @@ -0,0 +1,24 @@ +=== tests/cases/compiler/assignToFn.ts === +module M { +>M : Symbol(M, Decl(assignToFn.ts, 0, 0)) + + interface I { +>I : Symbol(I, Decl(assignToFn.ts, 0, 10)) + + f(n:number):boolean; +>f : Symbol(I.f, Decl(assignToFn.ts, 1, 17)) +>n : Symbol(n, Decl(assignToFn.ts, 2, 3)) + } + + var x:I={ f:function(n) { return true; } }; +>x : Symbol(x, Decl(assignToFn.ts, 5, 7)) +>I : Symbol(I, Decl(assignToFn.ts, 0, 10)) +>f : Symbol(f, Decl(assignToFn.ts, 5, 13)) +>n : Symbol(n, Decl(assignToFn.ts, 5, 25)) + + x.f="hello"; +>x.f : Symbol(I.f, Decl(assignToFn.ts, 1, 17)) +>x : Symbol(x, Decl(assignToFn.ts, 5, 7)) +>f : Symbol(I.f, Decl(assignToFn.ts, 1, 17)) +} + diff --git a/tests/baselines/reference/assignToFn.types b/tests/baselines/reference/assignToFn.types new file mode 100644 index 00000000000..927f2261fcf --- /dev/null +++ b/tests/baselines/reference/assignToFn.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/assignToFn.ts === +module M { +>M : typeof M + + interface I { +>I : I + + f(n:number):boolean; +>f : (n: number) => boolean +>n : number + } + + var x:I={ f:function(n) { return true; } }; +>x : I +>I : I +>{ f:function(n) { return true; } } : { f: (n: number) => true; } +>f : (n: number) => true +>function(n) { return true; } : (n: number) => true +>n : number +>true : true + + x.f="hello"; +>x.f="hello" : "hello" +>x.f : (n: number) => boolean +>x : I +>f : (n: number) => boolean +>"hello" : "hello" +} + diff --git a/tests/baselines/reference/assignToInvalidLHS.symbols b/tests/baselines/reference/assignToInvalidLHS.symbols new file mode 100644 index 00000000000..3a1cd4974b0 --- /dev/null +++ b/tests/baselines/reference/assignToInvalidLHS.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/assignToInvalidLHS.ts === +declare var y:any; +>y : Symbol(y, Decl(assignToInvalidLHS.ts, 0, 11)) + +// Below is actually valid JavaScript (see http://es5.github.com/#x8.7 ), even though will always fail at runtime with 'invalid left-hand side' +var x = new y = 5; +>x : Symbol(x, Decl(assignToInvalidLHS.ts, 3, 3)) +>y : Symbol(y, Decl(assignToInvalidLHS.ts, 0, 11)) + diff --git a/tests/baselines/reference/assignToInvalidLHS.types b/tests/baselines/reference/assignToInvalidLHS.types new file mode 100644 index 00000000000..7a24245010c --- /dev/null +++ b/tests/baselines/reference/assignToInvalidLHS.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/assignToInvalidLHS.ts === +declare var y:any; +>y : any + +// Below is actually valid JavaScript (see http://es5.github.com/#x8.7 ), even though will always fail at runtime with 'invalid left-hand side' +var x = new y = 5; +>x : number +>new y = 5 : 5 +>new y : any +>y : any +>5 : 5 + diff --git a/tests/baselines/reference/assignToModule.symbols b/tests/baselines/reference/assignToModule.symbols new file mode 100644 index 00000000000..9461056de11 --- /dev/null +++ b/tests/baselines/reference/assignToModule.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/assignToModule.ts === +module A {} +>A : Symbol(A, Decl(assignToModule.ts, 0, 0)) + +A = undefined; // invalid LHS +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/assignToModule.types b/tests/baselines/reference/assignToModule.types new file mode 100644 index 00000000000..887e3d2c2b1 --- /dev/null +++ b/tests/baselines/reference/assignToModule.types @@ -0,0 +1,9 @@ +=== tests/cases/compiler/assignToModule.ts === +module A {} +>A : any + +A = undefined; // invalid LHS +>A = undefined : undefined +>A : any +>undefined : undefined + diff --git a/tests/baselines/reference/assigningFromObjectToAnythingElse.symbols b/tests/baselines/reference/assigningFromObjectToAnythingElse.symbols new file mode 100644 index 00000000000..ed085701932 --- /dev/null +++ b/tests/baselines/reference/assigningFromObjectToAnythingElse.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/assigningFromObjectToAnythingElse.ts === +var x: Object; +>x : Symbol(x, Decl(assigningFromObjectToAnythingElse.ts, 0, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var y: RegExp; +>y : Symbol(y, Decl(assigningFromObjectToAnythingElse.ts, 1, 3)) +>RegExp : Symbol(RegExp, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +y = x; +>y : Symbol(y, Decl(assigningFromObjectToAnythingElse.ts, 1, 3)) +>x : Symbol(x, Decl(assigningFromObjectToAnythingElse.ts, 0, 3)) + +var a: String = Object.create(""); +>a : Symbol(a, Decl(assigningFromObjectToAnythingElse.ts, 4, 3)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var c: String = Object.create(1); +>c : Symbol(c, Decl(assigningFromObjectToAnythingElse.ts, 5, 3)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object.create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>create : Symbol(ObjectConstructor.create, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Number : Symbol(Number, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var w: Error = new Object(); +>w : Symbol(w, Decl(assigningFromObjectToAnythingElse.ts, 7, 3)) +>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/assigningFromObjectToAnythingElse.types b/tests/baselines/reference/assigningFromObjectToAnythingElse.types new file mode 100644 index 00000000000..2b31b0c7673 --- /dev/null +++ b/tests/baselines/reference/assigningFromObjectToAnythingElse.types @@ -0,0 +1,40 @@ +=== tests/cases/compiler/assigningFromObjectToAnythingElse.ts === +var x: Object; +>x : Object +>Object : Object + +var y: RegExp; +>y : RegExp +>RegExp : RegExp + +y = x; +>y = x : Object +>y : RegExp +>x : Object + +var a: String = Object.create(""); +>a : String +>String : String +>Object.create("") : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } +>Object : Object +>"" : "" + +var c: String = Object.create(1); +>c : String +>String : String +>Object.create(1) : any +>Object.create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } +>Object : ObjectConstructor +>create : { (o: object): any; (o: object, properties: PropertyDescriptorMap & ThisType): any; } +>Number : Number +>1 : 1 + +var w: Error = new Object(); +>w : Error +>Error : Error +>new Object() : Object +>Object : ObjectConstructor + diff --git a/tests/baselines/reference/assignmentCompat1.symbols b/tests/baselines/reference/assignmentCompat1.symbols new file mode 100644 index 00000000000..43d4525e498 --- /dev/null +++ b/tests/baselines/reference/assignmentCompat1.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompat1.ts === +var x = { one: 1 }; +>x : Symbol(x, Decl(assignmentCompat1.ts, 0, 3)) +>one : Symbol(one, Decl(assignmentCompat1.ts, 0, 9)) + +var y: { [index: string]: any }; +>y : Symbol(y, Decl(assignmentCompat1.ts, 1, 3)) +>index : Symbol(index, Decl(assignmentCompat1.ts, 1, 10)) + +var z: { [index: number]: any }; +>z : Symbol(z, Decl(assignmentCompat1.ts, 2, 3)) +>index : Symbol(index, Decl(assignmentCompat1.ts, 2, 10)) + +x = y; // Error +>x : Symbol(x, Decl(assignmentCompat1.ts, 0, 3)) +>y : Symbol(y, Decl(assignmentCompat1.ts, 1, 3)) + +y = x; // Ok because index signature type is any +>y : Symbol(y, Decl(assignmentCompat1.ts, 1, 3)) +>x : Symbol(x, Decl(assignmentCompat1.ts, 0, 3)) + +x = z; // Error +>x : Symbol(x, Decl(assignmentCompat1.ts, 0, 3)) +>z : Symbol(z, Decl(assignmentCompat1.ts, 2, 3)) + +z = x; // Ok because index signature type is any +>z : Symbol(z, Decl(assignmentCompat1.ts, 2, 3)) +>x : Symbol(x, Decl(assignmentCompat1.ts, 0, 3)) + +y = "foo"; // Error +>y : Symbol(y, Decl(assignmentCompat1.ts, 1, 3)) + +z = "foo"; // OK, string has numeric indexer +>z : Symbol(z, Decl(assignmentCompat1.ts, 2, 3)) + +z = false; // Error +>z : Symbol(z, Decl(assignmentCompat1.ts, 2, 3)) + + diff --git a/tests/baselines/reference/assignmentCompat1.types b/tests/baselines/reference/assignmentCompat1.types new file mode 100644 index 00000000000..7036cca1725 --- /dev/null +++ b/tests/baselines/reference/assignmentCompat1.types @@ -0,0 +1,51 @@ +=== tests/cases/compiler/assignmentCompat1.ts === +var x = { one: 1 }; +>x : { one: number; } +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + +var y: { [index: string]: any }; +>y : { [index: string]: any; } +>index : string + +var z: { [index: number]: any }; +>z : { [index: number]: any; } +>index : number + +x = y; // Error +>x = y : { [index: string]: any; } +>x : { one: number; } +>y : { [index: string]: any; } + +y = x; // Ok because index signature type is any +>y = x : { one: number; } +>y : { [index: string]: any; } +>x : { one: number; } + +x = z; // Error +>x = z : { [index: number]: any; } +>x : { one: number; } +>z : { [index: number]: any; } + +z = x; // Ok because index signature type is any +>z = x : { one: number; } +>z : { [index: number]: any; } +>x : { one: number; } + +y = "foo"; // Error +>y = "foo" : "foo" +>y : { [index: string]: any; } +>"foo" : "foo" + +z = "foo"; // OK, string has numeric indexer +>z = "foo" : "foo" +>z : { [index: number]: any; } +>"foo" : "foo" + +z = false; // Error +>z = false : false +>z : { [index: number]: any; } +>false : false + + diff --git a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.symbols b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.symbols new file mode 100644 index 00000000000..0558393c631 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.symbols @@ -0,0 +1,49 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts === +var numStrTuple: [number, string]; +>numStrTuple : Symbol(numStrTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 0, 3)) + +var numNumTuple: [number, number]; +>numNumTuple : Symbol(numNumTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 1, 3)) + +var numEmptyObjTuple: [number, {}]; +>numEmptyObjTuple : Symbol(numEmptyObjTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 2, 3)) + +var emptyObjTuple: [{}]; +>emptyObjTuple : Symbol(emptyObjTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 3, 3)) + +var numArray: number[]; +>numArray : Symbol(numArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 5, 3)) + +var emptyObjArray: {}[]; +>emptyObjArray : Symbol(emptyObjArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 6, 3)) + +// no error +numArray = numNumTuple; +>numArray : Symbol(numArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 5, 3)) +>numNumTuple : Symbol(numNumTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 1, 3)) + +emptyObjArray = emptyObjTuple; +>emptyObjArray : Symbol(emptyObjArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 6, 3)) +>emptyObjTuple : Symbol(emptyObjTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 3, 3)) + +emptyObjArray = numStrTuple; +>emptyObjArray : Symbol(emptyObjArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 6, 3)) +>numStrTuple : Symbol(numStrTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 0, 3)) + +emptyObjArray = numNumTuple; +>emptyObjArray : Symbol(emptyObjArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 6, 3)) +>numNumTuple : Symbol(numNumTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 1, 3)) + +emptyObjArray = numEmptyObjTuple; +>emptyObjArray : Symbol(emptyObjArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 6, 3)) +>numEmptyObjTuple : Symbol(numEmptyObjTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 2, 3)) + +// error +numArray = numStrTuple; +>numArray : Symbol(numArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 5, 3)) +>numStrTuple : Symbol(numStrTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 0, 3)) + +emptyObjTuple = emptyObjArray; +>emptyObjTuple : Symbol(emptyObjTuple, Decl(assignmentCompatBetweenTupleAndArray.ts, 3, 3)) +>emptyObjArray : Symbol(emptyObjArray, Decl(assignmentCompatBetweenTupleAndArray.ts, 6, 3)) + diff --git a/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.types b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.types new file mode 100644 index 00000000000..7d4750d02fa --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBetweenTupleAndArray.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatBetweenTupleAndArray.ts === +var numStrTuple: [number, string]; +>numStrTuple : [number, string] + +var numNumTuple: [number, number]; +>numNumTuple : [number, number] + +var numEmptyObjTuple: [number, {}]; +>numEmptyObjTuple : [number, {}] + +var emptyObjTuple: [{}]; +>emptyObjTuple : [{}] + +var numArray: number[]; +>numArray : number[] + +var emptyObjArray: {}[]; +>emptyObjArray : {}[] + +// no error +numArray = numNumTuple; +>numArray = numNumTuple : [number, number] +>numArray : number[] +>numNumTuple : [number, number] + +emptyObjArray = emptyObjTuple; +>emptyObjArray = emptyObjTuple : [{}] +>emptyObjArray : {}[] +>emptyObjTuple : [{}] + +emptyObjArray = numStrTuple; +>emptyObjArray = numStrTuple : [number, string] +>emptyObjArray : {}[] +>numStrTuple : [number, string] + +emptyObjArray = numNumTuple; +>emptyObjArray = numNumTuple : [number, number] +>emptyObjArray : {}[] +>numNumTuple : [number, number] + +emptyObjArray = numEmptyObjTuple; +>emptyObjArray = numEmptyObjTuple : [number, {}] +>emptyObjArray : {}[] +>numEmptyObjTuple : [number, {}] + +// error +numArray = numStrTuple; +>numArray = numStrTuple : [number, string] +>numArray : number[] +>numStrTuple : [number, string] + +emptyObjTuple = emptyObjArray; +>emptyObjTuple = emptyObjArray : {}[] +>emptyObjTuple : [{}] +>emptyObjArray : {}[] + diff --git a/tests/baselines/reference/assignmentCompatBug2.symbols b/tests/baselines/reference/assignmentCompatBug2.symbols new file mode 100644 index 00000000000..d34000b6fa7 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBug2.symbols @@ -0,0 +1,109 @@ +=== tests/cases/compiler/assignmentCompatBug2.ts === +var b2: { b: number;} = { a: 0 }; // error +>b2 : Symbol(b2, Decl(assignmentCompatBug2.ts, 0, 3)) +>b : Symbol(b, Decl(assignmentCompatBug2.ts, 0, 9)) +>a : Symbol(a, Decl(assignmentCompatBug2.ts, 0, 25)) + +b2 = { a: 0 }; // error +>b2 : Symbol(b2, Decl(assignmentCompatBug2.ts, 0, 3)) +>a : Symbol(a, Decl(assignmentCompatBug2.ts, 2, 6)) + +b2 = {b: 0, a: 0 }; +>b2 : Symbol(b2, Decl(assignmentCompatBug2.ts, 0, 3)) +>b : Symbol(b, Decl(assignmentCompatBug2.ts, 4, 6)) +>a : Symbol(a, Decl(assignmentCompatBug2.ts, 4, 11)) + +var b3: { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }; +>b3 : Symbol(b3, Decl(assignmentCompatBug2.ts, 6, 3)) +>f : Symbol(f, Decl(assignmentCompatBug2.ts, 6, 9)) +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 6, 12)) +>g : Symbol(g, Decl(assignmentCompatBug2.ts, 6, 31)) +>s : Symbol(s, Decl(assignmentCompatBug2.ts, 6, 34)) +>m : Symbol(m, Decl(assignmentCompatBug2.ts, 6, 53)) +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 6, 64)) +>k : Symbol(k, Decl(assignmentCompatBug2.ts, 6, 76)) +>a : Symbol(a, Decl(assignmentCompatBug2.ts, 6, 80)) + +b3 = { +>b3 : Symbol(b3, Decl(assignmentCompatBug2.ts, 6, 3)) + + f: (n) => { return 0; }, +>f : Symbol(f, Decl(assignmentCompatBug2.ts, 8, 6)) +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 9, 8)) + + g: (s) => { return 0; }, +>g : Symbol(g, Decl(assignmentCompatBug2.ts, 9, 28)) +>s : Symbol(s, Decl(assignmentCompatBug2.ts, 10, 8)) + + m: 0, +>m : Symbol(m, Decl(assignmentCompatBug2.ts, 10, 28)) + +}; // ok + +b3 = { +>b3 : Symbol(b3, Decl(assignmentCompatBug2.ts, 6, 3)) + + f: (n) => { return 0; }, +>f : Symbol(f, Decl(assignmentCompatBug2.ts, 14, 6)) +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 15, 8)) + + g: (s) => { return 0; }, +>g : Symbol(g, Decl(assignmentCompatBug2.ts, 15, 28)) +>s : Symbol(s, Decl(assignmentCompatBug2.ts, 16, 8)) + +}; // error + +b3 = { +>b3 : Symbol(b3, Decl(assignmentCompatBug2.ts, 6, 3)) + + f: (n) => { return 0; }, +>f : Symbol(f, Decl(assignmentCompatBug2.ts, 19, 6)) +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 20, 8)) + + m: 0, +>m : Symbol(m, Decl(assignmentCompatBug2.ts, 20, 28)) + +}; // error + +b3 = { +>b3 : Symbol(b3, Decl(assignmentCompatBug2.ts, 6, 3)) + + f: (n) => { return 0; }, +>f : Symbol(f, Decl(assignmentCompatBug2.ts, 24, 6)) +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 25, 8)) + + g: (s) => { return 0; }, +>g : Symbol(g, Decl(assignmentCompatBug2.ts, 25, 28)) +>s : Symbol(s, Decl(assignmentCompatBug2.ts, 26, 8)) + + m: 0, +>m : Symbol(m, Decl(assignmentCompatBug2.ts, 26, 28)) + + n: 0, +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 27, 9)) + + k: (a) =>{ return null; }, +>k : Symbol(k, Decl(assignmentCompatBug2.ts, 28, 9)) +>a : Symbol(a, Decl(assignmentCompatBug2.ts, 29, 8)) + +}; // ok + +b3 = { +>b3 : Symbol(b3, Decl(assignmentCompatBug2.ts, 6, 3)) + + f: (n) => { return 0; }, +>f : Symbol(f, Decl(assignmentCompatBug2.ts, 32, 6)) +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 33, 8)) + + g: (s) => { return 0; }, +>g : Symbol(g, Decl(assignmentCompatBug2.ts, 33, 28)) +>s : Symbol(s, Decl(assignmentCompatBug2.ts, 34, 8)) + + n: 0, +>n : Symbol(n, Decl(assignmentCompatBug2.ts, 34, 28)) + + k: (a) =>{ return null; }, +>k : Symbol(k, Decl(assignmentCompatBug2.ts, 35, 9)) +>a : Symbol(a, Decl(assignmentCompatBug2.ts, 36, 8)) + +}; // error diff --git a/tests/baselines/reference/assignmentCompatBug2.types b/tests/baselines/reference/assignmentCompatBug2.types new file mode 100644 index 00000000000..414f91b5bdc --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBug2.types @@ -0,0 +1,155 @@ +=== tests/cases/compiler/assignmentCompatBug2.ts === +var b2: { b: number;} = { a: 0 }; // error +>b2 : { b: number; } +>b : number +>{ a: 0 } : { a: number; } +>a : number +>0 : 0 + +b2 = { a: 0 }; // error +>b2 = { a: 0 } : { a: number; } +>b2 : { b: number; } +>{ a: 0 } : { a: number; } +>a : number +>0 : 0 + +b2 = {b: 0, a: 0 }; +>b2 = {b: 0, a: 0 } : { b: number; a: number; } +>b2 : { b: number; } +>{b: 0, a: 0 } : { b: number; a: number; } +>b : number +>0 : 0 +>a : number +>0 : 0 + +var b3: { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }; +>b3 : { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; } +>f : (n: number) => number +>n : number +>g : (s: string) => number +>s : string +>m : number +>n : number +>k : (a: any) => any +>a : any + +b3 = { +>b3 = { f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0,} : { f: (n: number) => number; g: (s: string) => number; m: number; } +>b3 : { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; } +>{ f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0,} : { f: (n: number) => number; g: (s: string) => number; m: number; } + + f: (n) => { return 0; }, +>f : (n: number) => number +>(n) => { return 0; } : (n: number) => number +>n : number +>0 : 0 + + g: (s) => { return 0; }, +>g : (s: string) => number +>(s) => { return 0; } : (s: string) => number +>s : string +>0 : 0 + + m: 0, +>m : number +>0 : 0 + +}; // ok + +b3 = { +>b3 = { f: (n) => { return 0; }, g: (s) => { return 0; },} : { f: (n: number) => number; g: (s: string) => number; } +>b3 : { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; } +>{ f: (n) => { return 0; }, g: (s) => { return 0; },} : { f: (n: number) => number; g: (s: string) => number; } + + f: (n) => { return 0; }, +>f : (n: number) => number +>(n) => { return 0; } : (n: number) => number +>n : number +>0 : 0 + + g: (s) => { return 0; }, +>g : (s: string) => number +>(s) => { return 0; } : (s: string) => number +>s : string +>0 : 0 + +}; // error + +b3 = { +>b3 = { f: (n) => { return 0; }, m: 0,} : { f: (n: number) => number; m: number; } +>b3 : { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; } +>{ f: (n) => { return 0; }, m: 0,} : { f: (n: number) => number; m: number; } + + f: (n) => { return 0; }, +>f : (n: number) => number +>(n) => { return 0; } : (n: number) => number +>n : number +>0 : 0 + + m: 0, +>m : number +>0 : 0 + +}; // error + +b3 = { +>b3 = { f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; m: number; n: number; k: (a: any) => any; } +>b3 : { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; } +>{ f: (n) => { return 0; }, g: (s) => { return 0; }, m: 0, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; m: number; n: number; k: (a: any) => any; } + + f: (n) => { return 0; }, +>f : (n: number) => number +>(n) => { return 0; } : (n: number) => number +>n : number +>0 : 0 + + g: (s) => { return 0; }, +>g : (s: string) => number +>(s) => { return 0; } : (s: string) => number +>s : string +>0 : 0 + + m: 0, +>m : number +>0 : 0 + + n: 0, +>n : number +>0 : 0 + + k: (a) =>{ return null; }, +>k : (a: any) => any +>(a) =>{ return null; } : (a: any) => any +>a : any +>null : null + +}; // ok + +b3 = { +>b3 = { f: (n) => { return 0; }, g: (s) => { return 0; }, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; } +>b3 : { f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; } +>{ f: (n) => { return 0; }, g: (s) => { return 0; }, n: 0, k: (a) =>{ return null; },} : { f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; } + + f: (n) => { return 0; }, +>f : (n: number) => number +>(n) => { return 0; } : (n: number) => number +>n : number +>0 : 0 + + g: (s) => { return 0; }, +>g : (s: string) => number +>(s) => { return 0; } : (s: string) => number +>s : string +>0 : 0 + + n: 0, +>n : number +>0 : 0 + + k: (a) =>{ return null; }, +>k : (a: any) => any +>(a) =>{ return null; } : (a: any) => any +>a : any +>null : null + +}; // error diff --git a/tests/baselines/reference/assignmentCompatBug3.symbols b/tests/baselines/reference/assignmentCompatBug3.symbols new file mode 100644 index 00000000000..6545195d4b8 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBug3.symbols @@ -0,0 +1,61 @@ +=== tests/cases/compiler/assignmentCompatBug3.ts === +function makePoint(x: number, y: number) { +>makePoint : Symbol(makePoint, Decl(assignmentCompatBug3.ts, 0, 0)) +>x : Symbol(x, Decl(assignmentCompatBug3.ts, 0, 19)) +>y : Symbol(y, Decl(assignmentCompatBug3.ts, 0, 29)) + + return { + get x() { return x;}, // shouldn't be "void" +>x : Symbol(x, Decl(assignmentCompatBug3.ts, 1, 12)) +>x : Symbol(x, Decl(assignmentCompatBug3.ts, 0, 19)) + + get y() { return y;}, // shouldn't be "void" +>y : Symbol(y, Decl(assignmentCompatBug3.ts, 2, 29)) +>y : Symbol(y, Decl(assignmentCompatBug3.ts, 0, 29)) + + //x: "yo", + //y: "boo", + dist: function () { +>dist : Symbol(dist, Decl(assignmentCompatBug3.ts, 3, 29)) + + return Math.sqrt(x*x+y*y); // shouldn't be picking up "x" and "y" from the object lit +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --)) +>x : Symbol(x, Decl(assignmentCompatBug3.ts, 0, 19)) +>x : Symbol(x, Decl(assignmentCompatBug3.ts, 0, 19)) +>y : Symbol(y, Decl(assignmentCompatBug3.ts, 0, 29)) +>y : Symbol(y, Decl(assignmentCompatBug3.ts, 0, 29)) + } + } +} + +class C { +>C : Symbol(C, Decl(assignmentCompatBug3.ts, 10, 1)) + + get x() { +>x : Symbol(C.x, Decl(assignmentCompatBug3.ts, 12, 9)) + + return 0; + } +} + +function foo(test: string) { } +>foo : Symbol(foo, Decl(assignmentCompatBug3.ts, 16, 1)) +>test : Symbol(test, Decl(assignmentCompatBug3.ts, 18, 13)) + +var x: any; +>x : Symbol(x, Decl(assignmentCompatBug3.ts, 20, 3)) + +var y: any; +>y : Symbol(y, Decl(assignmentCompatBug3.ts, 21, 3)) + +foo(x); +>foo : Symbol(foo, Decl(assignmentCompatBug3.ts, 16, 1)) +>x : Symbol(x, Decl(assignmentCompatBug3.ts, 20, 3)) + +foo(x + y); +>foo : Symbol(foo, Decl(assignmentCompatBug3.ts, 16, 1)) +>x : Symbol(x, Decl(assignmentCompatBug3.ts, 20, 3)) +>y : Symbol(y, Decl(assignmentCompatBug3.ts, 21, 3)) + diff --git a/tests/baselines/reference/assignmentCompatBug3.types b/tests/baselines/reference/assignmentCompatBug3.types new file mode 100644 index 00000000000..1c4581e2f19 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBug3.types @@ -0,0 +1,72 @@ +=== tests/cases/compiler/assignmentCompatBug3.ts === +function makePoint(x: number, y: number) { +>makePoint : (x: number, y: number) => { readonly x: number; readonly y: number; dist: () => number; } +>x : number +>y : number + + return { +>{ get x() { return x;}, // shouldn't be "void" get y() { return y;}, // shouldn't be "void" //x: "yo", //y: "boo", dist: function () { return Math.sqrt(x*x+y*y); // shouldn't be picking up "x" and "y" from the object lit } } : { readonly x: number; readonly y: number; dist: () => number; } + + get x() { return x;}, // shouldn't be "void" +>x : number +>x : number + + get y() { return y;}, // shouldn't be "void" +>y : number +>y : number + + //x: "yo", + //y: "boo", + dist: function () { +>dist : () => number +>function () { return Math.sqrt(x*x+y*y); // shouldn't be picking up "x" and "y" from the object lit } : () => number + + return Math.sqrt(x*x+y*y); // shouldn't be picking up "x" and "y" from the object lit +>Math.sqrt(x*x+y*y) : number +>Math.sqrt : (x: number) => number +>Math : Math +>sqrt : (x: number) => number +>x*x+y*y : number +>x*x : number +>x : number +>x : number +>y*y : number +>y : number +>y : number + } + } +} + +class C { +>C : C + + get x() { +>x : number + + return 0; +>0 : 0 + } +} + +function foo(test: string) { } +>foo : (test: string) => void +>test : string + +var x: any; +>x : any + +var y: any; +>y : any + +foo(x); +>foo(x) : void +>foo : (test: string) => void +>x : any + +foo(x + y); +>foo(x + y) : void +>foo : (test: string) => void +>x + y : any +>x : any +>y : any + diff --git a/tests/baselines/reference/assignmentCompatBug5.symbols b/tests/baselines/reference/assignmentCompatBug5.symbols new file mode 100644 index 00000000000..63d4af123b4 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBug5.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/assignmentCompatBug5.ts === +function foo1(x: { a: number; }) { } +>foo1 : Symbol(foo1, Decl(assignmentCompatBug5.ts, 0, 0)) +>x : Symbol(x, Decl(assignmentCompatBug5.ts, 0, 14)) +>a : Symbol(a, Decl(assignmentCompatBug5.ts, 0, 18)) + +foo1({ b: 5 }); +>foo1 : Symbol(foo1, Decl(assignmentCompatBug5.ts, 0, 0)) +>b : Symbol(b, Decl(assignmentCompatBug5.ts, 1, 6)) + +function foo2(x: number[]) { } +>foo2 : Symbol(foo2, Decl(assignmentCompatBug5.ts, 1, 15)) +>x : Symbol(x, Decl(assignmentCompatBug5.ts, 3, 14)) + +foo2(["s", "t"]); +>foo2 : Symbol(foo2, Decl(assignmentCompatBug5.ts, 1, 15)) + +function foo3(x: (n: number) =>number) { }; +>foo3 : Symbol(foo3, Decl(assignmentCompatBug5.ts, 4, 17)) +>x : Symbol(x, Decl(assignmentCompatBug5.ts, 6, 14)) +>n : Symbol(n, Decl(assignmentCompatBug5.ts, 6, 18)) + +foo3((s:string) => { }); +>foo3 : Symbol(foo3, Decl(assignmentCompatBug5.ts, 4, 17)) +>s : Symbol(s, Decl(assignmentCompatBug5.ts, 7, 6)) + +foo3((n) => { return; }); +>foo3 : Symbol(foo3, Decl(assignmentCompatBug5.ts, 4, 17)) +>n : Symbol(n, Decl(assignmentCompatBug5.ts, 8, 6)) + + diff --git a/tests/baselines/reference/assignmentCompatBug5.types b/tests/baselines/reference/assignmentCompatBug5.types new file mode 100644 index 00000000000..2b8358bb27f --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBug5.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatBug5.ts === +function foo1(x: { a: number; }) { } +>foo1 : (x: { a: number; }) => void +>x : { a: number; } +>a : number + +foo1({ b: 5 }); +>foo1({ b: 5 }) : void +>foo1 : (x: { a: number; }) => void +>{ b: 5 } : { b: number; } +>b : number +>5 : 5 + +function foo2(x: number[]) { } +>foo2 : (x: number[]) => void +>x : number[] + +foo2(["s", "t"]); +>foo2(["s", "t"]) : void +>foo2 : (x: number[]) => void +>["s", "t"] : string[] +>"s" : "s" +>"t" : "t" + +function foo3(x: (n: number) =>number) { }; +>foo3 : (x: (n: number) => number) => void +>x : (n: number) => number +>n : number + +foo3((s:string) => { }); +>foo3((s:string) => { }) : void +>foo3 : (x: (n: number) => number) => void +>(s:string) => { } : (s: string) => void +>s : string + +foo3((n) => { return; }); +>foo3((n) => { return; }) : void +>foo3 : (x: (n: number) => number) => void +>(n) => { return; } : (n: number) => void +>n : number + + diff --git a/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.symbols b/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.symbols new file mode 100644 index 00000000000..e0a2d00ac34 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts === +function foo(x: { id: number; name?: string; }): void; +>foo : Symbol(foo, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 0, 0)) +>x : Symbol(x, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 0, 13)) +>id : Symbol(id, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 0, 17)) +>name : Symbol(name, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 0, 29)) + +foo({ id: 1234 }); // Ok +>foo : Symbol(foo, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 0, 0)) +>id : Symbol(id, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 1, 5)) + +foo({ id: 1234, name: "hello" }); // Ok +>foo : Symbol(foo, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 0, 0)) +>id : Symbol(id, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 2, 5)) +>name : Symbol(name, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 2, 15)) + +foo({ id: 1234, name: false }); // Error, name of wrong type +>foo : Symbol(foo, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 0, 0)) +>id : Symbol(id, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 3, 5)) +>name : Symbol(name, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 3, 15)) + +foo({ name: "hello" }); // Error, id required but missing +>foo : Symbol(foo, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 0, 0)) +>name : Symbol(name, Decl(assignmentCompatFunctionsWithOptionalArgs.ts, 4, 5)) + diff --git a/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.types b/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.types new file mode 100644 index 00000000000..1f1beea0b38 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatFunctionsWithOptionalArgs.types @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatFunctionsWithOptionalArgs.ts === +function foo(x: { id: number; name?: string; }): void; +>foo : (x: { id: number; name?: string; }) => void +>x : { id: number; name?: string; } +>id : number +>name : string + +foo({ id: 1234 }); // Ok +>foo({ id: 1234 }) : void +>foo : (x: { id: number; name?: string; }) => void +>{ id: 1234 } : { id: number; } +>id : number +>1234 : 1234 + +foo({ id: 1234, name: "hello" }); // Ok +>foo({ id: 1234, name: "hello" }) : void +>foo : (x: { id: number; name?: string; }) => void +>{ id: 1234, name: "hello" } : { id: number; name: string; } +>id : number +>1234 : 1234 +>name : string +>"hello" : "hello" + +foo({ id: 1234, name: false }); // Error, name of wrong type +>foo({ id: 1234, name: false }) : void +>foo : (x: { id: number; name?: string; }) => void +>{ id: 1234, name: false } : { id: number; name: boolean; } +>id : number +>1234 : 1234 +>name : boolean +>false : false + +foo({ name: "hello" }); // Error, id required but missing +>foo({ name: "hello" }) : void +>foo : (x: { id: number; name?: string; }) => void +>{ name: "hello" } : { name: string; } +>name : string +>"hello" : "hello" + diff --git a/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.symbols b/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.symbols new file mode 100644 index 00000000000..2fa181500ae --- /dev/null +++ b/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/assignmentCompatInterfaceWithStringIndexSignature.ts === +interface IHandler { +>IHandler : Symbol(IHandler, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 0, 0)) + + (e): boolean; +>e : Symbol(e, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 1, 5)) +} + +interface IHandlerMap { +>IHandlerMap : Symbol(IHandlerMap, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 2, 1)) + + [type: string]: IHandler; +>type : Symbol(type, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 5, 5)) +>IHandler : Symbol(IHandler, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 0, 0)) +} + +class Foo { +>Foo : Symbol(Foo, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 6, 1)) + + public Boz(): void { } +>Boz : Symbol(Foo.Boz, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 8, 11)) +} + +function Biz(map: IHandlerMap) { } +>Biz : Symbol(Biz, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 10, 1)) +>map : Symbol(map, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 12, 13)) +>IHandlerMap : Symbol(IHandlerMap, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 2, 1)) + +Biz(new Foo()); +>Biz : Symbol(Biz, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 10, 1)) +>Foo : Symbol(Foo, Decl(assignmentCompatInterfaceWithStringIndexSignature.ts, 6, 1)) + diff --git a/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.types b/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.types new file mode 100644 index 00000000000..57371756706 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatInterfaceWithStringIndexSignature.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/assignmentCompatInterfaceWithStringIndexSignature.ts === +interface IHandler { +>IHandler : IHandler + + (e): boolean; +>e : any +} + +interface IHandlerMap { +>IHandlerMap : IHandlerMap + + [type: string]: IHandler; +>type : string +>IHandler : IHandler +} + +class Foo { +>Foo : Foo + + public Boz(): void { } +>Boz : () => void +} + +function Biz(map: IHandlerMap) { } +>Biz : (map: IHandlerMap) => void +>map : IHandlerMap +>IHandlerMap : IHandlerMap + +Biz(new Foo()); +>Biz(new Foo()) : void +>Biz : (map: IHandlerMap) => void +>new Foo() : Foo +>Foo : typeof Foo + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures.symbols b/tests/baselines/reference/assignmentCompatWithCallSignatures.symbols new file mode 100644 index 00000000000..26e3701c0e3 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures.symbols @@ -0,0 +1,128 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts === +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches + +interface T { +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures.ts, 0, 0)) + + (x: number): void; +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 3, 5)) +} +var t: T; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures.ts, 0, 0)) + +var a: { (x: number): void }; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 6, 10)) + +t = a; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) + +a = t; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) + +interface S { +>S : Symbol(S, Decl(assignmentCompatWithCallSignatures.ts, 9, 6)) + + (x: number): string; +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 12, 5)) +} +var s: S; +>s : Symbol(s, Decl(assignmentCompatWithCallSignatures.ts, 14, 3)) +>S : Symbol(S, Decl(assignmentCompatWithCallSignatures.ts, 9, 6)) + +var a2: { (x: number): string }; +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures.ts, 15, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 15, 11)) + +t = s; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>s : Symbol(s, Decl(assignmentCompatWithCallSignatures.ts, 14, 3)) + +t = a2; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures.ts, 15, 3)) + +a = s; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>s : Symbol(s, Decl(assignmentCompatWithCallSignatures.ts, 14, 3)) + +a = a2; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures.ts, 15, 3)) + +t = (x: T) => 1; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures.ts, 21, 5)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 21, 8)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures.ts, 21, 5)) + +t = () => 1; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) + +t = function (x: number) { return ''; } +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 23, 14)) + +a = (x: T) => 1; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures.ts, 24, 5)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 24, 8)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures.ts, 24, 5)) + +a = () => 1; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) + +a = function (x: number) { return ''; } +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 26, 14)) + +interface S2 { +>S2 : Symbol(S2, Decl(assignmentCompatWithCallSignatures.ts, 26, 39)) + + (x: string): void; +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 29, 5)) +} +var s2: S2; +>s2 : Symbol(s2, Decl(assignmentCompatWithCallSignatures.ts, 31, 3)) +>S2 : Symbol(S2, Decl(assignmentCompatWithCallSignatures.ts, 26, 39)) + +var a3: { (x: string): void }; +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures.ts, 32, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 32, 11)) + +// these are errors +t = s2; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>s2 : Symbol(s2, Decl(assignmentCompatWithCallSignatures.ts, 31, 3)) + +t = a3; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures.ts, 32, 3)) + +t = (x: string) => 1; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 36, 5)) + +t = function (x: string) { return ''; } +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 37, 14)) + +a = s2; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>s2 : Symbol(s2, Decl(assignmentCompatWithCallSignatures.ts, 31, 3)) + +a = a3; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures.ts, 32, 3)) + +a = (x: string) => 1; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 40, 5)) + +a = function (x: string) { return ''; } +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures.ts, 41, 14)) + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures.types b/tests/baselines/reference/assignmentCompatWithCallSignatures.types new file mode 100644 index 00000000000..f7faedf91e3 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures.types @@ -0,0 +1,168 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts === +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches + +interface T { +>T : T + + (x: number): void; +>x : number +} +var t: T; +>t : T +>T : T + +var a: { (x: number): void }; +>a : (x: number) => void +>x : number + +t = a; +>t = a : (x: number) => void +>t : T +>a : (x: number) => void + +a = t; +>a = t : T +>a : (x: number) => void +>t : T + +interface S { +>S : S + + (x: number): string; +>x : number +} +var s: S; +>s : S +>S : S + +var a2: { (x: number): string }; +>a2 : (x: number) => string +>x : number + +t = s; +>t = s : S +>t : T +>s : S + +t = a2; +>t = a2 : (x: number) => string +>t : T +>a2 : (x: number) => string + +a = s; +>a = s : S +>a : (x: number) => void +>s : S + +a = a2; +>a = a2 : (x: number) => string +>a : (x: number) => void +>a2 : (x: number) => string + +t = (x: T) => 1; +>t = (x: T) => 1 : (x: T) => number +>t : T +>(x: T) => 1 : (x: T) => number +>T : T +>x : T +>T : T +>1 : 1 + +t = () => 1; +>t = () => 1 : () => number +>t : T +>() => 1 : () => number +>1 : 1 + +t = function (x: number) { return ''; } +>t = function (x: number) { return ''; } : (x: number) => string +>t : T +>function (x: number) { return ''; } : (x: number) => string +>x : number +>'' : "" + +a = (x: T) => 1; +>a = (x: T) => 1 : (x: T) => number +>a : (x: number) => void +>(x: T) => 1 : (x: T) => number +>T : T +>x : T +>T : T +>1 : 1 + +a = () => 1; +>a = () => 1 : () => number +>a : (x: number) => void +>() => 1 : () => number +>1 : 1 + +a = function (x: number) { return ''; } +>a = function (x: number) { return ''; } : (x: number) => string +>a : (x: number) => void +>function (x: number) { return ''; } : (x: number) => string +>x : number +>'' : "" + +interface S2 { +>S2 : S2 + + (x: string): void; +>x : string +} +var s2: S2; +>s2 : S2 +>S2 : S2 + +var a3: { (x: string): void }; +>a3 : (x: string) => void +>x : string + +// these are errors +t = s2; +>t = s2 : S2 +>t : T +>s2 : S2 + +t = a3; +>t = a3 : (x: string) => void +>t : T +>a3 : (x: string) => void + +t = (x: string) => 1; +>t = (x: string) => 1 : (x: string) => number +>t : T +>(x: string) => 1 : (x: string) => number +>x : string +>1 : 1 + +t = function (x: string) { return ''; } +>t = function (x: string) { return ''; } : (x: string) => string +>t : T +>function (x: string) { return ''; } : (x: string) => string +>x : string +>'' : "" + +a = s2; +>a = s2 : S2 +>a : (x: number) => void +>s2 : S2 + +a = a3; +>a = a3 : (x: string) => void +>a : (x: number) => void +>a3 : (x: string) => void + +a = (x: string) => 1; +>a = (x: string) => 1 : (x: string) => number +>a : (x: number) => void +>(x: string) => 1 : (x: string) => number +>x : string +>1 : 1 + +a = function (x: string) { return ''; } +>a = function (x: string) { return ''; } : (x: string) => string +>a : (x: number) => void +>function (x: string) { return ''; } : (x: string) => string +>x : string +>'' : "" + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures2.symbols b/tests/baselines/reference/assignmentCompatWithCallSignatures2.symbols new file mode 100644 index 00000000000..267aea9fa5f --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures2.symbols @@ -0,0 +1,160 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts === +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches + +interface T { +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures2.ts, 0, 0)) + + f(x: number): void; +>f : Symbol(T.f, Decl(assignmentCompatWithCallSignatures2.ts, 2, 13)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 3, 6)) +} +var t: T; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures2.ts, 0, 0)) + +var a: { f(x: number): void }; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 6, 8)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 6, 11)) + +t = a; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) + +a = t; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) + +interface S { +>S : Symbol(S, Decl(assignmentCompatWithCallSignatures2.ts, 9, 6)) + + f(x: number): string; +>f : Symbol(S.f, Decl(assignmentCompatWithCallSignatures2.ts, 11, 13)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 12, 6)) +} +var s: S; +>s : Symbol(s, Decl(assignmentCompatWithCallSignatures2.ts, 14, 3)) +>S : Symbol(S, Decl(assignmentCompatWithCallSignatures2.ts, 9, 6)) + +var a2: { f(x: number): string }; +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures2.ts, 15, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 15, 9)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 15, 12)) + +t = s; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>s : Symbol(s, Decl(assignmentCompatWithCallSignatures2.ts, 14, 3)) + +t = a2; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures2.ts, 15, 3)) + +a = s; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>s : Symbol(s, Decl(assignmentCompatWithCallSignatures2.ts, 14, 3)) + +a = a2; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures2.ts, 15, 3)) + +t = { f: () => 1 }; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 21, 5)) + +t = { f: (x:T) => 1 }; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 22, 5)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures2.ts, 22, 10)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 22, 13)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures2.ts, 22, 10)) + +t = { f: function f() { return 1 } }; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 23, 5)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 23, 8)) + +t = { f(x: number) { return ''; } } +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 24, 5)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 24, 8)) + +a = { f: () => 1 } +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 25, 5)) + +a = { f: (x: T) => 1 }; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 26, 5)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures2.ts, 26, 10)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 26, 13)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures2.ts, 26, 10)) + +a = { f: function (x: number) { return ''; } } +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 27, 5)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 27, 19)) + +// errors +t = () => 1; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) + +t = function (x: number) { return ''; } +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 31, 14)) + +a = () => 1; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) + +a = function (x: number) { return ''; } +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 33, 14)) + +interface S2 { +>S2 : Symbol(S2, Decl(assignmentCompatWithCallSignatures2.ts, 33, 39)) + + f(x: string): void; +>f : Symbol(S2.f, Decl(assignmentCompatWithCallSignatures2.ts, 35, 14)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 36, 6)) +} +var s2: S2; +>s2 : Symbol(s2, Decl(assignmentCompatWithCallSignatures2.ts, 38, 3)) +>S2 : Symbol(S2, Decl(assignmentCompatWithCallSignatures2.ts, 33, 39)) + +var a3: { f(x: string): void }; +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures2.ts, 39, 3)) +>f : Symbol(f, Decl(assignmentCompatWithCallSignatures2.ts, 39, 9)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 39, 12)) + +// these are errors +t = s2; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>s2 : Symbol(s2, Decl(assignmentCompatWithCallSignatures2.ts, 38, 3)) + +t = a3; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures2.ts, 39, 3)) + +t = (x: string) => 1; +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 43, 5)) + +t = function (x: string) { return ''; } +>t : Symbol(t, Decl(assignmentCompatWithCallSignatures2.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 44, 14)) + +a = s2; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>s2 : Symbol(s2, Decl(assignmentCompatWithCallSignatures2.ts, 38, 3)) + +a = a3; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures2.ts, 39, 3)) + +a = (x: string) => 1; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 47, 5)) + +a = function (x: string) { return ''; } +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures2.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures2.ts, 48, 14)) + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures2.types b/tests/baselines/reference/assignmentCompatWithCallSignatures2.types new file mode 100644 index 00000000000..f20b03dbcce --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures2.types @@ -0,0 +1,221 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures2.ts === +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches + +interface T { +>T : T + + f(x: number): void; +>f : (x: number) => void +>x : number +} +var t: T; +>t : T +>T : T + +var a: { f(x: number): void }; +>a : { f(x: number): void; } +>f : (x: number) => void +>x : number + +t = a; +>t = a : { f(x: number): void; } +>t : T +>a : { f(x: number): void; } + +a = t; +>a = t : T +>a : { f(x: number): void; } +>t : T + +interface S { +>S : S + + f(x: number): string; +>f : (x: number) => string +>x : number +} +var s: S; +>s : S +>S : S + +var a2: { f(x: number): string }; +>a2 : { f(x: number): string; } +>f : (x: number) => string +>x : number + +t = s; +>t = s : S +>t : T +>s : S + +t = a2; +>t = a2 : { f(x: number): string; } +>t : T +>a2 : { f(x: number): string; } + +a = s; +>a = s : S +>a : { f(x: number): void; } +>s : S + +a = a2; +>a = a2 : { f(x: number): string; } +>a : { f(x: number): void; } +>a2 : { f(x: number): string; } + +t = { f: () => 1 }; +>t = { f: () => 1 } : { f: () => number; } +>t : T +>{ f: () => 1 } : { f: () => number; } +>f : () => number +>() => 1 : () => number +>1 : 1 + +t = { f: (x:T) => 1 }; +>t = { f: (x:T) => 1 } : { f: (x: T) => number; } +>t : T +>{ f: (x:T) => 1 } : { f: (x: T) => number; } +>f : (x: T) => number +>(x:T) => 1 : (x: T) => number +>T : T +>x : T +>T : T +>1 : 1 + +t = { f: function f() { return 1 } }; +>t = { f: function f() { return 1 } } : { f: () => number; } +>t : T +>{ f: function f() { return 1 } } : { f: () => number; } +>f : () => number +>function f() { return 1 } : () => number +>f : () => number +>1 : 1 + +t = { f(x: number) { return ''; } } +>t = { f(x: number) { return ''; } } : { f(x: number): string; } +>t : T +>{ f(x: number) { return ''; } } : { f(x: number): string; } +>f : (x: number) => string +>x : number +>'' : "" + +a = { f: () => 1 } +>a = { f: () => 1 } : { f: () => number; } +>a : { f(x: number): void; } +>{ f: () => 1 } : { f: () => number; } +>f : () => number +>() => 1 : () => number +>1 : 1 + +a = { f: (x: T) => 1 }; +>a = { f: (x: T) => 1 } : { f: (x: T) => number; } +>a : { f(x: number): void; } +>{ f: (x: T) => 1 } : { f: (x: T) => number; } +>f : (x: T) => number +>(x: T) => 1 : (x: T) => number +>T : T +>x : T +>T : T +>1 : 1 + +a = { f: function (x: number) { return ''; } } +>a = { f: function (x: number) { return ''; } } : { f: (x: number) => string; } +>a : { f(x: number): void; } +>{ f: function (x: number) { return ''; } } : { f: (x: number) => string; } +>f : (x: number) => string +>function (x: number) { return ''; } : (x: number) => string +>x : number +>'' : "" + +// errors +t = () => 1; +>t = () => 1 : () => number +>t : T +>() => 1 : () => number +>1 : 1 + +t = function (x: number) { return ''; } +>t = function (x: number) { return ''; } : (x: number) => string +>t : T +>function (x: number) { return ''; } : (x: number) => string +>x : number +>'' : "" + +a = () => 1; +>a = () => 1 : () => number +>a : { f(x: number): void; } +>() => 1 : () => number +>1 : 1 + +a = function (x: number) { return ''; } +>a = function (x: number) { return ''; } : (x: number) => string +>a : { f(x: number): void; } +>function (x: number) { return ''; } : (x: number) => string +>x : number +>'' : "" + +interface S2 { +>S2 : S2 + + f(x: string): void; +>f : (x: string) => void +>x : string +} +var s2: S2; +>s2 : S2 +>S2 : S2 + +var a3: { f(x: string): void }; +>a3 : { f(x: string): void; } +>f : (x: string) => void +>x : string + +// these are errors +t = s2; +>t = s2 : S2 +>t : T +>s2 : S2 + +t = a3; +>t = a3 : { f(x: string): void; } +>t : T +>a3 : { f(x: string): void; } + +t = (x: string) => 1; +>t = (x: string) => 1 : (x: string) => number +>t : T +>(x: string) => 1 : (x: string) => number +>x : string +>1 : 1 + +t = function (x: string) { return ''; } +>t = function (x: string) { return ''; } : (x: string) => string +>t : T +>function (x: string) { return ''; } : (x: string) => string +>x : string +>'' : "" + +a = s2; +>a = s2 : S2 +>a : { f(x: number): void; } +>s2 : S2 + +a = a3; +>a = a3 : { f(x: string): void; } +>a : { f(x: number): void; } +>a3 : { f(x: string): void; } + +a = (x: string) => 1; +>a = (x: string) => 1 : (x: string) => number +>a : { f(x: number): void; } +>(x: string) => 1 : (x: string) => number +>x : string +>1 : 1 + +a = function (x: string) { return ''; } +>a = function (x: string) { return ''; } : (x: string) => string +>a : { f(x: number): void; } +>function (x: string) { return ''; } : (x: string) => string +>x : string +>'' : "" + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.symbols b/tests/baselines/reference/assignmentCompatWithCallSignatures4.symbols new file mode 100644 index 00000000000..02d7a1a0bad --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.symbols @@ -0,0 +1,404 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts === +// These are mostly permitted with the current loose rules. All ok unless otherwise noted. + +module Errors { +>Errors : Symbol(Errors, Decl(assignmentCompatWithCallSignatures4.ts, 0, 0)) + + class Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithCallSignatures4.ts, 3, 16)) + + class Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithCallSignatures4.ts, 4, 32)) + + class Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithCallSignatures4.ts, 4, 47)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithCallSignatures4.ts, 5, 36)) + + class OtherDerived extends Base { bing: string; } +>OtherDerived : Symbol(OtherDerived, Decl(assignmentCompatWithCallSignatures4.ts, 5, 51)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>bing : Symbol(OtherDerived.bing, Decl(assignmentCompatWithCallSignatures4.ts, 6, 37)) + + module WithNonGenericSignaturesInBaseType { +>WithNonGenericSignaturesInBaseType : Symbol(WithNonGenericSignaturesInBaseType, Decl(assignmentCompatWithCallSignatures4.ts, 6, 53)) + + // target type with non-generic call signatures + var a2: (x: number) => string[]; +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures4.ts, 10, 11)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 10, 17)) + + var a7: (x: (arg: Base) => Derived) => (r: Base) => Derived2; +>a7 : Symbol(a7, Decl(assignmentCompatWithCallSignatures4.ts, 11, 11)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 11, 17)) +>arg : Symbol(arg, Decl(assignmentCompatWithCallSignatures4.ts, 11, 21)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>r : Symbol(r, Decl(assignmentCompatWithCallSignatures4.ts, 11, 48)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithCallSignatures4.ts, 4, 47)) + + var a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; +>a8 : Symbol(a8, Decl(assignmentCompatWithCallSignatures4.ts, 12, 11)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 12, 17)) +>arg : Symbol(arg, Decl(assignmentCompatWithCallSignatures4.ts, 12, 21)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignatures4.ts, 12, 43)) +>arg2 : Symbol(arg2, Decl(assignmentCompatWithCallSignatures4.ts, 12, 48)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>r : Symbol(r, Decl(assignmentCompatWithCallSignatures4.ts, 12, 76)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) + + var a10: (...x: Base[]) => Base; +>a10 : Symbol(a10, Decl(assignmentCompatWithCallSignatures4.ts, 13, 11)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 13, 18)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) + + var a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base; +>a11 : Symbol(a11, Decl(assignmentCompatWithCallSignatures4.ts, 14, 11)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 14, 18)) +>foo : Symbol(foo, Decl(assignmentCompatWithCallSignatures4.ts, 14, 22)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignatures4.ts, 14, 37)) +>foo : Symbol(foo, Decl(assignmentCompatWithCallSignatures4.ts, 14, 42)) +>bar : Symbol(bar, Decl(assignmentCompatWithCallSignatures4.ts, 14, 55)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) + + var a12: (x: Array, y: Array) => Array; +>a12 : Symbol(a12, Decl(assignmentCompatWithCallSignatures4.ts, 15, 11)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 15, 18)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignatures4.ts, 15, 33)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithCallSignatures4.ts, 4, 47)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) + + var a14: { +>a14 : Symbol(a14, Decl(assignmentCompatWithCallSignatures4.ts, 16, 11)) + + (x: number): number[]; +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 17, 17)) + + (x: string): string[]; +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 18, 17)) + + }; + var a15: (x: { a: string; b: number }) => number; +>a15 : Symbol(a15, Decl(assignmentCompatWithCallSignatures4.ts, 20, 11)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 20, 18)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 20, 22)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignatures4.ts, 20, 33)) + + var a16: { +>a16 : Symbol(a16, Decl(assignmentCompatWithCallSignatures4.ts, 21, 11)) + + (x: { +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 22, 17)) + + (a: number): number; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 23, 21)) + + (a?: number): number; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 24, 21)) + + }): number[]; + (x: { +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 26, 17)) + + (a: boolean): boolean; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 27, 21)) + + (a?: boolean): boolean; +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 28, 21)) + + }): boolean[]; + }; + var a17: { +>a17 : Symbol(a17, Decl(assignmentCompatWithCallSignatures4.ts, 31, 11)) + + (x: { +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 32, 17)) + + (a: T): T; +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 33, 21)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 33, 40)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 33, 21)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 33, 21)) + + (a: T): T; +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 34, 21)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 34, 37)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 34, 21)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 34, 21)) + + }): any[]; + (x: { +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 36, 17)) + + (a: T): T; +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 37, 21)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithCallSignatures4.ts, 4, 47)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 37, 41)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 37, 21)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 37, 21)) + + (a: T): T; +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 38, 21)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 38, 37)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 38, 21)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 38, 21)) + + }): any[]; + }; + + var b2: (x: T) => U[]; +>b2 : Symbol(b2, Decl(assignmentCompatWithCallSignatures4.ts, 42, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 42, 17)) +>U : Symbol(U, Decl(assignmentCompatWithCallSignatures4.ts, 42, 19)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 42, 23)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 42, 17)) +>U : Symbol(U, Decl(assignmentCompatWithCallSignatures4.ts, 42, 19)) + + a2 = b2; +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures4.ts, 10, 11)) +>b2 : Symbol(b2, Decl(assignmentCompatWithCallSignatures4.ts, 42, 11)) + + b2 = a2; +>b2 : Symbol(b2, Decl(assignmentCompatWithCallSignatures4.ts, 42, 11)) +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures4.ts, 10, 11)) + + var b7: (x: (arg: T) => U) => (r: T) => V; +>b7 : Symbol(b7, Decl(assignmentCompatWithCallSignatures4.ts, 46, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 46, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>U : Symbol(U, Decl(assignmentCompatWithCallSignatures4.ts, 46, 32)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>V : Symbol(V, Decl(assignmentCompatWithCallSignatures4.ts, 46, 51)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithCallSignatures4.ts, 4, 47)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 46, 72)) +>arg : Symbol(arg, Decl(assignmentCompatWithCallSignatures4.ts, 46, 76)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 46, 17)) +>U : Symbol(U, Decl(assignmentCompatWithCallSignatures4.ts, 46, 32)) +>r : Symbol(r, Decl(assignmentCompatWithCallSignatures4.ts, 46, 94)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 46, 17)) +>V : Symbol(V, Decl(assignmentCompatWithCallSignatures4.ts, 46, 51)) + + a7 = b7; +>a7 : Symbol(a7, Decl(assignmentCompatWithCallSignatures4.ts, 11, 11)) +>b7 : Symbol(b7, Decl(assignmentCompatWithCallSignatures4.ts, 46, 11)) + + b7 = a7; +>b7 : Symbol(b7, Decl(assignmentCompatWithCallSignatures4.ts, 46, 11)) +>a7 : Symbol(a7, Decl(assignmentCompatWithCallSignatures4.ts, 11, 11)) + + var b8: (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; +>b8 : Symbol(b8, Decl(assignmentCompatWithCallSignatures4.ts, 50, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 50, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>U : Symbol(U, Decl(assignmentCompatWithCallSignatures4.ts, 50, 32)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 50, 52)) +>arg : Symbol(arg, Decl(assignmentCompatWithCallSignatures4.ts, 50, 56)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 50, 17)) +>U : Symbol(U, Decl(assignmentCompatWithCallSignatures4.ts, 50, 32)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignatures4.ts, 50, 69)) +>arg2 : Symbol(arg2, Decl(assignmentCompatWithCallSignatures4.ts, 50, 74)) +>foo : Symbol(foo, Decl(assignmentCompatWithCallSignatures4.ts, 50, 81)) +>U : Symbol(U, Decl(assignmentCompatWithCallSignatures4.ts, 50, 32)) +>r : Symbol(r, Decl(assignmentCompatWithCallSignatures4.ts, 50, 108)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 50, 17)) +>U : Symbol(U, Decl(assignmentCompatWithCallSignatures4.ts, 50, 32)) + + a8 = b8; // error, { foo: number } and Base are incompatible +>a8 : Symbol(a8, Decl(assignmentCompatWithCallSignatures4.ts, 12, 11)) +>b8 : Symbol(b8, Decl(assignmentCompatWithCallSignatures4.ts, 50, 11)) + + b8 = a8; // error, { foo: number } and Base are incompatible +>b8 : Symbol(b8, Decl(assignmentCompatWithCallSignatures4.ts, 50, 11)) +>a8 : Symbol(a8, Decl(assignmentCompatWithCallSignatures4.ts, 12, 11)) + + + var b10: (...x: T[]) => T; +>b10 : Symbol(b10, Decl(assignmentCompatWithCallSignatures4.ts, 55, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 55, 18)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 55, 37)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 55, 18)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 55, 18)) + + a10 = b10; +>a10 : Symbol(a10, Decl(assignmentCompatWithCallSignatures4.ts, 13, 11)) +>b10 : Symbol(b10, Decl(assignmentCompatWithCallSignatures4.ts, 55, 11)) + + b10 = a10; +>b10 : Symbol(b10, Decl(assignmentCompatWithCallSignatures4.ts, 55, 11)) +>a10 : Symbol(a10, Decl(assignmentCompatWithCallSignatures4.ts, 13, 11)) + + var b11: (x: T, y: T) => T; +>b11 : Symbol(b11, Decl(assignmentCompatWithCallSignatures4.ts, 59, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 59, 18)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithCallSignatures4.ts, 3, 31)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 59, 37)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 59, 18)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignatures4.ts, 59, 42)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 59, 18)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 59, 18)) + + a11 = b11; +>a11 : Symbol(a11, Decl(assignmentCompatWithCallSignatures4.ts, 14, 11)) +>b11 : Symbol(b11, Decl(assignmentCompatWithCallSignatures4.ts, 59, 11)) + + b11 = a11; +>b11 : Symbol(b11, Decl(assignmentCompatWithCallSignatures4.ts, 59, 11)) +>a11 : Symbol(a11, Decl(assignmentCompatWithCallSignatures4.ts, 14, 11)) + + var b12: >(x: Array, y: Array) => T; +>b12 : Symbol(b12, Decl(assignmentCompatWithCallSignatures4.ts, 63, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 63, 18)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithCallSignatures4.ts, 4, 47)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 63, 45)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignatures4.ts, 63, 60)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 63, 18)) + + a12 = b12; +>a12 : Symbol(a12, Decl(assignmentCompatWithCallSignatures4.ts, 15, 11)) +>b12 : Symbol(b12, Decl(assignmentCompatWithCallSignatures4.ts, 63, 11)) + + b12 = a12; +>b12 : Symbol(b12, Decl(assignmentCompatWithCallSignatures4.ts, 63, 11)) +>a12 : Symbol(a12, Decl(assignmentCompatWithCallSignatures4.ts, 15, 11)) + + var b15: (x: { a: T; b: T }) => T; +>b15 : Symbol(b15, Decl(assignmentCompatWithCallSignatures4.ts, 67, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 67, 18)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 67, 21)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 67, 25)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 67, 18)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignatures4.ts, 67, 31)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 67, 18)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 67, 18)) + + a15 = b15; +>a15 : Symbol(a15, Decl(assignmentCompatWithCallSignatures4.ts, 20, 11)) +>b15 : Symbol(b15, Decl(assignmentCompatWithCallSignatures4.ts, 67, 11)) + + b15 = a15; +>b15 : Symbol(b15, Decl(assignmentCompatWithCallSignatures4.ts, 67, 11)) +>a15 : Symbol(a15, Decl(assignmentCompatWithCallSignatures4.ts, 20, 11)) + + var b15a: (x: { a: T; b: T }) => number; +>b15a : Symbol(b15a, Decl(assignmentCompatWithCallSignatures4.ts, 71, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 71, 19)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignatures4.ts, 2, 15)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 71, 35)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 71, 39)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 71, 19)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignatures4.ts, 71, 45)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 71, 19)) + + a15 = b15a; +>a15 : Symbol(a15, Decl(assignmentCompatWithCallSignatures4.ts, 20, 11)) +>b15a : Symbol(b15a, Decl(assignmentCompatWithCallSignatures4.ts, 71, 11)) + + b15a = a15; +>b15a : Symbol(b15a, Decl(assignmentCompatWithCallSignatures4.ts, 71, 11)) +>a15 : Symbol(a15, Decl(assignmentCompatWithCallSignatures4.ts, 20, 11)) + + var b16: (x: (a: T) => T) => T[]; +>b16 : Symbol(b16, Decl(assignmentCompatWithCallSignatures4.ts, 75, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 75, 18)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 75, 21)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 75, 25)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 75, 18)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 75, 18)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 75, 18)) + + a16 = b16; +>a16 : Symbol(a16, Decl(assignmentCompatWithCallSignatures4.ts, 21, 11)) +>b16 : Symbol(b16, Decl(assignmentCompatWithCallSignatures4.ts, 75, 11)) + + b16 = a16; +>b16 : Symbol(b16, Decl(assignmentCompatWithCallSignatures4.ts, 75, 11)) +>a16 : Symbol(a16, Decl(assignmentCompatWithCallSignatures4.ts, 21, 11)) + + var b17: (x: (a: T) => T) => any[]; +>b17 : Symbol(b17, Decl(assignmentCompatWithCallSignatures4.ts, 79, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 79, 18)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 79, 21)) +>a : Symbol(a, Decl(assignmentCompatWithCallSignatures4.ts, 79, 25)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 79, 18)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 79, 18)) + + a17 = b17; +>a17 : Symbol(a17, Decl(assignmentCompatWithCallSignatures4.ts, 31, 11)) +>b17 : Symbol(b17, Decl(assignmentCompatWithCallSignatures4.ts, 79, 11)) + + b17 = a17; +>b17 : Symbol(b17, Decl(assignmentCompatWithCallSignatures4.ts, 79, 11)) +>a17 : Symbol(a17, Decl(assignmentCompatWithCallSignatures4.ts, 31, 11)) + } + + module WithGenericSignaturesInBaseType { +>WithGenericSignaturesInBaseType : Symbol(WithGenericSignaturesInBaseType, Decl(assignmentCompatWithCallSignatures4.ts, 82, 5)) + + // target type has generic call signature + var a2: (x: T) => T[]; +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures4.ts, 86, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 86, 17)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 86, 20)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 86, 17)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 86, 17)) + + var b2: (x: T) => string[]; +>b2 : Symbol(b2, Decl(assignmentCompatWithCallSignatures4.ts, 87, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 87, 17)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 87, 20)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 87, 17)) + + a2 = b2; +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures4.ts, 86, 11)) +>b2 : Symbol(b2, Decl(assignmentCompatWithCallSignatures4.ts, 87, 11)) + + b2 = a2; +>b2 : Symbol(b2, Decl(assignmentCompatWithCallSignatures4.ts, 87, 11)) +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignatures4.ts, 86, 11)) + + // target type has generic call signature + var a3: (x: T) => string[]; +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures4.ts, 92, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 92, 17)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 92, 20)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 92, 17)) + + var b3: (x: T) => T[]; +>b3 : Symbol(b3, Decl(assignmentCompatWithCallSignatures4.ts, 93, 11)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 93, 17)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignatures4.ts, 93, 20)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 93, 17)) +>T : Symbol(T, Decl(assignmentCompatWithCallSignatures4.ts, 93, 17)) + + a3 = b3; +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures4.ts, 92, 11)) +>b3 : Symbol(b3, Decl(assignmentCompatWithCallSignatures4.ts, 93, 11)) + + b3 = a3; +>b3 : Symbol(b3, Decl(assignmentCompatWithCallSignatures4.ts, 93, 11)) +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignatures4.ts, 92, 11)) + } +} diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.types b/tests/baselines/reference/assignmentCompatWithCallSignatures4.types new file mode 100644 index 00000000000..4e4f3a836df --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.types @@ -0,0 +1,428 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts === +// These are mostly permitted with the current loose rules. All ok unless otherwise noted. + +module Errors { +>Errors : typeof Errors + + class Base { foo: string; } +>Base : Base +>foo : string + + class Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + + class Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + + class OtherDerived extends Base { bing: string; } +>OtherDerived : OtherDerived +>Base : Base +>bing : string + + module WithNonGenericSignaturesInBaseType { +>WithNonGenericSignaturesInBaseType : typeof WithNonGenericSignaturesInBaseType + + // target type with non-generic call signatures + var a2: (x: number) => string[]; +>a2 : (x: number) => string[] +>x : number + + var a7: (x: (arg: Base) => Derived) => (r: Base) => Derived2; +>a7 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 +>x : (arg: Base) => Derived +>arg : Base +>Base : Base +>Derived : Derived +>r : Base +>Base : Base +>Derived2 : Derived2 + + var a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; +>a8 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived +>x : (arg: Base) => Derived +>arg : Base +>Base : Base +>Derived : Derived +>y : (arg2: Base) => Derived +>arg2 : Base +>Base : Base +>Derived : Derived +>r : Base +>Base : Base +>Derived : Derived + + var a10: (...x: Base[]) => Base; +>a10 : (...x: Base[]) => Base +>x : Base[] +>Base : Base +>Base : Base + + var a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base; +>a11 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base +>x : { foo: string; } +>foo : string +>y : { foo: string; bar: string; } +>foo : string +>bar : string +>Base : Base + + var a12: (x: Array, y: Array) => Array; +>a12 : (x: Base[], y: Derived2[]) => Derived[] +>x : Base[] +>Array : T[] +>Base : Base +>y : Derived2[] +>Array : T[] +>Derived2 : Derived2 +>Array : T[] +>Derived : Derived + + var a14: { +>a14 : { (x: number): number[]; (x: string): string[]; } + + (x: number): number[]; +>x : number + + (x: string): string[]; +>x : string + + }; + var a15: (x: { a: string; b: number }) => number; +>a15 : (x: { a: string; b: number; }) => number +>x : { a: string; b: number; } +>a : string +>b : number + + var a16: { +>a16 : { (x: { (a: number): number; (a?: number): number; }): number[]; (x: { (a: boolean): boolean; (a?: boolean): boolean; }): boolean[]; } + + (x: { +>x : { (a: number): number; (a?: number): number; } + + (a: number): number; +>a : number + + (a?: number): number; +>a : number + + }): number[]; + (x: { +>x : { (a: boolean): boolean; (a?: boolean): boolean; } + + (a: boolean): boolean; +>a : boolean + + (a?: boolean): boolean; +>a : boolean + + }): boolean[]; + }; + var a17: { +>a17 : { (x: { (a: T): T; (a: T): T; }): any[]; (x: { (a: T): T; (a: T): T; }): any[]; } + + (x: { +>x : { (a: T): T; (a: T): T; } + + (a: T): T; +>T : T +>Derived : Derived +>a : T +>T : T +>T : T + + (a: T): T; +>T : T +>Base : Base +>a : T +>T : T +>T : T + + }): any[]; + (x: { +>x : { (a: T): T; (a: T): T; } + + (a: T): T; +>T : T +>Derived2 : Derived2 +>a : T +>T : T +>T : T + + (a: T): T; +>T : T +>Base : Base +>a : T +>T : T +>T : T + + }): any[]; + }; + + var b2: (x: T) => U[]; +>b2 : (x: T) => U[] +>T : T +>U : U +>x : T +>T : T +>U : U + + a2 = b2; +>a2 = b2 : (x: T) => U[] +>a2 : (x: number) => string[] +>b2 : (x: T) => U[] + + b2 = a2; +>b2 = a2 : (x: number) => string[] +>b2 : (x: T) => U[] +>a2 : (x: number) => string[] + + var b7: (x: (arg: T) => U) => (r: T) => V; +>b7 : (x: (arg: T) => U) => (r: T) => V +>T : T +>Base : Base +>U : U +>Derived : Derived +>V : V +>Derived2 : Derived2 +>x : (arg: T) => U +>arg : T +>T : T +>U : U +>r : T +>T : T +>V : V + + a7 = b7; +>a7 = b7 : (x: (arg: T) => U) => (r: T) => V +>a7 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 +>b7 : (x: (arg: T) => U) => (r: T) => V + + b7 = a7; +>b7 = a7 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 +>b7 : (x: (arg: T) => U) => (r: T) => V +>a7 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 + + var b8: (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; +>b8 : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U +>T : T +>Base : Base +>U : U +>Derived : Derived +>x : (arg: T) => U +>arg : T +>T : T +>U : U +>y : (arg2: { foo: number; }) => U +>arg2 : { foo: number; } +>foo : number +>U : U +>r : T +>T : T +>U : U + + a8 = b8; // error, { foo: number } and Base are incompatible +>a8 = b8 : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U +>a8 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived +>b8 : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U + + b8 = a8; // error, { foo: number } and Base are incompatible +>b8 = a8 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived +>b8 : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U +>a8 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived + + + var b10: (...x: T[]) => T; +>b10 : (...x: T[]) => T +>T : T +>Derived : Derived +>x : T[] +>T : T +>T : T + + a10 = b10; +>a10 = b10 : (...x: T[]) => T +>a10 : (...x: Base[]) => Base +>b10 : (...x: T[]) => T + + b10 = a10; +>b10 = a10 : (...x: Base[]) => Base +>b10 : (...x: T[]) => T +>a10 : (...x: Base[]) => Base + + var b11: (x: T, y: T) => T; +>b11 : (x: T, y: T) => T +>T : T +>Derived : Derived +>x : T +>T : T +>y : T +>T : T +>T : T + + a11 = b11; +>a11 = b11 : (x: T, y: T) => T +>a11 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base +>b11 : (x: T, y: T) => T + + b11 = a11; +>b11 = a11 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base +>b11 : (x: T, y: T) => T +>a11 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base + + var b12: >(x: Array, y: Array) => T; +>b12 : (x: Base[], y: Base[]) => T +>T : T +>Array : T[] +>Derived2 : Derived2 +>x : Base[] +>Array : T[] +>Base : Base +>y : Base[] +>Array : T[] +>Base : Base +>T : T + + a12 = b12; +>a12 = b12 : (x: Base[], y: Base[]) => T +>a12 : (x: Base[], y: Derived2[]) => Derived[] +>b12 : (x: Base[], y: Base[]) => T + + b12 = a12; +>b12 = a12 : (x: Base[], y: Derived2[]) => Derived[] +>b12 : (x: Base[], y: Base[]) => T +>a12 : (x: Base[], y: Derived2[]) => Derived[] + + var b15: (x: { a: T; b: T }) => T; +>b15 : (x: { a: T; b: T; }) => T +>T : T +>x : { a: T; b: T; } +>a : T +>T : T +>b : T +>T : T +>T : T + + a15 = b15; +>a15 = b15 : (x: { a: T; b: T; }) => T +>a15 : (x: { a: string; b: number; }) => number +>b15 : (x: { a: T; b: T; }) => T + + b15 = a15; +>b15 = a15 : (x: { a: string; b: number; }) => number +>b15 : (x: { a: T; b: T; }) => T +>a15 : (x: { a: string; b: number; }) => number + + var b15a: (x: { a: T; b: T }) => number; +>b15a : (x: { a: T; b: T; }) => number +>T : T +>Base : Base +>x : { a: T; b: T; } +>a : T +>T : T +>b : T +>T : T + + a15 = b15a; +>a15 = b15a : (x: { a: T; b: T; }) => number +>a15 : (x: { a: string; b: number; }) => number +>b15a : (x: { a: T; b: T; }) => number + + b15a = a15; +>b15a = a15 : (x: { a: string; b: number; }) => number +>b15a : (x: { a: T; b: T; }) => number +>a15 : (x: { a: string; b: number; }) => number + + var b16: (x: (a: T) => T) => T[]; +>b16 : (x: (a: T) => T) => T[] +>T : T +>x : (a: T) => T +>a : T +>T : T +>T : T +>T : T + + a16 = b16; +>a16 = b16 : (x: (a: T) => T) => T[] +>a16 : { (x: { (a: number): number; (a?: number): number; }): number[]; (x: { (a: boolean): boolean; (a?: boolean): boolean; }): boolean[]; } +>b16 : (x: (a: T) => T) => T[] + + b16 = a16; +>b16 = a16 : { (x: { (a: number): number; (a?: number): number; }): number[]; (x: { (a: boolean): boolean; (a?: boolean): boolean; }): boolean[]; } +>b16 : (x: (a: T) => T) => T[] +>a16 : { (x: { (a: number): number; (a?: number): number; }): number[]; (x: { (a: boolean): boolean; (a?: boolean): boolean; }): boolean[]; } + + var b17: (x: (a: T) => T) => any[]; +>b17 : (x: (a: T) => T) => any[] +>T : T +>x : (a: T) => T +>a : T +>T : T +>T : T + + a17 = b17; +>a17 = b17 : (x: (a: T) => T) => any[] +>a17 : { (x: { (a: T): T; (a: T): T; }): any[]; (x: { (a: T): T; (a: T): T; }): any[]; } +>b17 : (x: (a: T) => T) => any[] + + b17 = a17; +>b17 = a17 : { (x: { (a: T): T; (a: T): T; }): any[]; (x: { (a: T): T; (a: T): T; }): any[]; } +>b17 : (x: (a: T) => T) => any[] +>a17 : { (x: { (a: T): T; (a: T): T; }): any[]; (x: { (a: T): T; (a: T): T; }): any[]; } + } + + module WithGenericSignaturesInBaseType { +>WithGenericSignaturesInBaseType : typeof WithGenericSignaturesInBaseType + + // target type has generic call signature + var a2: (x: T) => T[]; +>a2 : (x: T) => T[] +>T : T +>x : T +>T : T +>T : T + + var b2: (x: T) => string[]; +>b2 : (x: T) => string[] +>T : T +>x : T +>T : T + + a2 = b2; +>a2 = b2 : (x: T) => string[] +>a2 : (x: T) => T[] +>b2 : (x: T) => string[] + + b2 = a2; +>b2 = a2 : (x: T) => T[] +>b2 : (x: T) => string[] +>a2 : (x: T) => T[] + + // target type has generic call signature + var a3: (x: T) => string[]; +>a3 : (x: T) => string[] +>T : T +>x : T +>T : T + + var b3: (x: T) => T[]; +>b3 : (x: T) => T[] +>T : T +>x : T +>T : T +>T : T + + a3 = b3; +>a3 = b3 : (x: T) => T[] +>a3 : (x: T) => string[] +>b3 : (x: T) => T[] + + b3 = a3; +>b3 = a3 : (x: T) => string[] +>b3 : (x: T) => T[] +>a3 : (x: T) => string[] + } +} diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.symbols b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.symbols new file mode 100644 index 00000000000..c2a10279efa --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.symbols @@ -0,0 +1,309 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts === +// call signatures in derived types must have the same or fewer optional parameters as the base type + +interface Base { +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 0, 0)) + + a: () => number; +>a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) + + a2: (x?: number) => number; +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 9)) + + a3: (x: number) => number; +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 9)) + + a4: (x: number, y?: number) => number; +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 19)) + + a5: (x?: number, y?: number) => number; +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 20)) + + a6: (x: number, y: number) => number; +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 8, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 8, 19)) +} +var b: Base; +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 0, 0)) + +var a: () => number; +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) + + a = () => 1 // ok, same number of required params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) + + a = (x?: number) => 1; // ok, same number of required params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 14, 9)) + + a = (x: number) => 1; // error, too many required params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 15, 9)) + + a = b.a; // ok +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) + + a = b.a2; // ok +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) + + a = b.a3; // error +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) + + a = b.a4; // error +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) + + a = b.a5; // ok +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) + + a = b.a6; // error +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) + +var a2: (x?: number) => number; +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 9)) + + a2 = () => 1; // ok, same number of required params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) + + a2 = (x?: number) => 1; // ok, same number of required params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 25, 10)) + + a2 = (x: number) => 1; // ok, same number of params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 26, 10)) + + a2 = b.a; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) + + a2 = b.a2; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) + + a2 = b.a3; // ok, same number of params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) + + a2 = b.a4; // ok, excess params are optional in b.a3 +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) + + a2 = b.a5; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) + + a2 = b.a6; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 23, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) + +var a3: (x: number) => number; +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 9)) + + a3 = () => 1; // ok, fewer required params +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) + + a3 = (x?: number) => 1; // ok, fewer required params +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 36, 10)) + + a3 = (x: number) => 1; // ok, same number of required params +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 37, 10)) + + a3 = (x: number, y: number) => 1; // error, too many required params +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 38, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 38, 20)) + + a3 = b.a; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) + + a3 = b.a2; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) + + a3 = b.a3; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) + + a3 = b.a4; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) + + a3 = b.a5; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) + + a3 = b.a6; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 34, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) + +var a4: (x: number, y?: number) => number; +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 19)) + + a4 = () => 1; // ok, fewer required params +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) + + a4 = (x?: number, y?: number) => 1; // ok, fewer required params +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 48, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 48, 21)) + + a4 = (x: number) => 1; // ok, same number of required params +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 49, 10)) + + a4 = (x: number, y: number) => 1; // ok, same number of params +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 50, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 50, 20)) + + a4 = b.a; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) + + a4 = b.a2; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) + + a4 = b.a3; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) + + a4 = b.a4; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) + + a4 = b.a5; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) + + a4 = b.a6; // ok, same number of params +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 46, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) + +var a5: (x?: number, y?: number) => number; +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 20)) + + a5 = () => 1; // ok, fewer required params +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) + + a5 = (x?: number, y?: number) => 1; // ok, fewer required params +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 60, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 60, 21)) + + a5 = (x: number) => 1; // ok, fewer params in lambda +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 61, 10)) + + a5 = (x: number, y: number) => 1; // ok, same number of params +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 62, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 62, 20)) + + a5 = b.a; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 2, 16)) + + a5 = b.a2; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 3, 20)) + + a5 = b.a3; // ok, fewer params in b.a3 +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 4, 31)) + + a5 = b.a4; // ok, same number of params +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 5, 30)) + + a5 = b.a5; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 6, 42)) + + a5 = b.a6; // ok, same number of params +>a5 : Symbol(a5, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 58, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) +>b : Symbol(b, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithCallSignaturesWithOptionalParameters.ts, 7, 43)) + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.types b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.types new file mode 100644 index 00000000000..1bb87d3255f --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.types @@ -0,0 +1,393 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts === +// call signatures in derived types must have the same or fewer optional parameters as the base type + +interface Base { +>Base : Base + + a: () => number; +>a : () => number + + a2: (x?: number) => number; +>a2 : (x?: number) => number +>x : number + + a3: (x: number) => number; +>a3 : (x: number) => number +>x : number + + a4: (x: number, y?: number) => number; +>a4 : (x: number, y?: number) => number +>x : number +>y : number + + a5: (x?: number, y?: number) => number; +>a5 : (x?: number, y?: number) => number +>x : number +>y : number + + a6: (x: number, y: number) => number; +>a6 : (x: number, y: number) => number +>x : number +>y : number +} +var b: Base; +>b : Base +>Base : Base + +var a: () => number; +>a : () => number + + a = () => 1 // ok, same number of required params +>a = () => 1 : () => number +>a : () => number +>() => 1 : () => number +>1 : 1 + + a = (x?: number) => 1; // ok, same number of required params +>a = (x?: number) => 1 : (x?: number) => number +>a : () => number +>(x?: number) => 1 : (x?: number) => number +>x : number +>1 : 1 + + a = (x: number) => 1; // error, too many required params +>a = (x: number) => 1 : (x: number) => number +>a : () => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a = b.a; // ok +>a = b.a : () => number +>a : () => number +>b.a : () => number +>b : Base +>a : () => number + + a = b.a2; // ok +>a = b.a2 : (x?: number) => number +>a : () => number +>b.a2 : (x?: number) => number +>b : Base +>a2 : (x?: number) => number + + a = b.a3; // error +>a = b.a3 : (x: number) => number +>a : () => number +>b.a3 : (x: number) => number +>b : Base +>a3 : (x: number) => number + + a = b.a4; // error +>a = b.a4 : (x: number, y?: number) => number +>a : () => number +>b.a4 : (x: number, y?: number) => number +>b : Base +>a4 : (x: number, y?: number) => number + + a = b.a5; // ok +>a = b.a5 : (x?: number, y?: number) => number +>a : () => number +>b.a5 : (x?: number, y?: number) => number +>b : Base +>a5 : (x?: number, y?: number) => number + + a = b.a6; // error +>a = b.a6 : (x: number, y: number) => number +>a : () => number +>b.a6 : (x: number, y: number) => number +>b : Base +>a6 : (x: number, y: number) => number + +var a2: (x?: number) => number; +>a2 : (x?: number) => number +>x : number + + a2 = () => 1; // ok, same number of required params +>a2 = () => 1 : () => number +>a2 : (x?: number) => number +>() => 1 : () => number +>1 : 1 + + a2 = (x?: number) => 1; // ok, same number of required params +>a2 = (x?: number) => 1 : (x?: number) => number +>a2 : (x?: number) => number +>(x?: number) => 1 : (x?: number) => number +>x : number +>1 : 1 + + a2 = (x: number) => 1; // ok, same number of params +>a2 = (x: number) => 1 : (x: number) => number +>a2 : (x?: number) => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a2 = b.a; // ok +>a2 = b.a : () => number +>a2 : (x?: number) => number +>b.a : () => number +>b : Base +>a : () => number + + a2 = b.a2; // ok +>a2 = b.a2 : (x?: number) => number +>a2 : (x?: number) => number +>b.a2 : (x?: number) => number +>b : Base +>a2 : (x?: number) => number + + a2 = b.a3; // ok, same number of params +>a2 = b.a3 : (x: number) => number +>a2 : (x?: number) => number +>b.a3 : (x: number) => number +>b : Base +>a3 : (x: number) => number + + a2 = b.a4; // ok, excess params are optional in b.a3 +>a2 = b.a4 : (x: number, y?: number) => number +>a2 : (x?: number) => number +>b.a4 : (x: number, y?: number) => number +>b : Base +>a4 : (x: number, y?: number) => number + + a2 = b.a5; // ok +>a2 = b.a5 : (x?: number, y?: number) => number +>a2 : (x?: number) => number +>b.a5 : (x?: number, y?: number) => number +>b : Base +>a5 : (x?: number, y?: number) => number + + a2 = b.a6; // error +>a2 = b.a6 : (x: number, y: number) => number +>a2 : (x?: number) => number +>b.a6 : (x: number, y: number) => number +>b : Base +>a6 : (x: number, y: number) => number + +var a3: (x: number) => number; +>a3 : (x: number) => number +>x : number + + a3 = () => 1; // ok, fewer required params +>a3 = () => 1 : () => number +>a3 : (x: number) => number +>() => 1 : () => number +>1 : 1 + + a3 = (x?: number) => 1; // ok, fewer required params +>a3 = (x?: number) => 1 : (x?: number) => number +>a3 : (x: number) => number +>(x?: number) => 1 : (x?: number) => number +>x : number +>1 : 1 + + a3 = (x: number) => 1; // ok, same number of required params +>a3 = (x: number) => 1 : (x: number) => number +>a3 : (x: number) => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a3 = (x: number, y: number) => 1; // error, too many required params +>a3 = (x: number, y: number) => 1 : (x: number, y: number) => number +>a3 : (x: number) => number +>(x: number, y: number) => 1 : (x: number, y: number) => number +>x : number +>y : number +>1 : 1 + + a3 = b.a; // ok +>a3 = b.a : () => number +>a3 : (x: number) => number +>b.a : () => number +>b : Base +>a : () => number + + a3 = b.a2; // ok +>a3 = b.a2 : (x?: number) => number +>a3 : (x: number) => number +>b.a2 : (x?: number) => number +>b : Base +>a2 : (x?: number) => number + + a3 = b.a3; // ok +>a3 = b.a3 : (x: number) => number +>a3 : (x: number) => number +>b.a3 : (x: number) => number +>b : Base +>a3 : (x: number) => number + + a3 = b.a4; // ok +>a3 = b.a4 : (x: number, y?: number) => number +>a3 : (x: number) => number +>b.a4 : (x: number, y?: number) => number +>b : Base +>a4 : (x: number, y?: number) => number + + a3 = b.a5; // ok +>a3 = b.a5 : (x?: number, y?: number) => number +>a3 : (x: number) => number +>b.a5 : (x?: number, y?: number) => number +>b : Base +>a5 : (x?: number, y?: number) => number + + a3 = b.a6; // error +>a3 = b.a6 : (x: number, y: number) => number +>a3 : (x: number) => number +>b.a6 : (x: number, y: number) => number +>b : Base +>a6 : (x: number, y: number) => number + +var a4: (x: number, y?: number) => number; +>a4 : (x: number, y?: number) => number +>x : number +>y : number + + a4 = () => 1; // ok, fewer required params +>a4 = () => 1 : () => number +>a4 : (x: number, y?: number) => number +>() => 1 : () => number +>1 : 1 + + a4 = (x?: number, y?: number) => 1; // ok, fewer required params +>a4 = (x?: number, y?: number) => 1 : (x?: number, y?: number) => number +>a4 : (x: number, y?: number) => number +>(x?: number, y?: number) => 1 : (x?: number, y?: number) => number +>x : number +>y : number +>1 : 1 + + a4 = (x: number) => 1; // ok, same number of required params +>a4 = (x: number) => 1 : (x: number) => number +>a4 : (x: number, y?: number) => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a4 = (x: number, y: number) => 1; // ok, same number of params +>a4 = (x: number, y: number) => 1 : (x: number, y: number) => number +>a4 : (x: number, y?: number) => number +>(x: number, y: number) => 1 : (x: number, y: number) => number +>x : number +>y : number +>1 : 1 + + a4 = b.a; // ok +>a4 = b.a : () => number +>a4 : (x: number, y?: number) => number +>b.a : () => number +>b : Base +>a : () => number + + a4 = b.a2; // ok +>a4 = b.a2 : (x?: number) => number +>a4 : (x: number, y?: number) => number +>b.a2 : (x?: number) => number +>b : Base +>a2 : (x?: number) => number + + a4 = b.a3; // ok +>a4 = b.a3 : (x: number) => number +>a4 : (x: number, y?: number) => number +>b.a3 : (x: number) => number +>b : Base +>a3 : (x: number) => number + + a4 = b.a4; // ok +>a4 = b.a4 : (x: number, y?: number) => number +>a4 : (x: number, y?: number) => number +>b.a4 : (x: number, y?: number) => number +>b : Base +>a4 : (x: number, y?: number) => number + + a4 = b.a5; // ok +>a4 = b.a5 : (x?: number, y?: number) => number +>a4 : (x: number, y?: number) => number +>b.a5 : (x?: number, y?: number) => number +>b : Base +>a5 : (x?: number, y?: number) => number + + a4 = b.a6; // ok, same number of params +>a4 = b.a6 : (x: number, y: number) => number +>a4 : (x: number, y?: number) => number +>b.a6 : (x: number, y: number) => number +>b : Base +>a6 : (x: number, y: number) => number + +var a5: (x?: number, y?: number) => number; +>a5 : (x?: number, y?: number) => number +>x : number +>y : number + + a5 = () => 1; // ok, fewer required params +>a5 = () => 1 : () => number +>a5 : (x?: number, y?: number) => number +>() => 1 : () => number +>1 : 1 + + a5 = (x?: number, y?: number) => 1; // ok, fewer required params +>a5 = (x?: number, y?: number) => 1 : (x?: number, y?: number) => number +>a5 : (x?: number, y?: number) => number +>(x?: number, y?: number) => 1 : (x?: number, y?: number) => number +>x : number +>y : number +>1 : 1 + + a5 = (x: number) => 1; // ok, fewer params in lambda +>a5 = (x: number) => 1 : (x: number) => number +>a5 : (x?: number, y?: number) => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a5 = (x: number, y: number) => 1; // ok, same number of params +>a5 = (x: number, y: number) => 1 : (x: number, y: number) => number +>a5 : (x?: number, y?: number) => number +>(x: number, y: number) => 1 : (x: number, y: number) => number +>x : number +>y : number +>1 : 1 + + a5 = b.a; // ok +>a5 = b.a : () => number +>a5 : (x?: number, y?: number) => number +>b.a : () => number +>b : Base +>a : () => number + + a5 = b.a2; // ok +>a5 = b.a2 : (x?: number) => number +>a5 : (x?: number, y?: number) => number +>b.a2 : (x?: number) => number +>b : Base +>a2 : (x?: number) => number + + a5 = b.a3; // ok, fewer params in b.a3 +>a5 = b.a3 : (x: number) => number +>a5 : (x?: number, y?: number) => number +>b.a3 : (x: number) => number +>b : Base +>a3 : (x: number) => number + + a5 = b.a4; // ok, same number of params +>a5 = b.a4 : (x: number, y?: number) => number +>a5 : (x?: number, y?: number) => number +>b.a4 : (x: number, y?: number) => number +>b : Base +>a4 : (x: number, y?: number) => number + + a5 = b.a5; // ok +>a5 = b.a5 : (x?: number, y?: number) => number +>a5 : (x?: number, y?: number) => number +>b.a5 : (x?: number, y?: number) => number +>b : Base +>a5 : (x?: number, y?: number) => number + + a5 = b.a6; // ok, same number of params +>a5 = b.a6 : (x: number, y: number) => number +>a5 : (x?: number, y?: number) => number +>b.a6 : (x: number, y: number) => number +>b : Base +>a6 : (x: number, y: number) => number + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.symbols b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.symbols new file mode 100644 index 00000000000..f38ad64d13d --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.symbols @@ -0,0 +1,174 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts === +// call signatures in derived types must have the same or fewer optional parameters as the target for assignment + +interface Base { +>Base : Symbol(Base, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 0, 0)) + + a: (...args: number[]) => number; +>a : Symbol(Base.a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 2, 16)) +>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 3, 8)) + + a2: (x: number, ...z: number[]) => number; +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 3, 37)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 4, 9)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 4, 19)) + + a3: (x: number, y?: string, ...z: number[]) => number; +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 4, 46)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 5, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 5, 19)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 5, 31)) + + a4: (x?: number, y?: string, ...z: number[]) => number; +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 5, 58)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 6, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 6, 20)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 6, 32)) +} + +var a: (...args: number[]) => number; // ok, same number of required params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3)) +>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 8)) + + a = () => 1; // ok, same number of required params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3)) + + a = (...args: number[]) => 1; // ok, same number of required params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3)) +>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 11, 9)) + + a = (...args: string[]) => 1; // error, type mismatch +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3)) +>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 12, 9)) + + a = (x?: number) => 1; // ok, same number of required params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 13, 9)) + + a = (x?: number, y?: number, z?: number) => 1; // ok, same number of required params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 14, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 14, 20)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 14, 32)) + + a = (x: number) => 1; // ok, rest param corresponds to infinite number of params +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 15, 9)) + + a = (x?: string) => 1; // error, incompatible type +>a : Symbol(a, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 9, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 16, 9)) + + +var a2: (x: number, ...z: number[]) => number; +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 9)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 19)) + + a2 = () => 1; // ok, fewer required params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) + + a2 = (...args: number[]) => 1; // ok, fewer required params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) +>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 21, 10)) + + a2 = (x?: number) => 1; // ok, fewer required params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 22, 10)) + + a2 = (x: number) => 1; // ok, same number of required params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 23, 10)) + + a2 = (x: number, ...args: number[]) => 1; // ok, same number of required params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 24, 10)) +>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 24, 20)) + + a2 = (x: number, ...args: string[]) => 1; // should be type mismatch error +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 25, 10)) +>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 25, 20)) + + a2 = (x: number, y: number) => 1; // ok, rest param corresponds to infinite number of params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 26, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 26, 20)) + + a2 = (x: number, y?: number) => 1; // ok, same number of required params +>a2 : Symbol(a2, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 19, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 27, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 27, 20)) + +var a3: (x: number, y?: string, ...z: number[]) => number; +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 19)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 31)) + + a3 = () => 1; // ok, fewer required params +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3)) + + a3 = (x?: number) => 1; // ok, fewer required params +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 31, 10)) + + a3 = (x: number) => 1; // ok, same number of required params +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 32, 10)) + + a3 = (x: number, y: string) => 1; // ok, all present params match +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 33, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 33, 20)) + + a3 = (x: number, y?: number, z?: number) => 1; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 34, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 34, 20)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 34, 32)) + + a3 = (x: number, ...z: number[]) => 1; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 35, 10)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 35, 20)) + + a3 = (x: string, y?: string, z?: string) => 1; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 29, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 36, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 36, 20)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 36, 32)) + +var a4: (x?: number, y?: string, ...z: number[]) => number; +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 9)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 20)) +>z : Symbol(z, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 32)) + + a4 = () => 1; // ok, fewer required params +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3)) + + a4 = (x?: number, y?: number) => 1; // error, type mismatch +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 40, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 40, 21)) + + a4 = (x: number) => 1; // ok, all present params match +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 41, 10)) + + a4 = (x: number, y?: number) => 1; // error, second param has type mismatch +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 42, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 42, 20)) + + a4 = (x?: number, y?: string) => 1; // ok, same number of required params with matching types +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 43, 10)) +>y : Symbol(y, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 43, 21)) + + a4 = (x: number, ...args: string[]) => 1; // error, rest params have type mismatch +>a4 : Symbol(a4, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 38, 3)) +>x : Symbol(x, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 44, 10)) +>args : Symbol(args, Decl(assignmentCompatWithCallSignaturesWithRestParameters.ts, 44, 20)) + diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.types b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.types new file mode 100644 index 00000000000..a2c726527cb --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.types @@ -0,0 +1,258 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts === +// call signatures in derived types must have the same or fewer optional parameters as the target for assignment + +interface Base { +>Base : Base + + a: (...args: number[]) => number; +>a : (...args: number[]) => number +>args : number[] + + a2: (x: number, ...z: number[]) => number; +>a2 : (x: number, ...z: number[]) => number +>x : number +>z : number[] + + a3: (x: number, y?: string, ...z: number[]) => number; +>a3 : (x: number, y?: string, ...z: number[]) => number +>x : number +>y : string +>z : number[] + + a4: (x?: number, y?: string, ...z: number[]) => number; +>a4 : (x?: number, y?: string, ...z: number[]) => number +>x : number +>y : string +>z : number[] +} + +var a: (...args: number[]) => number; // ok, same number of required params +>a : (...args: number[]) => number +>args : number[] + + a = () => 1; // ok, same number of required params +>a = () => 1 : () => number +>a : (...args: number[]) => number +>() => 1 : () => number +>1 : 1 + + a = (...args: number[]) => 1; // ok, same number of required params +>a = (...args: number[]) => 1 : (...args: number[]) => number +>a : (...args: number[]) => number +>(...args: number[]) => 1 : (...args: number[]) => number +>args : number[] +>1 : 1 + + a = (...args: string[]) => 1; // error, type mismatch +>a = (...args: string[]) => 1 : (...args: string[]) => number +>a : (...args: number[]) => number +>(...args: string[]) => 1 : (...args: string[]) => number +>args : string[] +>1 : 1 + + a = (x?: number) => 1; // ok, same number of required params +>a = (x?: number) => 1 : (x?: number) => number +>a : (...args: number[]) => number +>(x?: number) => 1 : (x?: number) => number +>x : number +>1 : 1 + + a = (x?: number, y?: number, z?: number) => 1; // ok, same number of required params +>a = (x?: number, y?: number, z?: number) => 1 : (x?: number, y?: number, z?: number) => number +>a : (...args: number[]) => number +>(x?: number, y?: number, z?: number) => 1 : (x?: number, y?: number, z?: number) => number +>x : number +>y : number +>z : number +>1 : 1 + + a = (x: number) => 1; // ok, rest param corresponds to infinite number of params +>a = (x: number) => 1 : (x: number) => number +>a : (...args: number[]) => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a = (x?: string) => 1; // error, incompatible type +>a = (x?: string) => 1 : (x?: string) => number +>a : (...args: number[]) => number +>(x?: string) => 1 : (x?: string) => number +>x : string +>1 : 1 + + +var a2: (x: number, ...z: number[]) => number; +>a2 : (x: number, ...z: number[]) => number +>x : number +>z : number[] + + a2 = () => 1; // ok, fewer required params +>a2 = () => 1 : () => number +>a2 : (x: number, ...z: number[]) => number +>() => 1 : () => number +>1 : 1 + + a2 = (...args: number[]) => 1; // ok, fewer required params +>a2 = (...args: number[]) => 1 : (...args: number[]) => number +>a2 : (x: number, ...z: number[]) => number +>(...args: number[]) => 1 : (...args: number[]) => number +>args : number[] +>1 : 1 + + a2 = (x?: number) => 1; // ok, fewer required params +>a2 = (x?: number) => 1 : (x?: number) => number +>a2 : (x: number, ...z: number[]) => number +>(x?: number) => 1 : (x?: number) => number +>x : number +>1 : 1 + + a2 = (x: number) => 1; // ok, same number of required params +>a2 = (x: number) => 1 : (x: number) => number +>a2 : (x: number, ...z: number[]) => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a2 = (x: number, ...args: number[]) => 1; // ok, same number of required params +>a2 = (x: number, ...args: number[]) => 1 : (x: number, ...args: number[]) => number +>a2 : (x: number, ...z: number[]) => number +>(x: number, ...args: number[]) => 1 : (x: number, ...args: number[]) => number +>x : number +>args : number[] +>1 : 1 + + a2 = (x: number, ...args: string[]) => 1; // should be type mismatch error +>a2 = (x: number, ...args: string[]) => 1 : (x: number, ...args: string[]) => number +>a2 : (x: number, ...z: number[]) => number +>(x: number, ...args: string[]) => 1 : (x: number, ...args: string[]) => number +>x : number +>args : string[] +>1 : 1 + + a2 = (x: number, y: number) => 1; // ok, rest param corresponds to infinite number of params +>a2 = (x: number, y: number) => 1 : (x: number, y: number) => number +>a2 : (x: number, ...z: number[]) => number +>(x: number, y: number) => 1 : (x: number, y: number) => number +>x : number +>y : number +>1 : 1 + + a2 = (x: number, y?: number) => 1; // ok, same number of required params +>a2 = (x: number, y?: number) => 1 : (x: number, y?: number) => number +>a2 : (x: number, ...z: number[]) => number +>(x: number, y?: number) => 1 : (x: number, y?: number) => number +>x : number +>y : number +>1 : 1 + +var a3: (x: number, y?: string, ...z: number[]) => number; +>a3 : (x: number, y?: string, ...z: number[]) => number +>x : number +>y : string +>z : number[] + + a3 = () => 1; // ok, fewer required params +>a3 = () => 1 : () => number +>a3 : (x: number, y?: string, ...z: number[]) => number +>() => 1 : () => number +>1 : 1 + + a3 = (x?: number) => 1; // ok, fewer required params +>a3 = (x?: number) => 1 : (x?: number) => number +>a3 : (x: number, y?: string, ...z: number[]) => number +>(x?: number) => 1 : (x?: number) => number +>x : number +>1 : 1 + + a3 = (x: number) => 1; // ok, same number of required params +>a3 = (x: number) => 1 : (x: number) => number +>a3 : (x: number, y?: string, ...z: number[]) => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a3 = (x: number, y: string) => 1; // ok, all present params match +>a3 = (x: number, y: string) => 1 : (x: number, y: string) => number +>a3 : (x: number, y?: string, ...z: number[]) => number +>(x: number, y: string) => 1 : (x: number, y: string) => number +>x : number +>y : string +>1 : 1 + + a3 = (x: number, y?: number, z?: number) => 1; // error +>a3 = (x: number, y?: number, z?: number) => 1 : (x: number, y?: number, z?: number) => number +>a3 : (x: number, y?: string, ...z: number[]) => number +>(x: number, y?: number, z?: number) => 1 : (x: number, y?: number, z?: number) => number +>x : number +>y : number +>z : number +>1 : 1 + + a3 = (x: number, ...z: number[]) => 1; // error +>a3 = (x: number, ...z: number[]) => 1 : (x: number, ...z: number[]) => number +>a3 : (x: number, y?: string, ...z: number[]) => number +>(x: number, ...z: number[]) => 1 : (x: number, ...z: number[]) => number +>x : number +>z : number[] +>1 : 1 + + a3 = (x: string, y?: string, z?: string) => 1; // error +>a3 = (x: string, y?: string, z?: string) => 1 : (x: string, y?: string, z?: string) => number +>a3 : (x: number, y?: string, ...z: number[]) => number +>(x: string, y?: string, z?: string) => 1 : (x: string, y?: string, z?: string) => number +>x : string +>y : string +>z : string +>1 : 1 + +var a4: (x?: number, y?: string, ...z: number[]) => number; +>a4 : (x?: number, y?: string, ...z: number[]) => number +>x : number +>y : string +>z : number[] + + a4 = () => 1; // ok, fewer required params +>a4 = () => 1 : () => number +>a4 : (x?: number, y?: string, ...z: number[]) => number +>() => 1 : () => number +>1 : 1 + + a4 = (x?: number, y?: number) => 1; // error, type mismatch +>a4 = (x?: number, y?: number) => 1 : (x?: number, y?: number) => number +>a4 : (x?: number, y?: string, ...z: number[]) => number +>(x?: number, y?: number) => 1 : (x?: number, y?: number) => number +>x : number +>y : number +>1 : 1 + + a4 = (x: number) => 1; // ok, all present params match +>a4 = (x: number) => 1 : (x: number) => number +>a4 : (x?: number, y?: string, ...z: number[]) => number +>(x: number) => 1 : (x: number) => number +>x : number +>1 : 1 + + a4 = (x: number, y?: number) => 1; // error, second param has type mismatch +>a4 = (x: number, y?: number) => 1 : (x: number, y?: number) => number +>a4 : (x?: number, y?: string, ...z: number[]) => number +>(x: number, y?: number) => 1 : (x: number, y?: number) => number +>x : number +>y : number +>1 : 1 + + a4 = (x?: number, y?: string) => 1; // ok, same number of required params with matching types +>a4 = (x?: number, y?: string) => 1 : (x?: number, y?: string) => number +>a4 : (x?: number, y?: string, ...z: number[]) => number +>(x?: number, y?: string) => 1 : (x?: number, y?: string) => number +>x : number +>y : string +>1 : 1 + + a4 = (x: number, ...args: string[]) => 1; // error, rest params have type mismatch +>a4 = (x: number, ...args: string[]) => 1 : (x: number, ...args: string[]) => number +>a4 : (x?: number, y?: string, ...z: number[]) => number +>(x: number, ...args: string[]) => 1 : (x: number, ...args: string[]) => number +>x : number +>args : string[] +>1 : 1 + diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures.symbols b/tests/baselines/reference/assignmentCompatWithConstructSignatures.symbols new file mode 100644 index 00000000000..78c153212b8 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures.symbols @@ -0,0 +1,102 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts === +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches + +interface T { +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures.ts, 0, 0)) + + new (x: number): void; +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 3, 9)) +} +var t: T; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures.ts, 0, 0)) + +var a: { new (x: number): void }; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 6, 14)) + +t = a; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) + +a = t; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) + +interface S { +>S : Symbol(S, Decl(assignmentCompatWithConstructSignatures.ts, 9, 6)) + + new (x: number): string; +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 12, 9)) +} +var s: S; +>s : Symbol(s, Decl(assignmentCompatWithConstructSignatures.ts, 14, 3)) +>S : Symbol(S, Decl(assignmentCompatWithConstructSignatures.ts, 9, 6)) + +var a2: { new (x: number): string }; +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures.ts, 15, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 15, 15)) + +t = s; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) +>s : Symbol(s, Decl(assignmentCompatWithConstructSignatures.ts, 14, 3)) + +t = a2; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures.ts, 15, 3)) + +a = s; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) +>s : Symbol(s, Decl(assignmentCompatWithConstructSignatures.ts, 14, 3)) + +a = a2; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures.ts, 15, 3)) + +interface S2 { +>S2 : Symbol(S2, Decl(assignmentCompatWithConstructSignatures.ts, 19, 7)) + + (x: string): void; +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 22, 5)) +} +var s2: S2; +>s2 : Symbol(s2, Decl(assignmentCompatWithConstructSignatures.ts, 24, 3)) +>S2 : Symbol(S2, Decl(assignmentCompatWithConstructSignatures.ts, 19, 7)) + +var a3: { (x: string): void }; +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures.ts, 25, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 25, 11)) + +// these are errors +t = s2; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) +>s2 : Symbol(s2, Decl(assignmentCompatWithConstructSignatures.ts, 24, 3)) + +t = a3; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures.ts, 25, 3)) + +t = (x: string) => 1; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 29, 5)) + +t = function (x: string) { return ''; } +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 30, 14)) + +a = s2; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) +>s2 : Symbol(s2, Decl(assignmentCompatWithConstructSignatures.ts, 24, 3)) + +a = a3; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures.ts, 25, 3)) + +a = (x: string) => 1; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 33, 5)) + +a = function (x: string) { return ''; } +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures.ts, 34, 14)) + diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures.types b/tests/baselines/reference/assignmentCompatWithConstructSignatures.types new file mode 100644 index 00000000000..038988807e5 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures.types @@ -0,0 +1,124 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures.ts === +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches + +interface T { +>T : T + + new (x: number): void; +>x : number +} +var t: T; +>t : T +>T : T + +var a: { new (x: number): void }; +>a : new (x: number) => void +>x : number + +t = a; +>t = a : new (x: number) => void +>t : T +>a : new (x: number) => void + +a = t; +>a = t : T +>a : new (x: number) => void +>t : T + +interface S { +>S : S + + new (x: number): string; +>x : number +} +var s: S; +>s : S +>S : S + +var a2: { new (x: number): string }; +>a2 : new (x: number) => string +>x : number + +t = s; +>t = s : S +>t : T +>s : S + +t = a2; +>t = a2 : new (x: number) => string +>t : T +>a2 : new (x: number) => string + +a = s; +>a = s : S +>a : new (x: number) => void +>s : S + +a = a2; +>a = a2 : new (x: number) => string +>a : new (x: number) => void +>a2 : new (x: number) => string + +interface S2 { +>S2 : S2 + + (x: string): void; +>x : string +} +var s2: S2; +>s2 : S2 +>S2 : S2 + +var a3: { (x: string): void }; +>a3 : (x: string) => void +>x : string + +// these are errors +t = s2; +>t = s2 : S2 +>t : T +>s2 : S2 + +t = a3; +>t = a3 : (x: string) => void +>t : T +>a3 : (x: string) => void + +t = (x: string) => 1; +>t = (x: string) => 1 : (x: string) => number +>t : T +>(x: string) => 1 : (x: string) => number +>x : string +>1 : 1 + +t = function (x: string) { return ''; } +>t = function (x: string) { return ''; } : (x: string) => string +>t : T +>function (x: string) { return ''; } : (x: string) => string +>x : string +>'' : "" + +a = s2; +>a = s2 : S2 +>a : new (x: number) => void +>s2 : S2 + +a = a3; +>a = a3 : (x: string) => void +>a : new (x: number) => void +>a3 : (x: string) => void + +a = (x: string) => 1; +>a = (x: string) => 1 : (x: string) => number +>a : new (x: number) => void +>(x: string) => 1 : (x: string) => number +>x : string +>1 : 1 + +a = function (x: string) { return ''; } +>a = function (x: string) { return ''; } : (x: string) => string +>a : new (x: number) => void +>function (x: string) { return ''; } : (x: string) => string +>x : string +>'' : "" + diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures2.symbols b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.symbols new file mode 100644 index 00000000000..ed67a37896e --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.symbols @@ -0,0 +1,123 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts === +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches + +interface T { +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures2.ts, 0, 0)) + + f: new (x: number) => void; +>f : Symbol(T.f, Decl(assignmentCompatWithConstructSignatures2.ts, 2, 13)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 3, 12)) +} +var t: T; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures2.ts, 0, 0)) + +var a: { f: new (x: number) => void }; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>f : Symbol(f, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 8)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 17)) + +t = a; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) + +a = t; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) + +interface S { +>S : Symbol(S, Decl(assignmentCompatWithConstructSignatures2.ts, 9, 6)) + + f: new (x: number) => string; +>f : Symbol(S.f, Decl(assignmentCompatWithConstructSignatures2.ts, 11, 13)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 12, 12)) +} +var s: S; +>s : Symbol(s, Decl(assignmentCompatWithConstructSignatures2.ts, 14, 3)) +>S : Symbol(S, Decl(assignmentCompatWithConstructSignatures2.ts, 9, 6)) + +var a2: { f: new (x: number) => string }; +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures2.ts, 15, 3)) +>f : Symbol(f, Decl(assignmentCompatWithConstructSignatures2.ts, 15, 9)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 15, 18)) + +t = s; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>s : Symbol(s, Decl(assignmentCompatWithConstructSignatures2.ts, 14, 3)) + +t = a2; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures2.ts, 15, 3)) + +a = s; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>s : Symbol(s, Decl(assignmentCompatWithConstructSignatures2.ts, 14, 3)) + +a = a2; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures2.ts, 15, 3)) + +// errors +t = () => 1; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) + +t = function (x: number) { return ''; } +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 23, 14)) + +a = () => 1; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) + +a = function (x: number) { return ''; } +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 25, 14)) + +interface S2 { +>S2 : Symbol(S2, Decl(assignmentCompatWithConstructSignatures2.ts, 25, 39)) + + f(x: string): void; +>f : Symbol(S2.f, Decl(assignmentCompatWithConstructSignatures2.ts, 27, 14)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 28, 6)) +} +var s2: S2; +>s2 : Symbol(s2, Decl(assignmentCompatWithConstructSignatures2.ts, 30, 3)) +>S2 : Symbol(S2, Decl(assignmentCompatWithConstructSignatures2.ts, 25, 39)) + +var a3: { f(x: string): void }; +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures2.ts, 31, 3)) +>f : Symbol(f, Decl(assignmentCompatWithConstructSignatures2.ts, 31, 9)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 31, 12)) + +// these are errors +t = s2; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>s2 : Symbol(s2, Decl(assignmentCompatWithConstructSignatures2.ts, 30, 3)) + +t = a3; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures2.ts, 31, 3)) + +t = (x: string) => 1; +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 35, 5)) + +t = function (x: string) { return ''; } +>t : Symbol(t, Decl(assignmentCompatWithConstructSignatures2.ts, 5, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 36, 14)) + +a = s2; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>s2 : Symbol(s2, Decl(assignmentCompatWithConstructSignatures2.ts, 30, 3)) + +a = a3; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures2.ts, 31, 3)) + +a = (x: string) => 1; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 39, 5)) + +a = function (x: string) { return ''; } +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures2.ts, 6, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures2.ts, 40, 14)) + diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures2.types b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.types new file mode 100644 index 00000000000..f797dcf83fa --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures2.types @@ -0,0 +1,157 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures2.ts === +// void returning call signatures can be assigned a non-void returning call signature that otherwise matches + +interface T { +>T : T + + f: new (x: number) => void; +>f : new (x: number) => void +>x : number +} +var t: T; +>t : T +>T : T + +var a: { f: new (x: number) => void }; +>a : { f: new (x: number) => void; } +>f : new (x: number) => void +>x : number + +t = a; +>t = a : { f: new (x: number) => void; } +>t : T +>a : { f: new (x: number) => void; } + +a = t; +>a = t : T +>a : { f: new (x: number) => void; } +>t : T + +interface S { +>S : S + + f: new (x: number) => string; +>f : new (x: number) => string +>x : number +} +var s: S; +>s : S +>S : S + +var a2: { f: new (x: number) => string }; +>a2 : { f: new (x: number) => string; } +>f : new (x: number) => string +>x : number + +t = s; +>t = s : S +>t : T +>s : S + +t = a2; +>t = a2 : { f: new (x: number) => string; } +>t : T +>a2 : { f: new (x: number) => string; } + +a = s; +>a = s : S +>a : { f: new (x: number) => void; } +>s : S + +a = a2; +>a = a2 : { f: new (x: number) => string; } +>a : { f: new (x: number) => void; } +>a2 : { f: new (x: number) => string; } + +// errors +t = () => 1; +>t = () => 1 : () => number +>t : T +>() => 1 : () => number +>1 : 1 + +t = function (x: number) { return ''; } +>t = function (x: number) { return ''; } : (x: number) => string +>t : T +>function (x: number) { return ''; } : (x: number) => string +>x : number +>'' : "" + +a = () => 1; +>a = () => 1 : () => number +>a : { f: new (x: number) => void; } +>() => 1 : () => number +>1 : 1 + +a = function (x: number) { return ''; } +>a = function (x: number) { return ''; } : (x: number) => string +>a : { f: new (x: number) => void; } +>function (x: number) { return ''; } : (x: number) => string +>x : number +>'' : "" + +interface S2 { +>S2 : S2 + + f(x: string): void; +>f : (x: string) => void +>x : string +} +var s2: S2; +>s2 : S2 +>S2 : S2 + +var a3: { f(x: string): void }; +>a3 : { f(x: string): void; } +>f : (x: string) => void +>x : string + +// these are errors +t = s2; +>t = s2 : S2 +>t : T +>s2 : S2 + +t = a3; +>t = a3 : { f(x: string): void; } +>t : T +>a3 : { f(x: string): void; } + +t = (x: string) => 1; +>t = (x: string) => 1 : (x: string) => number +>t : T +>(x: string) => 1 : (x: string) => number +>x : string +>1 : 1 + +t = function (x: string) { return ''; } +>t = function (x: string) { return ''; } : (x: string) => string +>t : T +>function (x: string) { return ''; } : (x: string) => string +>x : string +>'' : "" + +a = s2; +>a = s2 : S2 +>a : { f: new (x: number) => void; } +>s2 : S2 + +a = a3; +>a = a3 : { f(x: string): void; } +>a : { f: new (x: number) => void; } +>a3 : { f(x: string): void; } + +a = (x: string) => 1; +>a = (x: string) => 1 : (x: string) => number +>a : { f: new (x: number) => void; } +>(x: string) => 1 : (x: string) => number +>x : string +>1 : 1 + +a = function (x: string) { return ''; } +>a = function (x: string) { return ''; } : (x: string) => string +>a : { f: new (x: number) => void; } +>function (x: string) { return ''; } : (x: string) => string +>x : string +>'' : "" + diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.symbols b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.symbols new file mode 100644 index 00000000000..7b46a4ef456 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.symbols @@ -0,0 +1,404 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts === +// checking assignment compatibility relations for function types. + +module Errors { +>Errors : Symbol(Errors, Decl(assignmentCompatWithConstructSignatures4.ts, 0, 0)) + + class Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 16)) + + class Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithConstructSignatures4.ts, 4, 32)) + + class Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithConstructSignatures4.ts, 4, 47)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithConstructSignatures4.ts, 5, 36)) + + class OtherDerived extends Base { bing: string; } +>OtherDerived : Symbol(OtherDerived, Decl(assignmentCompatWithConstructSignatures4.ts, 5, 51)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>bing : Symbol(OtherDerived.bing, Decl(assignmentCompatWithConstructSignatures4.ts, 6, 37)) + + module WithNonGenericSignaturesInBaseType { +>WithNonGenericSignaturesInBaseType : Symbol(WithNonGenericSignaturesInBaseType, Decl(assignmentCompatWithConstructSignatures4.ts, 6, 53)) + + // target type with non-generic call signatures + var a2: new (x: number) => string[]; +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures4.ts, 10, 11)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 10, 21)) + + var a7: new (x: (arg: Base) => Derived) => (r: Base) => Derived2; +>a7 : Symbol(a7, Decl(assignmentCompatWithConstructSignatures4.ts, 11, 11)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 11, 21)) +>arg : Symbol(arg, Decl(assignmentCompatWithConstructSignatures4.ts, 11, 25)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>r : Symbol(r, Decl(assignmentCompatWithConstructSignatures4.ts, 11, 52)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithConstructSignatures4.ts, 4, 47)) + + var a8: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; +>a8 : Symbol(a8, Decl(assignmentCompatWithConstructSignatures4.ts, 12, 11)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 12, 21)) +>arg : Symbol(arg, Decl(assignmentCompatWithConstructSignatures4.ts, 12, 25)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures4.ts, 12, 47)) +>arg2 : Symbol(arg2, Decl(assignmentCompatWithConstructSignatures4.ts, 12, 52)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>r : Symbol(r, Decl(assignmentCompatWithConstructSignatures4.ts, 12, 80)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) + + var a10: new (...x: Base[]) => Base; +>a10 : Symbol(a10, Decl(assignmentCompatWithConstructSignatures4.ts, 13, 11)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 13, 22)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) + + var a11: new (x: { foo: string }, y: { foo: string; bar: string }) => Base; +>a11 : Symbol(a11, Decl(assignmentCompatWithConstructSignatures4.ts, 14, 11)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 14, 22)) +>foo : Symbol(foo, Decl(assignmentCompatWithConstructSignatures4.ts, 14, 26)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures4.ts, 14, 41)) +>foo : Symbol(foo, Decl(assignmentCompatWithConstructSignatures4.ts, 14, 46)) +>bar : Symbol(bar, Decl(assignmentCompatWithConstructSignatures4.ts, 14, 59)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) + + var a12: new (x: Array, y: Array) => Array; +>a12 : Symbol(a12, Decl(assignmentCompatWithConstructSignatures4.ts, 15, 11)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 15, 22)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures4.ts, 15, 37)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithConstructSignatures4.ts, 4, 47)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) + + var a14: { +>a14 : Symbol(a14, Decl(assignmentCompatWithConstructSignatures4.ts, 16, 11)) + + new (x: number): number[]; +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 17, 21)) + + new (x: string): string[]; +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 18, 21)) + + }; + var a15: new (x: { a: string; b: number }) => number; +>a15 : Symbol(a15, Decl(assignmentCompatWithConstructSignatures4.ts, 20, 11)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 20, 22)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 20, 26)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignatures4.ts, 20, 37)) + + var a16: { +>a16 : Symbol(a16, Decl(assignmentCompatWithConstructSignatures4.ts, 21, 11)) + + new (x: { +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 22, 21)) + + new (a: number): number; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 23, 25)) + + new (a?: number): number; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 24, 25)) + + }): number[]; + new (x: { +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 26, 21)) + + new (a: boolean): boolean; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 27, 25)) + + new (a?: boolean): boolean; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 28, 25)) + + }): boolean[]; + }; + var a17: { +>a17 : Symbol(a17, Decl(assignmentCompatWithConstructSignatures4.ts, 31, 11)) + + new (x: { +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 32, 21)) + + new (a: T): T; +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 33, 25)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 33, 44)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 33, 25)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 33, 25)) + + new (a: T): T; +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 34, 25)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 34, 41)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 34, 25)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 34, 25)) + + }): any[]; + new (x: { +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 36, 21)) + + new (a: T): T; +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 37, 25)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithConstructSignatures4.ts, 4, 47)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 37, 45)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 37, 25)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 37, 25)) + + new (a: T): T; +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 38, 25)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 38, 41)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 38, 25)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 38, 25)) + + }): any[]; + }; + + var b2: new (x: T) => U[]; +>b2 : Symbol(b2, Decl(assignmentCompatWithConstructSignatures4.ts, 42, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 42, 21)) +>U : Symbol(U, Decl(assignmentCompatWithConstructSignatures4.ts, 42, 23)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 42, 27)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 42, 21)) +>U : Symbol(U, Decl(assignmentCompatWithConstructSignatures4.ts, 42, 23)) + + a2 = b2; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures4.ts, 10, 11)) +>b2 : Symbol(b2, Decl(assignmentCompatWithConstructSignatures4.ts, 42, 11)) + + b2 = a2; // ok +>b2 : Symbol(b2, Decl(assignmentCompatWithConstructSignatures4.ts, 42, 11)) +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures4.ts, 10, 11)) + + var b7: new (x: (arg: T) => U) => (r: T) => V; +>b7 : Symbol(b7, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 21)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>U : Symbol(U, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 36)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>V : Symbol(V, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 55)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithConstructSignatures4.ts, 4, 47)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 76)) +>arg : Symbol(arg, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 80)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 21)) +>U : Symbol(U, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 36)) +>r : Symbol(r, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 98)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 21)) +>V : Symbol(V, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 55)) + + a7 = b7; // ok +>a7 : Symbol(a7, Decl(assignmentCompatWithConstructSignatures4.ts, 11, 11)) +>b7 : Symbol(b7, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 11)) + + b7 = a7; // ok +>b7 : Symbol(b7, Decl(assignmentCompatWithConstructSignatures4.ts, 46, 11)) +>a7 : Symbol(a7, Decl(assignmentCompatWithConstructSignatures4.ts, 11, 11)) + + var b8: new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; +>b8 : Symbol(b8, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 21)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>U : Symbol(U, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 36)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 56)) +>arg : Symbol(arg, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 60)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 21)) +>U : Symbol(U, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 36)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 73)) +>arg2 : Symbol(arg2, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 78)) +>foo : Symbol(foo, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 85)) +>U : Symbol(U, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 36)) +>r : Symbol(r, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 112)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 21)) +>U : Symbol(U, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 36)) + + a8 = b8; // error, type mismatch +>a8 : Symbol(a8, Decl(assignmentCompatWithConstructSignatures4.ts, 12, 11)) +>b8 : Symbol(b8, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 11)) + + b8 = a8; // error +>b8 : Symbol(b8, Decl(assignmentCompatWithConstructSignatures4.ts, 50, 11)) +>a8 : Symbol(a8, Decl(assignmentCompatWithConstructSignatures4.ts, 12, 11)) + + + var b10: new (...x: T[]) => T; +>b10 : Symbol(b10, Decl(assignmentCompatWithConstructSignatures4.ts, 55, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 55, 22)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 55, 41)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 55, 22)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 55, 22)) + + a10 = b10; // ok +>a10 : Symbol(a10, Decl(assignmentCompatWithConstructSignatures4.ts, 13, 11)) +>b10 : Symbol(b10, Decl(assignmentCompatWithConstructSignatures4.ts, 55, 11)) + + b10 = a10; // ok +>b10 : Symbol(b10, Decl(assignmentCompatWithConstructSignatures4.ts, 55, 11)) +>a10 : Symbol(a10, Decl(assignmentCompatWithConstructSignatures4.ts, 13, 11)) + + var b11: new (x: T, y: T) => T; +>b11 : Symbol(b11, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 22)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithConstructSignatures4.ts, 3, 31)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 41)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 22)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 46)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 22)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 22)) + + a11 = b11; // ok +>a11 : Symbol(a11, Decl(assignmentCompatWithConstructSignatures4.ts, 14, 11)) +>b11 : Symbol(b11, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 11)) + + b11 = a11; // ok +>b11 : Symbol(b11, Decl(assignmentCompatWithConstructSignatures4.ts, 59, 11)) +>a11 : Symbol(a11, Decl(assignmentCompatWithConstructSignatures4.ts, 14, 11)) + + var b12: new >(x: Array, y: Array) => T; +>b12 : Symbol(b12, Decl(assignmentCompatWithConstructSignatures4.ts, 63, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 63, 22)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithConstructSignatures4.ts, 4, 47)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 63, 49)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignatures4.ts, 63, 64)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 63, 22)) + + a12 = b12; // ok +>a12 : Symbol(a12, Decl(assignmentCompatWithConstructSignatures4.ts, 15, 11)) +>b12 : Symbol(b12, Decl(assignmentCompatWithConstructSignatures4.ts, 63, 11)) + + b12 = a12; // ok +>b12 : Symbol(b12, Decl(assignmentCompatWithConstructSignatures4.ts, 63, 11)) +>a12 : Symbol(a12, Decl(assignmentCompatWithConstructSignatures4.ts, 15, 11)) + + var b15: new (x: { a: T; b: T }) => T; +>b15 : Symbol(b15, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 22)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 25)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 29)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 22)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 35)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 22)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 22)) + + a15 = b15; // ok +>a15 : Symbol(a15, Decl(assignmentCompatWithConstructSignatures4.ts, 20, 11)) +>b15 : Symbol(b15, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 11)) + + b15 = a15; // ok +>b15 : Symbol(b15, Decl(assignmentCompatWithConstructSignatures4.ts, 67, 11)) +>a15 : Symbol(a15, Decl(assignmentCompatWithConstructSignatures4.ts, 20, 11)) + + var b15a: new (x: { a: T; b: T }) => number; +>b15a : Symbol(b15a, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 23)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignatures4.ts, 2, 15)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 39)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 43)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 23)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 49)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 23)) + + a15 = b15a; // ok +>a15 : Symbol(a15, Decl(assignmentCompatWithConstructSignatures4.ts, 20, 11)) +>b15a : Symbol(b15a, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 11)) + + b15a = a15; // ok +>b15a : Symbol(b15a, Decl(assignmentCompatWithConstructSignatures4.ts, 71, 11)) +>a15 : Symbol(a15, Decl(assignmentCompatWithConstructSignatures4.ts, 20, 11)) + + var b16: new (x: (a: T) => T) => T[]; +>b16 : Symbol(b16, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 22)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 25)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 29)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 22)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 22)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 22)) + + a16 = b16; // error +>a16 : Symbol(a16, Decl(assignmentCompatWithConstructSignatures4.ts, 21, 11)) +>b16 : Symbol(b16, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 11)) + + b16 = a16; // error +>b16 : Symbol(b16, Decl(assignmentCompatWithConstructSignatures4.ts, 75, 11)) +>a16 : Symbol(a16, Decl(assignmentCompatWithConstructSignatures4.ts, 21, 11)) + + var b17: new (x: (a: T) => T) => any[]; +>b17 : Symbol(b17, Decl(assignmentCompatWithConstructSignatures4.ts, 79, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 79, 22)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 79, 25)) +>a : Symbol(a, Decl(assignmentCompatWithConstructSignatures4.ts, 79, 29)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 79, 22)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 79, 22)) + + a17 = b17; // error +>a17 : Symbol(a17, Decl(assignmentCompatWithConstructSignatures4.ts, 31, 11)) +>b17 : Symbol(b17, Decl(assignmentCompatWithConstructSignatures4.ts, 79, 11)) + + b17 = a17; // error +>b17 : Symbol(b17, Decl(assignmentCompatWithConstructSignatures4.ts, 79, 11)) +>a17 : Symbol(a17, Decl(assignmentCompatWithConstructSignatures4.ts, 31, 11)) + } + + module WithGenericSignaturesInBaseType { +>WithGenericSignaturesInBaseType : Symbol(WithGenericSignaturesInBaseType, Decl(assignmentCompatWithConstructSignatures4.ts, 82, 5)) + + // target type has generic call signature + var a2: new (x: T) => T[]; +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures4.ts, 86, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 86, 21)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 86, 24)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 86, 21)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 86, 21)) + + var b2: new (x: T) => string[]; +>b2 : Symbol(b2, Decl(assignmentCompatWithConstructSignatures4.ts, 87, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 87, 21)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 87, 24)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 87, 21)) + + a2 = b2; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures4.ts, 86, 11)) +>b2 : Symbol(b2, Decl(assignmentCompatWithConstructSignatures4.ts, 87, 11)) + + b2 = a2; // ok +>b2 : Symbol(b2, Decl(assignmentCompatWithConstructSignatures4.ts, 87, 11)) +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignatures4.ts, 86, 11)) + + // target type has generic call signature + var a3: new (x: T) => string[]; +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures4.ts, 92, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 92, 21)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 92, 24)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 92, 21)) + + var b3: new (x: T) => T[]; +>b3 : Symbol(b3, Decl(assignmentCompatWithConstructSignatures4.ts, 93, 11)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 93, 21)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignatures4.ts, 93, 24)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 93, 21)) +>T : Symbol(T, Decl(assignmentCompatWithConstructSignatures4.ts, 93, 21)) + + a3 = b3; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures4.ts, 92, 11)) +>b3 : Symbol(b3, Decl(assignmentCompatWithConstructSignatures4.ts, 93, 11)) + + b3 = a3; // ok +>b3 : Symbol(b3, Decl(assignmentCompatWithConstructSignatures4.ts, 93, 11)) +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignatures4.ts, 92, 11)) + } +} diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.types b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.types new file mode 100644 index 00000000000..1844e5ac657 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.types @@ -0,0 +1,428 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts === +// checking assignment compatibility relations for function types. + +module Errors { +>Errors : typeof Errors + + class Base { foo: string; } +>Base : Base +>foo : string + + class Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + + class Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + + class OtherDerived extends Base { bing: string; } +>OtherDerived : OtherDerived +>Base : Base +>bing : string + + module WithNonGenericSignaturesInBaseType { +>WithNonGenericSignaturesInBaseType : typeof WithNonGenericSignaturesInBaseType + + // target type with non-generic call signatures + var a2: new (x: number) => string[]; +>a2 : new (x: number) => string[] +>x : number + + var a7: new (x: (arg: Base) => Derived) => (r: Base) => Derived2; +>a7 : new (x: (arg: Base) => Derived) => (r: Base) => Derived2 +>x : (arg: Base) => Derived +>arg : Base +>Base : Base +>Derived : Derived +>r : Base +>Base : Base +>Derived2 : Derived2 + + var a8: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; +>a8 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived +>x : (arg: Base) => Derived +>arg : Base +>Base : Base +>Derived : Derived +>y : (arg2: Base) => Derived +>arg2 : Base +>Base : Base +>Derived : Derived +>r : Base +>Base : Base +>Derived : Derived + + var a10: new (...x: Base[]) => Base; +>a10 : new (...x: Base[]) => Base +>x : Base[] +>Base : Base +>Base : Base + + var a11: new (x: { foo: string }, y: { foo: string; bar: string }) => Base; +>a11 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base +>x : { foo: string; } +>foo : string +>y : { foo: string; bar: string; } +>foo : string +>bar : string +>Base : Base + + var a12: new (x: Array, y: Array) => Array; +>a12 : new (x: Base[], y: Derived2[]) => Derived[] +>x : Base[] +>Array : T[] +>Base : Base +>y : Derived2[] +>Array : T[] +>Derived2 : Derived2 +>Array : T[] +>Derived : Derived + + var a14: { +>a14 : { new (x: number): number[]; new (x: string): string[]; } + + new (x: number): number[]; +>x : number + + new (x: string): string[]; +>x : string + + }; + var a15: new (x: { a: string; b: number }) => number; +>a15 : new (x: { a: string; b: number; }) => number +>x : { a: string; b: number; } +>a : string +>b : number + + var a16: { +>a16 : { new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; } + + new (x: { +>x : { new (a: number): number; new (a?: number): number; } + + new (a: number): number; +>a : number + + new (a?: number): number; +>a : number + + }): number[]; + new (x: { +>x : { new (a: boolean): boolean; new (a?: boolean): boolean; } + + new (a: boolean): boolean; +>a : boolean + + new (a?: boolean): boolean; +>a : boolean + + }): boolean[]; + }; + var a17: { +>a17 : { new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; } + + new (x: { +>x : { new (a: T): T; new (a: T): T; } + + new (a: T): T; +>T : T +>Derived : Derived +>a : T +>T : T +>T : T + + new (a: T): T; +>T : T +>Base : Base +>a : T +>T : T +>T : T + + }): any[]; + new (x: { +>x : { new (a: T): T; new (a: T): T; } + + new (a: T): T; +>T : T +>Derived2 : Derived2 +>a : T +>T : T +>T : T + + new (a: T): T; +>T : T +>Base : Base +>a : T +>T : T +>T : T + + }): any[]; + }; + + var b2: new (x: T) => U[]; +>b2 : new (x: T) => U[] +>T : T +>U : U +>x : T +>T : T +>U : U + + a2 = b2; // ok +>a2 = b2 : new (x: T) => U[] +>a2 : new (x: number) => string[] +>b2 : new (x: T) => U[] + + b2 = a2; // ok +>b2 = a2 : new (x: number) => string[] +>b2 : new (x: T) => U[] +>a2 : new (x: number) => string[] + + var b7: new (x: (arg: T) => U) => (r: T) => V; +>b7 : new (x: (arg: T) => U) => (r: T) => V +>T : T +>Base : Base +>U : U +>Derived : Derived +>V : V +>Derived2 : Derived2 +>x : (arg: T) => U +>arg : T +>T : T +>U : U +>r : T +>T : T +>V : V + + a7 = b7; // ok +>a7 = b7 : new (x: (arg: T) => U) => (r: T) => V +>a7 : new (x: (arg: Base) => Derived) => (r: Base) => Derived2 +>b7 : new (x: (arg: T) => U) => (r: T) => V + + b7 = a7; // ok +>b7 = a7 : new (x: (arg: Base) => Derived) => (r: Base) => Derived2 +>b7 : new (x: (arg: T) => U) => (r: T) => V +>a7 : new (x: (arg: Base) => Derived) => (r: Base) => Derived2 + + var b8: new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; +>b8 : new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U +>T : T +>Base : Base +>U : U +>Derived : Derived +>x : (arg: T) => U +>arg : T +>T : T +>U : U +>y : (arg2: { foo: number; }) => U +>arg2 : { foo: number; } +>foo : number +>U : U +>r : T +>T : T +>U : U + + a8 = b8; // error, type mismatch +>a8 = b8 : new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U +>a8 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived +>b8 : new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U + + b8 = a8; // error +>b8 = a8 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived +>b8 : new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U +>a8 : new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived + + + var b10: new (...x: T[]) => T; +>b10 : new (...x: T[]) => T +>T : T +>Derived : Derived +>x : T[] +>T : T +>T : T + + a10 = b10; // ok +>a10 = b10 : new (...x: T[]) => T +>a10 : new (...x: Base[]) => Base +>b10 : new (...x: T[]) => T + + b10 = a10; // ok +>b10 = a10 : new (...x: Base[]) => Base +>b10 : new (...x: T[]) => T +>a10 : new (...x: Base[]) => Base + + var b11: new (x: T, y: T) => T; +>b11 : new (x: T, y: T) => T +>T : T +>Derived : Derived +>x : T +>T : T +>y : T +>T : T +>T : T + + a11 = b11; // ok +>a11 = b11 : new (x: T, y: T) => T +>a11 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base +>b11 : new (x: T, y: T) => T + + b11 = a11; // ok +>b11 = a11 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base +>b11 : new (x: T, y: T) => T +>a11 : new (x: { foo: string; }, y: { foo: string; bar: string; }) => Base + + var b12: new >(x: Array, y: Array) => T; +>b12 : new (x: Base[], y: Base[]) => T +>T : T +>Array : T[] +>Derived2 : Derived2 +>x : Base[] +>Array : T[] +>Base : Base +>y : Base[] +>Array : T[] +>Base : Base +>T : T + + a12 = b12; // ok +>a12 = b12 : new (x: Base[], y: Base[]) => T +>a12 : new (x: Base[], y: Derived2[]) => Derived[] +>b12 : new (x: Base[], y: Base[]) => T + + b12 = a12; // ok +>b12 = a12 : new (x: Base[], y: Derived2[]) => Derived[] +>b12 : new (x: Base[], y: Base[]) => T +>a12 : new (x: Base[], y: Derived2[]) => Derived[] + + var b15: new (x: { a: T; b: T }) => T; +>b15 : new (x: { a: T; b: T; }) => T +>T : T +>x : { a: T; b: T; } +>a : T +>T : T +>b : T +>T : T +>T : T + + a15 = b15; // ok +>a15 = b15 : new (x: { a: T; b: T; }) => T +>a15 : new (x: { a: string; b: number; }) => number +>b15 : new (x: { a: T; b: T; }) => T + + b15 = a15; // ok +>b15 = a15 : new (x: { a: string; b: number; }) => number +>b15 : new (x: { a: T; b: T; }) => T +>a15 : new (x: { a: string; b: number; }) => number + + var b15a: new (x: { a: T; b: T }) => number; +>b15a : new (x: { a: T; b: T; }) => number +>T : T +>Base : Base +>x : { a: T; b: T; } +>a : T +>T : T +>b : T +>T : T + + a15 = b15a; // ok +>a15 = b15a : new (x: { a: T; b: T; }) => number +>a15 : new (x: { a: string; b: number; }) => number +>b15a : new (x: { a: T; b: T; }) => number + + b15a = a15; // ok +>b15a = a15 : new (x: { a: string; b: number; }) => number +>b15a : new (x: { a: T; b: T; }) => number +>a15 : new (x: { a: string; b: number; }) => number + + var b16: new (x: (a: T) => T) => T[]; +>b16 : new (x: (a: T) => T) => T[] +>T : T +>x : (a: T) => T +>a : T +>T : T +>T : T +>T : T + + a16 = b16; // error +>a16 = b16 : new (x: (a: T) => T) => T[] +>a16 : { new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; } +>b16 : new (x: (a: T) => T) => T[] + + b16 = a16; // error +>b16 = a16 : { new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; } +>b16 : new (x: (a: T) => T) => T[] +>a16 : { new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; } + + var b17: new (x: (a: T) => T) => any[]; +>b17 : new (x: (a: T) => T) => any[] +>T : T +>x : (a: T) => T +>a : T +>T : T +>T : T + + a17 = b17; // error +>a17 = b17 : new (x: (a: T) => T) => any[] +>a17 : { new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; } +>b17 : new (x: (a: T) => T) => any[] + + b17 = a17; // error +>b17 = a17 : { new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; } +>b17 : new (x: (a: T) => T) => any[] +>a17 : { new (x: { new (a: T): T; new (a: T): T; }): any[]; new (x: { new (a: T): T; new (a: T): T; }): any[]; } + } + + module WithGenericSignaturesInBaseType { +>WithGenericSignaturesInBaseType : typeof WithGenericSignaturesInBaseType + + // target type has generic call signature + var a2: new (x: T) => T[]; +>a2 : new (x: T) => T[] +>T : T +>x : T +>T : T +>T : T + + var b2: new (x: T) => string[]; +>b2 : new (x: T) => string[] +>T : T +>x : T +>T : T + + a2 = b2; // ok +>a2 = b2 : new (x: T) => string[] +>a2 : new (x: T) => T[] +>b2 : new (x: T) => string[] + + b2 = a2; // ok +>b2 = a2 : new (x: T) => T[] +>b2 : new (x: T) => string[] +>a2 : new (x: T) => T[] + + // target type has generic call signature + var a3: new (x: T) => string[]; +>a3 : new (x: T) => string[] +>T : T +>x : T +>T : T + + var b3: new (x: T) => T[]; +>b3 : new (x: T) => T[] +>T : T +>x : T +>T : T +>T : T + + a3 = b3; // ok +>a3 = b3 : new (x: T) => T[] +>a3 : new (x: T) => string[] +>b3 : new (x: T) => T[] + + b3 = a3; // ok +>b3 = a3 : new (x: T) => string[] +>b3 : new (x: T) => T[] +>a3 : new (x: T) => string[] + } +} diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.symbols b/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.symbols new file mode 100644 index 00000000000..5cd4f91642d --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.symbols @@ -0,0 +1,237 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts === +// call signatures in derived types must have the same or fewer optional parameters as the base type + +interface Base { +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 0, 0)) + + a: new () => number; +>a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) + + a2: new (x?: number) => number; +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 13)) + + a3: new (x: number) => number; +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 13)) + + a4: new (x: number, y?: number) => number; +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 13)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 23)) + + a5: new (x?: number, y?: number) => number; +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 13)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 24)) + + a6: new (x: number, y: number) => number; +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 8, 13)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 8, 23)) +} +var b: Base; +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>Base : Symbol(Base, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 0, 0)) + +var a: new () => number; +>a : Symbol(a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 12, 3)) + + a = b.a; // ok +>a : Symbol(a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) + + a = b.a2; // ok +>a : Symbol(a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) + + a = b.a3; // error +>a : Symbol(a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) + + a = b.a4; // error +>a : Symbol(a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) + + a = b.a5; // ok +>a : Symbol(a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) + + a = b.a6; // error +>a : Symbol(a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 12, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) + +var a2: new (x?: number) => number; +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 20, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 20, 13)) + + a2 = b.a; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 20, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) + + a2 = b.a2; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 20, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) + + a2 = b.a3; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 20, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) + + a2 = b.a4; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 20, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) + + a2 = b.a5; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 20, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) + + a2 = b.a6; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 20, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) + +var a3: new (x: number) => number; +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 28, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 28, 13)) + + a3 = b.a; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 28, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) + + a3 = b.a2; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 28, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) + + a3 = b.a3; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 28, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) + + a3 = b.a4; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 28, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) + + a3 = b.a5; // ok +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 28, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) + + a3 = b.a6; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 28, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) + +var a4: new (x: number, y?: number) => number; +>a4 : Symbol(a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 13)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 23)) + + a4 = b.a; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) + + a4 = b.a2; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) + + a4 = b.a3; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) + + a4 = b.a4; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) + + a4 = b.a5; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) + + a4 = b.a6; // ok +>a4 : Symbol(a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 36, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) + +var a5: new (x?: number, y?: number) => number; +>a5 : Symbol(a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 3)) +>x : Symbol(x, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 13)) +>y : Symbol(y, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 24)) + + a5 = b.a; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 3)) +>b.a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a : Symbol(Base.a, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 2, 16)) + + a5 = b.a2; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 3)) +>b.a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 3, 24)) + + a5 = b.a3; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 3)) +>b.a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 4, 35)) + + a5 = b.a4; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 3)) +>b.a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 5, 34)) + + a5 = b.a5; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 3)) +>b.a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 6, 46)) + + a5 = b.a6; // ok +>a5 : Symbol(a5, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 44, 3)) +>b.a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) +>b : Symbol(b, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 10, 3)) +>a6 : Symbol(Base.a6, Decl(assignmentCompatWithConstructSignaturesWithOptionalParameters.ts, 7, 47)) + diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.types b/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.types new file mode 100644 index 00000000000..c2f13da17bf --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithConstructSignaturesWithOptionalParameters.types @@ -0,0 +1,267 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignaturesWithOptionalParameters.ts === +// call signatures in derived types must have the same or fewer optional parameters as the base type + +interface Base { +>Base : Base + + a: new () => number; +>a : new () => number + + a2: new (x?: number) => number; +>a2 : new (x?: number) => number +>x : number + + a3: new (x: number) => number; +>a3 : new (x: number) => number +>x : number + + a4: new (x: number, y?: number) => number; +>a4 : new (x: number, y?: number) => number +>x : number +>y : number + + a5: new (x?: number, y?: number) => number; +>a5 : new (x?: number, y?: number) => number +>x : number +>y : number + + a6: new (x: number, y: number) => number; +>a6 : new (x: number, y: number) => number +>x : number +>y : number +} +var b: Base; +>b : Base +>Base : Base + +var a: new () => number; +>a : new () => number + + a = b.a; // ok +>a = b.a : new () => number +>a : new () => number +>b.a : new () => number +>b : Base +>a : new () => number + + a = b.a2; // ok +>a = b.a2 : new (x?: number) => number +>a : new () => number +>b.a2 : new (x?: number) => number +>b : Base +>a2 : new (x?: number) => number + + a = b.a3; // error +>a = b.a3 : new (x: number) => number +>a : new () => number +>b.a3 : new (x: number) => number +>b : Base +>a3 : new (x: number) => number + + a = b.a4; // error +>a = b.a4 : new (x: number, y?: number) => number +>a : new () => number +>b.a4 : new (x: number, y?: number) => number +>b : Base +>a4 : new (x: number, y?: number) => number + + a = b.a5; // ok +>a = b.a5 : new (x?: number, y?: number) => number +>a : new () => number +>b.a5 : new (x?: number, y?: number) => number +>b : Base +>a5 : new (x?: number, y?: number) => number + + a = b.a6; // error +>a = b.a6 : new (x: number, y: number) => number +>a : new () => number +>b.a6 : new (x: number, y: number) => number +>b : Base +>a6 : new (x: number, y: number) => number + +var a2: new (x?: number) => number; +>a2 : new (x?: number) => number +>x : number + + a2 = b.a; // ok +>a2 = b.a : new () => number +>a2 : new (x?: number) => number +>b.a : new () => number +>b : Base +>a : new () => number + + a2 = b.a2; // ok +>a2 = b.a2 : new (x?: number) => number +>a2 : new (x?: number) => number +>b.a2 : new (x?: number) => number +>b : Base +>a2 : new (x?: number) => number + + a2 = b.a3; // ok +>a2 = b.a3 : new (x: number) => number +>a2 : new (x?: number) => number +>b.a3 : new (x: number) => number +>b : Base +>a3 : new (x: number) => number + + a2 = b.a4; // ok +>a2 = b.a4 : new (x: number, y?: number) => number +>a2 : new (x?: number) => number +>b.a4 : new (x: number, y?: number) => number +>b : Base +>a4 : new (x: number, y?: number) => number + + a2 = b.a5; // ok +>a2 = b.a5 : new (x?: number, y?: number) => number +>a2 : new (x?: number) => number +>b.a5 : new (x?: number, y?: number) => number +>b : Base +>a5 : new (x?: number, y?: number) => number + + a2 = b.a6; // error +>a2 = b.a6 : new (x: number, y: number) => number +>a2 : new (x?: number) => number +>b.a6 : new (x: number, y: number) => number +>b : Base +>a6 : new (x: number, y: number) => number + +var a3: new (x: number) => number; +>a3 : new (x: number) => number +>x : number + + a3 = b.a; // ok +>a3 = b.a : new () => number +>a3 : new (x: number) => number +>b.a : new () => number +>b : Base +>a : new () => number + + a3 = b.a2; // ok +>a3 = b.a2 : new (x?: number) => number +>a3 : new (x: number) => number +>b.a2 : new (x?: number) => number +>b : Base +>a2 : new (x?: number) => number + + a3 = b.a3; // ok +>a3 = b.a3 : new (x: number) => number +>a3 : new (x: number) => number +>b.a3 : new (x: number) => number +>b : Base +>a3 : new (x: number) => number + + a3 = b.a4; // ok +>a3 = b.a4 : new (x: number, y?: number) => number +>a3 : new (x: number) => number +>b.a4 : new (x: number, y?: number) => number +>b : Base +>a4 : new (x: number, y?: number) => number + + a3 = b.a5; // ok +>a3 = b.a5 : new (x?: number, y?: number) => number +>a3 : new (x: number) => number +>b.a5 : new (x?: number, y?: number) => number +>b : Base +>a5 : new (x?: number, y?: number) => number + + a3 = b.a6; // error +>a3 = b.a6 : new (x: number, y: number) => number +>a3 : new (x: number) => number +>b.a6 : new (x: number, y: number) => number +>b : Base +>a6 : new (x: number, y: number) => number + +var a4: new (x: number, y?: number) => number; +>a4 : new (x: number, y?: number) => number +>x : number +>y : number + + a4 = b.a; // ok +>a4 = b.a : new () => number +>a4 : new (x: number, y?: number) => number +>b.a : new () => number +>b : Base +>a : new () => number + + a4 = b.a2; // ok +>a4 = b.a2 : new (x?: number) => number +>a4 : new (x: number, y?: number) => number +>b.a2 : new (x?: number) => number +>b : Base +>a2 : new (x?: number) => number + + a4 = b.a3; // ok +>a4 = b.a3 : new (x: number) => number +>a4 : new (x: number, y?: number) => number +>b.a3 : new (x: number) => number +>b : Base +>a3 : new (x: number) => number + + a4 = b.a4; // ok +>a4 = b.a4 : new (x: number, y?: number) => number +>a4 : new (x: number, y?: number) => number +>b.a4 : new (x: number, y?: number) => number +>b : Base +>a4 : new (x: number, y?: number) => number + + a4 = b.a5; // ok +>a4 = b.a5 : new (x?: number, y?: number) => number +>a4 : new (x: number, y?: number) => number +>b.a5 : new (x?: number, y?: number) => number +>b : Base +>a5 : new (x?: number, y?: number) => number + + a4 = b.a6; // ok +>a4 = b.a6 : new (x: number, y: number) => number +>a4 : new (x: number, y?: number) => number +>b.a6 : new (x: number, y: number) => number +>b : Base +>a6 : new (x: number, y: number) => number + +var a5: new (x?: number, y?: number) => number; +>a5 : new (x?: number, y?: number) => number +>x : number +>y : number + + a5 = b.a; // ok +>a5 = b.a : new () => number +>a5 : new (x?: number, y?: number) => number +>b.a : new () => number +>b : Base +>a : new () => number + + a5 = b.a2; // ok +>a5 = b.a2 : new (x?: number) => number +>a5 : new (x?: number, y?: number) => number +>b.a2 : new (x?: number) => number +>b : Base +>a2 : new (x?: number) => number + + a5 = b.a3; // ok +>a5 = b.a3 : new (x: number) => number +>a5 : new (x?: number, y?: number) => number +>b.a3 : new (x: number) => number +>b : Base +>a3 : new (x: number) => number + + a5 = b.a4; // ok +>a5 = b.a4 : new (x: number, y?: number) => number +>a5 : new (x?: number, y?: number) => number +>b.a4 : new (x: number, y?: number) => number +>b : Base +>a4 : new (x: number, y?: number) => number + + a5 = b.a5; // ok +>a5 = b.a5 : new (x?: number, y?: number) => number +>a5 : new (x?: number, y?: number) => number +>b.a5 : new (x?: number, y?: number) => number +>b : Base +>a5 : new (x?: number, y?: number) => number + + a5 = b.a6; // ok +>a5 = b.a6 : new (x: number, y: number) => number +>a5 : new (x?: number, y?: number) => number +>b.a6 : new (x: number, y: number) => number +>b : Base +>a6 : new (x: number, y: number) => number + diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.symbols b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.symbols new file mode 100644 index 00000000000..e3f1d226283 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.symbols @@ -0,0 +1,666 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts === +// call signatures in derived types must have the same or fewer optional parameters as the target for assignment + +module ClassTypeParam { +>ClassTypeParam : Symbol(ClassTypeParam, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 0, 0)) + + class Base { +>Base : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + a: () => T; +>a : Symbol(Base.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 19)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + a2: (x?: T) => T; +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 4, 19)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + a3: (x: T) => T; +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + a4: (x: T, y?: T) => T; +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 18)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + a5: (x?: T, y?: T) => T; +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 8, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 8, 19)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + init = () => { +>init : Symbol(Base.init, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 8, 32)) + + this.a = () => null; // ok, same T of required params +>this.a : Symbol(Base.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 19)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a : Symbol(Base.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 19)) + + this.a = (x?: T) => null; // ok, same T of required params +>this.a : Symbol(Base.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 19)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a : Symbol(Base.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 19)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 12, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a = (x: T) => null; // error, too many required params +>this.a : Symbol(Base.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 19)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a : Symbol(Base.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 19)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 13, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a2 = () => null; // ok, same T of required params +>this.a2 : Symbol(Base.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 4, 19)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 4, 19)) + + this.a2 = (x?: T) => null; // ok, same T of required params +>this.a2 : Symbol(Base.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 4, 19)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 4, 19)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 16, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a2 = (x: T) => null; // ok, same number of params +>this.a2 : Symbol(Base.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 4, 19)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a2 : Symbol(Base.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 4, 19)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 17, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a3 = () => null; // ok, fewer required params +>this.a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) + + this.a3 = (x?: T) => null; // ok, fewer required params +>this.a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 20, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a3 = (x: T) => null; // ok, same T of required params +>this.a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 21, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a3 = (x: T, y: T) => null; // error, too many required params +>this.a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a3 : Symbol(Base.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 5, 25)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 22, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 22, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a4 = () => null; // ok, fewer required params +>this.a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) + + this.a4 = (x?: T, y?: T) => null; // ok, fewer required params +>this.a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 25, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 25, 29)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a4 = (x: T) => null; // ok, same T of required params +>this.a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 26, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a4 = (x: T, y: T) => null; // ok, same number of params +>this.a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a4 : Symbol(Base.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 6, 24)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 27, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 27, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + + this.a5 = () => null; // ok, fewer required params +>this.a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) + + this.a5 = (x?: T, y?: T) => null; // ok, fewer required params +>this.a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 31, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 31, 29)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a5 = (x: T) => null; // ok, all present params match +>this.a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 32, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + + this.a5 = (x: T, y: T) => null; // ok, same number of params +>this.a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) +>this : Symbol(Base, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 2, 23)) +>a5 : Symbol(Base.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 7, 31)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 33, 23)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 33, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 3, 15)) + } + } +} + +module GenericSignaturesInvalid { +>GenericSignaturesInvalid : Symbol(GenericSignaturesInvalid, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 36, 1)) + + class Base2 { +>Base2 : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 38, 33)) + + a: () => T; +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 12)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 12)) + + a2: (x?: T) => T; +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 13)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 16)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 13)) + + a3: (x: T) => T; +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 13)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 16)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 13)) + + a4: (x: T, y?: T) => T; +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 13)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 16)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 13)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 21)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 13)) + + a5: (x?: T, y?: T) => T; +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 45, 13)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 45, 16)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 45, 13)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 45, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 45, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 45, 13)) + } + + class Target { +>Target : Symbol(Target, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 46, 5)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) + + a: () => T; +>a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) + + a2: (x?: T) => T; +>a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) + + a3: (x: T) => T; +>a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) + + a4: (x: T, y?: T) => T; +>a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 18)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) + + a5: (x?: T, y?: T) => T; +>a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 53, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 53, 19)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 17)) + } + + + function foo() { +>foo : Symbol(foo, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 54, 5)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 57, 17)) + + var b: Base2; +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>Base2 : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 38, 33)) + + var t: Target; +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>Target : Symbol(Target, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 46, 5)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 57, 17)) + + // all errors + b.a = t.a; +>b.a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>t.a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) + + b.a = t.a2; +>b.a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>t.a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) + + b.a = t.a3; +>b.a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>t.a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) + + b.a = t.a4; +>b.a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>t.a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) + + b.a = t.a5; +>b.a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 40, 17)) +>t.a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) + + b.a2 = t.a; +>b.a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>t.a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) + + b.a2 = t.a2; +>b.a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>t.a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) + + b.a2 = t.a3; +>b.a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>t.a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) + + b.a2 = t.a4; +>b.a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>t.a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) + + b.a2 = t.a5; +>b.a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 41, 22)) +>t.a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) + + b.a3 = t.a; +>b.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>t.a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) + + b.a3 = t.a2; +>b.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>t.a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) + + b.a3 = t.a3; +>b.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>t.a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) + + b.a3 = t.a4; +>b.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>t.a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) + + b.a3 = t.a5; +>b.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 42, 28)) +>t.a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) + + b.a4 = t.a; +>b.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>t.a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) + + b.a4 = t.a2; +>b.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>t.a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) + + b.a4 = t.a3; +>b.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>t.a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) + + b.a4 = t.a4; +>b.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>t.a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) + + b.a4 = t.a5; +>b.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 43, 27)) +>t.a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) + + b.a5 = t.a; +>b.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>t.a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a : Symbol(Target.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 48, 21)) + + b.a5 = t.a2; +>b.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>t.a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a2 : Symbol(Target.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 49, 19)) + + b.a5 = t.a3; +>b.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>t.a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a3 : Symbol(Target.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 50, 25)) + + b.a5 = t.a4; +>b.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>t.a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a4 : Symbol(Target.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 51, 24)) + + b.a5 = t.a5; +>b.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>b : Symbol(b, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 58, 11)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 44, 34)) +>t.a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) +>t : Symbol(t, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 59, 11)) +>a5 : Symbol(Target.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 52, 31)) + } +} + +module GenericSignaturesValid { +>GenericSignaturesValid : Symbol(GenericSignaturesValid, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 92, 1)) + + class Base2 { +>Base2 : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) + + a: () => T; +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 96, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 12)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 12)) + + a2: (x?: T) => T; +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 13)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 16)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 13)) + + a3: (x: T) => T; +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 13)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 16)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 13)) + + a4: (x: T, y?: T) => T; +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 13)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 16)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 13)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 21)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 13)) + + a5: (x?: T, y?: T) => T; +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 101, 13)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 101, 16)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 101, 13)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 101, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 101, 13)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 101, 13)) + + init = () => { +>init : Symbol(Base2.init, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 101, 35)) + + this.a = () => null; // ok, same T of required params +>this.a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 96, 17)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 96, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 104, 22)) + + this.a = (x?: T) => null; // ok, same T of required params +>this.a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 96, 17)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 96, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 105, 22)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 105, 25)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 105, 22)) + + this.a = (x: T) => null; // error, too many required params +>this.a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 96, 17)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a : Symbol(Base2.a, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 96, 17)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 106, 22)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 106, 25)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 106, 22)) + + this.a2 = () => null; // ok, same T of required params +>this.a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 22)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 108, 23)) + + this.a2 = (x?: T) => null; // ok, same T of required params +>this.a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 22)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 109, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 109, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 109, 23)) + + this.a2 = (x: T) => null; // ok, same number of params +>this.a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 22)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a2 : Symbol(Base2.a2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 97, 22)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 110, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 110, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 110, 23)) + + this.a3 = () => null; // ok, fewer required params +>this.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 112, 23)) + + this.a3 = (x?: T) => null; // ok, fewer required params +>this.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 113, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 113, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 113, 23)) + + this.a3 = (x: T) => null; // ok, same T of required params +>this.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 114, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 114, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 114, 23)) + + this.a3 = (x: T, y: T) => null; // error, too many required params +>this.a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a3 : Symbol(Base2.a3, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 98, 28)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 115, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 115, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 115, 23)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 115, 31)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 115, 23)) + + this.a4 = () => null; // ok, fewer required params +>this.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 117, 23)) + + this.a4 = (x?: T, y?: T) => null; // ok, fewer required params +>this.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 118, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 118, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 118, 23)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 118, 32)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 118, 23)) + + this.a4 = (x: T) => null; // ok, same T of required params +>this.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 119, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 119, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 119, 23)) + + this.a4 = (x: T, y: T) => null; // ok, same number of params +>this.a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a4 : Symbol(Base2.a4, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 99, 27)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 120, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 120, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 120, 23)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 120, 31)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 120, 23)) + + + this.a5 = () => null; // ok, fewer required params +>this.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 123, 23)) + + this.a5 = (x?: T, y?: T) => null; // ok, fewer required params +>this.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 124, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 124, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 124, 23)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 124, 32)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 124, 23)) + + this.a5 = (x: T) => null; // ok, all present params match +>this.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 125, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 125, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 125, 23)) + + this.a5 = (x: T, y: T) => null; // ok, same number of params +>this.a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>this : Symbol(Base2, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 94, 31)) +>a5 : Symbol(Base2.a5, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 100, 34)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 126, 23)) +>x : Symbol(x, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 126, 26)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 126, 23)) +>y : Symbol(y, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 126, 31)) +>T : Symbol(T, Decl(assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts, 126, 23)) + } + } +} diff --git a/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.types b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.types new file mode 100644 index 00000000000..28bcc4e190a --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.types @@ -0,0 +1,801 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignaturesWithOptionalParameters.ts === +// call signatures in derived types must have the same or fewer optional parameters as the target for assignment + +module ClassTypeParam { +>ClassTypeParam : typeof ClassTypeParam + + class Base { +>Base : Base +>T : T + + a: () => T; +>a : () => T +>T : T + + a2: (x?: T) => T; +>a2 : (x?: T) => T +>x : T +>T : T +>T : T + + a3: (x: T) => T; +>a3 : (x: T) => T +>x : T +>T : T +>T : T + + a4: (x: T, y?: T) => T; +>a4 : (x: T, y?: T) => T +>x : T +>T : T +>y : T +>T : T +>T : T + + a5: (x?: T, y?: T) => T; +>a5 : (x?: T, y?: T) => T +>x : T +>T : T +>y : T +>T : T +>T : T + + init = () => { +>init : () => void +>() => { this.a = () => null; // ok, same T of required params this.a = (x?: T) => null; // ok, same T of required params this.a = (x: T) => null; // error, too many required params this.a2 = () => null; // ok, same T of required params this.a2 = (x?: T) => null; // ok, same T of required params this.a2 = (x: T) => null; // ok, same number of params this.a3 = () => null; // ok, fewer required params this.a3 = (x?: T) => null; // ok, fewer required params this.a3 = (x: T) => null; // ok, same T of required params this.a3 = (x: T, y: T) => null; // error, too many required params this.a4 = () => null; // ok, fewer required params this.a4 = (x?: T, y?: T) => null; // ok, fewer required params this.a4 = (x: T) => null; // ok, same T of required params this.a4 = (x: T, y: T) => null; // ok, same number of params this.a5 = () => null; // ok, fewer required params this.a5 = (x?: T, y?: T) => null; // ok, fewer required params this.a5 = (x: T) => null; // ok, all present params match this.a5 = (x: T, y: T) => null; // ok, same number of params } : () => void + + this.a = () => null; // ok, same T of required params +>this.a = () => null : () => any +>this.a : () => T +>this : this +>a : () => T +>() => null : () => any +>null : null + + this.a = (x?: T) => null; // ok, same T of required params +>this.a = (x?: T) => null : (x?: T) => any +>this.a : () => T +>this : this +>a : () => T +>(x?: T) => null : (x?: T) => any +>x : T +>T : T +>null : null + + this.a = (x: T) => null; // error, too many required params +>this.a = (x: T) => null : (x: T) => any +>this.a : () => T +>this : this +>a : () => T +>(x: T) => null : (x: T) => any +>x : T +>T : T +>null : null + + this.a2 = () => null; // ok, same T of required params +>this.a2 = () => null : () => any +>this.a2 : (x?: T) => T +>this : this +>a2 : (x?: T) => T +>() => null : () => any +>null : null + + this.a2 = (x?: T) => null; // ok, same T of required params +>this.a2 = (x?: T) => null : (x?: T) => any +>this.a2 : (x?: T) => T +>this : this +>a2 : (x?: T) => T +>(x?: T) => null : (x?: T) => any +>x : T +>T : T +>null : null + + this.a2 = (x: T) => null; // ok, same number of params +>this.a2 = (x: T) => null : (x: T) => any +>this.a2 : (x?: T) => T +>this : this +>a2 : (x?: T) => T +>(x: T) => null : (x: T) => any +>x : T +>T : T +>null : null + + this.a3 = () => null; // ok, fewer required params +>this.a3 = () => null : () => any +>this.a3 : (x: T) => T +>this : this +>a3 : (x: T) => T +>() => null : () => any +>null : null + + this.a3 = (x?: T) => null; // ok, fewer required params +>this.a3 = (x?: T) => null : (x?: T) => any +>this.a3 : (x: T) => T +>this : this +>a3 : (x: T) => T +>(x?: T) => null : (x?: T) => any +>x : T +>T : T +>null : null + + this.a3 = (x: T) => null; // ok, same T of required params +>this.a3 = (x: T) => null : (x: T) => any +>this.a3 : (x: T) => T +>this : this +>a3 : (x: T) => T +>(x: T) => null : (x: T) => any +>x : T +>T : T +>null : null + + this.a3 = (x: T, y: T) => null; // error, too many required params +>this.a3 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a3 : (x: T) => T +>this : this +>a3 : (x: T) => T +>(x: T, y: T) => null : (x: T, y: T) => any +>x : T +>T : T +>y : T +>T : T +>null : null + + this.a4 = () => null; // ok, fewer required params +>this.a4 = () => null : () => any +>this.a4 : (x: T, y?: T) => T +>this : this +>a4 : (x: T, y?: T) => T +>() => null : () => any +>null : null + + this.a4 = (x?: T, y?: T) => null; // ok, fewer required params +>this.a4 = (x?: T, y?: T) => null : (x?: T, y?: T) => any +>this.a4 : (x: T, y?: T) => T +>this : this +>a4 : (x: T, y?: T) => T +>(x?: T, y?: T) => null : (x?: T, y?: T) => any +>x : T +>T : T +>y : T +>T : T +>null : null + + this.a4 = (x: T) => null; // ok, same T of required params +>this.a4 = (x: T) => null : (x: T) => any +>this.a4 : (x: T, y?: T) => T +>this : this +>a4 : (x: T, y?: T) => T +>(x: T) => null : (x: T) => any +>x : T +>T : T +>null : null + + this.a4 = (x: T, y: T) => null; // ok, same number of params +>this.a4 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a4 : (x: T, y?: T) => T +>this : this +>a4 : (x: T, y?: T) => T +>(x: T, y: T) => null : (x: T, y: T) => any +>x : T +>T : T +>y : T +>T : T +>null : null + + + this.a5 = () => null; // ok, fewer required params +>this.a5 = () => null : () => any +>this.a5 : (x?: T, y?: T) => T +>this : this +>a5 : (x?: T, y?: T) => T +>() => null : () => any +>null : null + + this.a5 = (x?: T, y?: T) => null; // ok, fewer required params +>this.a5 = (x?: T, y?: T) => null : (x?: T, y?: T) => any +>this.a5 : (x?: T, y?: T) => T +>this : this +>a5 : (x?: T, y?: T) => T +>(x?: T, y?: T) => null : (x?: T, y?: T) => any +>x : T +>T : T +>y : T +>T : T +>null : null + + this.a5 = (x: T) => null; // ok, all present params match +>this.a5 = (x: T) => null : (x: T) => any +>this.a5 : (x?: T, y?: T) => T +>this : this +>a5 : (x?: T, y?: T) => T +>(x: T) => null : (x: T) => any +>x : T +>T : T +>null : null + + this.a5 = (x: T, y: T) => null; // ok, same number of params +>this.a5 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a5 : (x?: T, y?: T) => T +>this : this +>a5 : (x?: T, y?: T) => T +>(x: T, y: T) => null : (x: T, y: T) => any +>x : T +>T : T +>y : T +>T : T +>null : null + } + } +} + +module GenericSignaturesInvalid { +>GenericSignaturesInvalid : typeof GenericSignaturesInvalid + + class Base2 { +>Base2 : Base2 + + a: () => T; +>a : () => T +>T : T +>T : T + + a2: (x?: T) => T; +>a2 : (x?: T) => T +>T : T +>x : T +>T : T +>T : T + + a3: (x: T) => T; +>a3 : (x: T) => T +>T : T +>x : T +>T : T +>T : T + + a4: (x: T, y?: T) => T; +>a4 : (x: T, y?: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + + a5: (x?: T, y?: T) => T; +>a5 : (x?: T, y?: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + } + + class Target { +>Target : Target +>T : T + + a: () => T; +>a : () => T +>T : T + + a2: (x?: T) => T; +>a2 : (x?: T) => T +>x : T +>T : T +>T : T + + a3: (x: T) => T; +>a3 : (x: T) => T +>x : T +>T : T +>T : T + + a4: (x: T, y?: T) => T; +>a4 : (x: T, y?: T) => T +>x : T +>T : T +>y : T +>T : T +>T : T + + a5: (x?: T, y?: T) => T; +>a5 : (x?: T, y?: T) => T +>x : T +>T : T +>y : T +>T : T +>T : T + } + + + function foo() { +>foo : () => void +>T : T + + var b: Base2; +>b : Base2 +>Base2 : Base2 + + var t: Target; +>t : Target +>Target : Target +>T : T + + // all errors + b.a = t.a; +>b.a = t.a : () => T +>b.a : () => T +>b : Base2 +>a : () => T +>t.a : () => T +>t : Target +>a : () => T + + b.a = t.a2; +>b.a = t.a2 : (x?: T) => T +>b.a : () => T +>b : Base2 +>a : () => T +>t.a2 : (x?: T) => T +>t : Target +>a2 : (x?: T) => T + + b.a = t.a3; +>b.a = t.a3 : (x: T) => T +>b.a : () => T +>b : Base2 +>a : () => T +>t.a3 : (x: T) => T +>t : Target +>a3 : (x: T) => T + + b.a = t.a4; +>b.a = t.a4 : (x: T, y?: T) => T +>b.a : () => T +>b : Base2 +>a : () => T +>t.a4 : (x: T, y?: T) => T +>t : Target +>a4 : (x: T, y?: T) => T + + b.a = t.a5; +>b.a = t.a5 : (x?: T, y?: T) => T +>b.a : () => T +>b : Base2 +>a : () => T +>t.a5 : (x?: T, y?: T) => T +>t : Target +>a5 : (x?: T, y?: T) => T + + b.a2 = t.a; +>b.a2 = t.a : () => T +>b.a2 : (x?: T) => T +>b : Base2 +>a2 : (x?: T) => T +>t.a : () => T +>t : Target +>a : () => T + + b.a2 = t.a2; +>b.a2 = t.a2 : (x?: T) => T +>b.a2 : (x?: T) => T +>b : Base2 +>a2 : (x?: T) => T +>t.a2 : (x?: T) => T +>t : Target +>a2 : (x?: T) => T + + b.a2 = t.a3; +>b.a2 = t.a3 : (x: T) => T +>b.a2 : (x?: T) => T +>b : Base2 +>a2 : (x?: T) => T +>t.a3 : (x: T) => T +>t : Target +>a3 : (x: T) => T + + b.a2 = t.a4; +>b.a2 = t.a4 : (x: T, y?: T) => T +>b.a2 : (x?: T) => T +>b : Base2 +>a2 : (x?: T) => T +>t.a4 : (x: T, y?: T) => T +>t : Target +>a4 : (x: T, y?: T) => T + + b.a2 = t.a5; +>b.a2 = t.a5 : (x?: T, y?: T) => T +>b.a2 : (x?: T) => T +>b : Base2 +>a2 : (x?: T) => T +>t.a5 : (x?: T, y?: T) => T +>t : Target +>a5 : (x?: T, y?: T) => T + + b.a3 = t.a; +>b.a3 = t.a : () => T +>b.a3 : (x: T) => T +>b : Base2 +>a3 : (x: T) => T +>t.a : () => T +>t : Target +>a : () => T + + b.a3 = t.a2; +>b.a3 = t.a2 : (x?: T) => T +>b.a3 : (x: T) => T +>b : Base2 +>a3 : (x: T) => T +>t.a2 : (x?: T) => T +>t : Target +>a2 : (x?: T) => T + + b.a3 = t.a3; +>b.a3 = t.a3 : (x: T) => T +>b.a3 : (x: T) => T +>b : Base2 +>a3 : (x: T) => T +>t.a3 : (x: T) => T +>t : Target +>a3 : (x: T) => T + + b.a3 = t.a4; +>b.a3 = t.a4 : (x: T, y?: T) => T +>b.a3 : (x: T) => T +>b : Base2 +>a3 : (x: T) => T +>t.a4 : (x: T, y?: T) => T +>t : Target +>a4 : (x: T, y?: T) => T + + b.a3 = t.a5; +>b.a3 = t.a5 : (x?: T, y?: T) => T +>b.a3 : (x: T) => T +>b : Base2 +>a3 : (x: T) => T +>t.a5 : (x?: T, y?: T) => T +>t : Target +>a5 : (x?: T, y?: T) => T + + b.a4 = t.a; +>b.a4 = t.a : () => T +>b.a4 : (x: T, y?: T) => T +>b : Base2 +>a4 : (x: T, y?: T) => T +>t.a : () => T +>t : Target +>a : () => T + + b.a4 = t.a2; +>b.a4 = t.a2 : (x?: T) => T +>b.a4 : (x: T, y?: T) => T +>b : Base2 +>a4 : (x: T, y?: T) => T +>t.a2 : (x?: T) => T +>t : Target +>a2 : (x?: T) => T + + b.a4 = t.a3; +>b.a4 = t.a3 : (x: T) => T +>b.a4 : (x: T, y?: T) => T +>b : Base2 +>a4 : (x: T, y?: T) => T +>t.a3 : (x: T) => T +>t : Target +>a3 : (x: T) => T + + b.a4 = t.a4; +>b.a4 = t.a4 : (x: T, y?: T) => T +>b.a4 : (x: T, y?: T) => T +>b : Base2 +>a4 : (x: T, y?: T) => T +>t.a4 : (x: T, y?: T) => T +>t : Target +>a4 : (x: T, y?: T) => T + + b.a4 = t.a5; +>b.a4 = t.a5 : (x?: T, y?: T) => T +>b.a4 : (x: T, y?: T) => T +>b : Base2 +>a4 : (x: T, y?: T) => T +>t.a5 : (x?: T, y?: T) => T +>t : Target +>a5 : (x?: T, y?: T) => T + + b.a5 = t.a; +>b.a5 = t.a : () => T +>b.a5 : (x?: T, y?: T) => T +>b : Base2 +>a5 : (x?: T, y?: T) => T +>t.a : () => T +>t : Target +>a : () => T + + b.a5 = t.a2; +>b.a5 = t.a2 : (x?: T) => T +>b.a5 : (x?: T, y?: T) => T +>b : Base2 +>a5 : (x?: T, y?: T) => T +>t.a2 : (x?: T) => T +>t : Target +>a2 : (x?: T) => T + + b.a5 = t.a3; +>b.a5 = t.a3 : (x: T) => T +>b.a5 : (x?: T, y?: T) => T +>b : Base2 +>a5 : (x?: T, y?: T) => T +>t.a3 : (x: T) => T +>t : Target +>a3 : (x: T) => T + + b.a5 = t.a4; +>b.a5 = t.a4 : (x: T, y?: T) => T +>b.a5 : (x?: T, y?: T) => T +>b : Base2 +>a5 : (x?: T, y?: T) => T +>t.a4 : (x: T, y?: T) => T +>t : Target +>a4 : (x: T, y?: T) => T + + b.a5 = t.a5; +>b.a5 = t.a5 : (x?: T, y?: T) => T +>b.a5 : (x?: T, y?: T) => T +>b : Base2 +>a5 : (x?: T, y?: T) => T +>t.a5 : (x?: T, y?: T) => T +>t : Target +>a5 : (x?: T, y?: T) => T + } +} + +module GenericSignaturesValid { +>GenericSignaturesValid : typeof GenericSignaturesValid + + class Base2 { +>Base2 : Base2 + + a: () => T; +>a : () => T +>T : T +>T : T + + a2: (x?: T) => T; +>a2 : (x?: T) => T +>T : T +>x : T +>T : T +>T : T + + a3: (x: T) => T; +>a3 : (x: T) => T +>T : T +>x : T +>T : T +>T : T + + a4: (x: T, y?: T) => T; +>a4 : (x: T, y?: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + + a5: (x?: T, y?: T) => T; +>a5 : (x?: T, y?: T) => T +>T : T +>x : T +>T : T +>y : T +>T : T +>T : T + + init = () => { +>init : () => void +>() => { this.a = () => null; // ok, same T of required params this.a = (x?: T) => null; // ok, same T of required params this.a = (x: T) => null; // error, too many required params this.a2 = () => null; // ok, same T of required params this.a2 = (x?: T) => null; // ok, same T of required params this.a2 = (x: T) => null; // ok, same number of params this.a3 = () => null; // ok, fewer required params this.a3 = (x?: T) => null; // ok, fewer required params this.a3 = (x: T) => null; // ok, same T of required params this.a3 = (x: T, y: T) => null; // error, too many required params this.a4 = () => null; // ok, fewer required params this.a4 = (x?: T, y?: T) => null; // ok, fewer required params this.a4 = (x: T) => null; // ok, same T of required params this.a4 = (x: T, y: T) => null; // ok, same number of params this.a5 = () => null; // ok, fewer required params this.a5 = (x?: T, y?: T) => null; // ok, fewer required params this.a5 = (x: T) => null; // ok, all present params match this.a5 = (x: T, y: T) => null; // ok, same number of params } : () => void + + this.a = () => null; // ok, same T of required params +>this.a = () => null : () => any +>this.a : () => T +>this : this +>a : () => T +>() => null : () => any +>T : T +>null : null + + this.a = (x?: T) => null; // ok, same T of required params +>this.a = (x?: T) => null : (x?: T) => any +>this.a : () => T +>this : this +>a : () => T +>(x?: T) => null : (x?: T) => any +>T : T +>x : T +>T : T +>null : null + + this.a = (x: T) => null; // error, too many required params +>this.a = (x: T) => null : (x: T) => any +>this.a : () => T +>this : this +>a : () => T +>(x: T) => null : (x: T) => any +>T : T +>x : T +>T : T +>null : null + + this.a2 = () => null; // ok, same T of required params +>this.a2 = () => null : () => any +>this.a2 : (x?: T) => T +>this : this +>a2 : (x?: T) => T +>() => null : () => any +>T : T +>null : null + + this.a2 = (x?: T) => null; // ok, same T of required params +>this.a2 = (x?: T) => null : (x?: T) => any +>this.a2 : (x?: T) => T +>this : this +>a2 : (x?: T) => T +>(x?: T) => null : (x?: T) => any +>T : T +>x : T +>T : T +>null : null + + this.a2 = (x: T) => null; // ok, same number of params +>this.a2 = (x: T) => null : (x: T) => any +>this.a2 : (x?: T) => T +>this : this +>a2 : (x?: T) => T +>(x: T) => null : (x: T) => any +>T : T +>x : T +>T : T +>null : null + + this.a3 = () => null; // ok, fewer required params +>this.a3 = () => null : () => any +>this.a3 : (x: T) => T +>this : this +>a3 : (x: T) => T +>() => null : () => any +>T : T +>null : null + + this.a3 = (x?: T) => null; // ok, fewer required params +>this.a3 = (x?: T) => null : (x?: T) => any +>this.a3 : (x: T) => T +>this : this +>a3 : (x: T) => T +>(x?: T) => null : (x?: T) => any +>T : T +>x : T +>T : T +>null : null + + this.a3 = (x: T) => null; // ok, same T of required params +>this.a3 = (x: T) => null : (x: T) => any +>this.a3 : (x: T) => T +>this : this +>a3 : (x: T) => T +>(x: T) => null : (x: T) => any +>T : T +>x : T +>T : T +>null : null + + this.a3 = (x: T, y: T) => null; // error, too many required params +>this.a3 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a3 : (x: T) => T +>this : this +>a3 : (x: T) => T +>(x: T, y: T) => null : (x: T, y: T) => any +>T : T +>x : T +>T : T +>y : T +>T : T +>null : null + + this.a4 = () => null; // ok, fewer required params +>this.a4 = () => null : () => any +>this.a4 : (x: T, y?: T) => T +>this : this +>a4 : (x: T, y?: T) => T +>() => null : () => any +>T : T +>null : null + + this.a4 = (x?: T, y?: T) => null; // ok, fewer required params +>this.a4 = (x?: T, y?: T) => null : (x?: T, y?: T) => any +>this.a4 : (x: T, y?: T) => T +>this : this +>a4 : (x: T, y?: T) => T +>(x?: T, y?: T) => null : (x?: T, y?: T) => any +>T : T +>x : T +>T : T +>y : T +>T : T +>null : null + + this.a4 = (x: T) => null; // ok, same T of required params +>this.a4 = (x: T) => null : (x: T) => any +>this.a4 : (x: T, y?: T) => T +>this : this +>a4 : (x: T, y?: T) => T +>(x: T) => null : (x: T) => any +>T : T +>x : T +>T : T +>null : null + + this.a4 = (x: T, y: T) => null; // ok, same number of params +>this.a4 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a4 : (x: T, y?: T) => T +>this : this +>a4 : (x: T, y?: T) => T +>(x: T, y: T) => null : (x: T, y: T) => any +>T : T +>x : T +>T : T +>y : T +>T : T +>null : null + + + this.a5 = () => null; // ok, fewer required params +>this.a5 = () => null : () => any +>this.a5 : (x?: T, y?: T) => T +>this : this +>a5 : (x?: T, y?: T) => T +>() => null : () => any +>T : T +>null : null + + this.a5 = (x?: T, y?: T) => null; // ok, fewer required params +>this.a5 = (x?: T, y?: T) => null : (x?: T, y?: T) => any +>this.a5 : (x?: T, y?: T) => T +>this : this +>a5 : (x?: T, y?: T) => T +>(x?: T, y?: T) => null : (x?: T, y?: T) => any +>T : T +>x : T +>T : T +>y : T +>T : T +>null : null + + this.a5 = (x: T) => null; // ok, all present params match +>this.a5 = (x: T) => null : (x: T) => any +>this.a5 : (x?: T, y?: T) => T +>this : this +>a5 : (x?: T, y?: T) => T +>(x: T) => null : (x: T) => any +>T : T +>x : T +>T : T +>null : null + + this.a5 = (x: T, y: T) => null; // ok, same number of params +>this.a5 = (x: T, y: T) => null : (x: T, y: T) => any +>this.a5 : (x?: T, y?: T) => T +>this : this +>a5 : (x?: T, y?: T) => T +>(x: T, y: T) => null : (x: T, y: T) => any +>T : T +>x : T +>T : T +>y : T +>T : T +>null : null + } + } +} diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.symbols b/tests/baselines/reference/assignmentCompatWithNumericIndexer.symbols new file mode 100644 index 00000000000..106d8a9351d --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.symbols @@ -0,0 +1,128 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts === +// Derived type indexer must be subtype of base type indexer + +interface Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer.ts, 0, 0)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithNumericIndexer.ts, 2, 16)) + +interface Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer.ts, 2, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer.ts, 0, 0)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithNumericIndexer.ts, 3, 32)) + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer.ts, 3, 47)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer.ts, 2, 31)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithNumericIndexer.ts, 4, 36)) + +class A { +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer.ts, 4, 51)) + + [x: number]: Base; +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer.ts, 7, 5)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer.ts, 0, 0)) +} + +var a: A; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 10, 3)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer.ts, 4, 51)) + +var b: { [x: number]: Derived; } +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer.ts, 11, 3)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer.ts, 11, 10)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer.ts, 2, 31)) + +a = b; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 10, 3)) +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer.ts, 11, 3)) + +b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer.ts, 11, 3)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 10, 3)) + +var b2: { [x: number]: Derived2; } +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer.ts, 15, 3)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer.ts, 15, 11)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer.ts, 3, 47)) + +a = b2; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 10, 3)) +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer.ts, 15, 3)) + +b2 = a; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer.ts, 15, 3)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 10, 3)) + +module Generics { +>Generics : Symbol(Generics, Decl(assignmentCompatWithNumericIndexer.ts, 17, 7)) + + class A { +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer.ts, 19, 17)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer.ts, 20, 12)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer.ts, 0, 0)) + + [x: number]: T; +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer.ts, 21, 9)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer.ts, 20, 12)) + } + + class B extends A { +>B : Symbol(B, Decl(assignmentCompatWithNumericIndexer.ts, 22, 5)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer.ts, 19, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer.ts, 0, 0)) + + [x: number]: Derived; // ok +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer.ts, 25, 9)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer.ts, 2, 31)) + } + + function foo() { +>foo : Symbol(foo, Decl(assignmentCompatWithNumericIndexer.ts, 26, 5)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer.ts, 28, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer.ts, 0, 0)) + + var a: A; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 29, 11)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer.ts, 19, 17)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer.ts, 28, 17)) + + var b: { [x: number]: Derived; } +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer.ts, 30, 11)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer.ts, 30, 18)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer.ts, 2, 31)) + + a = b; // error +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 29, 11)) +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer.ts, 30, 11)) + + b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer.ts, 30, 11)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 29, 11)) + + var b2: { [x: number]: Derived2; } +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer.ts, 34, 11)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer.ts, 34, 19)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer.ts, 3, 47)) + + a = b2; // error +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 29, 11)) +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer.ts, 34, 11)) + + b2 = a; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer.ts, 34, 11)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 29, 11)) + + var b3: { [x: number]: T; } +>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer.ts, 38, 11)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer.ts, 38, 19)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer.ts, 28, 17)) + + a = b3; // ok +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 29, 11)) +>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer.ts, 38, 11)) + + b3 = a; // ok +>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer.ts, 38, 11)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer.ts, 29, 11)) + } +} diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer.types b/tests/baselines/reference/assignmentCompatWithNumericIndexer.types new file mode 100644 index 00000000000..b1d61b0d71e --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer.types @@ -0,0 +1,138 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer.ts === +// Derived type indexer must be subtype of base type indexer + +interface Base { foo: string; } +>Base : Base +>foo : string + +interface Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + +class A { +>A : A + + [x: number]: Base; +>x : number +>Base : Base +} + +var a: A; +>a : A +>A : A + +var b: { [x: number]: Derived; } +>b : { [x: number]: Derived; } +>x : number +>Derived : Derived + +a = b; +>a = b : { [x: number]: Derived; } +>a : A +>b : { [x: number]: Derived; } + +b = a; // error +>b = a : A +>b : { [x: number]: Derived; } +>a : A + +var b2: { [x: number]: Derived2; } +>b2 : { [x: number]: Derived2; } +>x : number +>Derived2 : Derived2 + +a = b2; +>a = b2 : { [x: number]: Derived2; } +>a : A +>b2 : { [x: number]: Derived2; } + +b2 = a; // error +>b2 = a : A +>b2 : { [x: number]: Derived2; } +>a : A + +module Generics { +>Generics : typeof Generics + + class A { +>A : A +>T : T +>Base : Base + + [x: number]: T; +>x : number +>T : T + } + + class B extends A { +>B : B +>A : A +>Base : Base + + [x: number]: Derived; // ok +>x : number +>Derived : Derived + } + + function foo() { +>foo : () => void +>T : T +>Base : Base + + var a: A; +>a : A +>A : A +>T : T + + var b: { [x: number]: Derived; } +>b : { [x: number]: Derived; } +>x : number +>Derived : Derived + + a = b; // error +>a = b : { [x: number]: Derived; } +>a : A +>b : { [x: number]: Derived; } + + b = a; // error +>b = a : A +>b : { [x: number]: Derived; } +>a : A + + var b2: { [x: number]: Derived2; } +>b2 : { [x: number]: Derived2; } +>x : number +>Derived2 : Derived2 + + a = b2; // error +>a = b2 : { [x: number]: Derived2; } +>a : A +>b2 : { [x: number]: Derived2; } + + b2 = a; // error +>b2 = a : A +>b2 : { [x: number]: Derived2; } +>a : A + + var b3: { [x: number]: T; } +>b3 : { [x: number]: T; } +>x : number +>T : T + + a = b3; // ok +>a = b3 : { [x: number]: T; } +>a : A +>b3 : { [x: number]: T; } + + b3 = a; // ok +>b3 = a : A +>b3 : { [x: number]: T; } +>a : A + } +} diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.symbols b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.symbols new file mode 100644 index 00000000000..c1b9bd26f9d --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.symbols @@ -0,0 +1,128 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts === +// Derived type indexer must be subtype of base type indexer + +interface Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 16)) + +interface Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithNumericIndexer2.ts, 3, 32)) + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer2.ts, 3, 47)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithNumericIndexer2.ts, 4, 36)) + +interface A { +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 4, 51)) + + [x: number]: Base; +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 7, 5)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0)) +} + +var a: A; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 3)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 4, 51)) + +var b: { [x: number]: Derived; } +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 11, 3)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 11, 10)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31)) + +a = b; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 3)) +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 11, 3)) + +b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 11, 3)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 3)) + +var b2: { [x: number]: Derived2; } +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 15, 3)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 15, 11)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer2.ts, 3, 47)) + +a = b2; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 3)) +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 15, 3)) + +b2 = a; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 15, 3)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 10, 3)) + +module Generics { +>Generics : Symbol(Generics, Decl(assignmentCompatWithNumericIndexer2.ts, 17, 7)) + + interface A { +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 19, 17)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 20, 16)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0)) + + [x: number]: T; +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 21, 9)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 20, 16)) + } + + interface B extends A { +>B : Symbol(B, Decl(assignmentCompatWithNumericIndexer2.ts, 22, 5)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 19, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0)) + + [x: number]: Derived; // ok +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 25, 9)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31)) + } + + function foo() { +>foo : Symbol(foo, Decl(assignmentCompatWithNumericIndexer2.ts, 26, 5)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 28, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer2.ts, 0, 0)) + + var a: A; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer2.ts, 19, 17)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 28, 17)) + + var b: { [x: number]: Derived; } +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 30, 11)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 30, 18)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer2.ts, 2, 31)) + + a = b; // error +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11)) +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 30, 11)) + + b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer2.ts, 30, 11)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11)) + + var b2: { [x: number]: Derived2; } +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 34, 11)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 34, 19)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer2.ts, 3, 47)) + + a = b2; // error +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11)) +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 34, 11)) + + b2 = a; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer2.ts, 34, 11)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11)) + + var b3: { [x: number]: T; } +>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer2.ts, 38, 11)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer2.ts, 38, 19)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer2.ts, 28, 17)) + + a = b3; // ok +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11)) +>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer2.ts, 38, 11)) + + b3 = a; // ok +>b3 : Symbol(b3, Decl(assignmentCompatWithNumericIndexer2.ts, 38, 11)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer2.ts, 29, 11)) + } +} diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer2.types b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.types new file mode 100644 index 00000000000..c980c8ef9ea --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer2.types @@ -0,0 +1,138 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer2.ts === +// Derived type indexer must be subtype of base type indexer + +interface Base { foo: string; } +>Base : Base +>foo : string + +interface Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + +interface A { +>A : A + + [x: number]: Base; +>x : number +>Base : Base +} + +var a: A; +>a : A +>A : A + +var b: { [x: number]: Derived; } +>b : { [x: number]: Derived; } +>x : number +>Derived : Derived + +a = b; +>a = b : { [x: number]: Derived; } +>a : A +>b : { [x: number]: Derived; } + +b = a; // error +>b = a : A +>b : { [x: number]: Derived; } +>a : A + +var b2: { [x: number]: Derived2; } +>b2 : { [x: number]: Derived2; } +>x : number +>Derived2 : Derived2 + +a = b2; +>a = b2 : { [x: number]: Derived2; } +>a : A +>b2 : { [x: number]: Derived2; } + +b2 = a; // error +>b2 = a : A +>b2 : { [x: number]: Derived2; } +>a : A + +module Generics { +>Generics : typeof Generics + + interface A { +>A : A +>T : T +>Base : Base + + [x: number]: T; +>x : number +>T : T + } + + interface B extends A { +>B : B +>A : A +>Base : Base + + [x: number]: Derived; // ok +>x : number +>Derived : Derived + } + + function foo() { +>foo : () => void +>T : T +>Base : Base + + var a: A; +>a : A +>A : A +>T : T + + var b: { [x: number]: Derived; } +>b : { [x: number]: Derived; } +>x : number +>Derived : Derived + + a = b; // error +>a = b : { [x: number]: Derived; } +>a : A +>b : { [x: number]: Derived; } + + b = a; // error +>b = a : A +>b : { [x: number]: Derived; } +>a : A + + var b2: { [x: number]: Derived2; } +>b2 : { [x: number]: Derived2; } +>x : number +>Derived2 : Derived2 + + a = b2; // error +>a = b2 : { [x: number]: Derived2; } +>a : A +>b2 : { [x: number]: Derived2; } + + b2 = a; // error +>b2 = a : A +>b2 : { [x: number]: Derived2; } +>a : A + + var b3: { [x: number]: T; } +>b3 : { [x: number]: T; } +>x : number +>T : T + + a = b3; // ok +>a = b3 : { [x: number]: T; } +>a : A +>b3 : { [x: number]: T; } + + b3 = a; // ok +>b3 = a : A +>b3 : { [x: number]: T; } +>a : A + } +} diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.symbols b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.symbols new file mode 100644 index 00000000000..133f0e9ef12 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.symbols @@ -0,0 +1,114 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts === +// Derived type indexer must be subtype of base type indexer + +interface Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer3.ts, 0, 0)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithNumericIndexer3.ts, 2, 16)) + +interface Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer3.ts, 2, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer3.ts, 0, 0)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithNumericIndexer3.ts, 3, 32)) + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer3.ts, 3, 47)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer3.ts, 2, 31)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithNumericIndexer3.ts, 4, 36)) + +class A { +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer3.ts, 4, 51)) + + [x: number]: Derived; +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer3.ts, 7, 5)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer3.ts, 2, 31)) +} + +var a: A; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 10, 3)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer3.ts, 4, 51)) + +var b: { [x: number]: Base; }; +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer3.ts, 11, 3)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer3.ts, 11, 10)) +>Base : Symbol(Base, Decl(assignmentCompatWithNumericIndexer3.ts, 0, 0)) + +a = b; // error +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 10, 3)) +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer3.ts, 11, 3)) + +b = a; // ok +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer3.ts, 11, 3)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 10, 3)) + +class B2 extends A { +>B2 : Symbol(B2, Decl(assignmentCompatWithNumericIndexer3.ts, 14, 6)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer3.ts, 4, 51)) + + [x: number]: Derived2; // ok +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer3.ts, 17, 5)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer3.ts, 3, 47)) +} + +var b2: { [x: number]: Derived2; }; +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer3.ts, 20, 3)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer3.ts, 20, 11)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithNumericIndexer3.ts, 3, 47)) + +a = b2; // ok +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 10, 3)) +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer3.ts, 20, 3)) + +b2 = a; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer3.ts, 20, 3)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 10, 3)) + +module Generics { +>Generics : Symbol(Generics, Decl(assignmentCompatWithNumericIndexer3.ts, 22, 7)) + + class A { +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer3.ts, 24, 17)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer3.ts, 25, 12)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer3.ts, 2, 31)) + + [x: number]: T; +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer3.ts, 26, 9)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer3.ts, 25, 12)) + } + + function foo() { +>foo : Symbol(foo, Decl(assignmentCompatWithNumericIndexer3.ts, 27, 5)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer3.ts, 29, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer3.ts, 2, 31)) + + var a: A; +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 30, 11)) +>A : Symbol(A, Decl(assignmentCompatWithNumericIndexer3.ts, 24, 17)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer3.ts, 29, 17)) + + var b: { [x: number]: Derived; }; +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer3.ts, 31, 11)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer3.ts, 31, 18)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithNumericIndexer3.ts, 2, 31)) + + a = b; // error +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 30, 11)) +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer3.ts, 31, 11)) + + b = a; // ok +>b : Symbol(b, Decl(assignmentCompatWithNumericIndexer3.ts, 31, 11)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 30, 11)) + + var b2: { [x: number]: T; }; +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer3.ts, 35, 11)) +>x : Symbol(x, Decl(assignmentCompatWithNumericIndexer3.ts, 35, 19)) +>T : Symbol(T, Decl(assignmentCompatWithNumericIndexer3.ts, 29, 17)) + + a = b2; // ok +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 30, 11)) +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer3.ts, 35, 11)) + + b2 = a; // ok +>b2 : Symbol(b2, Decl(assignmentCompatWithNumericIndexer3.ts, 35, 11)) +>a : Symbol(a, Decl(assignmentCompatWithNumericIndexer3.ts, 30, 11)) + } +} diff --git a/tests/baselines/reference/assignmentCompatWithNumericIndexer3.types b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.types new file mode 100644 index 00000000000..3f7b0549254 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithNumericIndexer3.types @@ -0,0 +1,122 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithNumericIndexer3.ts === +// Derived type indexer must be subtype of base type indexer + +interface Base { foo: string; } +>Base : Base +>foo : string + +interface Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + +class A { +>A : A + + [x: number]: Derived; +>x : number +>Derived : Derived +} + +var a: A; +>a : A +>A : A + +var b: { [x: number]: Base; }; +>b : { [x: number]: Base; } +>x : number +>Base : Base + +a = b; // error +>a = b : { [x: number]: Base; } +>a : A +>b : { [x: number]: Base; } + +b = a; // ok +>b = a : A +>b : { [x: number]: Base; } +>a : A + +class B2 extends A { +>B2 : B2 +>A : A + + [x: number]: Derived2; // ok +>x : number +>Derived2 : Derived2 +} + +var b2: { [x: number]: Derived2; }; +>b2 : { [x: number]: Derived2; } +>x : number +>Derived2 : Derived2 + +a = b2; // ok +>a = b2 : { [x: number]: Derived2; } +>a : A +>b2 : { [x: number]: Derived2; } + +b2 = a; // error +>b2 = a : A +>b2 : { [x: number]: Derived2; } +>a : A + +module Generics { +>Generics : typeof Generics + + class A { +>A : A +>T : T +>Derived : Derived + + [x: number]: T; +>x : number +>T : T + } + + function foo() { +>foo : () => void +>T : T +>Derived : Derived + + var a: A; +>a : A +>A : A +>T : T + + var b: { [x: number]: Derived; }; +>b : { [x: number]: Derived; } +>x : number +>Derived : Derived + + a = b; // error +>a = b : { [x: number]: Derived; } +>a : A +>b : { [x: number]: Derived; } + + b = a; // ok +>b = a : A +>b : { [x: number]: Derived; } +>a : A + + var b2: { [x: number]: T; }; +>b2 : { [x: number]: T; } +>x : number +>T : T + + a = b2; // ok +>a = b2 : { [x: number]: T; } +>a : A +>b2 : { [x: number]: T; } + + b2 = a; // ok +>b2 = a : A +>b2 : { [x: number]: T; } +>a : A + } +} diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers4.symbols b/tests/baselines/reference/assignmentCompatWithObjectMembers4.symbols new file mode 100644 index 00000000000..845747216f8 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers4.symbols @@ -0,0 +1,302 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers4.ts === +// members N and M of types S and T have the same name, same accessibility, same optionality, and N is not assignable M + +module OnlyDerived { +>OnlyDerived : Symbol(OnlyDerived, Decl(assignmentCompatWithObjectMembers4.ts, 0, 0)) + + class Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 2, 20)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithObjectMembers4.ts, 3, 16)) + + class Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembers4.ts, 3, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 2, 20)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithObjectMembers4.ts, 4, 32)) + + class Derived2 extends Base { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 4, 47)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 2, 20)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithObjectMembers4.ts, 5, 33)) + + class S { foo: Derived; } +>S : Symbol(S, Decl(assignmentCompatWithObjectMembers4.ts, 5, 48)) +>foo : Symbol(S.foo, Decl(assignmentCompatWithObjectMembers4.ts, 7, 13)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembers4.ts, 3, 31)) + + class T { foo: Derived2; } +>T : Symbol(T, Decl(assignmentCompatWithObjectMembers4.ts, 7, 29)) +>foo : Symbol(T.foo, Decl(assignmentCompatWithObjectMembers4.ts, 8, 13)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 4, 47)) + + var s: S; +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 9, 7)) +>S : Symbol(S, Decl(assignmentCompatWithObjectMembers4.ts, 5, 48)) + + var t: T; +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 10, 7)) +>T : Symbol(T, Decl(assignmentCompatWithObjectMembers4.ts, 7, 29)) + + interface S2 { foo: Derived; } +>S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembers4.ts, 10, 13)) +>foo : Symbol(S2.foo, Decl(assignmentCompatWithObjectMembers4.ts, 12, 18)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembers4.ts, 3, 31)) + + interface T2 { foo: Derived2; } +>T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembers4.ts, 12, 34)) +>foo : Symbol(T2.foo, Decl(assignmentCompatWithObjectMembers4.ts, 13, 18)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 4, 47)) + + var s2: S2; +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 14, 7)) +>S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembers4.ts, 10, 13)) + + var t2: T2; +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembers4.ts, 15, 7)) +>T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembers4.ts, 12, 34)) + + var a: { foo: Derived; } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 17, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembers4.ts, 17, 12)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembers4.ts, 3, 31)) + + var b: { foo: Derived2; } +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 18, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembers4.ts, 18, 12)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 4, 47)) + + var a2 = { foo: new Derived() }; +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembers4.ts, 20, 14)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembers4.ts, 3, 31)) + + var b2 = { foo: new Derived2() }; +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembers4.ts, 21, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembers4.ts, 21, 14)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 4, 47)) + + s = t; // error +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 9, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 10, 7)) + + t = s; // error +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 10, 7)) +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 9, 7)) + + s = s2; // ok +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 9, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 14, 7)) + + s = a2; // ok +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 9, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) + + s2 = t2; // error +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 14, 7)) +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembers4.ts, 15, 7)) + + t2 = s2; // error +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembers4.ts, 15, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 14, 7)) + + s2 = t; // error +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 14, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 10, 7)) + + s2 = b; // error +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 14, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 18, 7)) + + s2 = a2; // ok +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 14, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) + + a = b; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 17, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 18, 7)) + + b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 18, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 17, 7)) + + a = s; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 17, 7)) +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 9, 7)) + + a = s2; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 17, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 14, 7)) + + a = a2; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 17, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) + + a2 = b2; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembers4.ts, 21, 7)) + + b2 = a2; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembers4.ts, 21, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) + + a2 = b; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 18, 7)) + + a2 = t2; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembers4.ts, 15, 7)) + + a2 = t; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 20, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 10, 7)) +} + +module WithBase { +>WithBase : Symbol(WithBase, Decl(assignmentCompatWithObjectMembers4.ts, 45, 1)) + + class Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 47, 17)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithObjectMembers4.ts, 48, 16)) + + class Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembers4.ts, 48, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 47, 17)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithObjectMembers4.ts, 49, 32)) + + class Derived2 extends Base { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 49, 47)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 47, 17)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithObjectMembers4.ts, 50, 33)) + + class S { foo: Base; } +>S : Symbol(S, Decl(assignmentCompatWithObjectMembers4.ts, 50, 48)) +>foo : Symbol(S.foo, Decl(assignmentCompatWithObjectMembers4.ts, 52, 13)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 47, 17)) + + class T { foo: Derived2; } +>T : Symbol(T, Decl(assignmentCompatWithObjectMembers4.ts, 52, 26)) +>foo : Symbol(T.foo, Decl(assignmentCompatWithObjectMembers4.ts, 53, 13)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 49, 47)) + + var s: S; +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 54, 7)) +>S : Symbol(S, Decl(assignmentCompatWithObjectMembers4.ts, 50, 48)) + + var t: T; +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 55, 7)) +>T : Symbol(T, Decl(assignmentCompatWithObjectMembers4.ts, 52, 26)) + + interface S2 { foo: Base; } +>S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembers4.ts, 55, 13)) +>foo : Symbol(S2.foo, Decl(assignmentCompatWithObjectMembers4.ts, 57, 18)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 47, 17)) + + interface T2 { foo: Derived2; } +>T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembers4.ts, 57, 31)) +>foo : Symbol(T2.foo, Decl(assignmentCompatWithObjectMembers4.ts, 58, 18)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 49, 47)) + + var s2: S2; +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 59, 7)) +>S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembers4.ts, 55, 13)) + + var t2: T2; +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembers4.ts, 60, 7)) +>T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembers4.ts, 57, 31)) + + var a: { foo: Base; } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 62, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembers4.ts, 62, 12)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 47, 17)) + + var b: { foo: Derived2; } +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 63, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembers4.ts, 63, 12)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 49, 47)) + + var a2 = { foo: new Base() }; +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembers4.ts, 65, 14)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembers4.ts, 47, 17)) + + var b2 = { foo: new Derived2() }; +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembers4.ts, 66, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembers4.ts, 66, 14)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembers4.ts, 49, 47)) + + s = t; // ok +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 54, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 55, 7)) + + t = s; // error +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 55, 7)) +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 54, 7)) + + s = s2; // ok +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 54, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 59, 7)) + + s = a2; // ok +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 54, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) + + s2 = t2; // ok +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 59, 7)) +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembers4.ts, 60, 7)) + + t2 = s2; // error +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembers4.ts, 60, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 59, 7)) + + s2 = t; // ok +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 59, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 55, 7)) + + s2 = b; // ok +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 59, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 63, 7)) + + s2 = a2; // ok +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 59, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) + + a = b; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 62, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 63, 7)) + + b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 63, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 62, 7)) + + a = s; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 62, 7)) +>s : Symbol(s, Decl(assignmentCompatWithObjectMembers4.ts, 54, 7)) + + a = s2; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 62, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembers4.ts, 59, 7)) + + a = a2; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembers4.ts, 62, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) + + a2 = b2; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembers4.ts, 66, 7)) + + b2 = a2; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembers4.ts, 66, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) + + a2 = b; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembers4.ts, 63, 7)) + + a2 = t2; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembers4.ts, 60, 7)) + + a2 = t; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembers4.ts, 65, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembers4.ts, 55, 7)) +} diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers4.types b/tests/baselines/reference/assignmentCompatWithObjectMembers4.types new file mode 100644 index 00000000000..1d7fb3eae7b --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers4.types @@ -0,0 +1,348 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers4.ts === +// members N and M of types S and T have the same name, same accessibility, same optionality, and N is not assignable M + +module OnlyDerived { +>OnlyDerived : typeof OnlyDerived + + class Base { foo: string; } +>Base : Base +>foo : string + + class Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + + class Derived2 extends Base { baz: string; } +>Derived2 : Derived2 +>Base : Base +>baz : string + + class S { foo: Derived; } +>S : S +>foo : Derived +>Derived : Derived + + class T { foo: Derived2; } +>T : T +>foo : Derived2 +>Derived2 : Derived2 + + var s: S; +>s : S +>S : S + + var t: T; +>t : T +>T : T + + interface S2 { foo: Derived; } +>S2 : S2 +>foo : Derived +>Derived : Derived + + interface T2 { foo: Derived2; } +>T2 : T2 +>foo : Derived2 +>Derived2 : Derived2 + + var s2: S2; +>s2 : S2 +>S2 : S2 + + var t2: T2; +>t2 : T2 +>T2 : T2 + + var a: { foo: Derived; } +>a : { foo: Derived; } +>foo : Derived +>Derived : Derived + + var b: { foo: Derived2; } +>b : { foo: Derived2; } +>foo : Derived2 +>Derived2 : Derived2 + + var a2 = { foo: new Derived() }; +>a2 : { foo: Derived; } +>{ foo: new Derived() } : { foo: Derived; } +>foo : Derived +>new Derived() : Derived +>Derived : typeof Derived + + var b2 = { foo: new Derived2() }; +>b2 : { foo: Derived2; } +>{ foo: new Derived2() } : { foo: Derived2; } +>foo : Derived2 +>new Derived2() : Derived2 +>Derived2 : typeof Derived2 + + s = t; // error +>s = t : T +>s : S +>t : T + + t = s; // error +>t = s : S +>t : T +>s : S + + s = s2; // ok +>s = s2 : S2 +>s : S +>s2 : S2 + + s = a2; // ok +>s = a2 : { foo: Derived; } +>s : S +>a2 : { foo: Derived; } + + s2 = t2; // error +>s2 = t2 : T2 +>s2 : S2 +>t2 : T2 + + t2 = s2; // error +>t2 = s2 : S2 +>t2 : T2 +>s2 : S2 + + s2 = t; // error +>s2 = t : T +>s2 : S2 +>t : T + + s2 = b; // error +>s2 = b : { foo: Derived2; } +>s2 : S2 +>b : { foo: Derived2; } + + s2 = a2; // ok +>s2 = a2 : { foo: Derived; } +>s2 : S2 +>a2 : { foo: Derived; } + + a = b; // error +>a = b : { foo: Derived2; } +>a : { foo: Derived; } +>b : { foo: Derived2; } + + b = a; // error +>b = a : { foo: Derived; } +>b : { foo: Derived2; } +>a : { foo: Derived; } + + a = s; // ok +>a = s : S +>a : { foo: Derived; } +>s : S + + a = s2; // ok +>a = s2 : S2 +>a : { foo: Derived; } +>s2 : S2 + + a = a2; // ok +>a = a2 : { foo: Derived; } +>a : { foo: Derived; } +>a2 : { foo: Derived; } + + a2 = b2; // error +>a2 = b2 : { foo: Derived2; } +>a2 : { foo: Derived; } +>b2 : { foo: Derived2; } + + b2 = a2; // error +>b2 = a2 : { foo: Derived; } +>b2 : { foo: Derived2; } +>a2 : { foo: Derived; } + + a2 = b; // error +>a2 = b : { foo: Derived2; } +>a2 : { foo: Derived; } +>b : { foo: Derived2; } + + a2 = t2; // error +>a2 = t2 : T2 +>a2 : { foo: Derived; } +>t2 : T2 + + a2 = t; // error +>a2 = t : T +>a2 : { foo: Derived; } +>t : T +} + +module WithBase { +>WithBase : typeof WithBase + + class Base { foo: string; } +>Base : Base +>foo : string + + class Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + + class Derived2 extends Base { baz: string; } +>Derived2 : Derived2 +>Base : Base +>baz : string + + class S { foo: Base; } +>S : S +>foo : Base +>Base : Base + + class T { foo: Derived2; } +>T : T +>foo : Derived2 +>Derived2 : Derived2 + + var s: S; +>s : S +>S : S + + var t: T; +>t : T +>T : T + + interface S2 { foo: Base; } +>S2 : S2 +>foo : Base +>Base : Base + + interface T2 { foo: Derived2; } +>T2 : T2 +>foo : Derived2 +>Derived2 : Derived2 + + var s2: S2; +>s2 : S2 +>S2 : S2 + + var t2: T2; +>t2 : T2 +>T2 : T2 + + var a: { foo: Base; } +>a : { foo: Base; } +>foo : Base +>Base : Base + + var b: { foo: Derived2; } +>b : { foo: Derived2; } +>foo : Derived2 +>Derived2 : Derived2 + + var a2 = { foo: new Base() }; +>a2 : { foo: Base; } +>{ foo: new Base() } : { foo: Base; } +>foo : Base +>new Base() : Base +>Base : typeof Base + + var b2 = { foo: new Derived2() }; +>b2 : { foo: Derived2; } +>{ foo: new Derived2() } : { foo: Derived2; } +>foo : Derived2 +>new Derived2() : Derived2 +>Derived2 : typeof Derived2 + + s = t; // ok +>s = t : T +>s : S +>t : T + + t = s; // error +>t = s : S +>t : T +>s : S + + s = s2; // ok +>s = s2 : S2 +>s : S +>s2 : S2 + + s = a2; // ok +>s = a2 : { foo: Base; } +>s : S +>a2 : { foo: Base; } + + s2 = t2; // ok +>s2 = t2 : T2 +>s2 : S2 +>t2 : T2 + + t2 = s2; // error +>t2 = s2 : S2 +>t2 : T2 +>s2 : S2 + + s2 = t; // ok +>s2 = t : T +>s2 : S2 +>t : T + + s2 = b; // ok +>s2 = b : { foo: Derived2; } +>s2 : S2 +>b : { foo: Derived2; } + + s2 = a2; // ok +>s2 = a2 : { foo: Base; } +>s2 : S2 +>a2 : { foo: Base; } + + a = b; // ok +>a = b : { foo: Derived2; } +>a : { foo: Base; } +>b : { foo: Derived2; } + + b = a; // error +>b = a : { foo: Base; } +>b : { foo: Derived2; } +>a : { foo: Base; } + + a = s; // ok +>a = s : S +>a : { foo: Base; } +>s : S + + a = s2; // ok +>a = s2 : S2 +>a : { foo: Base; } +>s2 : S2 + + a = a2; // ok +>a = a2 : { foo: Base; } +>a : { foo: Base; } +>a2 : { foo: Base; } + + a2 = b2; // ok +>a2 = b2 : { foo: Derived2; } +>a2 : { foo: Base; } +>b2 : { foo: Derived2; } + + b2 = a2; // error +>b2 = a2 : { foo: Base; } +>b2 : { foo: Derived2; } +>a2 : { foo: Base; } + + a2 = b; // ok +>a2 = b : { foo: Derived2; } +>a2 : { foo: Base; } +>b : { foo: Derived2; } + + a2 = t2; // ok +>a2 = t2 : T2 +>a2 : { foo: Base; } +>t2 : T2 + + a2 = t; // ok +>a2 = t : T +>a2 : { foo: Base; } +>t : T +} diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers5.symbols b/tests/baselines/reference/assignmentCompatWithObjectMembers5.symbols new file mode 100644 index 00000000000..541f2b72b58 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers5.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers5.ts === +class C { +>C : Symbol(C, Decl(assignmentCompatWithObjectMembers5.ts, 0, 0)) + + foo: string; +>foo : Symbol(C.foo, Decl(assignmentCompatWithObjectMembers5.ts, 0, 9)) +} + +var c: C; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembers5.ts, 4, 3)) +>C : Symbol(C, Decl(assignmentCompatWithObjectMembers5.ts, 0, 0)) + +interface I { +>I : Symbol(I, Decl(assignmentCompatWithObjectMembers5.ts, 4, 9)) + + fooo: string; +>fooo : Symbol(I.fooo, Decl(assignmentCompatWithObjectMembers5.ts, 6, 13)) +} + +var i: I; +>i : Symbol(i, Decl(assignmentCompatWithObjectMembers5.ts, 10, 3)) +>I : Symbol(I, Decl(assignmentCompatWithObjectMembers5.ts, 4, 9)) + +c = i; // error +>c : Symbol(c, Decl(assignmentCompatWithObjectMembers5.ts, 4, 3)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembers5.ts, 10, 3)) + +i = c; // error +>i : Symbol(i, Decl(assignmentCompatWithObjectMembers5.ts, 10, 3)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembers5.ts, 4, 3)) + diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers5.types b/tests/baselines/reference/assignmentCompatWithObjectMembers5.types new file mode 100644 index 00000000000..87c213ff0fd --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers5.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembers5.ts === +class C { +>C : C + + foo: string; +>foo : string +} + +var c: C; +>c : C +>C : C + +interface I { +>I : I + + fooo: string; +>fooo : string +} + +var i: I; +>i : I +>I : I + +c = i; // error +>c = i : I +>c : C +>i : I + +i = c; // error +>i = c : C +>i : I +>c : C + diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.symbols b/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.symbols new file mode 100644 index 00000000000..f1ec2133314 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.symbols @@ -0,0 +1,285 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts === +// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M + +module TargetIsPublic { +>TargetIsPublic : Symbol(TargetIsPublic, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 0, 0), Decl(assignmentCompatWithObjectMembersAccessibility.ts, 53, 1)) + + // targets + class Base { +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 2, 23)) + + public foo: string; +>foo : Symbol(Base.foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 4, 16)) + } + + interface I { +>I : Symbol(I, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 6, 5)) + + foo: string; +>foo : Symbol(I.foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 8, 17)) + } + + var a: { foo: string; } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 12)) + + var b: Base; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 2, 23)) + + var i: I; +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) +>I : Symbol(I, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 6, 5)) + + // sources + class D { +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 13)) + + public foo: string; +>foo : Symbol(D.foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 17, 13)) + } + + class E { +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 19, 5)) + + private foo: string; +>foo : Symbol(E.foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 21, 13)) + } + var d: D; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 13)) + + var e: E; +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 19, 5)) + + a = b; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) + + a = i; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) + + a = d; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) + + a = e; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) + + b = a; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) + + b = i; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) + + b = d; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) + + b = e; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) + + i = a; +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) + + i = b; +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) + + i = d; +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) + + i = e; // error +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) + + d = a; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) + + d = b; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) + + d = i; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) + + d = e; // error +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) + + e = a; // errror +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 12, 7)) + + e = b; // errror +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 13, 7)) + + e = i; // errror +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 14, 7)) + + e = d; // errror +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 24, 7)) + + e = e; +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 25, 7)) + +} + +module TargetIsPublic { +>TargetIsPublic : Symbol(TargetIsPublic, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 0, 0), Decl(assignmentCompatWithObjectMembersAccessibility.ts, 53, 1)) + + // targets + class Base { +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 55, 23)) + + private foo: string; +>foo : Symbol(Base.foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 57, 16)) + } + + interface I extends Base { +>I : Symbol(I, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 59, 5)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 55, 23)) + } + + var a: { foo: string; } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) +>foo : Symbol(foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 12)) + + var b: Base; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 55, 23)) + + var i: I; +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) +>I : Symbol(I, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 59, 5)) + + // sources + class D { +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 13)) + + public foo: string; +>foo : Symbol(D.foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 69, 13)) + } + + class E { +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 71, 5)) + + private foo: string; +>foo : Symbol(E.foo, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 73, 13)) + } + + var d: D; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 13)) + + var e: E; +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 71, 5)) + + a = b; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) + + a = i; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) + + a = d; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) + + a = e; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) + + b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) + + b = i; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) + + b = d; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) + + b = e; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) + + b = b; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) + + i = a; // error +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) + + i = b; +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) + + i = d; // error +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) + + i = e; // error +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) + + i = i; +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) + + d = a; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) + + d = b; // error +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) + + d = i; // error +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) + + d = e; // error +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) + + e = a; // errror +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 64, 7)) + + e = b; // errror +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 65, 7)) + + e = i; // errror +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) +>i : Symbol(i, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 66, 7)) + + e = d; // errror +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 77, 7)) + + e = e; +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersAccessibility.ts, 78, 7)) + +} diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.types b/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.types new file mode 100644 index 00000000000..ec65f474f20 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersAccessibility.types @@ -0,0 +1,329 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersAccessibility.ts === +// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M + +module TargetIsPublic { +>TargetIsPublic : typeof TargetIsPublic + + // targets + class Base { +>Base : Base + + public foo: string; +>foo : string + } + + interface I { +>I : I + + foo: string; +>foo : string + } + + var a: { foo: string; } +>a : { foo: string; } +>foo : string + + var b: Base; +>b : Base +>Base : Base + + var i: I; +>i : I +>I : I + + // sources + class D { +>D : D + + public foo: string; +>foo : string + } + + class E { +>E : E + + private foo: string; +>foo : string + } + var d: D; +>d : D +>D : D + + var e: E; +>e : E +>E : E + + a = b; +>a = b : Base +>a : { foo: string; } +>b : Base + + a = i; +>a = i : I +>a : { foo: string; } +>i : I + + a = d; +>a = d : D +>a : { foo: string; } +>d : D + + a = e; // error +>a = e : E +>a : { foo: string; } +>e : E + + b = a; +>b = a : { foo: string; } +>b : Base +>a : { foo: string; } + + b = i; +>b = i : I +>b : Base +>i : I + + b = d; +>b = d : D +>b : Base +>d : D + + b = e; // error +>b = e : E +>b : Base +>e : E + + i = a; +>i = a : { foo: string; } +>i : I +>a : { foo: string; } + + i = b; +>i = b : Base +>i : I +>b : Base + + i = d; +>i = d : D +>i : I +>d : D + + i = e; // error +>i = e : E +>i : I +>e : E + + d = a; +>d = a : { foo: string; } +>d : D +>a : { foo: string; } + + d = b; +>d = b : Base +>d : D +>b : Base + + d = i; +>d = i : I +>d : D +>i : I + + d = e; // error +>d = e : E +>d : D +>e : E + + e = a; // errror +>e = a : { foo: string; } +>e : E +>a : { foo: string; } + + e = b; // errror +>e = b : Base +>e : E +>b : Base + + e = i; // errror +>e = i : I +>e : E +>i : I + + e = d; // errror +>e = d : D +>e : E +>d : D + + e = e; +>e = e : E +>e : E +>e : E + +} + +module TargetIsPublic { +>TargetIsPublic : typeof TargetIsPublic + + // targets + class Base { +>Base : Base + + private foo: string; +>foo : string + } + + interface I extends Base { +>I : I +>Base : Base + } + + var a: { foo: string; } +>a : { foo: string; } +>foo : string + + var b: Base; +>b : Base +>Base : Base + + var i: I; +>i : I +>I : I + + // sources + class D { +>D : D + + public foo: string; +>foo : string + } + + class E { +>E : E + + private foo: string; +>foo : string + } + + var d: D; +>d : D +>D : D + + var e: E; +>e : E +>E : E + + a = b; // error +>a = b : Base +>a : { foo: string; } +>b : Base + + a = i; // error +>a = i : I +>a : { foo: string; } +>i : I + + a = d; +>a = d : D +>a : { foo: string; } +>d : D + + a = e; // error +>a = e : E +>a : { foo: string; } +>e : E + + b = a; // error +>b = a : { foo: string; } +>b : Base +>a : { foo: string; } + + b = i; +>b = i : I +>b : Base +>i : I + + b = d; // error +>b = d : D +>b : Base +>d : D + + b = e; // error +>b = e : E +>b : Base +>e : E + + b = b; +>b = b : Base +>b : Base +>b : Base + + i = a; // error +>i = a : { foo: string; } +>i : I +>a : { foo: string; } + + i = b; +>i = b : Base +>i : I +>b : Base + + i = d; // error +>i = d : D +>i : I +>d : D + + i = e; // error +>i = e : E +>i : I +>e : E + + i = i; +>i = i : I +>i : I +>i : I + + d = a; +>d = a : { foo: string; } +>d : D +>a : { foo: string; } + + d = b; // error +>d = b : Base +>d : D +>b : Base + + d = i; // error +>d = i : I +>d : D +>i : I + + d = e; // error +>d = e : E +>d : D +>e : E + + e = a; // errror +>e = a : { foo: string; } +>e : E +>a : { foo: string; } + + e = b; // errror +>e = b : Base +>e : E +>b : Base + + e = i; // errror +>e = i : I +>e : E +>i : I + + e = d; // errror +>e = d : D +>e : E +>d : D + + e = e; +>e = e : E +>e : E +>e : E + +} diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.symbols b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.symbols new file mode 100644 index 00000000000..f3271f0e9c3 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.symbols @@ -0,0 +1,242 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts === +// Derived member is not optional but base member is, should be ok + +class Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithObjectMembersOptionality.ts, 2, 12)) + +class Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality.ts, 2, 27)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithObjectMembersOptionality.ts, 3, 28)) + +class Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembersOptionality.ts, 3, 43)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality.ts, 2, 27)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithObjectMembersOptionality.ts, 4, 32)) + +module TargetHasOptional { +>TargetHasOptional : Symbol(TargetHasOptional, Decl(assignmentCompatWithObjectMembersOptionality.ts, 4, 47)) + + // targets + interface C { +>C : Symbol(C, Decl(assignmentCompatWithObjectMembersOptionality.ts, 6, 26)) + + opt?: Base +>opt : Symbol(C.opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 8, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) + } + var c: C; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 11, 7)) +>C : Symbol(C, Decl(assignmentCompatWithObjectMembersOptionality.ts, 6, 26)) + + var a: { opt?: Base; } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 7)) +>opt : Symbol(opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 12)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) + + var b: typeof a = { opt: new Base() } +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 7)) +>opt : Symbol(opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 23)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) + + // sources + interface D { +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 41)) + + opt: Base; +>opt : Symbol(D.opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 17, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) + } + interface E { +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersOptionality.ts, 19, 5)) + + opt: Derived; +>opt : Symbol(E.opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 20, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality.ts, 2, 27)) + } + interface F { +>F : Symbol(F, Decl(assignmentCompatWithObjectMembersOptionality.ts, 22, 5)) + + opt?: Derived; +>opt : Symbol(F.opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 23, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality.ts, 2, 27)) + } + var d: D; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality.ts, 26, 7)) +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 41)) + + var e: E; +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality.ts, 27, 7)) +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersOptionality.ts, 19, 5)) + + var f: F; +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality.ts, 28, 7)) +>F : Symbol(F, Decl(assignmentCompatWithObjectMembersOptionality.ts, 22, 5)) + + // all ok + c = d; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 11, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality.ts, 26, 7)) + + c = e; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 11, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality.ts, 27, 7)) + + c = f; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 11, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality.ts, 28, 7)) + + c = a; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 11, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 7)) + + a = d; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality.ts, 26, 7)) + + a = e; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality.ts, 27, 7)) + + a = f; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality.ts, 28, 7)) + + a = c; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 7)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 11, 7)) + + b = d; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality.ts, 26, 7)) + + b = e; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality.ts, 27, 7)) + + b = f; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality.ts, 28, 7)) + + b = a; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 13, 7)) + + b = c; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 14, 7)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 11, 7)) +} + +module SourceHasOptional { +>SourceHasOptional : Symbol(SourceHasOptional, Decl(assignmentCompatWithObjectMembersOptionality.ts, 46, 1)) + + // targets + interface C { +>C : Symbol(C, Decl(assignmentCompatWithObjectMembersOptionality.ts, 48, 26)) + + opt: Base +>opt : Symbol(C.opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 50, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) + } + var c: C; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 53, 7)) +>C : Symbol(C, Decl(assignmentCompatWithObjectMembersOptionality.ts, 48, 26)) + + var a: { opt: Base; } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 55, 7)) +>opt : Symbol(opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 55, 12)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) + + var b = { opt: new Base() } +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 7)) +>opt : Symbol(opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 13)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) + + // sources + interface D { +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 31)) + + opt?: Base; +>opt : Symbol(D.opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 59, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality.ts, 0, 0)) + } + interface E { +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersOptionality.ts, 61, 5)) + + opt?: Derived; +>opt : Symbol(E.opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 62, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality.ts, 2, 27)) + } + interface F { +>F : Symbol(F, Decl(assignmentCompatWithObjectMembersOptionality.ts, 64, 5)) + + opt: Derived; +>opt : Symbol(F.opt, Decl(assignmentCompatWithObjectMembersOptionality.ts, 65, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality.ts, 2, 27)) + } + var d: D; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality.ts, 68, 7)) +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 31)) + + var e: E; +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality.ts, 69, 7)) +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersOptionality.ts, 61, 5)) + + var f: F; +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality.ts, 70, 7)) +>F : Symbol(F, Decl(assignmentCompatWithObjectMembersOptionality.ts, 64, 5)) + + c = d; // error +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 53, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality.ts, 68, 7)) + + c = e; // error +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 53, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality.ts, 69, 7)) + + c = f; // ok +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 53, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality.ts, 70, 7)) + + c = a; // ok +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 53, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 55, 7)) + + a = d; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 55, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality.ts, 68, 7)) + + a = e; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 55, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality.ts, 69, 7)) + + a = f; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 55, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality.ts, 70, 7)) + + a = c; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 55, 7)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 53, 7)) + + b = d; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality.ts, 68, 7)) + + b = e; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality.ts, 69, 7)) + + b = f; // ok +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality.ts, 70, 7)) + + b = a; // ok +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality.ts, 55, 7)) + + b = c; // ok +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality.ts, 56, 7)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality.ts, 53, 7)) +} diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.types b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.types new file mode 100644 index 00000000000..8727b7567b6 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality.types @@ -0,0 +1,272 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality.ts === +// Derived member is not optional but base member is, should be ok + +class Base { foo: string; } +>Base : Base +>foo : string + +class Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + +class Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + +module TargetHasOptional { +>TargetHasOptional : typeof TargetHasOptional + + // targets + interface C { +>C : C + + opt?: Base +>opt : Base +>Base : Base + } + var c: C; +>c : C +>C : C + + var a: { opt?: Base; } +>a : { opt?: Base; } +>opt : Base +>Base : Base + + var b: typeof a = { opt: new Base() } +>b : { opt?: Base; } +>a : { opt?: Base; } +>{ opt: new Base() } : { opt: Base; } +>opt : Base +>new Base() : Base +>Base : typeof Base + + // sources + interface D { +>D : D + + opt: Base; +>opt : Base +>Base : Base + } + interface E { +>E : E + + opt: Derived; +>opt : Derived +>Derived : Derived + } + interface F { +>F : F + + opt?: Derived; +>opt : Derived +>Derived : Derived + } + var d: D; +>d : D +>D : D + + var e: E; +>e : E +>E : E + + var f: F; +>f : F +>F : F + + // all ok + c = d; +>c = d : D +>c : C +>d : D + + c = e; +>c = e : E +>c : C +>e : E + + c = f; +>c = f : F +>c : C +>f : F + + c = a; +>c = a : { opt?: Base; } +>c : C +>a : { opt?: Base; } + + a = d; +>a = d : D +>a : { opt?: Base; } +>d : D + + a = e; +>a = e : E +>a : { opt?: Base; } +>e : E + + a = f; +>a = f : F +>a : { opt?: Base; } +>f : F + + a = c; +>a = c : C +>a : { opt?: Base; } +>c : C + + b = d; +>b = d : D +>b : { opt?: Base; } +>d : D + + b = e; +>b = e : E +>b : { opt?: Base; } +>e : E + + b = f; +>b = f : F +>b : { opt?: Base; } +>f : F + + b = a; +>b = a : { opt?: Base; } +>b : { opt?: Base; } +>a : { opt?: Base; } + + b = c; +>b = c : C +>b : { opt?: Base; } +>c : C +} + +module SourceHasOptional { +>SourceHasOptional : typeof SourceHasOptional + + // targets + interface C { +>C : C + + opt: Base +>opt : Base +>Base : Base + } + var c: C; +>c : C +>C : C + + var a: { opt: Base; } +>a : { opt: Base; } +>opt : Base +>Base : Base + + var b = { opt: new Base() } +>b : { opt: Base; } +>{ opt: new Base() } : { opt: Base; } +>opt : Base +>new Base() : Base +>Base : typeof Base + + // sources + interface D { +>D : D + + opt?: Base; +>opt : Base +>Base : Base + } + interface E { +>E : E + + opt?: Derived; +>opt : Derived +>Derived : Derived + } + interface F { +>F : F + + opt: Derived; +>opt : Derived +>Derived : Derived + } + var d: D; +>d : D +>D : D + + var e: E; +>e : E +>E : E + + var f: F; +>f : F +>F : F + + c = d; // error +>c = d : D +>c : C +>d : D + + c = e; // error +>c = e : E +>c : C +>e : E + + c = f; // ok +>c = f : F +>c : C +>f : F + + c = a; // ok +>c = a : { opt: Base; } +>c : C +>a : { opt: Base; } + + a = d; // error +>a = d : D +>a : { opt: Base; } +>d : D + + a = e; // error +>a = e : E +>a : { opt: Base; } +>e : E + + a = f; // ok +>a = f : F +>a : { opt: Base; } +>f : F + + a = c; // ok +>a = c : C +>a : { opt: Base; } +>c : C + + b = d; // error +>b = d : D +>b : { opt: Base; } +>d : D + + b = e; // error +>b = e : E +>b : { opt: Base; } +>e : E + + b = f; // ok +>b = f : F +>b : { opt: Base; } +>f : F + + b = a; // ok +>b = a : { opt: Base; } +>b : { opt: Base; } +>a : { opt: Base; } + + b = c; // ok +>b = c : C +>b : { opt: Base; } +>c : C +} diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.symbols b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.symbols new file mode 100644 index 00000000000..b303c168408 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.symbols @@ -0,0 +1,245 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts === +// M is optional and S contains no property with the same name as M +// N is optional and T contains no property with the same name as N + +class Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 3, 12)) + +class Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 3, 27)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 4, 28)) + +class Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 4, 43)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 3, 27)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 5, 32)) + +module TargetHasOptional { +>TargetHasOptional : Symbol(TargetHasOptional, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 5, 47)) + + // targets + interface C { +>C : Symbol(C, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 7, 26)) + + opt?: Base +>opt : Symbol(C.opt, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 9, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) + } + var c: C; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 12, 7)) +>C : Symbol(C, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 7, 26)) + + var a: { opt?: Base; } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 7)) +>opt : Symbol(opt, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 12)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) + + var b: typeof a = { opt: new Base() } +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 7)) +>opt : Symbol(opt, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 23)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) + + // sources + interface D { +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 41)) + + other: Base; +>other : Symbol(D.other, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 18, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) + } + interface E { +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 20, 5)) + + other: Derived; +>other : Symbol(E.other, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 21, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 3, 27)) + } + interface F { +>F : Symbol(F, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 23, 5)) + + other?: Derived; +>other : Symbol(F.other, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 24, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 3, 27)) + } + var d: D; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 27, 7)) +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 41)) + + var e: E; +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 28, 7)) +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 20, 5)) + + var f: F; +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 29, 7)) +>F : Symbol(F, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 23, 5)) + + // disallowed by weak type checking + c = d; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 12, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 27, 7)) + + c = e; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 12, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 28, 7)) + + c = f; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 12, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 29, 7)) + + a = d; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 27, 7)) + + a = e; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 28, 7)) + + a = f; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 29, 7)) + + b = d; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 27, 7)) + + b = e; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 28, 7)) + + b = f; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 29, 7)) + + // ok + c = a; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 12, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 7)) + + a = c; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 7)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 12, 7)) + + b = a; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 14, 7)) + + b = c; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 15, 7)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 12, 7)) +} + +module SourceHasOptional { +>SourceHasOptional : Symbol(SourceHasOptional, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 47, 1)) + + // targets + interface C { +>C : Symbol(C, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 49, 26)) + + opt: Base +>opt : Symbol(C.opt, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 51, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) + } + var c: C; +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 54, 7)) +>C : Symbol(C, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 49, 26)) + + var a: { opt: Base; } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 56, 7)) +>opt : Symbol(opt, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 56, 12)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) + + var b = { opt: new Base() } +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 7)) +>opt : Symbol(opt, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 13)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) + + // sources + interface D { +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 31)) + + other?: Base; +>other : Symbol(D.other, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 60, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 0, 0)) + } + interface E { +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 62, 5)) + + other?: Derived; +>other : Symbol(E.other, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 63, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 3, 27)) + } + interface F { +>F : Symbol(F, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 65, 5)) + + other: Derived; +>other : Symbol(F.other, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 66, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 3, 27)) + } + var d: D; +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 69, 7)) +>D : Symbol(D, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 31)) + + var e: E; +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 70, 7)) +>E : Symbol(E, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 62, 5)) + + var f: F; +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 71, 7)) +>F : Symbol(F, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 65, 5)) + + c = d; // error +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 54, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 69, 7)) + + c = e; // error +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 54, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 70, 7)) + + c = f; // error +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 54, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 71, 7)) + + c = a; // ok +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 54, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 56, 7)) + + a = d; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 56, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 69, 7)) + + a = e; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 56, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 70, 7)) + + a = f; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 56, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 71, 7)) + + a = c; // ok +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 56, 7)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 54, 7)) + + b = d; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 7)) +>d : Symbol(d, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 69, 7)) + + b = e; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 7)) +>e : Symbol(e, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 70, 7)) + + b = f; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 7)) +>f : Symbol(f, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 71, 7)) + + b = a; // ok +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 56, 7)) + + b = c; // ok +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 57, 7)) +>c : Symbol(c, Decl(assignmentCompatWithObjectMembersOptionality2.ts, 54, 7)) +} + diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.types b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.types new file mode 100644 index 00000000000..3481816b544 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersOptionality2.types @@ -0,0 +1,275 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersOptionality2.ts === +// M is optional and S contains no property with the same name as M +// N is optional and T contains no property with the same name as N + +class Base { foo: string; } +>Base : Base +>foo : string + +class Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + +class Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + +module TargetHasOptional { +>TargetHasOptional : typeof TargetHasOptional + + // targets + interface C { +>C : C + + opt?: Base +>opt : Base +>Base : Base + } + var c: C; +>c : C +>C : C + + var a: { opt?: Base; } +>a : { opt?: Base; } +>opt : Base +>Base : Base + + var b: typeof a = { opt: new Base() } +>b : { opt?: Base; } +>a : { opt?: Base; } +>{ opt: new Base() } : { opt: Base; } +>opt : Base +>new Base() : Base +>Base : typeof Base + + // sources + interface D { +>D : D + + other: Base; +>other : Base +>Base : Base + } + interface E { +>E : E + + other: Derived; +>other : Derived +>Derived : Derived + } + interface F { +>F : F + + other?: Derived; +>other : Derived +>Derived : Derived + } + var d: D; +>d : D +>D : D + + var e: E; +>e : E +>E : E + + var f: F; +>f : F +>F : F + + // disallowed by weak type checking + c = d; +>c = d : D +>c : C +>d : D + + c = e; +>c = e : E +>c : C +>e : E + + c = f; +>c = f : F +>c : C +>f : F + + a = d; +>a = d : D +>a : { opt?: Base; } +>d : D + + a = e; +>a = e : E +>a : { opt?: Base; } +>e : E + + a = f; +>a = f : F +>a : { opt?: Base; } +>f : F + + b = d; +>b = d : D +>b : { opt?: Base; } +>d : D + + b = e; +>b = e : E +>b : { opt?: Base; } +>e : E + + b = f; +>b = f : F +>b : { opt?: Base; } +>f : F + + // ok + c = a; +>c = a : { opt?: Base; } +>c : C +>a : { opt?: Base; } + + a = c; +>a = c : C +>a : { opt?: Base; } +>c : C + + b = a; +>b = a : { opt?: Base; } +>b : { opt?: Base; } +>a : { opt?: Base; } + + b = c; +>b = c : C +>b : { opt?: Base; } +>c : C +} + +module SourceHasOptional { +>SourceHasOptional : typeof SourceHasOptional + + // targets + interface C { +>C : C + + opt: Base +>opt : Base +>Base : Base + } + var c: C; +>c : C +>C : C + + var a: { opt: Base; } +>a : { opt: Base; } +>opt : Base +>Base : Base + + var b = { opt: new Base() } +>b : { opt: Base; } +>{ opt: new Base() } : { opt: Base; } +>opt : Base +>new Base() : Base +>Base : typeof Base + + // sources + interface D { +>D : D + + other?: Base; +>other : Base +>Base : Base + } + interface E { +>E : E + + other?: Derived; +>other : Derived +>Derived : Derived + } + interface F { +>F : F + + other: Derived; +>other : Derived +>Derived : Derived + } + var d: D; +>d : D +>D : D + + var e: E; +>e : E +>E : E + + var f: F; +>f : F +>F : F + + c = d; // error +>c = d : D +>c : C +>d : D + + c = e; // error +>c = e : E +>c : C +>e : E + + c = f; // error +>c = f : F +>c : C +>f : F + + c = a; // ok +>c = a : { opt: Base; } +>c : C +>a : { opt: Base; } + + a = d; // error +>a = d : D +>a : { opt: Base; } +>d : D + + a = e; // error +>a = e : E +>a : { opt: Base; } +>e : E + + a = f; // error +>a = f : F +>a : { opt: Base; } +>f : F + + a = c; // ok +>a = c : C +>a : { opt: Base; } +>c : C + + b = d; // error +>b = d : D +>b : { opt: Base; } +>d : D + + b = e; // error +>b = e : E +>b : { opt: Base; } +>e : E + + b = f; // error +>b = f : F +>b : { opt: Base; } +>f : F + + b = a; // ok +>b = a : { opt: Base; } +>b : { opt: Base; } +>a : { opt: Base; } + + b = c; // ok +>b = c : C +>b : { opt: Base; } +>c : C +} + diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.symbols b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.symbols new file mode 100644 index 00000000000..b33dd82f99a --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.symbols @@ -0,0 +1,255 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersStringNumericNames.ts === +// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M +// string named numeric properties work correctly, errors below unless otherwise noted + +module JustStrings { +>JustStrings : Symbol(JustStrings, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 0, 0)) + + class S { '1': string; } +>S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 3, 20)) + + class T { '1.': string; } +>T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 28)) + + var s: S; +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) +>S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 3, 20)) + + var t: T; +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 7)) +>T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 4, 28)) + + interface S2 { '1': string; bar?: string } +>S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 13)) +>bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 31)) + + interface T2 { '1.0': string; baz?: string } +>T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 46)) +>baz : Symbol(T2.baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 10, 33)) + + var s2: S2; +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 11, 7)) +>S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 13)) + + var t2: T2; +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 12, 7)) +>T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 9, 46)) + + var a: { '1.': string; bar?: string } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 7)) +>bar : Symbol(bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 26)) + + var b: { '1.0': string; baz?: string } +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 7)) +>baz : Symbol(baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 27)) + + var a2 = { '1.0': '' }; +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) + + var b2 = { '1': '' }; +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 18, 7)) + + s = t; +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 7)) + + t = s; +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 7)) +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) + + s = s2; // ok +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 11, 7)) + + s = a2; +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) + + s2 = t2; +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 11, 7)) +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 12, 7)) + + t2 = s2; +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 12, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 11, 7)) + + s2 = t; +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 11, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 7)) + + s2 = b; +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 11, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 7)) + + s2 = a2; +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 11, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) + + a = b; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 7)) + + b = a; +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 7)) + + a = s; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 7)) +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 6, 7)) + + a = s2; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 11, 7)) + + a = a2; +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 14, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) + + a2 = b2; +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 18, 7)) + + b2 = a2; +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 18, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) + + a2 = b; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 15, 7)) + + a2 = t2; // ok +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 12, 7)) + + a2 = t; +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 17, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 7, 7)) +} + +module NumbersAndStrings { +>NumbersAndStrings : Symbol(NumbersAndStrings, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 42, 1)) + + class S { '1': string; } +>S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 44, 26)) + + class T { 1: string; } +>T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 28)) + + var s: S; +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 47, 7)) +>S : Symbol(S, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 44, 26)) + + var t: T; +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 7)) +>T : Symbol(T, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 45, 28)) + + interface S2 { '1': string; bar?: string } +>S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 13)) +>bar : Symbol(S2.bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 31)) + + interface T2 { 1.0: string; baz?: string } +>T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 46)) +>baz : Symbol(T2.baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 51, 31)) + + var s2: S2; +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 52, 7)) +>S2 : Symbol(S2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 13)) + + var t2: T2; +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 53, 7)) +>T2 : Symbol(T2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 50, 46)) + + var a: { '1.': string; bar?: string } +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 7)) +>bar : Symbol(bar, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 26)) + + var b: { 1.0: string; baz?: string } +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 7)) +>baz : Symbol(baz, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 25)) + + var a2 = { '1.0': '' }; +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) + + var b2 = { 1.: '' }; +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 59, 7)) + + s = t; // ok +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 47, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 7)) + + t = s; // ok +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 7)) +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 47, 7)) + + s = s2; // ok +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 47, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 52, 7)) + + s = a2; // error +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 47, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) + + s2 = t2; // ok +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 52, 7)) +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 53, 7)) + + t2 = s2; // ok +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 53, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 52, 7)) + + s2 = t; // ok +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 52, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 7)) + + s2 = b; // ok +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 52, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 7)) + + s2 = a2; // error +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 52, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) + + a = b; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 7)) + + b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 7)) +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 7)) + + a = s; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 7)) +>s : Symbol(s, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 47, 7)) + + a = s2; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 7)) +>s2 : Symbol(s2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 52, 7)) + + a = a2; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) + + a = b2; // error +>a : Symbol(a, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 55, 7)) +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 59, 7)) + + a2 = b2; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 59, 7)) + + b2 = a2; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 59, 7)) +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) + + a2 = b; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) +>b : Symbol(b, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 56, 7)) + + a2 = t2; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) +>t2 : Symbol(t2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 53, 7)) + + a2 = t; // error +>a2 : Symbol(a2, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 58, 7)) +>t : Symbol(t, Decl(assignmentCompatWithObjectMembersStringNumericNames.ts, 48, 7)) +} diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.types b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.types new file mode 100644 index 00000000000..6d021b024cb --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersStringNumericNames.types @@ -0,0 +1,302 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithObjectMembersStringNumericNames.ts === +// members N and M of types S and T have the same name, same accessibility, same optionality, and N is assignable M +// string named numeric properties work correctly, errors below unless otherwise noted + +module JustStrings { +>JustStrings : typeof JustStrings + + class S { '1': string; } +>S : S + + class T { '1.': string; } +>T : T + + var s: S; +>s : S +>S : S + + var t: T; +>t : T +>T : T + + interface S2 { '1': string; bar?: string } +>S2 : S2 +>bar : string + + interface T2 { '1.0': string; baz?: string } +>T2 : T2 +>baz : string + + var s2: S2; +>s2 : S2 +>S2 : S2 + + var t2: T2; +>t2 : T2 +>T2 : T2 + + var a: { '1.': string; bar?: string } +>a : { '1.': string; bar?: string; } +>bar : string + + var b: { '1.0': string; baz?: string } +>b : { '1.0': string; baz?: string; } +>baz : string + + var a2 = { '1.0': '' }; +>a2 : { '1.0': string; } +>{ '1.0': '' } : { '1.0': string; } +>'' : "" + + var b2 = { '1': '' }; +>b2 : { '1': string; } +>{ '1': '' } : { '1': string; } +>'' : "" + + s = t; +>s = t : T +>s : S +>t : T + + t = s; +>t = s : S +>t : T +>s : S + + s = s2; // ok +>s = s2 : S2 +>s : S +>s2 : S2 + + s = a2; +>s = a2 : { '1.0': string; } +>s : S +>a2 : { '1.0': string; } + + s2 = t2; +>s2 = t2 : T2 +>s2 : S2 +>t2 : T2 + + t2 = s2; +>t2 = s2 : S2 +>t2 : T2 +>s2 : S2 + + s2 = t; +>s2 = t : T +>s2 : S2 +>t : T + + s2 = b; +>s2 = b : { '1.0': string; baz?: string; } +>s2 : S2 +>b : { '1.0': string; baz?: string; } + + s2 = a2; +>s2 = a2 : { '1.0': string; } +>s2 : S2 +>a2 : { '1.0': string; } + + a = b; +>a = b : { '1.0': string; baz?: string; } +>a : { '1.': string; bar?: string; } +>b : { '1.0': string; baz?: string; } + + b = a; +>b = a : { '1.': string; bar?: string; } +>b : { '1.0': string; baz?: string; } +>a : { '1.': string; bar?: string; } + + a = s; +>a = s : S +>a : { '1.': string; bar?: string; } +>s : S + + a = s2; +>a = s2 : S2 +>a : { '1.': string; bar?: string; } +>s2 : S2 + + a = a2; +>a = a2 : { '1.0': string; } +>a : { '1.': string; bar?: string; } +>a2 : { '1.0': string; } + + a2 = b2; +>a2 = b2 : { '1': string; } +>a2 : { '1.0': string; } +>b2 : { '1': string; } + + b2 = a2; +>b2 = a2 : { '1.0': string; } +>b2 : { '1': string; } +>a2 : { '1.0': string; } + + a2 = b; // ok +>a2 = b : { '1.0': string; baz?: string; } +>a2 : { '1.0': string; } +>b : { '1.0': string; baz?: string; } + + a2 = t2; // ok +>a2 = t2 : T2 +>a2 : { '1.0': string; } +>t2 : T2 + + a2 = t; +>a2 = t : T +>a2 : { '1.0': string; } +>t : T +} + +module NumbersAndStrings { +>NumbersAndStrings : typeof NumbersAndStrings + + class S { '1': string; } +>S : S + + class T { 1: string; } +>T : T + + var s: S; +>s : S +>S : S + + var t: T; +>t : T +>T : T + + interface S2 { '1': string; bar?: string } +>S2 : S2 +>bar : string + + interface T2 { 1.0: string; baz?: string } +>T2 : T2 +>baz : string + + var s2: S2; +>s2 : S2 +>S2 : S2 + + var t2: T2; +>t2 : T2 +>T2 : T2 + + var a: { '1.': string; bar?: string } +>a : { '1.': string; bar?: string; } +>bar : string + + var b: { 1.0: string; baz?: string } +>b : { 1.0: string; baz?: string; } +>baz : string + + var a2 = { '1.0': '' }; +>a2 : { '1.0': string; } +>{ '1.0': '' } : { '1.0': string; } +>'' : "" + + var b2 = { 1.: '' }; +>b2 : { 1.: string; } +>{ 1.: '' } : { 1.: string; } +>'' : "" + + s = t; // ok +>s = t : T +>s : S +>t : T + + t = s; // ok +>t = s : S +>t : T +>s : S + + s = s2; // ok +>s = s2 : S2 +>s : S +>s2 : S2 + + s = a2; // error +>s = a2 : { '1.0': string; } +>s : S +>a2 : { '1.0': string; } + + s2 = t2; // ok +>s2 = t2 : T2 +>s2 : S2 +>t2 : T2 + + t2 = s2; // ok +>t2 = s2 : S2 +>t2 : T2 +>s2 : S2 + + s2 = t; // ok +>s2 = t : T +>s2 : S2 +>t : T + + s2 = b; // ok +>s2 = b : { 1.0: string; baz?: string; } +>s2 : S2 +>b : { 1.0: string; baz?: string; } + + s2 = a2; // error +>s2 = a2 : { '1.0': string; } +>s2 : S2 +>a2 : { '1.0': string; } + + a = b; // error +>a = b : { 1.0: string; baz?: string; } +>a : { '1.': string; bar?: string; } +>b : { 1.0: string; baz?: string; } + + b = a; // error +>b = a : { '1.': string; bar?: string; } +>b : { 1.0: string; baz?: string; } +>a : { '1.': string; bar?: string; } + + a = s; // error +>a = s : S +>a : { '1.': string; bar?: string; } +>s : S + + a = s2; // error +>a = s2 : S2 +>a : { '1.': string; bar?: string; } +>s2 : S2 + + a = a2; // error +>a = a2 : { '1.0': string; } +>a : { '1.': string; bar?: string; } +>a2 : { '1.0': string; } + + a = b2; // error +>a = b2 : { 1.: string; } +>a : { '1.': string; bar?: string; } +>b2 : { 1.: string; } + + a2 = b2; // error +>a2 = b2 : { 1.: string; } +>a2 : { '1.0': string; } +>b2 : { 1.: string; } + + b2 = a2; // error +>b2 = a2 : { '1.0': string; } +>b2 : { 1.: string; } +>a2 : { '1.0': string; } + + a2 = b; // error +>a2 = b : { 1.0: string; baz?: string; } +>a2 : { '1.0': string; } +>b : { 1.0: string; baz?: string; } + + a2 = t2; // error +>a2 = t2 : T2 +>a2 : { '1.0': string; } +>t2 : T2 + + a2 = t; // error +>a2 = t : T +>a2 : { '1.0': string; } +>t : T +} diff --git a/tests/baselines/reference/assignmentCompatWithOverloads.symbols b/tests/baselines/reference/assignmentCompatWithOverloads.symbols new file mode 100644 index 00000000000..34e108e6647 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithOverloads.symbols @@ -0,0 +1,64 @@ +=== tests/cases/compiler/assignmentCompatWithOverloads.ts === +function f1(x: string): number { return null; } +>f1 : Symbol(f1, Decl(assignmentCompatWithOverloads.ts, 0, 0)) +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 0, 12)) + +function f2(x: string): string { return null; } +>f2 : Symbol(f2, Decl(assignmentCompatWithOverloads.ts, 0, 47)) +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 2, 12)) + +function f3(x: number): number { return null; } +>f3 : Symbol(f3, Decl(assignmentCompatWithOverloads.ts, 2, 47)) +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 4, 12)) + +function f4(x: string): string; +>f4 : Symbol(f4, Decl(assignmentCompatWithOverloads.ts, 4, 47), Decl(assignmentCompatWithOverloads.ts, 6, 31), Decl(assignmentCompatWithOverloads.ts, 8, 31)) +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 6, 12)) + +function f4(x: number): number; +>f4 : Symbol(f4, Decl(assignmentCompatWithOverloads.ts, 4, 47), Decl(assignmentCompatWithOverloads.ts, 6, 31), Decl(assignmentCompatWithOverloads.ts, 8, 31)) +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 8, 12)) + +function f4(x: any): any { return undefined; } +>f4 : Symbol(f4, Decl(assignmentCompatWithOverloads.ts, 4, 47), Decl(assignmentCompatWithOverloads.ts, 6, 31), Decl(assignmentCompatWithOverloads.ts, 8, 31)) +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 10, 12)) +>undefined : Symbol(undefined) + +var g: (s1: string) => number; +>g : Symbol(g, Decl(assignmentCompatWithOverloads.ts, 12, 3)) +>s1 : Symbol(s1, Decl(assignmentCompatWithOverloads.ts, 12, 8)) + +g = f1; // OK +>g : Symbol(g, Decl(assignmentCompatWithOverloads.ts, 12, 3)) +>f1 : Symbol(f1, Decl(assignmentCompatWithOverloads.ts, 0, 0)) + +g = f2; // Error +>g : Symbol(g, Decl(assignmentCompatWithOverloads.ts, 12, 3)) +>f2 : Symbol(f2, Decl(assignmentCompatWithOverloads.ts, 0, 47)) + +g = f3; // Error +>g : Symbol(g, Decl(assignmentCompatWithOverloads.ts, 12, 3)) +>f3 : Symbol(f3, Decl(assignmentCompatWithOverloads.ts, 2, 47)) + +g = f4; // Error +>g : Symbol(g, Decl(assignmentCompatWithOverloads.ts, 12, 3)) +>f4 : Symbol(f4, Decl(assignmentCompatWithOverloads.ts, 4, 47), Decl(assignmentCompatWithOverloads.ts, 6, 31), Decl(assignmentCompatWithOverloads.ts, 8, 31)) + +class C { +>C : Symbol(C, Decl(assignmentCompatWithOverloads.ts, 20, 7)) + + constructor(x: string); +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 23, 16)) + +constructor(x: any) {} +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 24, 12)) +} + +var d: new(x: number) => void; +>d : Symbol(d, Decl(assignmentCompatWithOverloads.ts, 27, 3)) +>x : Symbol(x, Decl(assignmentCompatWithOverloads.ts, 27, 11)) + +d = C; // Error +>d : Symbol(d, Decl(assignmentCompatWithOverloads.ts, 27, 3)) +>C : Symbol(C, Decl(assignmentCompatWithOverloads.ts, 20, 7)) + diff --git a/tests/baselines/reference/assignmentCompatWithOverloads.types b/tests/baselines/reference/assignmentCompatWithOverloads.types new file mode 100644 index 00000000000..5da16dc01b2 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithOverloads.types @@ -0,0 +1,72 @@ +=== tests/cases/compiler/assignmentCompatWithOverloads.ts === +function f1(x: string): number { return null; } +>f1 : (x: string) => number +>x : string +>null : null + +function f2(x: string): string { return null; } +>f2 : (x: string) => string +>x : string +>null : null + +function f3(x: number): number { return null; } +>f3 : (x: number) => number +>x : number +>null : null + +function f4(x: string): string; +>f4 : { (x: string): string; (x: number): number; } +>x : string + +function f4(x: number): number; +>f4 : { (x: string): string; (x: number): number; } +>x : number + +function f4(x: any): any { return undefined; } +>f4 : { (x: string): string; (x: number): number; } +>x : any +>undefined : undefined + +var g: (s1: string) => number; +>g : (s1: string) => number +>s1 : string + +g = f1; // OK +>g = f1 : (x: string) => number +>g : (s1: string) => number +>f1 : (x: string) => number + +g = f2; // Error +>g = f2 : (x: string) => string +>g : (s1: string) => number +>f2 : (x: string) => string + +g = f3; // Error +>g = f3 : (x: number) => number +>g : (s1: string) => number +>f3 : (x: number) => number + +g = f4; // Error +>g = f4 : { (x: string): string; (x: number): number; } +>g : (s1: string) => number +>f4 : { (x: string): string; (x: number): number; } + +class C { +>C : C + + constructor(x: string); +>x : string + +constructor(x: any) {} +>x : any +} + +var d: new(x: number) => void; +>d : new (x: number) => void +>x : number + +d = C; // Error +>d = C : typeof C +>d : new (x: number) => void +>C : typeof C + diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.symbols b/tests/baselines/reference/assignmentCompatWithStringIndexer.symbols new file mode 100644 index 00000000000..6649a8bb0d9 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.symbols @@ -0,0 +1,156 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts === +// index signatures must be compatible in assignments + +interface Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer.ts, 0, 0)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithStringIndexer.ts, 2, 16)) + +interface Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer.ts, 2, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer.ts, 0, 0)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithStringIndexer.ts, 3, 32)) + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer.ts, 3, 47)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer.ts, 2, 31)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithStringIndexer.ts, 4, 36)) + +class A { +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer.ts, 4, 51)) + + [x: string]: Base; +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 7, 5)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer.ts, 0, 0)) +} + +var a: A; +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer.ts, 10, 3)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer.ts, 4, 51)) + +var b: { [x: string]: Derived; } +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer.ts, 12, 3)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 12, 10)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer.ts, 2, 31)) + +a = b; // ok +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer.ts, 10, 3)) +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer.ts, 12, 3)) + +b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer.ts, 12, 3)) +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer.ts, 10, 3)) + +var b2: { [x: string]: Derived2; } +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer.ts, 16, 3)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 16, 11)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer.ts, 3, 47)) + +a = b2; // ok +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer.ts, 10, 3)) +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer.ts, 16, 3)) + +b2 = a; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer.ts, 16, 3)) +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer.ts, 10, 3)) + +module Generics { +>Generics : Symbol(Generics, Decl(assignmentCompatWithStringIndexer.ts, 18, 7)) + + class A { +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer.ts, 20, 17)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer.ts, 21, 12)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer.ts, 0, 0)) + + [x: string]: T; +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 22, 9)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer.ts, 21, 12)) + } + + class B extends A { +>B : Symbol(B, Decl(assignmentCompatWithStringIndexer.ts, 23, 5)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer.ts, 20, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer.ts, 0, 0)) + + [x: string]: Derived; // ok +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 26, 9)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer.ts, 2, 31)) + } + + var b1: { [x: string]: Derived; }; +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer.ts, 29, 7)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 29, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer.ts, 2, 31)) + + var a1: A; +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer.ts, 30, 7)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer.ts, 20, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer.ts, 0, 0)) + + a1 = b1; // ok +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer.ts, 30, 7)) +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer.ts, 29, 7)) + + b1 = a1; // error +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer.ts, 29, 7)) +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer.ts, 30, 7)) + + class B2 extends A { +>B2 : Symbol(B2, Decl(assignmentCompatWithStringIndexer.ts, 32, 12)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer.ts, 20, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer.ts, 0, 0)) + + [x: string]: Derived2; // ok +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 35, 9)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer.ts, 3, 47)) + } + + var b2: { [x: string]: Derived2; }; +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer.ts, 38, 7)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 38, 15)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer.ts, 3, 47)) + + a1 = b2; // ok +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer.ts, 30, 7)) +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer.ts, 38, 7)) + + b2 = a1; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer.ts, 38, 7)) +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer.ts, 30, 7)) + + function foo() { +>foo : Symbol(foo, Decl(assignmentCompatWithStringIndexer.ts, 40, 12)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer.ts, 42, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer.ts, 0, 0)) + + var b3: { [x: string]: Derived; }; +>b3 : Symbol(b3, Decl(assignmentCompatWithStringIndexer.ts, 43, 11)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 43, 19)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer.ts, 2, 31)) + + var a3: A; +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer.ts, 44, 11)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer.ts, 20, 17)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer.ts, 42, 17)) + + a3 = b3; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer.ts, 44, 11)) +>b3 : Symbol(b3, Decl(assignmentCompatWithStringIndexer.ts, 43, 11)) + + b3 = a3; // error +>b3 : Symbol(b3, Decl(assignmentCompatWithStringIndexer.ts, 43, 11)) +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer.ts, 44, 11)) + + var b4: { [x: string]: Derived2; }; +>b4 : Symbol(b4, Decl(assignmentCompatWithStringIndexer.ts, 48, 11)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer.ts, 48, 19)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer.ts, 3, 47)) + + a3 = b4; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer.ts, 44, 11)) +>b4 : Symbol(b4, Decl(assignmentCompatWithStringIndexer.ts, 48, 11)) + + b4 = a3; // error +>b4 : Symbol(b4, Decl(assignmentCompatWithStringIndexer.ts, 48, 11)) +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer.ts, 44, 11)) + } +} diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer.types b/tests/baselines/reference/assignmentCompatWithStringIndexer.types new file mode 100644 index 00000000000..2ecb1889406 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer.types @@ -0,0 +1,168 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer.ts === +// index signatures must be compatible in assignments + +interface Base { foo: string; } +>Base : Base +>foo : string + +interface Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + +class A { +>A : A + + [x: string]: Base; +>x : string +>Base : Base +} + +var a: A; +>a : A +>A : A + +var b: { [x: string]: Derived; } +>b : { [x: string]: Derived; } +>x : string +>Derived : Derived + +a = b; // ok +>a = b : { [x: string]: Derived; } +>a : A +>b : { [x: string]: Derived; } + +b = a; // error +>b = a : A +>b : { [x: string]: Derived; } +>a : A + +var b2: { [x: string]: Derived2; } +>b2 : { [x: string]: Derived2; } +>x : string +>Derived2 : Derived2 + +a = b2; // ok +>a = b2 : { [x: string]: Derived2; } +>a : A +>b2 : { [x: string]: Derived2; } + +b2 = a; // error +>b2 = a : A +>b2 : { [x: string]: Derived2; } +>a : A + +module Generics { +>Generics : typeof Generics + + class A { +>A : A +>T : T +>Base : Base + + [x: string]: T; +>x : string +>T : T + } + + class B extends A { +>B : B +>A : A +>Base : Base + + [x: string]: Derived; // ok +>x : string +>Derived : Derived + } + + var b1: { [x: string]: Derived; }; +>b1 : { [x: string]: Derived; } +>x : string +>Derived : Derived + + var a1: A; +>a1 : A +>A : A +>Base : Base + + a1 = b1; // ok +>a1 = b1 : { [x: string]: Derived; } +>a1 : A +>b1 : { [x: string]: Derived; } + + b1 = a1; // error +>b1 = a1 : A +>b1 : { [x: string]: Derived; } +>a1 : A + + class B2 extends A { +>B2 : B2 +>A : A +>Base : Base + + [x: string]: Derived2; // ok +>x : string +>Derived2 : Derived2 + } + + var b2: { [x: string]: Derived2; }; +>b2 : { [x: string]: Derived2; } +>x : string +>Derived2 : Derived2 + + a1 = b2; // ok +>a1 = b2 : { [x: string]: Derived2; } +>a1 : A +>b2 : { [x: string]: Derived2; } + + b2 = a1; // error +>b2 = a1 : A +>b2 : { [x: string]: Derived2; } +>a1 : A + + function foo() { +>foo : () => void +>T : T +>Base : Base + + var b3: { [x: string]: Derived; }; +>b3 : { [x: string]: Derived; } +>x : string +>Derived : Derived + + var a3: A; +>a3 : A +>A : A +>T : T + + a3 = b3; // error +>a3 = b3 : { [x: string]: Derived; } +>a3 : A +>b3 : { [x: string]: Derived; } + + b3 = a3; // error +>b3 = a3 : A +>b3 : { [x: string]: Derived; } +>a3 : A + + var b4: { [x: string]: Derived2; }; +>b4 : { [x: string]: Derived2; } +>x : string +>Derived2 : Derived2 + + a3 = b4; // error +>a3 = b4 : { [x: string]: Derived2; } +>a3 : A +>b4 : { [x: string]: Derived2; } + + b4 = a3; // error +>b4 = a3 : A +>b4 : { [x: string]: Derived2; } +>a3 : A + } +} diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer2.symbols b/tests/baselines/reference/assignmentCompatWithStringIndexer2.symbols new file mode 100644 index 00000000000..b1ce13bdbb7 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer2.symbols @@ -0,0 +1,156 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts === +// index signatures must be compatible in assignments + +interface Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer2.ts, 0, 0)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithStringIndexer2.ts, 2, 16)) + +interface Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer2.ts, 2, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer2.ts, 0, 0)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithStringIndexer2.ts, 3, 32)) + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer2.ts, 3, 47)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer2.ts, 2, 31)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithStringIndexer2.ts, 4, 36)) + +interface A { +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer2.ts, 4, 51)) + + [x: string]: Base; +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 7, 5)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer2.ts, 0, 0)) +} + +var a: A; +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer2.ts, 10, 3)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer2.ts, 4, 51)) + +var b: { [x: string]: Derived; } +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer2.ts, 12, 3)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 12, 10)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer2.ts, 2, 31)) + +a = b; // ok +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer2.ts, 10, 3)) +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer2.ts, 12, 3)) + +b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer2.ts, 12, 3)) +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer2.ts, 10, 3)) + +var b2: { [x: string]: Derived2; } +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer2.ts, 16, 3)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 16, 11)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer2.ts, 3, 47)) + +a = b2; // ok +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer2.ts, 10, 3)) +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer2.ts, 16, 3)) + +b2 = a; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer2.ts, 16, 3)) +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer2.ts, 10, 3)) + +module Generics { +>Generics : Symbol(Generics, Decl(assignmentCompatWithStringIndexer2.ts, 18, 7)) + + interface A { +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer2.ts, 20, 17)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer2.ts, 21, 16)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer2.ts, 0, 0)) + + [x: string]: T; +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 22, 9)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer2.ts, 21, 16)) + } + + interface B extends A { +>B : Symbol(B, Decl(assignmentCompatWithStringIndexer2.ts, 23, 5)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer2.ts, 20, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer2.ts, 0, 0)) + + [x: string]: Derived; // ok +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 26, 9)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer2.ts, 2, 31)) + } + + var b1: { [x: string]: Derived; }; +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer2.ts, 29, 7)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 29, 15)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer2.ts, 2, 31)) + + var a1: A; +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer2.ts, 30, 7)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer2.ts, 20, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer2.ts, 0, 0)) + + a1 = b1; // ok +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer2.ts, 30, 7)) +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer2.ts, 29, 7)) + + b1 = a1; // error +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer2.ts, 29, 7)) +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer2.ts, 30, 7)) + + interface B2 extends A { +>B2 : Symbol(B2, Decl(assignmentCompatWithStringIndexer2.ts, 32, 12)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer2.ts, 20, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer2.ts, 0, 0)) + + [x: string]: Derived2; // ok +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 35, 9)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer2.ts, 3, 47)) + } + + var b2: { [x: string]: Derived2; }; +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer2.ts, 38, 7)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 38, 15)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer2.ts, 3, 47)) + + a1 = b2; // ok +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer2.ts, 30, 7)) +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer2.ts, 38, 7)) + + b2 = a1; // error +>b2 : Symbol(b2, Decl(assignmentCompatWithStringIndexer2.ts, 38, 7)) +>a1 : Symbol(a1, Decl(assignmentCompatWithStringIndexer2.ts, 30, 7)) + + function foo() { +>foo : Symbol(foo, Decl(assignmentCompatWithStringIndexer2.ts, 40, 12)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer2.ts, 42, 17)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer2.ts, 0, 0)) + + var b3: { [x: string]: Derived; }; +>b3 : Symbol(b3, Decl(assignmentCompatWithStringIndexer2.ts, 43, 11)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 43, 19)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer2.ts, 2, 31)) + + var a3: A; +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer2.ts, 44, 11)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer2.ts, 20, 17)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer2.ts, 42, 17)) + + a3 = b3; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer2.ts, 44, 11)) +>b3 : Symbol(b3, Decl(assignmentCompatWithStringIndexer2.ts, 43, 11)) + + b3 = a3; // error +>b3 : Symbol(b3, Decl(assignmentCompatWithStringIndexer2.ts, 43, 11)) +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer2.ts, 44, 11)) + + var b4: { [x: string]: Derived2; }; +>b4 : Symbol(b4, Decl(assignmentCompatWithStringIndexer2.ts, 48, 11)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer2.ts, 48, 19)) +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer2.ts, 3, 47)) + + a3 = b4; // error +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer2.ts, 44, 11)) +>b4 : Symbol(b4, Decl(assignmentCompatWithStringIndexer2.ts, 48, 11)) + + b4 = a3; // error +>b4 : Symbol(b4, Decl(assignmentCompatWithStringIndexer2.ts, 48, 11)) +>a3 : Symbol(a3, Decl(assignmentCompatWithStringIndexer2.ts, 44, 11)) + } +} diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer2.types b/tests/baselines/reference/assignmentCompatWithStringIndexer2.types new file mode 100644 index 00000000000..4c9d2729a6c --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer2.types @@ -0,0 +1,168 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer2.ts === +// index signatures must be compatible in assignments + +interface Base { foo: string; } +>Base : Base +>foo : string + +interface Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + +interface A { +>A : A + + [x: string]: Base; +>x : string +>Base : Base +} + +var a: A; +>a : A +>A : A + +var b: { [x: string]: Derived; } +>b : { [x: string]: Derived; } +>x : string +>Derived : Derived + +a = b; // ok +>a = b : { [x: string]: Derived; } +>a : A +>b : { [x: string]: Derived; } + +b = a; // error +>b = a : A +>b : { [x: string]: Derived; } +>a : A + +var b2: { [x: string]: Derived2; } +>b2 : { [x: string]: Derived2; } +>x : string +>Derived2 : Derived2 + +a = b2; // ok +>a = b2 : { [x: string]: Derived2; } +>a : A +>b2 : { [x: string]: Derived2; } + +b2 = a; // error +>b2 = a : A +>b2 : { [x: string]: Derived2; } +>a : A + +module Generics { +>Generics : typeof Generics + + interface A { +>A : A +>T : T +>Base : Base + + [x: string]: T; +>x : string +>T : T + } + + interface B extends A { +>B : B +>A : A +>Base : Base + + [x: string]: Derived; // ok +>x : string +>Derived : Derived + } + + var b1: { [x: string]: Derived; }; +>b1 : { [x: string]: Derived; } +>x : string +>Derived : Derived + + var a1: A; +>a1 : A +>A : A +>Base : Base + + a1 = b1; // ok +>a1 = b1 : { [x: string]: Derived; } +>a1 : A +>b1 : { [x: string]: Derived; } + + b1 = a1; // error +>b1 = a1 : A +>b1 : { [x: string]: Derived; } +>a1 : A + + interface B2 extends A { +>B2 : B2 +>A : A +>Base : Base + + [x: string]: Derived2; // ok +>x : string +>Derived2 : Derived2 + } + + var b2: { [x: string]: Derived2; }; +>b2 : { [x: string]: Derived2; } +>x : string +>Derived2 : Derived2 + + a1 = b2; // ok +>a1 = b2 : { [x: string]: Derived2; } +>a1 : A +>b2 : { [x: string]: Derived2; } + + b2 = a1; // error +>b2 = a1 : A +>b2 : { [x: string]: Derived2; } +>a1 : A + + function foo() { +>foo : () => void +>T : T +>Base : Base + + var b3: { [x: string]: Derived; }; +>b3 : { [x: string]: Derived; } +>x : string +>Derived : Derived + + var a3: A; +>a3 : A +>A : A +>T : T + + a3 = b3; // error +>a3 = b3 : { [x: string]: Derived; } +>a3 : A +>b3 : { [x: string]: Derived; } + + b3 = a3; // error +>b3 = a3 : A +>b3 : { [x: string]: Derived; } +>a3 : A + + var b4: { [x: string]: Derived2; }; +>b4 : { [x: string]: Derived2; } +>x : string +>Derived2 : Derived2 + + a3 = b4; // error +>a3 = b4 : { [x: string]: Derived2; } +>a3 : A +>b4 : { [x: string]: Derived2; } + + b4 = a3; // error +>b4 = a3 : A +>b4 : { [x: string]: Derived2; } +>a3 : A + } +} diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer3.symbols b/tests/baselines/reference/assignmentCompatWithStringIndexer3.symbols new file mode 100644 index 00000000000..751fb44c8dc --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer3.symbols @@ -0,0 +1,68 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts === +// Derived type indexer must be subtype of base type indexer + +interface Base { foo: string; } +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer3.ts, 0, 0)) +>foo : Symbol(Base.foo, Decl(assignmentCompatWithStringIndexer3.ts, 2, 16)) + +interface Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer3.ts, 2, 31)) +>Base : Symbol(Base, Decl(assignmentCompatWithStringIndexer3.ts, 0, 0)) +>bar : Symbol(Derived.bar, Decl(assignmentCompatWithStringIndexer3.ts, 3, 32)) + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(assignmentCompatWithStringIndexer3.ts, 3, 47)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer3.ts, 2, 31)) +>baz : Symbol(Derived2.baz, Decl(assignmentCompatWithStringIndexer3.ts, 4, 36)) + +var a: A; +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer3.ts, 6, 3)) + +var b1: { [x: string]: string; } +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer3.ts, 7, 3)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer3.ts, 7, 11)) + +a = b1; // error +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer3.ts, 6, 3)) +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer3.ts, 7, 3)) + +b1 = a; // error +>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer3.ts, 7, 3)) +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer3.ts, 6, 3)) + +module Generics { +>Generics : Symbol(Generics, Decl(assignmentCompatWithStringIndexer3.ts, 9, 7)) + + class A { +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer3.ts, 11, 17)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer3.ts, 12, 12)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer3.ts, 2, 31)) + + [x: string]: T; +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer3.ts, 13, 9)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer3.ts, 12, 12)) + } + + function foo() { +>foo : Symbol(foo, Decl(assignmentCompatWithStringIndexer3.ts, 14, 5)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer3.ts, 16, 17)) +>Derived : Symbol(Derived, Decl(assignmentCompatWithStringIndexer3.ts, 2, 31)) + + var a: A; +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer3.ts, 17, 11)) +>A : Symbol(A, Decl(assignmentCompatWithStringIndexer3.ts, 11, 17)) +>T : Symbol(T, Decl(assignmentCompatWithStringIndexer3.ts, 16, 17)) + + var b: { [x: string]: string; } +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer3.ts, 18, 11)) +>x : Symbol(x, Decl(assignmentCompatWithStringIndexer3.ts, 18, 18)) + + a = b; // error +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer3.ts, 17, 11)) +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer3.ts, 18, 11)) + + b = a; // error +>b : Symbol(b, Decl(assignmentCompatWithStringIndexer3.ts, 18, 11)) +>a : Symbol(a, Decl(assignmentCompatWithStringIndexer3.ts, 17, 11)) + } +} diff --git a/tests/baselines/reference/assignmentCompatWithStringIndexer3.types b/tests/baselines/reference/assignmentCompatWithStringIndexer3.types new file mode 100644 index 00000000000..eda67798465 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatWithStringIndexer3.types @@ -0,0 +1,73 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithStringIndexer3.ts === +// Derived type indexer must be subtype of base type indexer + +interface Base { foo: string; } +>Base : Base +>foo : string + +interface Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + +interface Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + +var a: A; +>a : any +>A : No type information available! + +var b1: { [x: string]: string; } +>b1 : { [x: string]: string; } +>x : string + +a = b1; // error +>a = b1 : { [x: string]: string; } +>a : any +>b1 : { [x: string]: string; } + +b1 = a; // error +>b1 = a : any +>b1 : { [x: string]: string; } +>a : any + +module Generics { +>Generics : typeof Generics + + class A { +>A : A +>T : T +>Derived : Derived + + [x: string]: T; +>x : string +>T : T + } + + function foo() { +>foo : () => void +>T : T +>Derived : Derived + + var a: A; +>a : A +>A : A +>T : T + + var b: { [x: string]: string; } +>b : { [x: string]: string; } +>x : string + + a = b; // error +>a = b : { [x: string]: string; } +>a : A +>b : { [x: string]: string; } + + b = a; // error +>b = a : A +>b : { [x: string]: string; } +>a : A + } +} diff --git a/tests/baselines/reference/assignmentCompatability11.symbols b/tests/baselines/reference/assignmentCompatability11.symbols new file mode 100644 index 00000000000..f086d046bd0 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability11.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability11.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability11.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability11.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability11.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability11.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability11.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability11.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability11.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability11.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability11.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability11.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability11.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability11.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability11.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability11.ts, 3, 1)) + + export var obj = {two: 1}; +>obj : Symbol(obj, Decl(assignmentCompatability11.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability11.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability11.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability11.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability11.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability11.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability11.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability11.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability11.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability11.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability11.types b/tests/baselines/reference/assignmentCompatability11.types new file mode 100644 index 00000000000..d035fe74084 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability11.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/assignmentCompatability11.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {two: 1}; +>obj : { two: number; } +>{two: 1} : { two: number; } +>two : number +>1 : 1 + + export var __val__obj = obj; +>__val__obj : { two: number; } +>obj : { two: number; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { two: number; } +>__test2__ : typeof __test2__ +>__val__obj : { two: number; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability12.symbols b/tests/baselines/reference/assignmentCompatability12.symbols new file mode 100644 index 00000000000..ed758739991 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability12.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability12.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability12.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability12.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability12.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability12.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability12.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability12.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability12.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability12.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability12.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability12.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability12.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability12.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability12.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability12.ts, 3, 1)) + + export var obj = {one: "1"}; +>obj : Symbol(obj, Decl(assignmentCompatability12.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability12.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability12.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability12.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability12.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability12.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability12.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability12.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability12.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability12.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability12.types b/tests/baselines/reference/assignmentCompatability12.types new file mode 100644 index 00000000000..34e83a7dc44 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability12.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/assignmentCompatability12.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {one: "1"}; +>obj : { one: string; } +>{one: "1"} : { one: string; } +>one : string +>"1" : "1" + + export var __val__obj = obj; +>__val__obj : { one: string; } +>obj : { one: string; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { one: string; } +>__test2__ : typeof __test2__ +>__val__obj : { one: string; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability13.symbols b/tests/baselines/reference/assignmentCompatability13.symbols new file mode 100644 index 00000000000..fbe3a51d0fd --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability13.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability13.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability13.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability13.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability13.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability13.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability13.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability13.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability13.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability13.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability13.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability13.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability13.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability13.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability13.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability13.ts, 3, 1)) + + export var obj = {two: "1"}; +>obj : Symbol(obj, Decl(assignmentCompatability13.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability13.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability13.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability13.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability13.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability13.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability13.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability13.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability13.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability13.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability13.types b/tests/baselines/reference/assignmentCompatability13.types new file mode 100644 index 00000000000..3ee0e4a15b5 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability13.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/assignmentCompatability13.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {two: "1"}; +>obj : { two: string; } +>{two: "1"} : { two: string; } +>two : string +>"1" : "1" + + export var __val__obj = obj; +>__val__obj : { two: string; } +>obj : { two: string; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { two: string; } +>__test2__ : typeof __test2__ +>__val__obj : { two: string; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability14.symbols b/tests/baselines/reference/assignmentCompatability14.symbols new file mode 100644 index 00000000000..8d777292a28 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability14.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability14.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability14.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability14.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability14.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability14.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability14.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability14.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability14.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability14.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability14.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability14.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability14.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability14.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability14.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability14.ts, 3, 1)) + + export var obj = {one: true}; +>obj : Symbol(obj, Decl(assignmentCompatability14.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability14.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability14.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability14.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability14.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability14.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability14.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability14.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability14.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability14.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability14.types b/tests/baselines/reference/assignmentCompatability14.types new file mode 100644 index 00000000000..0eee6b21695 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability14.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/assignmentCompatability14.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {one: true}; +>obj : { one: boolean; } +>{one: true} : { one: boolean; } +>one : boolean +>true : true + + export var __val__obj = obj; +>__val__obj : { one: boolean; } +>obj : { one: boolean; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { one: boolean; } +>__test2__ : typeof __test2__ +>__val__obj : { one: boolean; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability15.symbols b/tests/baselines/reference/assignmentCompatability15.symbols new file mode 100644 index 00000000000..3eb985703c8 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability15.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability15.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability15.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability15.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability15.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability15.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability15.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability15.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability15.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability15.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability15.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability15.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability15.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability15.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability15.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability15.ts, 3, 1)) + + export var obj = {two: true}; +>obj : Symbol(obj, Decl(assignmentCompatability15.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability15.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability15.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability15.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability15.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability15.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability15.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability15.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability15.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability15.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability15.types b/tests/baselines/reference/assignmentCompatability15.types new file mode 100644 index 00000000000..426c55f55dc --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability15.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/assignmentCompatability15.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {two: true}; +>obj : { two: boolean; } +>{two: true} : { two: boolean; } +>two : boolean +>true : true + + export var __val__obj = obj; +>__val__obj : { two: boolean; } +>obj : { two: boolean; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { two: boolean; } +>__test2__ : typeof __test2__ +>__val__obj : { two: boolean; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability16.symbols b/tests/baselines/reference/assignmentCompatability16.symbols new file mode 100644 index 00000000000..a7beb212c21 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability16.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability16.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability16.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability16.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability16.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability16.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability16.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability16.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability16.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability16.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability16.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability16.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability16.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability16.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability16.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability16.ts, 3, 1)) + + export var obj = {one: [1]}; +>obj : Symbol(obj, Decl(assignmentCompatability16.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability16.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability16.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability16.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability16.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability16.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability16.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability16.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability16.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability16.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability16.types b/tests/baselines/reference/assignmentCompatability16.types new file mode 100644 index 00000000000..bc37bd93de6 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability16.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/assignmentCompatability16.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {one: [1]}; +>obj : { one: any[]; } +>{one: [1]} : { one: any[]; } +>one : any[] +>[1] : any[] +>[1] : number[] +>1 : 1 + + export var __val__obj = obj; +>__val__obj : { one: any[]; } +>obj : { one: any[]; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { one: any[]; } +>__test2__ : typeof __test2__ +>__val__obj : { one: any[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability17.symbols b/tests/baselines/reference/assignmentCompatability17.symbols new file mode 100644 index 00000000000..5affec312e5 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability17.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability17.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability17.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability17.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability17.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability17.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability17.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability17.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability17.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability17.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability17.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability17.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability17.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability17.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability17.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability17.ts, 3, 1)) + + export var obj = {two: [1]}; +>obj : Symbol(obj, Decl(assignmentCompatability17.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability17.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability17.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability17.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability17.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability17.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability17.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability17.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability17.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability17.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability17.types b/tests/baselines/reference/assignmentCompatability17.types new file mode 100644 index 00000000000..b6d6854d8a9 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability17.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/assignmentCompatability17.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {two: [1]}; +>obj : { two: any[]; } +>{two: [1]} : { two: any[]; } +>two : any[] +>[1] : any[] +>[1] : number[] +>1 : 1 + + export var __val__obj = obj; +>__val__obj : { two: any[]; } +>obj : { two: any[]; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { two: any[]; } +>__test2__ : typeof __test2__ +>__val__obj : { two: any[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability18.symbols b/tests/baselines/reference/assignmentCompatability18.symbols new file mode 100644 index 00000000000..4dfdba13873 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability18.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability18.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability18.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability18.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability18.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability18.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability18.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability18.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability18.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability18.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability18.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability18.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability18.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability18.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability18.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability18.ts, 3, 1)) + + export var obj = {one: [1]}; +>obj : Symbol(obj, Decl(assignmentCompatability18.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability18.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability18.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability18.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability18.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability18.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability18.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability18.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability18.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability18.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability18.types b/tests/baselines/reference/assignmentCompatability18.types new file mode 100644 index 00000000000..cae2094c992 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability18.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/assignmentCompatability18.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {one: [1]}; +>obj : { one: number[]; } +>{one: [1]} : { one: number[]; } +>one : number[] +>[1] : number[] +>1 : 1 + + export var __val__obj = obj; +>__val__obj : { one: number[]; } +>obj : { one: number[]; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { one: number[]; } +>__test2__ : typeof __test2__ +>__val__obj : { one: number[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability19.symbols b/tests/baselines/reference/assignmentCompatability19.symbols new file mode 100644 index 00000000000..bb6aa900441 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability19.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability19.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability19.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability19.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability19.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability19.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability19.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability19.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability19.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability19.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability19.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability19.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability19.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability19.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability19.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability19.ts, 3, 1)) + + export var obj = {two: [1]}; +>obj : Symbol(obj, Decl(assignmentCompatability19.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability19.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability19.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability19.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability19.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability19.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability19.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability19.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability19.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability19.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability19.types b/tests/baselines/reference/assignmentCompatability19.types new file mode 100644 index 00000000000..41fad382aa5 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability19.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/assignmentCompatability19.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {two: [1]}; +>obj : { two: number[]; } +>{two: [1]} : { two: number[]; } +>two : number[] +>[1] : number[] +>1 : 1 + + export var __val__obj = obj; +>__val__obj : { two: number[]; } +>obj : { two: number[]; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { two: number[]; } +>__test2__ : typeof __test2__ +>__val__obj : { two: number[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability20.symbols b/tests/baselines/reference/assignmentCompatability20.symbols new file mode 100644 index 00000000000..e3572bf81d4 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability20.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability20.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability20.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability20.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability20.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability20.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability20.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability20.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability20.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability20.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability20.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability20.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability20.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability20.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability20.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability20.ts, 3, 1)) + + export var obj = {one: ["1"]}; +>obj : Symbol(obj, Decl(assignmentCompatability20.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability20.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability20.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability20.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability20.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability20.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability20.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability20.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability20.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability20.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability20.types b/tests/baselines/reference/assignmentCompatability20.types new file mode 100644 index 00000000000..666ad22e681 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability20.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/assignmentCompatability20.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {one: ["1"]}; +>obj : { one: string[]; } +>{one: ["1"]} : { one: string[]; } +>one : string[] +>["1"] : string[] +>"1" : "1" + + export var __val__obj = obj; +>__val__obj : { one: string[]; } +>obj : { one: string[]; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { one: string[]; } +>__test2__ : typeof __test2__ +>__val__obj : { one: string[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability21.symbols b/tests/baselines/reference/assignmentCompatability21.symbols new file mode 100644 index 00000000000..184844b5885 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability21.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability21.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability21.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability21.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability21.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability21.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability21.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability21.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability21.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability21.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability21.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability21.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability21.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability21.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability21.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability21.ts, 3, 1)) + + export var obj = {two: ["1"]}; +>obj : Symbol(obj, Decl(assignmentCompatability21.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability21.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability21.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability21.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability21.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability21.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability21.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability21.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability21.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability21.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability21.types b/tests/baselines/reference/assignmentCompatability21.types new file mode 100644 index 00000000000..2b0c8e90b7b --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability21.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/assignmentCompatability21.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {two: ["1"]}; +>obj : { two: string[]; } +>{two: ["1"]} : { two: string[]; } +>two : string[] +>["1"] : string[] +>"1" : "1" + + export var __val__obj = obj; +>__val__obj : { two: string[]; } +>obj : { two: string[]; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { two: string[]; } +>__test2__ : typeof __test2__ +>__val__obj : { two: string[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability22.symbols b/tests/baselines/reference/assignmentCompatability22.symbols new file mode 100644 index 00000000000..457d367ebca --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability22.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability22.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability22.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability22.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability22.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability22.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability22.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability22.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability22.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability22.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability22.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability22.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability22.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability22.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability22.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability22.ts, 3, 1)) + + export var obj = {one: [true]}; +>obj : Symbol(obj, Decl(assignmentCompatability22.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability22.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability22.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability22.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability22.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability22.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability22.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability22.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability22.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability22.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability22.types b/tests/baselines/reference/assignmentCompatability22.types new file mode 100644 index 00000000000..d94f7b51ee7 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability22.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/assignmentCompatability22.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {one: [true]}; +>obj : { one: boolean[]; } +>{one: [true]} : { one: boolean[]; } +>one : boolean[] +>[true] : boolean[] +>true : true + + export var __val__obj = obj; +>__val__obj : { one: boolean[]; } +>obj : { one: boolean[]; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { one: boolean[]; } +>__test2__ : typeof __test2__ +>__val__obj : { one: boolean[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability23.symbols b/tests/baselines/reference/assignmentCompatability23.symbols new file mode 100644 index 00000000000..6c42276e49a --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability23.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability23.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability23.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability23.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability23.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability23.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability23.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability23.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability23.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability23.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability23.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability23.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability23.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability23.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability23.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability23.ts, 3, 1)) + + export var obj = {two: [true]}; +>obj : Symbol(obj, Decl(assignmentCompatability23.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability23.ts, 5, 22)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability23.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability23.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability23.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability23.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability23.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability23.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability23.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability23.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability23.types b/tests/baselines/reference/assignmentCompatability23.types new file mode 100644 index 00000000000..8c3f1155f71 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability23.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/assignmentCompatability23.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = {two: [true]}; +>obj : { two: boolean[]; } +>{two: [true]} : { two: boolean[]; } +>two : boolean[] +>[true] : boolean[] +>true : true + + export var __val__obj = obj; +>__val__obj : { two: boolean[]; } +>obj : { two: boolean[]; } +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : { two: boolean[]; } +>__test2__ : typeof __test2__ +>__val__obj : { two: boolean[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability24.symbols b/tests/baselines/reference/assignmentCompatability24.symbols new file mode 100644 index 00000000000..43914094463 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability24.symbols @@ -0,0 +1,43 @@ +=== tests/cases/compiler/assignmentCompatability24.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability24.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability24.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability24.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability24.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability24.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability24.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability24.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability24.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability24.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability24.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability24.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability24.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability24.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability24.ts, 3, 1)) + + export var obj = function f(a: Tstring) { return a; };; +>obj : Symbol(obj, Decl(assignmentCompatability24.ts, 5, 14)) +>f : Symbol(f, Decl(assignmentCompatability24.ts, 5, 20)) +>Tstring : Symbol(Tstring, Decl(assignmentCompatability24.ts, 5, 32)) +>a : Symbol(a, Decl(assignmentCompatability24.ts, 5, 41)) +>Tstring : Symbol(Tstring, Decl(assignmentCompatability24.ts, 5, 32)) +>a : Symbol(a, Decl(assignmentCompatability24.ts, 5, 41)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability24.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability24.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability24.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability24.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability24.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability24.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability24.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability24.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability24.types b/tests/baselines/reference/assignmentCompatability24.types new file mode 100644 index 00000000000..63fccee0c1c --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability24.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/assignmentCompatability24.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj = function f(a: Tstring) { return a; };; +>obj : (a: Tstring) => Tstring +>function f(a: Tstring) { return a; } : (a: Tstring) => Tstring +>f : (a: Tstring) => Tstring +>Tstring : Tstring +>a : Tstring +>Tstring : Tstring +>a : Tstring + + export var __val__obj = obj; +>__val__obj : (a: Tstring) => Tstring +>obj : (a: Tstring) => Tstring +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : (a: Tstring) => Tstring +>__test2__ : typeof __test2__ +>__val__obj : (a: Tstring) => Tstring +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability25.symbols b/tests/baselines/reference/assignmentCompatability25.symbols new file mode 100644 index 00000000000..c161232a2dd --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability25.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability25.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability25.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability25.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability25.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability25.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability25.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability25.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability25.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability25.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability25.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability25.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability25.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability25.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability25.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability25.ts, 3, 1)) + + export var aa:{two:number;};; +>aa : Symbol(aa, Decl(assignmentCompatability25.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability25.ts, 5, 19)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability25.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability25.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability25.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability25.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability25.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability25.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability25.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability25.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability25.types b/tests/baselines/reference/assignmentCompatability25.types new file mode 100644 index 00000000000..3f24a798d65 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability25.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability25.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{two:number;};; +>aa : { two: number; } +>two : number + + export var __val__aa = aa; +>__val__aa : { two: number; } +>aa : { two: number; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { two: number; } +>__test2__ : typeof __test2__ +>__val__aa : { two: number; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability26.symbols b/tests/baselines/reference/assignmentCompatability26.symbols new file mode 100644 index 00000000000..83286055c81 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability26.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability26.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability26.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability26.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability26.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability26.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability26.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability26.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability26.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability26.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability26.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability26.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability26.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability26.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability26.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability26.ts, 3, 1)) + + export var aa:{one:string;};; +>aa : Symbol(aa, Decl(assignmentCompatability26.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability26.ts, 5, 19)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability26.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability26.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability26.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability26.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability26.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability26.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability26.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability26.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability26.types b/tests/baselines/reference/assignmentCompatability26.types new file mode 100644 index 00000000000..9653a606705 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability26.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability26.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{one:string;};; +>aa : { one: string; } +>one : string + + export var __val__aa = aa; +>__val__aa : { one: string; } +>aa : { one: string; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { one: string; } +>__test2__ : typeof __test2__ +>__val__aa : { one: string; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability27.symbols b/tests/baselines/reference/assignmentCompatability27.symbols new file mode 100644 index 00000000000..a0d12446512 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability27.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability27.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability27.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability27.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability27.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability27.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability27.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability27.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability27.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability27.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability27.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability27.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability27.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability27.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability27.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability27.ts, 3, 1)) + + export var aa:{two:string;};; +>aa : Symbol(aa, Decl(assignmentCompatability27.ts, 5, 14)) +>two : Symbol(two, Decl(assignmentCompatability27.ts, 5, 19)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability27.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability27.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability27.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability27.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability27.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability27.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability27.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability27.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability27.types b/tests/baselines/reference/assignmentCompatability27.types new file mode 100644 index 00000000000..c04554e5764 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability27.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability27.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{two:string;};; +>aa : { two: string; } +>two : string + + export var __val__aa = aa; +>__val__aa : { two: string; } +>aa : { two: string; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { two: string; } +>__test2__ : typeof __test2__ +>__val__aa : { two: string; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability28.symbols b/tests/baselines/reference/assignmentCompatability28.symbols new file mode 100644 index 00000000000..da7daeb29e1 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability28.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability28.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability28.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability28.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability28.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability28.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability28.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability28.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability28.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability28.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability28.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability28.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability28.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability28.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability28.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability28.ts, 3, 1)) + + export var aa:{one:boolean;};; +>aa : Symbol(aa, Decl(assignmentCompatability28.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability28.ts, 5, 19)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability28.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability28.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability28.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability28.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability28.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability28.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability28.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability28.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability28.types b/tests/baselines/reference/assignmentCompatability28.types new file mode 100644 index 00000000000..bdf277b0664 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability28.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability28.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{one:boolean;};; +>aa : { one: boolean; } +>one : boolean + + export var __val__aa = aa; +>__val__aa : { one: boolean; } +>aa : { one: boolean; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { one: boolean; } +>__test2__ : typeof __test2__ +>__val__aa : { one: boolean; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability29.symbols b/tests/baselines/reference/assignmentCompatability29.symbols new file mode 100644 index 00000000000..0c6aac71681 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability29.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability29.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability29.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability29.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability29.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability29.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability29.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability29.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability29.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability29.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability29.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability29.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability29.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability29.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability29.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability29.ts, 3, 1)) + + export var aa:{one:any[];};; +>aa : Symbol(aa, Decl(assignmentCompatability29.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability29.ts, 5, 19)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability29.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability29.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability29.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability29.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability29.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability29.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability29.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability29.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability29.types b/tests/baselines/reference/assignmentCompatability29.types new file mode 100644 index 00000000000..7a87e4f8bee --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability29.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability29.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{one:any[];};; +>aa : { one: any[]; } +>one : any[] + + export var __val__aa = aa; +>__val__aa : { one: any[]; } +>aa : { one: any[]; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { one: any[]; } +>__test2__ : typeof __test2__ +>__val__aa : { one: any[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability30.symbols b/tests/baselines/reference/assignmentCompatability30.symbols new file mode 100644 index 00000000000..b3e8b43d695 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability30.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability30.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability30.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability30.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability30.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability30.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability30.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability30.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability30.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability30.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability30.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability30.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability30.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability30.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability30.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability30.ts, 3, 1)) + + export var aa:{one:number[];};; +>aa : Symbol(aa, Decl(assignmentCompatability30.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability30.ts, 5, 19)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability30.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability30.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability30.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability30.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability30.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability30.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability30.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability30.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability30.types b/tests/baselines/reference/assignmentCompatability30.types new file mode 100644 index 00000000000..ca541edb554 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability30.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability30.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{one:number[];};; +>aa : { one: number[]; } +>one : number[] + + export var __val__aa = aa; +>__val__aa : { one: number[]; } +>aa : { one: number[]; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { one: number[]; } +>__test2__ : typeof __test2__ +>__val__aa : { one: number[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability31.symbols b/tests/baselines/reference/assignmentCompatability31.symbols new file mode 100644 index 00000000000..e7b453941cc --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability31.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability31.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability31.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability31.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability31.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability31.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability31.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability31.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability31.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability31.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability31.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability31.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability31.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability31.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability31.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability31.ts, 3, 1)) + + export var aa:{one:string[];};; +>aa : Symbol(aa, Decl(assignmentCompatability31.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability31.ts, 5, 19)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability31.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability31.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability31.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability31.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability31.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability31.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability31.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability31.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability31.types b/tests/baselines/reference/assignmentCompatability31.types new file mode 100644 index 00000000000..2c4ec726bcb --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability31.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability31.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{one:string[];};; +>aa : { one: string[]; } +>one : string[] + + export var __val__aa = aa; +>__val__aa : { one: string[]; } +>aa : { one: string[]; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { one: string[]; } +>__test2__ : typeof __test2__ +>__val__aa : { one: string[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability32.symbols b/tests/baselines/reference/assignmentCompatability32.symbols new file mode 100644 index 00000000000..b4d1da0e520 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability32.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability32.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability32.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability32.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability32.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability32.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability32.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability32.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability32.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability32.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability32.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability32.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability32.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability32.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability32.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability32.ts, 3, 1)) + + export var aa:{one:boolean[];};; +>aa : Symbol(aa, Decl(assignmentCompatability32.ts, 5, 14)) +>one : Symbol(one, Decl(assignmentCompatability32.ts, 5, 19)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability32.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability32.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability32.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability32.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability32.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability32.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability32.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability32.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability32.types b/tests/baselines/reference/assignmentCompatability32.types new file mode 100644 index 00000000000..e7e9c3ef929 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability32.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability32.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{one:boolean[];};; +>aa : { one: boolean[]; } +>one : boolean[] + + export var __val__aa = aa; +>__val__aa : { one: boolean[]; } +>aa : { one: boolean[]; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { one: boolean[]; } +>__test2__ : typeof __test2__ +>__val__aa : { one: boolean[]; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability33.symbols b/tests/baselines/reference/assignmentCompatability33.symbols new file mode 100644 index 00000000000..fb6e8d9d5cd --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability33.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability33.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability33.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability33.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability33.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability33.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability33.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability33.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability33.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability33.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability33.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability33.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability33.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability33.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability33.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability33.ts, 3, 1)) + + export var obj: { (a: Tstring): Tstring; }; +>obj : Symbol(obj, Decl(assignmentCompatability33.ts, 5, 14)) +>Tstring : Symbol(Tstring, Decl(assignmentCompatability33.ts, 5, 23)) +>a : Symbol(a, Decl(assignmentCompatability33.ts, 5, 32)) +>Tstring : Symbol(Tstring, Decl(assignmentCompatability33.ts, 5, 23)) +>Tstring : Symbol(Tstring, Decl(assignmentCompatability33.ts, 5, 23)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability33.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability33.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability33.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability33.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability33.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability33.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability33.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability33.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability33.types b/tests/baselines/reference/assignmentCompatability33.types new file mode 100644 index 00000000000..9420c0f1bc9 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability33.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/assignmentCompatability33.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj: { (a: Tstring): Tstring; }; +>obj : (a: Tstring) => Tstring +>Tstring : Tstring +>a : Tstring +>Tstring : Tstring +>Tstring : Tstring + + export var __val__obj = obj; +>__val__obj : (a: Tstring) => Tstring +>obj : (a: Tstring) => Tstring +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : (a: Tstring) => Tstring +>__test2__ : typeof __test2__ +>__val__obj : (a: Tstring) => Tstring +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability34.symbols b/tests/baselines/reference/assignmentCompatability34.symbols new file mode 100644 index 00000000000..b6bca968e33 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability34.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability34.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability34.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability34.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability34.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability34.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability34.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability34.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability34.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability34.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability34.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability34.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability34.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability34.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability34.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability34.ts, 3, 1)) + + export var obj: { (a:Tnumber):Tnumber;}; +>obj : Symbol(obj, Decl(assignmentCompatability34.ts, 5, 14)) +>Tnumber : Symbol(Tnumber, Decl(assignmentCompatability34.ts, 5, 23)) +>a : Symbol(a, Decl(assignmentCompatability34.ts, 5, 32)) +>Tnumber : Symbol(Tnumber, Decl(assignmentCompatability34.ts, 5, 23)) +>Tnumber : Symbol(Tnumber, Decl(assignmentCompatability34.ts, 5, 23)) + + export var __val__obj = obj; +>__val__obj : Symbol(__val__obj, Decl(assignmentCompatability34.ts, 6, 14)) +>obj : Symbol(obj, Decl(assignmentCompatability34.ts, 5, 14)) +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability34.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability34.ts, 3, 1)) +>__val__obj : Symbol(__test2__.__val__obj, Decl(assignmentCompatability34.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability34.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability34.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability34.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability34.types b/tests/baselines/reference/assignmentCompatability34.types new file mode 100644 index 00000000000..323dd84c787 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability34.types @@ -0,0 +1,45 @@ +=== tests/cases/compiler/assignmentCompatability34.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var obj: { (a:Tnumber):Tnumber;}; +>obj : (a: Tnumber) => Tnumber +>Tnumber : Tnumber +>a : Tnumber +>Tnumber : Tnumber +>Tnumber : Tnumber + + export var __val__obj = obj; +>__val__obj : (a: Tnumber) => Tnumber +>obj : (a: Tnumber) => Tnumber +} +__test2__.__val__obj = __test1__.__val__obj4 +>__test2__.__val__obj = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj : (a: Tnumber) => Tnumber +>__test2__ : typeof __test2__ +>__val__obj : (a: Tnumber) => Tnumber +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability35.symbols b/tests/baselines/reference/assignmentCompatability35.symbols new file mode 100644 index 00000000000..04910af5eb6 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability35.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentCompatability35.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability35.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability35.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability35.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability35.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability35.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability35.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability35.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability35.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability35.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability35.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability35.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability35.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability35.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability35.ts, 3, 1)) + + export var aa:{[index:number]:number;};; +>aa : Symbol(aa, Decl(assignmentCompatability35.ts, 5, 14)) +>index : Symbol(index, Decl(assignmentCompatability35.ts, 5, 20)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability35.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability35.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability35.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability35.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability35.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability35.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability35.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability35.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability35.types b/tests/baselines/reference/assignmentCompatability35.types new file mode 100644 index 00000000000..50da60fd0d9 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability35.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/assignmentCompatability35.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{[index:number]:number;};; +>aa : { [index: number]: number; } +>index : number + + export var __val__aa = aa; +>__val__aa : { [index: number]: number; } +>aa : { [index: number]: number; } +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : { [index: number]: number; } +>__test2__ : typeof __test2__ +>__val__aa : { [index: number]: number; } +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability37.symbols b/tests/baselines/reference/assignmentCompatability37.symbols new file mode 100644 index 00000000000..3be2f9df6d3 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability37.symbols @@ -0,0 +1,41 @@ +=== tests/cases/compiler/assignmentCompatability37.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability37.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability37.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability37.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability37.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability37.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability37.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability37.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability37.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability37.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability37.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability37.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability37.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability37.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability37.ts, 3, 1)) + + export var aa:{ new (param: Tnumber); };; +>aa : Symbol(aa, Decl(assignmentCompatability37.ts, 5, 14)) +>Tnumber : Symbol(Tnumber, Decl(assignmentCompatability37.ts, 5, 25)) +>param : Symbol(param, Decl(assignmentCompatability37.ts, 5, 34)) +>Tnumber : Symbol(Tnumber, Decl(assignmentCompatability37.ts, 5, 25)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability37.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability37.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability37.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability37.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability37.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability37.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability37.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability37.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability37.types b/tests/baselines/reference/assignmentCompatability37.types new file mode 100644 index 00000000000..44f1b7d120b --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability37.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/assignmentCompatability37.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{ new (param: Tnumber); };; +>aa : new (param: Tnumber) => any +>Tnumber : Tnumber +>param : Tnumber +>Tnumber : Tnumber + + export var __val__aa = aa; +>__val__aa : new (param: Tnumber) => any +>aa : new (param: Tnumber) => any +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : new (param: Tnumber) => any +>__test2__ : typeof __test2__ +>__val__aa : new (param: Tnumber) => any +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability38.symbols b/tests/baselines/reference/assignmentCompatability38.symbols new file mode 100644 index 00000000000..e5575900d99 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability38.symbols @@ -0,0 +1,41 @@ +=== tests/cases/compiler/assignmentCompatability38.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability38.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability38.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability38.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability38.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability38.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability38.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability38.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability38.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability38.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability38.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability38.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability38.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability38.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability38.ts, 3, 1)) + + export var aa:{ new (param: Tstring); };; +>aa : Symbol(aa, Decl(assignmentCompatability38.ts, 5, 14)) +>Tstring : Symbol(Tstring, Decl(assignmentCompatability38.ts, 5, 25)) +>param : Symbol(param, Decl(assignmentCompatability38.ts, 5, 34)) +>Tstring : Symbol(Tstring, Decl(assignmentCompatability38.ts, 5, 25)) + + export var __val__aa = aa; +>__val__aa : Symbol(__val__aa, Decl(assignmentCompatability38.ts, 6, 14)) +>aa : Symbol(aa, Decl(assignmentCompatability38.ts, 5, 14)) +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability38.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability38.ts, 3, 1)) +>__val__aa : Symbol(__test2__.__val__aa, Decl(assignmentCompatability38.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability38.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability38.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability38.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability38.types b/tests/baselines/reference/assignmentCompatability38.types new file mode 100644 index 00000000000..ae23533fb08 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability38.types @@ -0,0 +1,44 @@ +=== tests/cases/compiler/assignmentCompatability38.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export var aa:{ new (param: Tstring); };; +>aa : new (param: Tstring) => any +>Tstring : Tstring +>param : Tstring +>Tstring : Tstring + + export var __val__aa = aa; +>__val__aa : new (param: Tstring) => any +>aa : new (param: Tstring) => any +} +__test2__.__val__aa = __test1__.__val__obj4 +>__test2__.__val__aa = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__aa : new (param: Tstring) => any +>__test2__ : typeof __test2__ +>__val__aa : new (param: Tstring) => any +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability39.symbols b/tests/baselines/reference/assignmentCompatability39.symbols new file mode 100644 index 00000000000..e015316facc --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability39.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/assignmentCompatability39.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability39.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability39.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability39.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability39.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability39.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability39.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability39.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability39.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability39.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability39.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability39.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability39.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability39.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability39.ts, 3, 1)) + + export class classWithTwoPublic { constructor(public one: T, public two: U) {} } var x2 = new classWithTwoPublic(1, "a");; +>classWithTwoPublic : Symbol(classWithTwoPublic, Decl(assignmentCompatability39.ts, 4, 18)) +>T : Symbol(T, Decl(assignmentCompatability39.ts, 5, 44)) +>U : Symbol(U, Decl(assignmentCompatability39.ts, 5, 46)) +>one : Symbol(classWithTwoPublic.one, Decl(assignmentCompatability39.ts, 5, 63)) +>T : Symbol(T, Decl(assignmentCompatability39.ts, 5, 44)) +>two : Symbol(classWithTwoPublic.two, Decl(assignmentCompatability39.ts, 5, 77)) +>U : Symbol(U, Decl(assignmentCompatability39.ts, 5, 46)) +>x2 : Symbol(x2, Decl(assignmentCompatability39.ts, 5, 104)) +>classWithTwoPublic : Symbol(classWithTwoPublic, Decl(assignmentCompatability39.ts, 4, 18)) + + export var __val__x2 = x2; +>__val__x2 : Symbol(__val__x2, Decl(assignmentCompatability39.ts, 6, 14)) +>x2 : Symbol(x2, Decl(assignmentCompatability39.ts, 5, 104)) +} +__test2__.__val__x2 = __test1__.__val__obj4 +>__test2__.__val__x2 : Symbol(__test2__.__val__x2, Decl(assignmentCompatability39.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability39.ts, 3, 1)) +>__val__x2 : Symbol(__test2__.__val__x2, Decl(assignmentCompatability39.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability39.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability39.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability39.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability39.types b/tests/baselines/reference/assignmentCompatability39.types new file mode 100644 index 00000000000..9621c62d07c --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability39.types @@ -0,0 +1,52 @@ +=== tests/cases/compiler/assignmentCompatability39.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export class classWithTwoPublic { constructor(public one: T, public two: U) {} } var x2 = new classWithTwoPublic(1, "a");; +>classWithTwoPublic : classWithTwoPublic +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>x2 : classWithTwoPublic +>new classWithTwoPublic(1, "a") : classWithTwoPublic +>classWithTwoPublic : typeof classWithTwoPublic +>1 : 1 +>"a" : "a" + + export var __val__x2 = x2; +>__val__x2 : classWithTwoPublic +>x2 : classWithTwoPublic +} +__test2__.__val__x2 = __test1__.__val__obj4 +>__test2__.__val__x2 = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__x2 : __test2__.classWithTwoPublic +>__test2__ : typeof __test2__ +>__val__x2 : __test2__.classWithTwoPublic +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability40.symbols b/tests/baselines/reference/assignmentCompatability40.symbols new file mode 100644 index 00000000000..177c83e3d62 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability40.symbols @@ -0,0 +1,43 @@ +=== tests/cases/compiler/assignmentCompatability40.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability40.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability40.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability40.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability40.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability40.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability40.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability40.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability40.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability40.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability40.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability40.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability40.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability40.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability40.ts, 3, 1)) + + export class classWithPrivate { constructor(private one: T) {} } var x5 = new classWithPrivate(1);; +>classWithPrivate : Symbol(classWithPrivate, Decl(assignmentCompatability40.ts, 4, 18)) +>T : Symbol(T, Decl(assignmentCompatability40.ts, 5, 44)) +>one : Symbol(classWithPrivate.one, Decl(assignmentCompatability40.ts, 5, 61)) +>T : Symbol(T, Decl(assignmentCompatability40.ts, 5, 44)) +>x5 : Symbol(x5, Decl(assignmentCompatability40.ts, 5, 107)) +>classWithPrivate : Symbol(classWithPrivate, Decl(assignmentCompatability40.ts, 4, 18)) + + export var __val__x5 = x5; +>__val__x5 : Symbol(__val__x5, Decl(assignmentCompatability40.ts, 6, 14)) +>x5 : Symbol(x5, Decl(assignmentCompatability40.ts, 5, 107)) +} +__test2__.__val__x5 = __test1__.__val__obj4 +>__test2__.__val__x5 : Symbol(__test2__.__val__x5, Decl(assignmentCompatability40.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability40.ts, 3, 1)) +>__val__x5 : Symbol(__test2__.__val__x5, Decl(assignmentCompatability40.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability40.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability40.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability40.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability40.types b/tests/baselines/reference/assignmentCompatability40.types new file mode 100644 index 00000000000..31a598ffe25 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability40.types @@ -0,0 +1,48 @@ +=== tests/cases/compiler/assignmentCompatability40.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export class classWithPrivate { constructor(private one: T) {} } var x5 = new classWithPrivate(1);; +>classWithPrivate : classWithPrivate +>T : T +>one : T +>T : T +>x5 : classWithPrivate +>new classWithPrivate(1) : classWithPrivate +>classWithPrivate : typeof classWithPrivate +>1 : 1 + + export var __val__x5 = x5; +>__val__x5 : classWithPrivate +>x5 : classWithPrivate +} +__test2__.__val__x5 = __test1__.__val__obj4 +>__test2__.__val__x5 = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__x5 : __test2__.classWithPrivate +>__test2__ : typeof __test2__ +>__val__x5 : __test2__.classWithPrivate +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability41.symbols b/tests/baselines/reference/assignmentCompatability41.symbols new file mode 100644 index 00000000000..22096f56a7d --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability41.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/assignmentCompatability41.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability41.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability41.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability41.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability41.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability41.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability41.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability41.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability41.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability41.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability41.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability41.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability41.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability41.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability41.ts, 3, 1)) + + export class classWithTwoPrivate { constructor(private one: T, private two: U) {} } var x6 = new classWithTwoPrivate(1, "a");; +>classWithTwoPrivate : Symbol(classWithTwoPrivate, Decl(assignmentCompatability41.ts, 4, 18)) +>T : Symbol(T, Decl(assignmentCompatability41.ts, 5, 44)) +>U : Symbol(U, Decl(assignmentCompatability41.ts, 5, 46)) +>one : Symbol(classWithTwoPrivate.one, Decl(assignmentCompatability41.ts, 5, 63)) +>T : Symbol(T, Decl(assignmentCompatability41.ts, 5, 44)) +>two : Symbol(classWithTwoPrivate.two, Decl(assignmentCompatability41.ts, 5, 78)) +>U : Symbol(U, Decl(assignmentCompatability41.ts, 5, 46)) +>x6 : Symbol(x6, Decl(assignmentCompatability41.ts, 5, 104)) +>classWithTwoPrivate : Symbol(classWithTwoPrivate, Decl(assignmentCompatability41.ts, 4, 18)) + + export var __val__x6 = x6; +>__val__x6 : Symbol(__val__x6, Decl(assignmentCompatability41.ts, 6, 14)) +>x6 : Symbol(x6, Decl(assignmentCompatability41.ts, 5, 104)) +} +__test2__.__val__x6 = __test1__.__val__obj4 +>__test2__.__val__x6 : Symbol(__test2__.__val__x6, Decl(assignmentCompatability41.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability41.ts, 3, 1)) +>__val__x6 : Symbol(__test2__.__val__x6, Decl(assignmentCompatability41.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability41.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability41.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability41.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability41.types b/tests/baselines/reference/assignmentCompatability41.types new file mode 100644 index 00000000000..343cd4e81b6 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability41.types @@ -0,0 +1,52 @@ +=== tests/cases/compiler/assignmentCompatability41.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export class classWithTwoPrivate { constructor(private one: T, private two: U) {} } var x6 = new classWithTwoPrivate(1, "a");; +>classWithTwoPrivate : classWithTwoPrivate +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>x6 : classWithTwoPrivate +>new classWithTwoPrivate(1, "a") : classWithTwoPrivate +>classWithTwoPrivate : typeof classWithTwoPrivate +>1 : 1 +>"a" : "a" + + export var __val__x6 = x6; +>__val__x6 : classWithTwoPrivate +>x6 : classWithTwoPrivate +} +__test2__.__val__x6 = __test1__.__val__obj4 +>__test2__.__val__x6 = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__x6 : __test2__.classWithTwoPrivate +>__test2__ : typeof __test2__ +>__val__x6 : __test2__.classWithTwoPrivate +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability42.symbols b/tests/baselines/reference/assignmentCompatability42.symbols new file mode 100644 index 00000000000..399e6fab579 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability42.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/assignmentCompatability42.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability42.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability42.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability42.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability42.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability42.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability42.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability42.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability42.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability42.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability42.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability42.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability42.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability42.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability42.ts, 3, 1)) + + export class classWithPublicPrivate { constructor(public one: T, private two: U) {} } var x7 = new classWithPublicPrivate(1, "a");; +>classWithPublicPrivate : Symbol(classWithPublicPrivate, Decl(assignmentCompatability42.ts, 4, 18)) +>T : Symbol(T, Decl(assignmentCompatability42.ts, 5, 44)) +>U : Symbol(U, Decl(assignmentCompatability42.ts, 5, 46)) +>one : Symbol(classWithPublicPrivate.one, Decl(assignmentCompatability42.ts, 5, 63)) +>T : Symbol(T, Decl(assignmentCompatability42.ts, 5, 44)) +>two : Symbol(classWithPublicPrivate.two, Decl(assignmentCompatability42.ts, 5, 77)) +>U : Symbol(U, Decl(assignmentCompatability42.ts, 5, 46)) +>x7 : Symbol(x7, Decl(assignmentCompatability42.ts, 5, 104)) +>classWithPublicPrivate : Symbol(classWithPublicPrivate, Decl(assignmentCompatability42.ts, 4, 18)) + + export var __val__x7 = x7; +>__val__x7 : Symbol(__val__x7, Decl(assignmentCompatability42.ts, 6, 14)) +>x7 : Symbol(x7, Decl(assignmentCompatability42.ts, 5, 104)) +} +__test2__.__val__x7 = __test1__.__val__obj4 +>__test2__.__val__x7 : Symbol(__test2__.__val__x7, Decl(assignmentCompatability42.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability42.ts, 3, 1)) +>__val__x7 : Symbol(__test2__.__val__x7, Decl(assignmentCompatability42.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability42.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability42.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability42.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability42.types b/tests/baselines/reference/assignmentCompatability42.types new file mode 100644 index 00000000000..168d718e1e4 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability42.types @@ -0,0 +1,52 @@ +=== tests/cases/compiler/assignmentCompatability42.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export class classWithPublicPrivate { constructor(public one: T, private two: U) {} } var x7 = new classWithPublicPrivate(1, "a");; +>classWithPublicPrivate : classWithPublicPrivate +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>x7 : classWithPublicPrivate +>new classWithPublicPrivate(1, "a") : classWithPublicPrivate +>classWithPublicPrivate : typeof classWithPublicPrivate +>1 : 1 +>"a" : "a" + + export var __val__x7 = x7; +>__val__x7 : classWithPublicPrivate +>x7 : classWithPublicPrivate +} +__test2__.__val__x7 = __test1__.__val__obj4 +>__test2__.__val__x7 = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__x7 : __test2__.classWithPublicPrivate +>__test2__ : typeof __test2__ +>__val__x7 : __test2__.classWithPublicPrivate +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability43.symbols b/tests/baselines/reference/assignmentCompatability43.symbols new file mode 100644 index 00000000000..0b0f1489f1f --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability43.symbols @@ -0,0 +1,48 @@ +=== tests/cases/compiler/assignmentCompatability43.ts === +module __test1__ { +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability43.ts, 0, 0)) + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability43.ts, 0, 18)) +>T : Symbol(T, Decl(assignmentCompatability43.ts, 1, 52)) +>U : Symbol(U, Decl(assignmentCompatability43.ts, 1, 54)) +>one : Symbol(interfaceWithPublicAndOptional.one, Decl(assignmentCompatability43.ts, 1, 58)) +>T : Symbol(T, Decl(assignmentCompatability43.ts, 1, 52)) +>two : Symbol(interfaceWithPublicAndOptional.two, Decl(assignmentCompatability43.ts, 1, 66)) +>U : Symbol(U, Decl(assignmentCompatability43.ts, 1, 54)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability43.ts, 1, 83)) +>interfaceWithPublicAndOptional : Symbol(interfaceWithPublicAndOptional, Decl(assignmentCompatability43.ts, 0, 18)) +>one : Symbol(one, Decl(assignmentCompatability43.ts, 1, 139)) + + export var __val__obj4 = obj4; +>__val__obj4 : Symbol(__val__obj4, Decl(assignmentCompatability43.ts, 2, 14)) +>obj4 : Symbol(obj4, Decl(assignmentCompatability43.ts, 1, 83)) +} +module __test2__ { +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability43.ts, 3, 1)) + + export interface interfaceTwo { one: T; two: U; }; var obj2: interfaceTwo = { one: 1, two: "a" };; +>interfaceTwo : Symbol(interfaceTwo, Decl(assignmentCompatability43.ts, 4, 18)) +>T : Symbol(T, Decl(assignmentCompatability43.ts, 5, 52)) +>U : Symbol(U, Decl(assignmentCompatability43.ts, 5, 54)) +>one : Symbol(interfaceTwo.one, Decl(assignmentCompatability43.ts, 5, 58)) +>T : Symbol(T, Decl(assignmentCompatability43.ts, 5, 52)) +>two : Symbol(interfaceTwo.two, Decl(assignmentCompatability43.ts, 5, 66)) +>U : Symbol(U, Decl(assignmentCompatability43.ts, 5, 54)) +>obj2 : Symbol(obj2, Decl(assignmentCompatability43.ts, 5, 83)) +>interfaceTwo : Symbol(interfaceTwo, Decl(assignmentCompatability43.ts, 4, 18)) +>one : Symbol(one, Decl(assignmentCompatability43.ts, 5, 121)) +>two : Symbol(two, Decl(assignmentCompatability43.ts, 5, 129)) + + export var __val__obj2 = obj2; +>__val__obj2 : Symbol(__val__obj2, Decl(assignmentCompatability43.ts, 6, 14)) +>obj2 : Symbol(obj2, Decl(assignmentCompatability43.ts, 5, 83)) +} +__test2__.__val__obj2 = __test1__.__val__obj4 +>__test2__.__val__obj2 : Symbol(__test2__.__val__obj2, Decl(assignmentCompatability43.ts, 6, 14)) +>__test2__ : Symbol(__test2__, Decl(assignmentCompatability43.ts, 3, 1)) +>__val__obj2 : Symbol(__test2__.__val__obj2, Decl(assignmentCompatability43.ts, 6, 14)) +>__test1__.__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability43.ts, 2, 14)) +>__test1__ : Symbol(__test1__, Decl(assignmentCompatability43.ts, 0, 0)) +>__val__obj4 : Symbol(__test1__.__val__obj4, Decl(assignmentCompatability43.ts, 2, 14)) + diff --git a/tests/baselines/reference/assignmentCompatability43.types b/tests/baselines/reference/assignmentCompatability43.types new file mode 100644 index 00000000000..8693eb35fbe --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability43.types @@ -0,0 +1,54 @@ +=== tests/cases/compiler/assignmentCompatability43.ts === +module __test1__ { +>__test1__ : typeof __test1__ + + export interface interfaceWithPublicAndOptional { one: T; two?: U; }; var obj4: interfaceWithPublicAndOptional = { one: 1 };; +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj4 : interfaceWithPublicAndOptional +>interfaceWithPublicAndOptional : interfaceWithPublicAndOptional +>{ one: 1 } : { one: number; } +>one : number +>1 : 1 + + export var __val__obj4 = obj4; +>__val__obj4 : interfaceWithPublicAndOptional +>obj4 : interfaceWithPublicAndOptional +} +module __test2__ { +>__test2__ : typeof __test2__ + + export interface interfaceTwo { one: T; two: U; }; var obj2: interfaceTwo = { one: 1, two: "a" };; +>interfaceTwo : interfaceTwo +>T : T +>U : U +>one : T +>T : T +>two : U +>U : U +>obj2 : interfaceTwo +>interfaceTwo : interfaceTwo +>{ one: 1, two: "a" } : { one: number; two: string; } +>one : number +>1 : 1 +>two : string +>"a" : "a" + + export var __val__obj2 = obj2; +>__val__obj2 : interfaceTwo +>obj2 : interfaceTwo +} +__test2__.__val__obj2 = __test1__.__val__obj4 +>__test2__.__val__obj2 = __test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test2__.__val__obj2 : __test2__.interfaceTwo +>__test2__ : typeof __test2__ +>__val__obj2 : __test2__.interfaceTwo +>__test1__.__val__obj4 : __test1__.interfaceWithPublicAndOptional +>__test1__ : typeof __test1__ +>__val__obj4 : __test1__.interfaceWithPublicAndOptional + diff --git a/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.symbols b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.symbols new file mode 100644 index 00000000000..b28f7cd682e --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.symbols @@ -0,0 +1,60 @@ +=== tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts === +// 3.8.4 Assignment Compatibility + +interface Applicable { +>Applicable : Symbol(Applicable, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 0, 0)) + + apply(blah: any); // also works for 'apply' +>apply : Symbol(Applicable.apply, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 2, 22)) +>blah : Symbol(blah, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 3, 10)) +} + +var x: Applicable; +>x : Symbol(x, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 6, 3)) +>Applicable : Symbol(Applicable, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 0, 0)) + +// Should fail +x = ''; +>x : Symbol(x, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 6, 3)) + +x = ['']; +>x : Symbol(x, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 6, 3)) + +x = 4; +>x : Symbol(x, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 6, 3)) + +x = {}; +>x : Symbol(x, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 6, 3)) + +// Should work +function f() { }; +>f : Symbol(f, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 12, 7)) + +x = f; +>x : Symbol(x, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 6, 3)) +>f : Symbol(f, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 12, 7)) + +function fn(c: Applicable) { } +>fn : Symbol(fn, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 16, 6)) +>c : Symbol(c, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 18, 12)) +>Applicable : Symbol(Applicable, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 0, 0)) + +// Should Fail +fn(''); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 16, 6)) + +fn(['']); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 16, 6)) + +fn(4); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 16, 6)) + +fn({}); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 16, 6)) + + +// Should work +fn(a => { }); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 16, 6)) +>a : Symbol(a, Decl(assignmentCompatability_checking-apply-member-off-of-function-interface.ts, 28, 3)) + diff --git a/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.types b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.types new file mode 100644 index 00000000000..8d92d936bad --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.types @@ -0,0 +1,81 @@ +=== tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts === +// 3.8.4 Assignment Compatibility + +interface Applicable { +>Applicable : Applicable + + apply(blah: any); // also works for 'apply' +>apply : (blah: any) => any +>blah : any +} + +var x: Applicable; +>x : Applicable +>Applicable : Applicable + +// Should fail +x = ''; +>x = '' : "" +>x : Applicable +>'' : "" + +x = ['']; +>x = [''] : string[] +>x : Applicable +>[''] : string[] +>'' : "" + +x = 4; +>x = 4 : 4 +>x : Applicable +>4 : 4 + +x = {}; +>x = {} : {} +>x : Applicable +>{} : {} + +// Should work +function f() { }; +>f : () => void + +x = f; +>x = f : () => void +>x : Applicable +>f : () => void + +function fn(c: Applicable) { } +>fn : (c: Applicable) => void +>c : Applicable +>Applicable : Applicable + +// Should Fail +fn(''); +>fn('') : void +>fn : (c: Applicable) => void +>'' : "" + +fn(['']); +>fn(['']) : void +>fn : (c: Applicable) => void +>[''] : string[] +>'' : "" + +fn(4); +>fn(4) : void +>fn : (c: Applicable) => void +>4 : 4 + +fn({}); +>fn({}) : void +>fn : (c: Applicable) => void +>{} : {} + + +// Should work +fn(a => { }); +>fn(a => { }) : void +>fn : (c: Applicable) => void +>a => { } : (a: any) => void +>a : any + diff --git a/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.symbols b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.symbols new file mode 100644 index 00000000000..7fe01e7bb76 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.symbols @@ -0,0 +1,60 @@ +=== tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts === +// 3.8.4 Assignment Compatibility + +interface Callable { +>Callable : Symbol(Callable, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 0, 0)) + + call(blah: any); // also works for 'apply' +>call : Symbol(Callable.call, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 2, 20)) +>blah : Symbol(blah, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 3, 9)) +} + +var x: Callable; +>x : Symbol(x, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 6, 3)) +>Callable : Symbol(Callable, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 0, 0)) + +// Should fail +x = ''; +>x : Symbol(x, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 6, 3)) + +x = ['']; +>x : Symbol(x, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 6, 3)) + +x = 4; +>x : Symbol(x, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 6, 3)) + +x = {}; +>x : Symbol(x, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 6, 3)) + +// Should work +function f() { }; +>f : Symbol(f, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 12, 7)) + +x = f; +>x : Symbol(x, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 6, 3)) +>f : Symbol(f, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 12, 7)) + +function fn(c: Callable) { } +>fn : Symbol(fn, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 16, 6)) +>c : Symbol(c, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 18, 12)) +>Callable : Symbol(Callable, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 0, 0)) + +// Should Fail +fn(''); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 16, 6)) + +fn(['']); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 16, 6)) + +fn(4); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 16, 6)) + +fn({}); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 16, 6)) + + +// Should work +fn(a => { }); +>fn : Symbol(fn, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 16, 6)) +>a : Symbol(a, Decl(assignmentCompatability_checking-call-member-off-of-function-interface.ts, 28, 3)) + diff --git a/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.types b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.types new file mode 100644 index 00000000000..7b512d28fe9 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.types @@ -0,0 +1,81 @@ +=== tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts === +// 3.8.4 Assignment Compatibility + +interface Callable { +>Callable : Callable + + call(blah: any); // also works for 'apply' +>call : (blah: any) => any +>blah : any +} + +var x: Callable; +>x : Callable +>Callable : Callable + +// Should fail +x = ''; +>x = '' : "" +>x : Callable +>'' : "" + +x = ['']; +>x = [''] : string[] +>x : Callable +>[''] : string[] +>'' : "" + +x = 4; +>x = 4 : 4 +>x : Callable +>4 : 4 + +x = {}; +>x = {} : {} +>x : Callable +>{} : {} + +// Should work +function f() { }; +>f : () => void + +x = f; +>x = f : () => void +>x : Callable +>f : () => void + +function fn(c: Callable) { } +>fn : (c: Callable) => void +>c : Callable +>Callable : Callable + +// Should Fail +fn(''); +>fn('') : void +>fn : (c: Callable) => void +>'' : "" + +fn(['']); +>fn(['']) : void +>fn : (c: Callable) => void +>[''] : string[] +>'' : "" + +fn(4); +>fn(4) : void +>fn : (c: Callable) => void +>4 : 4 + +fn({}); +>fn({}) : void +>fn : (c: Callable) => void +>{} : {} + + +// Should work +fn(a => { }); +>fn(a => { }) : void +>fn : (c: Callable) => void +>a => { } : (a: any) => void +>a : any + diff --git a/tests/baselines/reference/assignmentLHSIsValue.symbols b/tests/baselines/reference/assignmentLHSIsValue.symbols new file mode 100644 index 00000000000..17925257dfb --- /dev/null +++ b/tests/baselines/reference/assignmentLHSIsValue.symbols @@ -0,0 +1,165 @@ +=== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts === +// expected error for all the LHS of assignments +var value: any; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +// this +class C { +>C : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) + + constructor() { this = value; } +>this : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + + foo() { this = value; } +>foo : Symbol(C.foo, Decl(assignmentLHSIsValue.ts, 5, 35)) +>this : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + + static sfoo() { this = value; } +>sfoo : Symbol(C.sfoo, Decl(assignmentLHSIsValue.ts, 6, 27)) +>this : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) +} + +function foo() { this = value; } +>foo : Symbol(foo, Decl(assignmentLHSIsValue.ts, 8, 1)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +this = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +// identifiers: module, class, enum, function +module M { export var a; } +>M : Symbol(M, Decl(assignmentLHSIsValue.ts, 12, 13)) +>a : Symbol(a, Decl(assignmentLHSIsValue.ts, 15, 21)) + +M = value; +>M : Symbol(M, Decl(assignmentLHSIsValue.ts, 12, 13)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +C = value; +>C : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +enum E { } +>E : Symbol(E, Decl(assignmentLHSIsValue.ts, 18, 10)) + +E = value; +>E : Symbol(E, Decl(assignmentLHSIsValue.ts, 18, 10)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +foo = value; +>foo : Symbol(foo, Decl(assignmentLHSIsValue.ts, 8, 1)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +// literals +null = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +true = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +false = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +0 = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +'' = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +/d+/ = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +// object literals +{ a: 0} = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +// array literals +['', ''] = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +// super +class Derived extends C { +>Derived : Symbol(Derived, Decl(assignmentLHSIsValue.ts, 37, 17)) +>C : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) + + constructor() { super(); super = value; } +>super : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>super : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + + foo() { super = value } +>foo : Symbol(Derived.foo, Decl(assignmentLHSIsValue.ts, 41, 45)) +>super : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + + static sfoo() { super = value; } +>sfoo : Symbol(Derived.sfoo, Decl(assignmentLHSIsValue.ts, 43, 27)) +>super : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) +} + +// function expression +function bar() { } = value; +>bar : Symbol(bar, Decl(assignmentLHSIsValue.ts, 46, 1)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +() => { } = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +// function calls +foo() = value; +>foo : Symbol(foo, Decl(assignmentLHSIsValue.ts, 8, 1)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +// parentheses, the containted expression is value +(this) = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(M) = value; +>M : Symbol(M, Decl(assignmentLHSIsValue.ts, 12, 13)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(C) = value; +>C : Symbol(C, Decl(assignmentLHSIsValue.ts, 1, 15)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(E) = value; +>E : Symbol(E, Decl(assignmentLHSIsValue.ts, 18, 10)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(foo) = value; +>foo : Symbol(foo, Decl(assignmentLHSIsValue.ts, 8, 1)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(null) = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(true) = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(0) = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +('') = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(/d+/) = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +({}) = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +([]) = value; +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(function baz() { }) = value; +>baz : Symbol(baz, Decl(assignmentLHSIsValue.ts, 68, 1)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + +(foo()) = value; +>foo : Symbol(foo, Decl(assignmentLHSIsValue.ts, 8, 1)) +>value : Symbol(value, Decl(assignmentLHSIsValue.ts, 1, 3)) + diff --git a/tests/baselines/reference/assignmentLHSIsValue.types b/tests/baselines/reference/assignmentLHSIsValue.types new file mode 100644 index 00000000000..b35c15bfe23 --- /dev/null +++ b/tests/baselines/reference/assignmentLHSIsValue.types @@ -0,0 +1,245 @@ +=== tests/cases/conformance/expressions/assignmentOperator/assignmentLHSIsValue.ts === +// expected error for all the LHS of assignments +var value: any; +>value : any + +// this +class C { +>C : C + + constructor() { this = value; } +>this = value : any +>this : this +>value : any + + foo() { this = value; } +>foo : () => void +>this = value : any +>this : this +>value : any + + static sfoo() { this = value; } +>sfoo : () => void +>this = value : any +>this : typeof C +>value : any +} + +function foo() { this = value; } +>foo : () => void +>this = value : any +>this : any +>value : any + +this = value; +>this = value : any +>this : any +>value : any + +// identifiers: module, class, enum, function +module M { export var a; } +>M : typeof M +>a : any + +M = value; +>M = value : any +>M : any +>value : any + +C = value; +>C = value : any +>C : any +>value : any + +enum E { } +>E : E + +E = value; +>E = value : any +>E : any +>value : any + +foo = value; +>foo = value : any +>foo : any +>value : any + +// literals +null = value; +>null = value : any +>null : null +>value : any + +true = value; +>true = value : any +>true : true +>value : any + +false = value; +>false = value : any +>false : false +>value : any + +0 = value; +>0 = value : any +>0 : 0 +>value : any + +'' = value; +>'' = value : any +>'' : "" +>value : any + +/d+/ = value; +>/d+/ = value : any +>/d+/ : RegExp +>value : any + +// object literals +{ a: 0} = value; +>a : any +>0 : 0 +>value : any + +// array literals +['', ''] = value; +>['', ''] = value : any +>['', ''] : [string, string] +>'' : "" +>'' : "" +>value : any + +// super +class Derived extends C { +>Derived : Derived +>C : C + + constructor() { super(); super = value; } +>super() : void +>super : typeof C +>super = value : any +>super : any +>super : C +> : any +>value : any + + foo() { super = value } +>foo : () => void +>super = value : any +>super : any +>super : C +> : any +>value : any + + static sfoo() { super = value; } +>sfoo : () => void +>super = value : any +>super : any +>super : typeof C +> : any +>value : any +} + +// function expression +function bar() { } = value; +>bar : () => void +>value : any + +() => { } = value; +>() => { } : () => void +>value : any + +// function calls +foo() = value; +>foo() = value : any +>foo() : void +>foo : () => void +>value : any + +// parentheses, the containted expression is value +(this) = value; +>(this) = value : any +>(this) : any +>this : any +>value : any + +(M) = value; +>(M) = value : any +>(M) : any +>M : any +>value : any + +(C) = value; +>(C) = value : any +>(C) : any +>C : any +>value : any + +(E) = value; +>(E) = value : any +>(E) : any +>E : any +>value : any + +(foo) = value; +>(foo) = value : any +>(foo) : any +>foo : any +>value : any + +(null) = value; +>(null) = value : any +>(null) : null +>null : null +>value : any + +(true) = value; +>(true) = value : any +>(true) : true +>true : true +>value : any + +(0) = value; +>(0) = value : any +>(0) : 0 +>0 : 0 +>value : any + +('') = value; +>('') = value : any +>('') : "" +>'' : "" +>value : any + +(/d+/) = value; +>(/d+/) = value : any +>(/d+/) : RegExp +>/d+/ : RegExp +>value : any + +({}) = value; +>({}) = value : any +>({}) : {} +>{} : {} +>value : any + +([]) = value; +>([]) = value : any +>([]) : undefined[] +>[] : undefined[] +>value : any + +(function baz() { }) = value; +>(function baz() { }) = value : any +>(function baz() { }) : () => void +>function baz() { } : () => void +>baz : () => void +>value : any + +(foo()) = value; +>(foo()) = value : any +>(foo()) : void +>foo() : void +>foo : () => void +>value : any + diff --git a/tests/baselines/reference/assignmentRestElementWithErrorSourceType.symbols b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.symbols new file mode 100644 index 00000000000..3b88728b282 --- /dev/null +++ b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts === +var tuple: [string, number]; +>tuple : Symbol(tuple, Decl(assignmentRestElementWithErrorSourceType.ts, 0, 3)) + +[...c] = tupel; // intentionally misspelled diff --git a/tests/baselines/reference/assignmentRestElementWithErrorSourceType.types b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.types new file mode 100644 index 00000000000..41bdd948d95 --- /dev/null +++ b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts === +var tuple: [string, number]; +>tuple : [string, number] + +[...c] = tupel; // intentionally misspelled +>[...c] = tupel : any +>[...c] : undefined[] +>...c : any +>c : any +>tupel : any + diff --git a/tests/baselines/reference/assignmentToFunction.symbols b/tests/baselines/reference/assignmentToFunction.symbols new file mode 100644 index 00000000000..5dc3b673489 --- /dev/null +++ b/tests/baselines/reference/assignmentToFunction.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/assignmentToFunction.ts === +function fn() { } +>fn : Symbol(fn, Decl(assignmentToFunction.ts, 0, 0)) + +fn = () => 3; +>fn : Symbol(fn, Decl(assignmentToFunction.ts, 0, 0)) + +module foo { +>foo : Symbol(foo, Decl(assignmentToFunction.ts, 1, 13)) + + function xyz() { +>xyz : Symbol(xyz, Decl(assignmentToFunction.ts, 3, 12)) + + function bar() { +>bar : Symbol(bar, Decl(assignmentToFunction.ts, 4, 20)) + } + bar = null; +>bar : Symbol(bar, Decl(assignmentToFunction.ts, 4, 20)) + } +} diff --git a/tests/baselines/reference/assignmentToFunction.types b/tests/baselines/reference/assignmentToFunction.types new file mode 100644 index 00000000000..9e3ad6cdb89 --- /dev/null +++ b/tests/baselines/reference/assignmentToFunction.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/assignmentToFunction.ts === +function fn() { } +>fn : () => void + +fn = () => 3; +>fn = () => 3 : () => number +>fn : any +>() => 3 : () => number +>3 : 3 + +module foo { +>foo : typeof foo + + function xyz() { +>xyz : () => void + + function bar() { +>bar : () => void + } + bar = null; +>bar = null : null +>bar : any +>null : null + } +} diff --git a/tests/baselines/reference/assignmentToObject.symbols b/tests/baselines/reference/assignmentToObject.symbols new file mode 100644 index 00000000000..a087732bc0f --- /dev/null +++ b/tests/baselines/reference/assignmentToObject.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/assignmentToObject.ts === +var a = { toString: 5 }; +>a : Symbol(a, Decl(assignmentToObject.ts, 0, 3)) +>toString : Symbol(toString, Decl(assignmentToObject.ts, 0, 9)) + +var b: {} = a; // ok +>b : Symbol(b, Decl(assignmentToObject.ts, 1, 3)) +>a : Symbol(a, Decl(assignmentToObject.ts, 0, 3)) + +var c: Object = a; // should be error +>c : Symbol(c, Decl(assignmentToObject.ts, 2, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(assignmentToObject.ts, 0, 3)) + diff --git a/tests/baselines/reference/assignmentToObject.types b/tests/baselines/reference/assignmentToObject.types new file mode 100644 index 00000000000..f39b1210c01 --- /dev/null +++ b/tests/baselines/reference/assignmentToObject.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/assignmentToObject.ts === +var a = { toString: 5 }; +>a : { toString: number; } +>{ toString: 5 } : { toString: number; } +>toString : number +>5 : 5 + +var b: {} = a; // ok +>b : {} +>a : { toString: number; } + +var c: Object = a; // should be error +>c : Object +>Object : Object +>a : { toString: number; } + diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.symbols b/tests/baselines/reference/assignmentToObjectAndFunction.symbols new file mode 100644 index 00000000000..9beee3b6872 --- /dev/null +++ b/tests/baselines/reference/assignmentToObjectAndFunction.symbols @@ -0,0 +1,69 @@ +=== tests/cases/compiler/assignmentToObjectAndFunction.ts === +var errObj: Object = { toString: 0 }; // Error, incompatible toString +>errObj : Symbol(errObj, Decl(assignmentToObjectAndFunction.ts, 0, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>toString : Symbol(toString, Decl(assignmentToObjectAndFunction.ts, 0, 22)) + +var goodObj: Object = { +>goodObj : Symbol(goodObj, Decl(assignmentToObjectAndFunction.ts, 1, 3)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + toString(x?) { +>toString : Symbol(toString, Decl(assignmentToObjectAndFunction.ts, 1, 23)) +>x : Symbol(x, Decl(assignmentToObjectAndFunction.ts, 2, 13)) + + return ""; + } +}; // Ok, because toString is a subtype of Object's toString + +var errFun: Function = {}; // Error for no call signature +>errFun : Symbol(errFun, Decl(assignmentToObjectAndFunction.ts, 7, 3)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +function foo() { } +>foo : Symbol(foo, Decl(assignmentToObjectAndFunction.ts, 7, 26), Decl(assignmentToObjectAndFunction.ts, 9, 18)) + +module foo { +>foo : Symbol(foo, Decl(assignmentToObjectAndFunction.ts, 7, 26), Decl(assignmentToObjectAndFunction.ts, 9, 18)) + + export var boom = 0; +>boom : Symbol(boom, Decl(assignmentToObjectAndFunction.ts, 11, 14)) +} + +var goodFundule: Function = foo; // ok +>goodFundule : Symbol(goodFundule, Decl(assignmentToObjectAndFunction.ts, 14, 3)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>foo : Symbol(foo, Decl(assignmentToObjectAndFunction.ts, 7, 26), Decl(assignmentToObjectAndFunction.ts, 9, 18)) + +function bar() { } +>bar : Symbol(bar, Decl(assignmentToObjectAndFunction.ts, 14, 32), Decl(assignmentToObjectAndFunction.ts, 16, 18)) + +module bar { +>bar : Symbol(bar, Decl(assignmentToObjectAndFunction.ts, 14, 32), Decl(assignmentToObjectAndFunction.ts, 16, 18)) + + export function apply(thisArg: string, argArray?: string) { } +>apply : Symbol(apply, Decl(assignmentToObjectAndFunction.ts, 17, 12)) +>thisArg : Symbol(thisArg, Decl(assignmentToObjectAndFunction.ts, 18, 26)) +>argArray : Symbol(argArray, Decl(assignmentToObjectAndFunction.ts, 18, 42)) +} + +var goodFundule2: Function = bar; // ok +>goodFundule2 : Symbol(goodFundule2, Decl(assignmentToObjectAndFunction.ts, 21, 3)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>bar : Symbol(bar, Decl(assignmentToObjectAndFunction.ts, 14, 32), Decl(assignmentToObjectAndFunction.ts, 16, 18)) + +function bad() { } +>bad : Symbol(bad, Decl(assignmentToObjectAndFunction.ts, 21, 33), Decl(assignmentToObjectAndFunction.ts, 23, 18)) + +module bad { +>bad : Symbol(bad, Decl(assignmentToObjectAndFunction.ts, 21, 33), Decl(assignmentToObjectAndFunction.ts, 23, 18)) + + export var apply = 0; +>apply : Symbol(apply, Decl(assignmentToObjectAndFunction.ts, 25, 14)) +} + +var badFundule: Function = bad; // error +>badFundule : Symbol(badFundule, Decl(assignmentToObjectAndFunction.ts, 28, 3)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>bad : Symbol(bad, Decl(assignmentToObjectAndFunction.ts, 21, 33), Decl(assignmentToObjectAndFunction.ts, 23, 18)) + diff --git a/tests/baselines/reference/assignmentToObjectAndFunction.types b/tests/baselines/reference/assignmentToObjectAndFunction.types new file mode 100644 index 00000000000..d7c6a4f4b12 --- /dev/null +++ b/tests/baselines/reference/assignmentToObjectAndFunction.types @@ -0,0 +1,76 @@ +=== tests/cases/compiler/assignmentToObjectAndFunction.ts === +var errObj: Object = { toString: 0 }; // Error, incompatible toString +>errObj : Object +>Object : Object +>{ toString: 0 } : { toString: number; } +>toString : number +>0 : 0 + +var goodObj: Object = { +>goodObj : Object +>Object : Object +>{ toString(x?) { return ""; }} : { toString(x?: any): string; } + + toString(x?) { +>toString : (x?: any) => string +>x : any + + return ""; +>"" : "" + } +}; // Ok, because toString is a subtype of Object's toString + +var errFun: Function = {}; // Error for no call signature +>errFun : Function +>Function : Function +>{} : {} + +function foo() { } +>foo : typeof foo + +module foo { +>foo : typeof foo + + export var boom = 0; +>boom : number +>0 : 0 +} + +var goodFundule: Function = foo; // ok +>goodFundule : Function +>Function : Function +>foo : typeof foo + +function bar() { } +>bar : typeof bar + +module bar { +>bar : typeof bar + + export function apply(thisArg: string, argArray?: string) { } +>apply : (thisArg: string, argArray?: string) => void +>thisArg : string +>argArray : string +} + +var goodFundule2: Function = bar; // ok +>goodFundule2 : Function +>Function : Function +>bar : typeof bar + +function bad() { } +>bad : typeof bad + +module bad { +>bad : typeof bad + + export var apply = 0; +>apply : number +>0 : 0 +} + +var badFundule: Function = bad; // error +>badFundule : Function +>Function : Function +>bad : typeof bad + diff --git a/tests/baselines/reference/assignmentToParenthesizedExpression1.symbols b/tests/baselines/reference/assignmentToParenthesizedExpression1.symbols new file mode 100644 index 00000000000..63de71a6408 --- /dev/null +++ b/tests/baselines/reference/assignmentToParenthesizedExpression1.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/assignmentToParenthesizedExpression1.ts === +var x; +>x : Symbol(x, Decl(assignmentToParenthesizedExpression1.ts, 0, 3)) + +(1, x)=0; +>x : Symbol(x, Decl(assignmentToParenthesizedExpression1.ts, 0, 3)) + diff --git a/tests/baselines/reference/assignmentToParenthesizedExpression1.types b/tests/baselines/reference/assignmentToParenthesizedExpression1.types new file mode 100644 index 00000000000..a1273376b75 --- /dev/null +++ b/tests/baselines/reference/assignmentToParenthesizedExpression1.types @@ -0,0 +1,12 @@ +=== tests/cases/compiler/assignmentToParenthesizedExpression1.ts === +var x; +>x : any + +(1, x)=0; +>(1, x)=0 : 0 +>(1, x) : any +>1, x : any +>1 : 1 +>x : any +>0 : 0 + diff --git a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.symbols b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.symbols new file mode 100644 index 00000000000..6330ac20b5f --- /dev/null +++ b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.symbols @@ -0,0 +1,210 @@ +=== tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts === +var x: number; +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 0, 3)) + +x = 3; // OK +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 0, 3)) + +(x) = 3; // OK +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 0, 3)) + +x = ''; // Error +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 0, 3)) + +(x) = ''; // Error +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 0, 3)) + +module M { +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) + + export var y: number; +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) +} +M.y = 3; // OK +>M.y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) +>y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) + +(M).y = 3; // OK +>(M).y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) +>y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) + +(M.y) = 3; // OK +>M.y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) +>y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) + +M.y = ''; // Error +>M.y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) +>y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) + +(M).y = ''; // Error +>(M).y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) +>y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) + +(M.y) = ''; // Error +>M.y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) +>y : Symbol(M.y, Decl(assignmentToParenthesizedIdentifiers.ts, 7, 14)) + +M = { y: 3 }; // Error +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 16, 5)) + +(M) = { y: 3 }; // Error +>M : Symbol(M, Decl(assignmentToParenthesizedIdentifiers.ts, 4, 9)) +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 17, 7)) + +module M2 { +>M2 : Symbol(M2, Decl(assignmentToParenthesizedIdentifiers.ts, 17, 15)) + + export module M3 { +>M3 : Symbol(M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) + + export var x: number; +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 21, 18)) + } + + M3 = { x: 3 }; // Error +>M3 : Symbol(M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 24, 10)) +} +M2.M3 = { x: 3 }; // OK +>M2.M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>M2 : Symbol(M2, Decl(assignmentToParenthesizedIdentifiers.ts, 17, 15)) +>M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 26, 9)) + +(M2).M3 = { x: 3 }; // OK +>(M2).M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>M2 : Symbol(M2, Decl(assignmentToParenthesizedIdentifiers.ts, 17, 15)) +>M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 27, 11)) + +(M2.M3) = { x: 3 }; // OK +>M2.M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>M2 : Symbol(M2, Decl(assignmentToParenthesizedIdentifiers.ts, 17, 15)) +>M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 28, 11)) + +M2.M3 = { x: '' }; // Error +>M2.M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>M2 : Symbol(M2, Decl(assignmentToParenthesizedIdentifiers.ts, 17, 15)) +>M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 30, 9)) + +(M2).M3 = { x: '' }; // Error +>(M2).M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>M2 : Symbol(M2, Decl(assignmentToParenthesizedIdentifiers.ts, 17, 15)) +>M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 31, 11)) + +(M2.M3) = { x: '' }; // Error +>M2.M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>M2 : Symbol(M2, Decl(assignmentToParenthesizedIdentifiers.ts, 17, 15)) +>M3 : Symbol(M2.M3, Decl(assignmentToParenthesizedIdentifiers.ts, 19, 11)) +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 32, 11)) + + +function fn() { } +>fn : Symbol(fn, Decl(assignmentToParenthesizedIdentifiers.ts, 32, 20)) + +fn = () => 3; // Bug 823548: Should be error (fn is not a reference) +>fn : Symbol(fn, Decl(assignmentToParenthesizedIdentifiers.ts, 32, 20)) + +(fn) = () => 3; // Should be error +>fn : Symbol(fn, Decl(assignmentToParenthesizedIdentifiers.ts, 32, 20)) + +function fn2(x: number, y: { t: number }) { +>fn2 : Symbol(fn2, Decl(assignmentToParenthesizedIdentifiers.ts, 37, 15)) +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 13)) +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + x = 3; +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 13)) + + (x) = 3; // OK +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 13)) + + x = ''; // Error +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 13)) + + (x) = ''; // Error +>x : Symbol(x, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 13)) + + (y).t = 3; // OK +>(y).t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + (y.t) = 3; // OK +>y.t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + (y).t = ''; // Error +>(y).t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + (y.t) = ''; // Error +>y.t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>t : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + y['t'] = 3; // OK +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>'t' : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + (y)['t'] = 3; // OK +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>'t' : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + (y['t']) = 3; // OK +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>'t' : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + y['t'] = ''; // Error +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>'t' : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + (y)['t'] = ''; // Error +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>'t' : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) + + (y['t']) = ''; // Error +>y : Symbol(y, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 23)) +>'t' : Symbol(t, Decl(assignmentToParenthesizedIdentifiers.ts, 39, 28)) +} + +enum E { +>E : Symbol(E, Decl(assignmentToParenthesizedIdentifiers.ts, 56, 1)) + + A +>A : Symbol(E.A, Decl(assignmentToParenthesizedIdentifiers.ts, 58, 8)) +} +E = undefined; // Error +>E : Symbol(E, Decl(assignmentToParenthesizedIdentifiers.ts, 56, 1)) +>undefined : Symbol(undefined) + +(E) = undefined; // Error +>E : Symbol(E, Decl(assignmentToParenthesizedIdentifiers.ts, 56, 1)) +>undefined : Symbol(undefined) + +class C { +>C : Symbol(C, Decl(assignmentToParenthesizedIdentifiers.ts, 62, 16)) + +} + +C = undefined; // Error +>C : Symbol(C, Decl(assignmentToParenthesizedIdentifiers.ts, 62, 16)) +>undefined : Symbol(undefined) + +(C) = undefined; // Error +>C : Symbol(C, Decl(assignmentToParenthesizedIdentifiers.ts, 62, 16)) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.types b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.types new file mode 100644 index 00000000000..ab95fb8cb2f --- /dev/null +++ b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.types @@ -0,0 +1,325 @@ +=== tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts === +var x: number; +>x : number + +x = 3; // OK +>x = 3 : 3 +>x : number +>3 : 3 + +(x) = 3; // OK +>(x) = 3 : 3 +>(x) : number +>x : number +>3 : 3 + +x = ''; // Error +>x = '' : "" +>x : number +>'' : "" + +(x) = ''; // Error +>(x) = '' : "" +>(x) : number +>x : number +>'' : "" + +module M { +>M : typeof M + + export var y: number; +>y : number +} +M.y = 3; // OK +>M.y = 3 : 3 +>M.y : number +>M : typeof M +>y : number +>3 : 3 + +(M).y = 3; // OK +>(M).y = 3 : 3 +>(M).y : number +>(M) : typeof M +>M : typeof M +>y : number +>3 : 3 + +(M.y) = 3; // OK +>(M.y) = 3 : 3 +>(M.y) : number +>M.y : number +>M : typeof M +>y : number +>3 : 3 + +M.y = ''; // Error +>M.y = '' : "" +>M.y : number +>M : typeof M +>y : number +>'' : "" + +(M).y = ''; // Error +>(M).y = '' : "" +>(M).y : number +>(M) : typeof M +>M : typeof M +>y : number +>'' : "" + +(M.y) = ''; // Error +>(M.y) = '' : "" +>(M.y) : number +>M.y : number +>M : typeof M +>y : number +>'' : "" + +M = { y: 3 }; // Error +>M = { y: 3 } : { y: number; } +>M : any +>{ y: 3 } : { y: number; } +>y : number +>3 : 3 + +(M) = { y: 3 }; // Error +>(M) = { y: 3 } : { y: number; } +>(M) : any +>M : any +>{ y: 3 } : { y: number; } +>y : number +>3 : 3 + +module M2 { +>M2 : typeof M2 + + export module M3 { +>M3 : typeof M3 + + export var x: number; +>x : number + } + + M3 = { x: 3 }; // Error +>M3 = { x: 3 } : { x: number; } +>M3 : any +>{ x: 3 } : { x: number; } +>x : number +>3 : 3 +} +M2.M3 = { x: 3 }; // OK +>M2.M3 = { x: 3 } : { x: number; } +>M2.M3 : typeof M2.M3 +>M2 : typeof M2 +>M3 : typeof M2.M3 +>{ x: 3 } : { x: number; } +>x : number +>3 : 3 + +(M2).M3 = { x: 3 }; // OK +>(M2).M3 = { x: 3 } : { x: number; } +>(M2).M3 : typeof M2.M3 +>(M2) : typeof M2 +>M2 : typeof M2 +>M3 : typeof M2.M3 +>{ x: 3 } : { x: number; } +>x : number +>3 : 3 + +(M2.M3) = { x: 3 }; // OK +>(M2.M3) = { x: 3 } : { x: number; } +>(M2.M3) : typeof M2.M3 +>M2.M3 : typeof M2.M3 +>M2 : typeof M2 +>M3 : typeof M2.M3 +>{ x: 3 } : { x: number; } +>x : number +>3 : 3 + +M2.M3 = { x: '' }; // Error +>M2.M3 = { x: '' } : { x: string; } +>M2.M3 : typeof M2.M3 +>M2 : typeof M2 +>M3 : typeof M2.M3 +>{ x: '' } : { x: string; } +>x : string +>'' : "" + +(M2).M3 = { x: '' }; // Error +>(M2).M3 = { x: '' } : { x: string; } +>(M2).M3 : typeof M2.M3 +>(M2) : typeof M2 +>M2 : typeof M2 +>M3 : typeof M2.M3 +>{ x: '' } : { x: string; } +>x : string +>'' : "" + +(M2.M3) = { x: '' }; // Error +>(M2.M3) = { x: '' } : { x: string; } +>(M2.M3) : typeof M2.M3 +>M2.M3 : typeof M2.M3 +>M2 : typeof M2 +>M3 : typeof M2.M3 +>{ x: '' } : { x: string; } +>x : string +>'' : "" + + +function fn() { } +>fn : () => void + +fn = () => 3; // Bug 823548: Should be error (fn is not a reference) +>fn = () => 3 : () => number +>fn : any +>() => 3 : () => number +>3 : 3 + +(fn) = () => 3; // Should be error +>(fn) = () => 3 : () => number +>(fn) : any +>fn : any +>() => 3 : () => number +>3 : 3 + +function fn2(x: number, y: { t: number }) { +>fn2 : (x: number, y: { t: number; }) => void +>x : number +>y : { t: number; } +>t : number + + x = 3; +>x = 3 : 3 +>x : number +>3 : 3 + + (x) = 3; // OK +>(x) = 3 : 3 +>(x) : number +>x : number +>3 : 3 + + x = ''; // Error +>x = '' : "" +>x : number +>'' : "" + + (x) = ''; // Error +>(x) = '' : "" +>(x) : number +>x : number +>'' : "" + + (y).t = 3; // OK +>(y).t = 3 : 3 +>(y).t : number +>(y) : { t: number; } +>y : { t: number; } +>t : number +>3 : 3 + + (y.t) = 3; // OK +>(y.t) = 3 : 3 +>(y.t) : number +>y.t : number +>y : { t: number; } +>t : number +>3 : 3 + + (y).t = ''; // Error +>(y).t = '' : "" +>(y).t : number +>(y) : { t: number; } +>y : { t: number; } +>t : number +>'' : "" + + (y.t) = ''; // Error +>(y.t) = '' : "" +>(y.t) : number +>y.t : number +>y : { t: number; } +>t : number +>'' : "" + + y['t'] = 3; // OK +>y['t'] = 3 : 3 +>y['t'] : number +>y : { t: number; } +>'t' : "t" +>3 : 3 + + (y)['t'] = 3; // OK +>(y)['t'] = 3 : 3 +>(y)['t'] : number +>(y) : { t: number; } +>y : { t: number; } +>'t' : "t" +>3 : 3 + + (y['t']) = 3; // OK +>(y['t']) = 3 : 3 +>(y['t']) : number +>y['t'] : number +>y : { t: number; } +>'t' : "t" +>3 : 3 + + y['t'] = ''; // Error +>y['t'] = '' : "" +>y['t'] : number +>y : { t: number; } +>'t' : "t" +>'' : "" + + (y)['t'] = ''; // Error +>(y)['t'] = '' : "" +>(y)['t'] : number +>(y) : { t: number; } +>y : { t: number; } +>'t' : "t" +>'' : "" + + (y['t']) = ''; // Error +>(y['t']) = '' : "" +>(y['t']) : number +>y['t'] : number +>y : { t: number; } +>'t' : "t" +>'' : "" +} + +enum E { +>E : E + + A +>A : E +} +E = undefined; // Error +>E = undefined : undefined +>E : any +>undefined : undefined + +(E) = undefined; // Error +>(E) = undefined : undefined +>(E) : any +>E : any +>undefined : undefined + +class C { +>C : C + +} + +C = undefined; // Error +>C = undefined : undefined +>C : any +>undefined : undefined + +(C) = undefined; // Error +>(C) = undefined : undefined +>(C) : any +>C : any +>undefined : undefined + diff --git a/tests/baselines/reference/assignmentToReferenceTypes.symbols b/tests/baselines/reference/assignmentToReferenceTypes.symbols new file mode 100644 index 00000000000..55a385f0b03 --- /dev/null +++ b/tests/baselines/reference/assignmentToReferenceTypes.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/assignmentToReferenceTypes.ts === +// Should all be allowed + +module M { +>M : Symbol(M, Decl(assignmentToReferenceTypes.ts, 0, 0)) +} +M = null; + +class C { +>C : Symbol(C, Decl(assignmentToReferenceTypes.ts, 4, 9)) +} +C = null; +>C : Symbol(C, Decl(assignmentToReferenceTypes.ts, 4, 9)) + +enum E { +>E : Symbol(E, Decl(assignmentToReferenceTypes.ts, 8, 9)) +} +E = null; +>E : Symbol(E, Decl(assignmentToReferenceTypes.ts, 8, 9)) + +function f() { } +>f : Symbol(f, Decl(assignmentToReferenceTypes.ts, 12, 9)) + +f = null; +>f : Symbol(f, Decl(assignmentToReferenceTypes.ts, 12, 9)) + +var x = 1; +>x : Symbol(x, Decl(assignmentToReferenceTypes.ts, 17, 3)) + +x = null; +>x : Symbol(x, Decl(assignmentToReferenceTypes.ts, 17, 3)) + +function g(x) { +>g : Symbol(g, Decl(assignmentToReferenceTypes.ts, 18, 9)) +>x : Symbol(x, Decl(assignmentToReferenceTypes.ts, 20, 11)) + + x = null; +>x : Symbol(x, Decl(assignmentToReferenceTypes.ts, 20, 11)) +} diff --git a/tests/baselines/reference/assignmentToReferenceTypes.types b/tests/baselines/reference/assignmentToReferenceTypes.types new file mode 100644 index 00000000000..78c5e283368 --- /dev/null +++ b/tests/baselines/reference/assignmentToReferenceTypes.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/assignmentToReferenceTypes.ts === +// Should all be allowed + +module M { +>M : any +} +M = null; +>M = null : null +>M : any +>null : null + +class C { +>C : C +} +C = null; +>C = null : null +>C : any +>null : null + +enum E { +>E : E +} +E = null; +>E = null : null +>E : any +>null : null + +function f() { } +>f : () => void + +f = null; +>f = null : null +>f : any +>null : null + +var x = 1; +>x : number +>1 : 1 + +x = null; +>x = null : null +>x : number +>null : null + +function g(x) { +>g : (x: any) => void +>x : any + + x = null; +>x = null : null +>x : any +>null : null +} diff --git a/tests/baselines/reference/assignments.symbols b/tests/baselines/reference/assignments.symbols new file mode 100644 index 00000000000..731045c3133 --- /dev/null +++ b/tests/baselines/reference/assignments.symbols @@ -0,0 +1,57 @@ +=== tests/cases/conformance/expressions/valuesAndReferences/assignments.ts === +// In this file: +// Assign to a module +// Assign to a class +// Assign to an enum +// Assign to a function +// Assign to a variable +// Assign to a parameter +// Assign to an interface + +module M { } +>M : Symbol(M, Decl(assignments.ts, 0, 0)) + +M = null; // Error + +class C { } +>C : Symbol(C, Decl(assignments.ts, 10, 9)) + +C = null; // Error +>C : Symbol(C, Decl(assignments.ts, 10, 9)) + +enum E { A } +>E : Symbol(E, Decl(assignments.ts, 13, 9)) +>A : Symbol(E.A, Decl(assignments.ts, 15, 8)) + +E = null; // Error +>E : Symbol(E, Decl(assignments.ts, 13, 9)) + +E.A = null; // OK per spec, Error per implementation (509581) +>E.A : Symbol(E.A, Decl(assignments.ts, 15, 8)) +>E : Symbol(E, Decl(assignments.ts, 13, 9)) +>A : Symbol(E.A, Decl(assignments.ts, 15, 8)) + +function fn() { } +>fn : Symbol(fn, Decl(assignments.ts, 17, 11)) + +fn = null; // Should be error +>fn : Symbol(fn, Decl(assignments.ts, 17, 11)) + +var v; +>v : Symbol(v, Decl(assignments.ts, 22, 3)) + +v = null; // OK +>v : Symbol(v, Decl(assignments.ts, 22, 3)) + +function fn2(p) { +>fn2 : Symbol(fn2, Decl(assignments.ts, 23, 9)) +>p : Symbol(p, Decl(assignments.ts, 25, 13)) + + p = null; // OK +>p : Symbol(p, Decl(assignments.ts, 25, 13)) +} + +interface I { } +>I : Symbol(I, Decl(assignments.ts, 27, 1)) + +I = null; // Error diff --git a/tests/baselines/reference/assignments.types b/tests/baselines/reference/assignments.types new file mode 100644 index 00000000000..70d034a4101 --- /dev/null +++ b/tests/baselines/reference/assignments.types @@ -0,0 +1,76 @@ +=== tests/cases/conformance/expressions/valuesAndReferences/assignments.ts === +// In this file: +// Assign to a module +// Assign to a class +// Assign to an enum +// Assign to a function +// Assign to a variable +// Assign to a parameter +// Assign to an interface + +module M { } +>M : any + +M = null; // Error +>M = null : null +>M : any +>null : null + +class C { } +>C : C + +C = null; // Error +>C = null : null +>C : any +>null : null + +enum E { A } +>E : E +>A : E + +E = null; // Error +>E = null : null +>E : any +>null : null + +E.A = null; // OK per spec, Error per implementation (509581) +>E.A = null : null +>E.A : any +>E : typeof E +>A : any +>null : null + +function fn() { } +>fn : () => void + +fn = null; // Should be error +>fn = null : null +>fn : any +>null : null + +var v; +>v : any + +v = null; // OK +>v = null : null +>v : any +>null : null + +function fn2(p) { +>fn2 : (p: any) => void +>p : any + + p = null; // OK +>p = null : null +>p : any +>null : null +} + +interface I { } +>I : I + +I = null; // Error +>I = null : null +>I : any +>null : null + diff --git a/tests/baselines/reference/asyncAliasReturnType_es5.symbols b/tests/baselines/reference/asyncAliasReturnType_es5.symbols index b61fbf6e275..5e024c27d5e 100644 --- a/tests/baselines/reference/asyncAliasReturnType_es5.symbols +++ b/tests/baselines/reference/asyncAliasReturnType_es5.symbols @@ -2,7 +2,7 @@ type PromiseAlias = Promise; >PromiseAlias : Symbol(PromiseAlias, Decl(asyncAliasReturnType_es5.ts, 0, 0)) >T : Symbol(T, Decl(asyncAliasReturnType_es5.ts, 0, 18)) ->Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) >T : Symbol(T, Decl(asyncAliasReturnType_es5.ts, 0, 18)) async function f(): PromiseAlias { diff --git a/tests/baselines/reference/asyncArrowFunction10_es2017.symbols b/tests/baselines/reference/asyncArrowFunction10_es2017.symbols new file mode 100644 index 00000000000..dd8516ca0e9 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es2017.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts === +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction10_es2017.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + // Legal to use 'await' in a type context. + var v: await; +>v : Symbol(v, Decl(asyncArrowFunction10_es2017.ts, 2, 6)) +} + diff --git a/tests/baselines/reference/asyncArrowFunction10_es2017.types b/tests/baselines/reference/asyncArrowFunction10_es2017.types new file mode 100644 index 00000000000..b9a95c7189b --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es2017.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction10_es2017.ts === +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => { // Legal to use 'await' in a type context. var v: await;} : () => Promise +>Promise : Promise + + // Legal to use 'await' in a type context. + var v: await; +>v : any +>await : No type information available! +} + diff --git a/tests/baselines/reference/asyncArrowFunction10_es5.symbols b/tests/baselines/reference/asyncArrowFunction10_es5.symbols new file mode 100644 index 00000000000..51f63cf481d --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es5.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction10_es5.ts === +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction10_es5.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + // Legal to use 'await' in a type context. + var v: await; +>v : Symbol(v, Decl(asyncArrowFunction10_es5.ts, 2, 6)) +} + diff --git a/tests/baselines/reference/asyncArrowFunction10_es5.types b/tests/baselines/reference/asyncArrowFunction10_es5.types new file mode 100644 index 00000000000..a1c02c7b6fd --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es5.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction10_es5.ts === +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => { // Legal to use 'await' in a type context. var v: await;} : () => Promise +>Promise : Promise + + // Legal to use 'await' in a type context. + var v: await; +>v : any +>await : No type information available! +} + diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.symbols b/tests/baselines/reference/asyncArrowFunction10_es6.symbols new file mode 100644 index 00000000000..7962e8328bc --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es6.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts === +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction10_es6.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + // Legal to use 'await' in a type context. + var v: await; +>v : Symbol(v, Decl(asyncArrowFunction10_es6.ts, 2, 6)) +} + diff --git a/tests/baselines/reference/asyncArrowFunction10_es6.types b/tests/baselines/reference/asyncArrowFunction10_es6.types new file mode 100644 index 00000000000..85a55d92479 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction10_es6.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction10_es6.ts === +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => { // Legal to use 'await' in a type context. var v: await;} : () => Promise +>Promise : Promise + + // Legal to use 'await' in a type context. + var v: await; +>v : any +>await : No type information available! +} + diff --git a/tests/baselines/reference/asyncArrowFunction3_es2017.symbols b/tests/baselines/reference/asyncArrowFunction3_es2017.symbols new file mode 100644 index 00000000000..8564be785ab --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es2017.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts === +function f(await = await) { +>f : Symbol(f, Decl(asyncArrowFunction3_es2017.ts, 0, 0)) +>await : Symbol(await, Decl(asyncArrowFunction3_es2017.ts, 0, 11)) +>await : Symbol(await, Decl(asyncArrowFunction3_es2017.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es2017.types b/tests/baselines/reference/asyncArrowFunction3_es2017.types new file mode 100644 index 00000000000..bd5c2afc67a --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es2017.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction3_es2017.ts === +function f(await = await) { +>f : (await?: any) => void +>await : any +>await : any +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es5.symbols b/tests/baselines/reference/asyncArrowFunction3_es5.symbols new file mode 100644 index 00000000000..f91744bc7fe --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es5.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts === +function f(await = await) { +>f : Symbol(f, Decl(asyncArrowFunction3_es5.ts, 0, 0)) +>await : Symbol(await, Decl(asyncArrowFunction3_es5.ts, 0, 11)) +>await : Symbol(await, Decl(asyncArrowFunction3_es5.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es5.types b/tests/baselines/reference/asyncArrowFunction3_es5.types new file mode 100644 index 00000000000..c4873df1371 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es5.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction3_es5.ts === +function f(await = await) { +>f : (await?: any) => void +>await : any +>await : any +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.symbols b/tests/baselines/reference/asyncArrowFunction3_es6.symbols new file mode 100644 index 00000000000..f623c139aa0 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts === +function f(await = await) { +>f : Symbol(f, Decl(asyncArrowFunction3_es6.ts, 0, 0)) +>await : Symbol(await, Decl(asyncArrowFunction3_es6.ts, 0, 11)) +>await : Symbol(await, Decl(asyncArrowFunction3_es6.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncArrowFunction3_es6.types b/tests/baselines/reference/asyncArrowFunction3_es6.types new file mode 100644 index 00000000000..c43b50de4ae --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction3_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction3_es6.ts === +function f(await = await) { +>f : (await?: any) => void +>await : any +>await : any +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.symbols b/tests/baselines/reference/asyncArrowFunction5_es2017.symbols new file mode 100644 index 00000000000..9f74f496892 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts === +var foo = async (await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction5_es2017.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(asyncArrowFunction5_es2017.ts, 0, 24)) +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.types b/tests/baselines/reference/asyncArrowFunction5_es2017.types new file mode 100644 index 00000000000..95cebf9afba --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts === +var foo = async (await): Promise => { +>foo : any +>async (await) : any +>async : any +>await : any +>Promise : PromiseConstructor +> : void +> : any +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.symbols b/tests/baselines/reference/asyncArrowFunction5_es5.symbols new file mode 100644 index 00000000000..ff2891bb814 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es5.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts === +var foo = async (await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction5_es5.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(asyncArrowFunction5_es5.ts, 0, 24)) +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.types b/tests/baselines/reference/asyncArrowFunction5_es5.types new file mode 100644 index 00000000000..93385915415 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es5.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts === +var foo = async (await): Promise => { +>foo : any +>async (await) : any +>async : any +>await : any +>Promise : PromiseConstructor +> : void +> : any +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.symbols b/tests/baselines/reference/asyncArrowFunction5_es6.symbols new file mode 100644 index 00000000000..44827a41f9b --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts === +var foo = async (await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction5_es6.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(asyncArrowFunction5_es6.ts, 0, 24)) +} diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.types b/tests/baselines/reference/asyncArrowFunction5_es6.types new file mode 100644 index 00000000000..1fffb0b1dbd --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction5_es6.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts === +var foo = async (await): Promise => { +>foo : any +>async (await) : any +>async : any +>await : any +>Promise : PromiseConstructor +> : void +> : any +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es2017.symbols b/tests/baselines/reference/asyncArrowFunction6_es2017.symbols new file mode 100644 index 00000000000..c75b45cce81 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es2017.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts === +var foo = async (a = await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction6_es2017.ts, 0, 3)) +>a : Symbol(a, Decl(asyncArrowFunction6_es2017.ts, 0, 17)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es2017.types b/tests/baselines/reference/asyncArrowFunction6_es2017.types new file mode 100644 index 00000000000..d1d8b98944f --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es2017.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction6_es2017.ts === +var foo = async (a = await): Promise => { +>foo : (a?: any) => Promise +>async (a = await): Promise => {} : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es5.symbols b/tests/baselines/reference/asyncArrowFunction6_es5.symbols new file mode 100644 index 00000000000..51f3a218ecc --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es5.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts === +var foo = async (a = await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction6_es5.ts, 0, 3)) +>a : Symbol(a, Decl(asyncArrowFunction6_es5.ts, 0, 17)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es5.types b/tests/baselines/reference/asyncArrowFunction6_es5.types new file mode 100644 index 00000000000..d5458c6bc1c --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es5.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction6_es5.ts === +var foo = async (a = await): Promise => { +>foo : (a?: any) => Promise +>async (a = await): Promise => {} : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.symbols b/tests/baselines/reference/asyncArrowFunction6_es6.symbols new file mode 100644 index 00000000000..e3fa9a191f0 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts === +var foo = async (a = await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction6_es6.ts, 0, 3)) +>a : Symbol(a, Decl(asyncArrowFunction6_es6.ts, 0, 17)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncArrowFunction6_es6.types b/tests/baselines/reference/asyncArrowFunction6_es6.types new file mode 100644 index 00000000000..66957807462 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction6_es6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction6_es6.ts === +var foo = async (a = await): Promise => { +>foo : (a?: any) => Promise +>async (a = await): Promise => {} : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncArrowFunction7_es2017.symbols b/tests/baselines/reference/asyncArrowFunction7_es2017.symbols new file mode 100644 index 00000000000..c6e24798e70 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es2017.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts === +var bar = async (): Promise => { +>bar : Symbol(bar, Decl(asyncArrowFunction7_es2017.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction7_es2017.ts, 2, 5)) +>a : Symbol(a, Decl(asyncArrowFunction7_es2017.ts, 2, 19)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + } +} diff --git a/tests/baselines/reference/asyncArrowFunction7_es2017.types b/tests/baselines/reference/asyncArrowFunction7_es2017.types new file mode 100644 index 00000000000..48c2195dec5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es2017.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction7_es2017.ts === +var bar = async (): Promise => { +>bar : () => Promise +>async (): Promise => { // 'await' here is an identifier, and not an await expression. var foo = async (a = await): Promise => { }} : () => Promise +>Promise : Promise + + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { +>foo : (a?: any) => Promise +>async (a = await): Promise => { } : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise + } +} diff --git a/tests/baselines/reference/asyncArrowFunction7_es5.symbols b/tests/baselines/reference/asyncArrowFunction7_es5.symbols new file mode 100644 index 00000000000..e2cda0a8997 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es5.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts === +var bar = async (): Promise => { +>bar : Symbol(bar, Decl(asyncArrowFunction7_es5.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction7_es5.ts, 2, 5)) +>a : Symbol(a, Decl(asyncArrowFunction7_es5.ts, 2, 19)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} diff --git a/tests/baselines/reference/asyncArrowFunction7_es5.types b/tests/baselines/reference/asyncArrowFunction7_es5.types new file mode 100644 index 00000000000..cb468123db7 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es5.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction7_es5.ts === +var bar = async (): Promise => { +>bar : () => Promise +>async (): Promise => { // 'await' here is an identifier, and not an await expression. var foo = async (a = await): Promise => { }} : () => Promise +>Promise : Promise + + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { +>foo : (a?: any) => Promise +>async (a = await): Promise => { } : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise + } +} diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.symbols b/tests/baselines/reference/asyncArrowFunction7_es6.symbols new file mode 100644 index 00000000000..c2d9d8404da --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es6.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts === +var bar = async (): Promise => { +>bar : Symbol(bar, Decl(asyncArrowFunction7_es6.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction7_es6.ts, 2, 5)) +>a : Symbol(a, Decl(asyncArrowFunction7_es6.ts, 2, 19)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + } +} diff --git a/tests/baselines/reference/asyncArrowFunction7_es6.types b/tests/baselines/reference/asyncArrowFunction7_es6.types new file mode 100644 index 00000000000..8687451f03b --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction7_es6.types @@ -0,0 +1,16 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction7_es6.ts === +var bar = async (): Promise => { +>bar : () => Promise +>async (): Promise => { // 'await' here is an identifier, and not an await expression. var foo = async (a = await): Promise => { }} : () => Promise +>Promise : Promise + + // 'await' here is an identifier, and not an await expression. + var foo = async (a = await): Promise => { +>foo : (a?: any) => Promise +>async (a = await): Promise => { } : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise + } +} diff --git a/tests/baselines/reference/asyncArrowFunction8_es2017.symbols b/tests/baselines/reference/asyncArrowFunction8_es2017.symbols new file mode 100644 index 00000000000..568416e148c --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es2017.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts === +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction8_es2017.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + var v = { [await]: foo } +>v : Symbol(v, Decl(asyncArrowFunction8_es2017.ts, 1, 5)) +>foo : Symbol(foo, Decl(asyncArrowFunction8_es2017.ts, 0, 3)) +} diff --git a/tests/baselines/reference/asyncArrowFunction8_es2017.types b/tests/baselines/reference/asyncArrowFunction8_es2017.types new file mode 100644 index 00000000000..62064fe9614 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es2017.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction8_es2017.ts === +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => { var v = { [await]: foo }} : () => Promise +>Promise : Promise + + var v = { [await]: foo } +>v : { [x: number]: () => Promise; } +>{ [await]: foo } : { [x: number]: () => Promise; } +>await : any +> : any +>foo : () => Promise +} diff --git a/tests/baselines/reference/asyncArrowFunction8_es5.symbols b/tests/baselines/reference/asyncArrowFunction8_es5.symbols new file mode 100644 index 00000000000..414f2303fe3 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es5.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction8_es5.ts === +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction8_es5.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + var v = { [await]: foo } +>v : Symbol(v, Decl(asyncArrowFunction8_es5.ts, 1, 5)) +>foo : Symbol(foo, Decl(asyncArrowFunction8_es5.ts, 0, 3)) +} diff --git a/tests/baselines/reference/asyncArrowFunction8_es5.types b/tests/baselines/reference/asyncArrowFunction8_es5.types new file mode 100644 index 00000000000..c89bf47b0c6 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es5.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction8_es5.ts === +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => { var v = { [await]: foo }} : () => Promise +>Promise : Promise + + var v = { [await]: foo } +>v : { [x: number]: () => Promise; } +>{ [await]: foo } : { [x: number]: () => Promise; } +>await : any +> : any +>foo : () => Promise +} diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.symbols b/tests/baselines/reference/asyncArrowFunction8_es6.symbols new file mode 100644 index 00000000000..47117f2c61c --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es6.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts === +var foo = async (): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction8_es6.ts, 0, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + var v = { [await]: foo } +>v : Symbol(v, Decl(asyncArrowFunction8_es6.ts, 1, 5)) +>foo : Symbol(foo, Decl(asyncArrowFunction8_es6.ts, 0, 3)) +} diff --git a/tests/baselines/reference/asyncArrowFunction8_es6.types b/tests/baselines/reference/asyncArrowFunction8_es6.types new file mode 100644 index 00000000000..aae1a0dcaeb --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction8_es6.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction8_es6.ts === +var foo = async (): Promise => { +>foo : () => Promise +>async (): Promise => { var v = { [await]: foo }} : () => Promise +>Promise : Promise + + var v = { [await]: foo } +>v : { [x: number]: () => Promise; } +>{ [await]: foo } : { [x: number]: () => Promise; } +>await : any +> : any +>foo : () => Promise +} diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.symbols b/tests/baselines/reference/asyncArrowFunction9_es2017.symbols new file mode 100644 index 00000000000..d15a8d3ee98 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts === +var foo = async (a = await => await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction9_es2017.ts, 0, 3)) +>await : Symbol(await, Decl(asyncArrowFunction9_es2017.ts, 0, 20)) +>await : Symbol(await, Decl(asyncArrowFunction9_es2017.ts, 0, 20)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(asyncArrowFunction9_es2017.ts, 0, 37)) +} diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.types b/tests/baselines/reference/asyncArrowFunction9_es2017.types new file mode 100644 index 00000000000..48a29643016 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts === +var foo = async (a = await => await): Promise => { +>foo : any +>async (a = await => await) : any +>async : any +>a = await => await : (await: any) => any +>a : any +>await => await : (await: any) => any +>await : any +>await : any +>Promise : PromiseConstructor +> : void +> : any +} diff --git a/tests/baselines/reference/asyncArrowFunction9_es5.symbols b/tests/baselines/reference/asyncArrowFunction9_es5.symbols new file mode 100644 index 00000000000..e0e27ba2f75 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es5.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts === +var foo = async (a = await => await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction9_es5.ts, 0, 3)) +>await : Symbol(await, Decl(asyncArrowFunction9_es5.ts, 0, 20)) +>await : Symbol(await, Decl(asyncArrowFunction9_es5.ts, 0, 20)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(asyncArrowFunction9_es5.ts, 0, 37)) +} diff --git a/tests/baselines/reference/asyncArrowFunction9_es5.types b/tests/baselines/reference/asyncArrowFunction9_es5.types new file mode 100644 index 00000000000..43f685a4e48 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es5.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts === +var foo = async (a = await => await): Promise => { +>foo : any +>async (a = await => await) : any +>async : any +>a = await => await : (await: any) => any +>a : any +>await => await : (await: any) => any +>await : any +>await : any +>Promise : PromiseConstructor +> : void +> : any +} diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.symbols b/tests/baselines/reference/asyncArrowFunction9_es6.symbols new file mode 100644 index 00000000000..6d0506402bb --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts === +var foo = async (a = await => await): Promise => { +>foo : Symbol(foo, Decl(asyncArrowFunction9_es6.ts, 0, 3)) +>await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) +>await : Symbol(await, Decl(asyncArrowFunction9_es6.ts, 0, 20)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(asyncArrowFunction9_es6.ts, 0, 37)) +} diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.types b/tests/baselines/reference/asyncArrowFunction9_es6.types new file mode 100644 index 00000000000..8bfa14b4ff5 --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunction9_es6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts === +var foo = async (a = await => await): Promise => { +>foo : any +>async (a = await => await) : any +>async : any +>a = await => await : (await: any) => any +>a : any +>await => await : (await: any) => any +>await : any +>await : any +>Promise : PromiseConstructor +> : void +> : any +} diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5.symbols b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5.symbols new file mode 100644 index 00000000000..bbfafadc6bf --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es5.ts === +class C { +>C : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 0, 0)) + + method() { +>method : Symbol(C.method, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 0, 9)) + + function other() {} +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 1, 13)) + + var fn = async () => await other.apply(this, arguments); +>fn : Symbol(fn, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 3, 9)) +>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>other : Symbol(other, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 1, 13)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>this : Symbol(C, Decl(asyncArrowFunctionCapturesArguments_es5.ts, 0, 0)) +>arguments : Symbol(arguments) + } +} + diff --git a/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5.types b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5.types new file mode 100644 index 00000000000..6eaff62c0bf --- /dev/null +++ b/tests/baselines/reference/asyncArrowFunctionCapturesArguments_es5.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunctionCapturesArguments_es5.ts === +class C { +>C : C + + method() { +>method : () => void + + function other() {} +>other : () => void + + var fn = async () => await other.apply(this, arguments); +>fn : () => Promise +>async () => await other.apply(this, arguments) : () => Promise +>await other.apply(this, arguments) : any +>other.apply(this, arguments) : any +>other.apply : (this: Function, thisArg: any, argArray?: any) => any +>other : () => void +>apply : (this: Function, thisArg: any, argArray?: any) => any +>this : this +>arguments : IArguments + } +} + diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.symbols b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.symbols new file mode 100644 index 00000000000..d7b11474f28 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.symbols @@ -0,0 +1,111 @@ +=== tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts === +import { MyPromise } from "missing"; +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es2017.ts, 2, 11)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +declare var mp: MyPromise; +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es2017.ts, 3, 11)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) + +async function f0() { } +>f0 : Symbol(f0, Decl(asyncAwaitIsolatedModules_es2017.ts, 3, 34)) + +async function f1(): Promise { } +>f1 : Symbol(f1, Decl(asyncAwaitIsolatedModules_es2017.ts, 5, 23)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +async function f3(): MyPromise { } +>f3 : Symbol(f3, Decl(asyncAwaitIsolatedModules_es2017.ts, 6, 38)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) + +let f4 = async function() { } +>f4 : Symbol(f4, Decl(asyncAwaitIsolatedModules_es2017.ts, 9, 3)) + +let f5 = async function(): Promise { } +>f5 : Symbol(f5, Decl(asyncAwaitIsolatedModules_es2017.ts, 10, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +let f6 = async function(): MyPromise { } +>f6 : Symbol(f6, Decl(asyncAwaitIsolatedModules_es2017.ts, 11, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) + +let f7 = async () => { }; +>f7 : Symbol(f7, Decl(asyncAwaitIsolatedModules_es2017.ts, 13, 3)) + +let f8 = async (): Promise => { }; +>f8 : Symbol(f8, Decl(asyncAwaitIsolatedModules_es2017.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +let f9 = async (): MyPromise => { }; +>f9 : Symbol(f9, Decl(asyncAwaitIsolatedModules_es2017.ts, 15, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) + +let f10 = async () => p; +>f10 : Symbol(f10, Decl(asyncAwaitIsolatedModules_es2017.ts, 16, 3)) +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es2017.ts, 2, 11)) + +let f11 = async () => mp; +>f11 : Symbol(f11, Decl(asyncAwaitIsolatedModules_es2017.ts, 17, 3)) +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es2017.ts, 3, 11)) + +let f12 = async (): Promise => mp; +>f12 : Symbol(f12, Decl(asyncAwaitIsolatedModules_es2017.ts, 18, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es2017.ts, 3, 11)) + +let f13 = async (): MyPromise => p; +>f13 : Symbol(f13, Decl(asyncAwaitIsolatedModules_es2017.ts, 19, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es2017.ts, 2, 11)) + +let o = { +>o : Symbol(o, Decl(asyncAwaitIsolatedModules_es2017.ts, 21, 3)) + + async m1() { }, +>m1 : Symbol(m1, Decl(asyncAwaitIsolatedModules_es2017.ts, 21, 9)) + + async m2(): Promise { }, +>m2 : Symbol(m2, Decl(asyncAwaitIsolatedModules_es2017.ts, 22, 16)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwaitIsolatedModules_es2017.ts, 23, 31)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) + +}; + +class C { +>C : Symbol(C, Decl(asyncAwaitIsolatedModules_es2017.ts, 25, 2)) + + async m1() { } +>m1 : Symbol(C.m1, Decl(asyncAwaitIsolatedModules_es2017.ts, 27, 9)) + + async m2(): Promise { } +>m2 : Symbol(C.m2, Decl(asyncAwaitIsolatedModules_es2017.ts, 28, 15)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(C.m3, Decl(asyncAwaitIsolatedModules_es2017.ts, 29, 30)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) + + static async m4() { } +>m4 : Symbol(C.m4, Decl(asyncAwaitIsolatedModules_es2017.ts, 30, 32)) + + static async m5(): Promise { } +>m5 : Symbol(C.m5, Decl(asyncAwaitIsolatedModules_es2017.ts, 31, 22)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + static async m6(): MyPromise { } +>m6 : Symbol(C.m6, Decl(asyncAwaitIsolatedModules_es2017.ts, 32, 37)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es2017.ts, 0, 8)) +} + +module M { +>M : Symbol(M, Decl(asyncAwaitIsolatedModules_es2017.ts, 34, 1)) + + export async function f1() { } +>f1 : Symbol(f1, Decl(asyncAwaitIsolatedModules_es2017.ts, 36, 10)) +} diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.types b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.types new file mode 100644 index 00000000000..b4619989757 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es2017.types @@ -0,0 +1,122 @@ +=== tests/cases/conformance/async/es2017/asyncAwaitIsolatedModules_es2017.ts === +import { MyPromise } from "missing"; +>MyPromise : any + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare var mp: MyPromise; +>mp : any +>MyPromise : any + +async function f0() { } +>f0 : () => Promise + +async function f1(): Promise { } +>f1 : () => Promise +>Promise : Promise + +async function f3(): MyPromise { } +>f3 : () => any +>MyPromise : any + +let f4 = async function() { } +>f4 : () => Promise +>async function() { } : () => Promise + +let f5 = async function(): Promise { } +>f5 : () => Promise +>async function(): Promise { } : () => Promise +>Promise : Promise + +let f6 = async function(): MyPromise { } +>f6 : () => any +>async function(): MyPromise { } : () => any +>MyPromise : any + +let f7 = async () => { }; +>f7 : () => Promise +>async () => { } : () => Promise + +let f8 = async (): Promise => { }; +>f8 : () => Promise +>async (): Promise => { } : () => Promise +>Promise : Promise + +let f9 = async (): MyPromise => { }; +>f9 : () => any +>async (): MyPromise => { } : () => any +>MyPromise : any + +let f10 = async () => p; +>f10 : () => Promise +>async () => p : () => Promise +>p : Promise + +let f11 = async () => mp; +>f11 : () => Promise +>async () => mp : () => Promise +>mp : any + +let f12 = async (): Promise => mp; +>f12 : () => Promise +>async (): Promise => mp : () => Promise +>Promise : Promise +>mp : any + +let f13 = async (): MyPromise => p; +>f13 : () => any +>async (): MyPromise => p : () => any +>MyPromise : any +>p : Promise + +let o = { +>o : { m1(): Promise; m2(): Promise; m3(): any; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): any; } + + async m1() { }, +>m1 : () => Promise + + async m2(): Promise { }, +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => any +>MyPromise : any + +}; + +class C { +>C : C + + async m1() { } +>m1 : () => Promise + + async m2(): Promise { } +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => any +>MyPromise : any + + static async m4() { } +>m4 : () => Promise + + static async m5(): Promise { } +>m5 : () => Promise +>Promise : Promise + + static async m6(): MyPromise { } +>m6 : () => any +>MyPromise : any +} + +module M { +>M : typeof M + + export async function f1() { } +>f1 : () => Promise +} diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es5.symbols b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.symbols new file mode 100644 index 00000000000..eaa6042ee3d --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.symbols @@ -0,0 +1,111 @@ +=== tests/cases/conformance/async/es5/asyncAwaitIsolatedModules_es5.ts === +import { MyPromise } from "missing"; +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es5.ts, 2, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +declare var mp: MyPromise; +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es5.ts, 3, 11)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) + +async function f0() { } +>f0 : Symbol(f0, Decl(asyncAwaitIsolatedModules_es5.ts, 3, 34)) + +async function f1(): Promise { } +>f1 : Symbol(f1, Decl(asyncAwaitIsolatedModules_es5.ts, 5, 23)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +async function f3(): MyPromise { } +>f3 : Symbol(f3, Decl(asyncAwaitIsolatedModules_es5.ts, 6, 38)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) + +let f4 = async function() { } +>f4 : Symbol(f4, Decl(asyncAwaitIsolatedModules_es5.ts, 9, 3)) + +let f5 = async function(): Promise { } +>f5 : Symbol(f5, Decl(asyncAwaitIsolatedModules_es5.ts, 10, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +let f6 = async function(): MyPromise { } +>f6 : Symbol(f6, Decl(asyncAwaitIsolatedModules_es5.ts, 11, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) + +let f7 = async () => { }; +>f7 : Symbol(f7, Decl(asyncAwaitIsolatedModules_es5.ts, 13, 3)) + +let f8 = async (): Promise => { }; +>f8 : Symbol(f8, Decl(asyncAwaitIsolatedModules_es5.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +let f9 = async (): MyPromise => { }; +>f9 : Symbol(f9, Decl(asyncAwaitIsolatedModules_es5.ts, 15, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) + +let f10 = async () => p; +>f10 : Symbol(f10, Decl(asyncAwaitIsolatedModules_es5.ts, 16, 3)) +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es5.ts, 2, 11)) + +let f11 = async () => mp; +>f11 : Symbol(f11, Decl(asyncAwaitIsolatedModules_es5.ts, 17, 3)) +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es5.ts, 3, 11)) + +let f12 = async (): Promise => mp; +>f12 : Symbol(f12, Decl(asyncAwaitIsolatedModules_es5.ts, 18, 3)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es5.ts, 3, 11)) + +let f13 = async (): MyPromise => p; +>f13 : Symbol(f13, Decl(asyncAwaitIsolatedModules_es5.ts, 19, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es5.ts, 2, 11)) + +let o = { +>o : Symbol(o, Decl(asyncAwaitIsolatedModules_es5.ts, 21, 3)) + + async m1() { }, +>m1 : Symbol(m1, Decl(asyncAwaitIsolatedModules_es5.ts, 21, 9)) + + async m2(): Promise { }, +>m2 : Symbol(m2, Decl(asyncAwaitIsolatedModules_es5.ts, 22, 16)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwaitIsolatedModules_es5.ts, 23, 31)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) + +}; + +class C { +>C : Symbol(C, Decl(asyncAwaitIsolatedModules_es5.ts, 25, 2)) + + async m1() { } +>m1 : Symbol(C.m1, Decl(asyncAwaitIsolatedModules_es5.ts, 27, 9)) + + async m2(): Promise { } +>m2 : Symbol(C.m2, Decl(asyncAwaitIsolatedModules_es5.ts, 28, 15)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(C.m3, Decl(asyncAwaitIsolatedModules_es5.ts, 29, 30)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) + + static async m4() { } +>m4 : Symbol(C.m4, Decl(asyncAwaitIsolatedModules_es5.ts, 30, 32)) + + static async m5(): Promise { } +>m5 : Symbol(C.m5, Decl(asyncAwaitIsolatedModules_es5.ts, 31, 22)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + static async m6(): MyPromise { } +>m6 : Symbol(C.m6, Decl(asyncAwaitIsolatedModules_es5.ts, 32, 37)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es5.ts, 0, 8)) +} + +module M { +>M : Symbol(M, Decl(asyncAwaitIsolatedModules_es5.ts, 34, 1)) + + export async function f1() { } +>f1 : Symbol(f1, Decl(asyncAwaitIsolatedModules_es5.ts, 36, 10)) +} diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es5.types b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.types new file mode 100644 index 00000000000..8630666ec62 --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es5.types @@ -0,0 +1,122 @@ +=== tests/cases/conformance/async/es5/asyncAwaitIsolatedModules_es5.ts === +import { MyPromise } from "missing"; +>MyPromise : any + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare var mp: MyPromise; +>mp : any +>MyPromise : any + +async function f0() { } +>f0 : () => Promise + +async function f1(): Promise { } +>f1 : () => Promise +>Promise : Promise + +async function f3(): MyPromise { } +>f3 : () => any +>MyPromise : any + +let f4 = async function() { } +>f4 : () => Promise +>async function() { } : () => Promise + +let f5 = async function(): Promise { } +>f5 : () => Promise +>async function(): Promise { } : () => Promise +>Promise : Promise + +let f6 = async function(): MyPromise { } +>f6 : () => any +>async function(): MyPromise { } : () => any +>MyPromise : any + +let f7 = async () => { }; +>f7 : () => Promise +>async () => { } : () => Promise + +let f8 = async (): Promise => { }; +>f8 : () => Promise +>async (): Promise => { } : () => Promise +>Promise : Promise + +let f9 = async (): MyPromise => { }; +>f9 : () => any +>async (): MyPromise => { } : () => any +>MyPromise : any + +let f10 = async () => p; +>f10 : () => Promise +>async () => p : () => Promise +>p : Promise + +let f11 = async () => mp; +>f11 : () => Promise +>async () => mp : () => Promise +>mp : any + +let f12 = async (): Promise => mp; +>f12 : () => Promise +>async (): Promise => mp : () => Promise +>Promise : Promise +>mp : any + +let f13 = async (): MyPromise => p; +>f13 : () => any +>async (): MyPromise => p : () => any +>MyPromise : any +>p : Promise + +let o = { +>o : { m1(): Promise; m2(): Promise; m3(): any; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): any; } + + async m1() { }, +>m1 : () => Promise + + async m2(): Promise { }, +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => any +>MyPromise : any + +}; + +class C { +>C : C + + async m1() { } +>m1 : () => Promise + + async m2(): Promise { } +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => any +>MyPromise : any + + static async m4() { } +>m4 : () => Promise + + static async m5(): Promise { } +>m5 : () => Promise +>Promise : Promise + + static async m6(): MyPromise { } +>m6 : () => any +>MyPromise : any +} + +module M { +>M : typeof M + + export async function f1() { } +>f1 : () => Promise +} diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.symbols b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.symbols new file mode 100644 index 00000000000..2d1808b8b8b --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.symbols @@ -0,0 +1,111 @@ +=== tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts === +import { MyPromise } from "missing"; +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) + +declare var p: Promise; +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es6.ts, 2, 11)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +declare var mp: MyPromise; +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es6.ts, 3, 11)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) + +async function f0() { } +>f0 : Symbol(f0, Decl(asyncAwaitIsolatedModules_es6.ts, 3, 34)) + +async function f1(): Promise { } +>f1 : Symbol(f1, Decl(asyncAwaitIsolatedModules_es6.ts, 5, 23)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +async function f3(): MyPromise { } +>f3 : Symbol(f3, Decl(asyncAwaitIsolatedModules_es6.ts, 6, 38)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) + +let f4 = async function() { } +>f4 : Symbol(f4, Decl(asyncAwaitIsolatedModules_es6.ts, 9, 3)) + +let f5 = async function(): Promise { } +>f5 : Symbol(f5, Decl(asyncAwaitIsolatedModules_es6.ts, 10, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +let f6 = async function(): MyPromise { } +>f6 : Symbol(f6, Decl(asyncAwaitIsolatedModules_es6.ts, 11, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) + +let f7 = async () => { }; +>f7 : Symbol(f7, Decl(asyncAwaitIsolatedModules_es6.ts, 13, 3)) + +let f8 = async (): Promise => { }; +>f8 : Symbol(f8, Decl(asyncAwaitIsolatedModules_es6.ts, 14, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +let f9 = async (): MyPromise => { }; +>f9 : Symbol(f9, Decl(asyncAwaitIsolatedModules_es6.ts, 15, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) + +let f10 = async () => p; +>f10 : Symbol(f10, Decl(asyncAwaitIsolatedModules_es6.ts, 16, 3)) +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es6.ts, 2, 11)) + +let f11 = async () => mp; +>f11 : Symbol(f11, Decl(asyncAwaitIsolatedModules_es6.ts, 17, 3)) +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es6.ts, 3, 11)) + +let f12 = async (): Promise => mp; +>f12 : Symbol(f12, Decl(asyncAwaitIsolatedModules_es6.ts, 18, 3)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>mp : Symbol(mp, Decl(asyncAwaitIsolatedModules_es6.ts, 3, 11)) + +let f13 = async (): MyPromise => p; +>f13 : Symbol(f13, Decl(asyncAwaitIsolatedModules_es6.ts, 19, 3)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) +>p : Symbol(p, Decl(asyncAwaitIsolatedModules_es6.ts, 2, 11)) + +let o = { +>o : Symbol(o, Decl(asyncAwaitIsolatedModules_es6.ts, 21, 3)) + + async m1() { }, +>m1 : Symbol(m1, Decl(asyncAwaitIsolatedModules_es6.ts, 21, 9)) + + async m2(): Promise { }, +>m2 : Symbol(m2, Decl(asyncAwaitIsolatedModules_es6.ts, 22, 16)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(m3, Decl(asyncAwaitIsolatedModules_es6.ts, 23, 31)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) + +}; + +class C { +>C : Symbol(C, Decl(asyncAwaitIsolatedModules_es6.ts, 25, 2)) + + async m1() { } +>m1 : Symbol(C.m1, Decl(asyncAwaitIsolatedModules_es6.ts, 27, 9)) + + async m2(): Promise { } +>m2 : Symbol(C.m2, Decl(asyncAwaitIsolatedModules_es6.ts, 28, 15)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + async m3(): MyPromise { } +>m3 : Symbol(C.m3, Decl(asyncAwaitIsolatedModules_es6.ts, 29, 30)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) + + static async m4() { } +>m4 : Symbol(C.m4, Decl(asyncAwaitIsolatedModules_es6.ts, 30, 32)) + + static async m5(): Promise { } +>m5 : Symbol(C.m5, Decl(asyncAwaitIsolatedModules_es6.ts, 31, 22)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + static async m6(): MyPromise { } +>m6 : Symbol(C.m6, Decl(asyncAwaitIsolatedModules_es6.ts, 32, 37)) +>MyPromise : Symbol(MyPromise, Decl(asyncAwaitIsolatedModules_es6.ts, 0, 8)) +} + +module M { +>M : Symbol(M, Decl(asyncAwaitIsolatedModules_es6.ts, 34, 1)) + + export async function f1() { } +>f1 : Symbol(f1, Decl(asyncAwaitIsolatedModules_es6.ts, 36, 10)) +} diff --git a/tests/baselines/reference/asyncAwaitIsolatedModules_es6.types b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.types new file mode 100644 index 00000000000..7c2d9d0fa0b --- /dev/null +++ b/tests/baselines/reference/asyncAwaitIsolatedModules_es6.types @@ -0,0 +1,122 @@ +=== tests/cases/conformance/async/es6/asyncAwaitIsolatedModules_es6.ts === +import { MyPromise } from "missing"; +>MyPromise : any + +declare var p: Promise; +>p : Promise +>Promise : Promise + +declare var mp: MyPromise; +>mp : any +>MyPromise : any + +async function f0() { } +>f0 : () => Promise + +async function f1(): Promise { } +>f1 : () => Promise +>Promise : Promise + +async function f3(): MyPromise { } +>f3 : () => any +>MyPromise : any + +let f4 = async function() { } +>f4 : () => Promise +>async function() { } : () => Promise + +let f5 = async function(): Promise { } +>f5 : () => Promise +>async function(): Promise { } : () => Promise +>Promise : Promise + +let f6 = async function(): MyPromise { } +>f6 : () => any +>async function(): MyPromise { } : () => any +>MyPromise : any + +let f7 = async () => { }; +>f7 : () => Promise +>async () => { } : () => Promise + +let f8 = async (): Promise => { }; +>f8 : () => Promise +>async (): Promise => { } : () => Promise +>Promise : Promise + +let f9 = async (): MyPromise => { }; +>f9 : () => any +>async (): MyPromise => { } : () => any +>MyPromise : any + +let f10 = async () => p; +>f10 : () => Promise +>async () => p : () => Promise +>p : Promise + +let f11 = async () => mp; +>f11 : () => Promise +>async () => mp : () => Promise +>mp : any + +let f12 = async (): Promise => mp; +>f12 : () => Promise +>async (): Promise => mp : () => Promise +>Promise : Promise +>mp : any + +let f13 = async (): MyPromise => p; +>f13 : () => any +>async (): MyPromise => p : () => any +>MyPromise : any +>p : Promise + +let o = { +>o : { m1(): Promise; m2(): Promise; m3(): any; } +>{ async m1() { }, async m2(): Promise { }, async m3(): MyPromise { }} : { m1(): Promise; m2(): Promise; m3(): any; } + + async m1() { }, +>m1 : () => Promise + + async m2(): Promise { }, +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => any +>MyPromise : any + +}; + +class C { +>C : C + + async m1() { } +>m1 : () => Promise + + async m2(): Promise { } +>m2 : () => Promise +>Promise : Promise + + async m3(): MyPromise { } +>m3 : () => any +>MyPromise : any + + static async m4() { } +>m4 : () => Promise + + static async m5(): Promise { } +>m5 : () => Promise +>Promise : Promise + + static async m6(): MyPromise { } +>m6 : () => any +>MyPromise : any +} + +module M { +>M : typeof M + + export async function f1() { } +>f1 : () => Promise +} diff --git a/tests/baselines/reference/asyncClass_es5.symbols b/tests/baselines/reference/asyncClass_es5.symbols new file mode 100644 index 00000000000..f8f1ae8a067 --- /dev/null +++ b/tests/baselines/reference/asyncClass_es5.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es5/asyncClass_es5.ts === +async class C { +>C : Symbol(C, Decl(asyncClass_es5.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncClass_es5.types b/tests/baselines/reference/asyncClass_es5.types new file mode 100644 index 00000000000..9d3a2d1453b --- /dev/null +++ b/tests/baselines/reference/asyncClass_es5.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es5/asyncClass_es5.ts === +async class C { +>C : C +} diff --git a/tests/baselines/reference/asyncClass_es6.symbols b/tests/baselines/reference/asyncClass_es6.symbols new file mode 100644 index 00000000000..a268c0f8351 --- /dev/null +++ b/tests/baselines/reference/asyncClass_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncClass_es6.ts === +async class C { +>C : Symbol(C, Decl(asyncClass_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncClass_es6.types b/tests/baselines/reference/asyncClass_es6.types new file mode 100644 index 00000000000..1136f3f8210 --- /dev/null +++ b/tests/baselines/reference/asyncClass_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncClass_es6.ts === +async class C { +>C : C +} diff --git a/tests/baselines/reference/asyncConstructor_es5.symbols b/tests/baselines/reference/asyncConstructor_es5.symbols new file mode 100644 index 00000000000..3895d80e077 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es5.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es5/asyncConstructor_es5.ts === +class C { +>C : Symbol(C, Decl(asyncConstructor_es5.ts, 0, 0)) + + async constructor() { + } +} diff --git a/tests/baselines/reference/asyncConstructor_es5.types b/tests/baselines/reference/asyncConstructor_es5.types new file mode 100644 index 00000000000..a7847ee6968 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es5.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es5/asyncConstructor_es5.ts === +class C { +>C : C + + async constructor() { + } +} diff --git a/tests/baselines/reference/asyncConstructor_es6.symbols b/tests/baselines/reference/asyncConstructor_es6.symbols new file mode 100644 index 00000000000..82fdcf33e1e --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/asyncConstructor_es6.ts === +class C { +>C : Symbol(C, Decl(asyncConstructor_es6.ts, 0, 0)) + + async constructor() { + } +} diff --git a/tests/baselines/reference/asyncConstructor_es6.types b/tests/baselines/reference/asyncConstructor_es6.types new file mode 100644 index 00000000000..cff36dbcb40 --- /dev/null +++ b/tests/baselines/reference/asyncConstructor_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/asyncConstructor_es6.ts === +class C { +>C : C + + async constructor() { + } +} diff --git a/tests/baselines/reference/asyncDeclare_es5.symbols b/tests/baselines/reference/asyncDeclare_es5.symbols new file mode 100644 index 00000000000..e839dc90e24 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es5.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es5/asyncDeclare_es5.ts === +declare async function foo(): Promise; +>foo : Symbol(foo, Decl(asyncDeclare_es5.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + diff --git a/tests/baselines/reference/asyncDeclare_es5.types b/tests/baselines/reference/asyncDeclare_es5.types new file mode 100644 index 00000000000..91f034324eb --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es5.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es5/asyncDeclare_es5.ts === +declare async function foo(): Promise; +>foo : () => Promise +>Promise : Promise + diff --git a/tests/baselines/reference/asyncDeclare_es6.symbols b/tests/baselines/reference/asyncDeclare_es6.symbols new file mode 100644 index 00000000000..85ea6c9f905 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncDeclare_es6.ts === +declare async function foo(): Promise; +>foo : Symbol(foo, Decl(asyncDeclare_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + diff --git a/tests/baselines/reference/asyncDeclare_es6.types b/tests/baselines/reference/asyncDeclare_es6.types new file mode 100644 index 00000000000..b4cb50157a3 --- /dev/null +++ b/tests/baselines/reference/asyncDeclare_es6.types @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/asyncDeclare_es6.ts === +declare async function foo(): Promise; +>foo : () => Promise +>Promise : Promise + diff --git a/tests/baselines/reference/asyncEnum_es5.symbols b/tests/baselines/reference/asyncEnum_es5.symbols new file mode 100644 index 00000000000..5fedc239a71 --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es5.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es5/asyncEnum_es5.ts === +async enum E { +>E : Symbol(E, Decl(asyncEnum_es5.ts, 0, 0)) + + Value +>Value : Symbol(E.Value, Decl(asyncEnum_es5.ts, 0, 14)) +} diff --git a/tests/baselines/reference/asyncEnum_es5.types b/tests/baselines/reference/asyncEnum_es5.types new file mode 100644 index 00000000000..2f94fd33152 --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es5.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es5/asyncEnum_es5.ts === +async enum E { +>E : E + + Value +>Value : E +} diff --git a/tests/baselines/reference/asyncEnum_es6.symbols b/tests/baselines/reference/asyncEnum_es6.symbols new file mode 100644 index 00000000000..ee5ef5df67b --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es6.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/asyncEnum_es6.ts === +async enum E { +>E : Symbol(E, Decl(asyncEnum_es6.ts, 0, 0)) + + Value +>Value : Symbol(E.Value, Decl(asyncEnum_es6.ts, 0, 14)) +} diff --git a/tests/baselines/reference/asyncEnum_es6.types b/tests/baselines/reference/asyncEnum_es6.types new file mode 100644 index 00000000000..c28b646edf9 --- /dev/null +++ b/tests/baselines/reference/asyncEnum_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/asyncEnum_es6.ts === +async enum E { +>E : E + + Value +>Value : E +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.symbols new file mode 100644 index 00000000000..1079ab5c323 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts === +async function foo(a = await => await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es2017.ts, 0, 0)) +>a : Symbol(a, Decl(asyncFunctionDeclaration10_es2017.ts, 0, 19)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.types new file mode 100644 index 00000000000..906a0966c0a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es2017.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration10_es2017.ts === +async function foo(a = await => await): Promise { +>foo : (a?: any) => any +>a : any +>await : any +> : any +>await : any +>Promise {} : boolean +>PromisePromise : PromiseConstructor +>void : undefined +> : any +>{} : {} +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es5.symbols new file mode 100644 index 00000000000..1d9f9c590d8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts === +async function foo(a = await => await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es5.ts, 0, 0)) +>a : Symbol(a, Decl(asyncFunctionDeclaration10_es5.ts, 0, 19)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es5.types b/tests/baselines/reference/asyncFunctionDeclaration10_es5.types new file mode 100644 index 00000000000..70a16d0fc52 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es5.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration10_es5.ts === +async function foo(a = await => await): Promise { +>foo : (a?: any) => any +>a : any +>await : any +> : any +>await : any +>Promise {} : boolean +>PromisePromise : PromiseConstructor +>void : undefined +> : any +>{} : {} +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols new file mode 100644 index 00000000000..cbfb1bbf88d --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts === +async function foo(a = await => await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration10_es6.ts, 0, 0)) +>a : Symbol(a, Decl(asyncFunctionDeclaration10_es6.ts, 0, 19)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration10_es6.types b/tests/baselines/reference/asyncFunctionDeclaration10_es6.types new file mode 100644 index 00000000000..f5d5ae89afd --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration10_es6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration10_es6.ts === +async function foo(a = await => await): Promise { +>foo : (a?: any) => any +>a : any +>await : any +> : any +>await : any +>Promise {} : boolean +>PromisePromise : PromiseConstructor +>void : undefined +> : any +>{} : {} +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.symbols new file mode 100644 index 00000000000..54cecdaf238 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts === +var v = async function await(): Promise { } +>v : Symbol(v, Decl(asyncFunctionDeclaration12_es2017.ts, 0, 3)) +>await : Symbol(await, Decl(asyncFunctionDeclaration12_es2017.ts, 0, 22)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types new file mode 100644 index 00000000000..1881a3cb4fd --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts === +var v = async function await(): Promise { } +>v : () => any +>async function : () => any +>await : () => Promise +>(): Promise { } : () => Promise +>Promise : Promise + diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration12_es5.symbols new file mode 100644 index 00000000000..231dc33c20d --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts === +var v = async function await(): Promise { } +>v : Symbol(v, Decl(asyncFunctionDeclaration12_es5.ts, 0, 3)) +>await : Symbol(await, Decl(asyncFunctionDeclaration12_es5.ts, 0, 22)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.types b/tests/baselines/reference/asyncFunctionDeclaration12_es5.types new file mode 100644 index 00000000000..242eca7c5a4 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts === +var v = async function await(): Promise { } +>v : () => any +>async function : () => any +>await : () => Promise +>(): Promise { } : () => Promise +>Promise : Promise + diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration12_es6.symbols new file mode 100644 index 00000000000..f8adf060dc9 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts === +var v = async function await(): Promise { } +>v : Symbol(v, Decl(asyncFunctionDeclaration12_es6.ts, 0, 3)) +>await : Symbol(await, Decl(asyncFunctionDeclaration12_es6.ts, 0, 22)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.types b/tests/baselines/reference/asyncFunctionDeclaration12_es6.types new file mode 100644 index 00000000000..acf108d9761 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts === +var v = async function await(): Promise { } +>v : () => any +>async function : () => any +>await : () => Promise +>(): Promise { } : () => Promise +>Promise : Promise + diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.symbols new file mode 100644 index 00000000000..8ee3ca58938 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration13_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + // Legal to use 'await' in a type context. + var v: await; +>v : Symbol(v, Decl(asyncFunctionDeclaration13_es2017.ts, 2, 6)) +} + diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.types new file mode 100644 index 00000000000..c93c19da496 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es2017.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration13_es2017.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + // Legal to use 'await' in a type context. + var v: await; +>v : any +>await : No type information available! +} + diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration13_es5.symbols new file mode 100644 index 00000000000..e92467e5f41 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es5.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration13_es5.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration13_es5.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + // Legal to use 'await' in a type context. + var v: await; +>v : Symbol(v, Decl(asyncFunctionDeclaration13_es5.ts, 2, 6)) +} + diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es5.types b/tests/baselines/reference/asyncFunctionDeclaration13_es5.types new file mode 100644 index 00000000000..c8ec02c275d --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es5.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration13_es5.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + // Legal to use 'await' in a type context. + var v: await; +>v : any +>await : No type information available! +} + diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration13_es6.symbols new file mode 100644 index 00000000000..05d7c586cab --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration13_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + // Legal to use 'await' in a type context. + var v: await; +>v : Symbol(v, Decl(asyncFunctionDeclaration13_es6.ts, 2, 6)) +} + diff --git a/tests/baselines/reference/asyncFunctionDeclaration13_es6.types b/tests/baselines/reference/asyncFunctionDeclaration13_es6.types new file mode 100644 index 00000000000..7e963caab85 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration13_es6.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration13_es6.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + // Legal to use 'await' in a type context. + var v: await; +>v : any +>await : No type information available! +} + diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration15_es5.symbols new file mode 100644 index 00000000000..3bc9a18ca81 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es5.symbols @@ -0,0 +1,83 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts === +declare class Thenable { then(): void; } +>Thenable : Symbol(Thenable, Decl(asyncFunctionDeclaration15_es5.ts, 0, 0)) +>then : Symbol(Thenable.then, Decl(asyncFunctionDeclaration15_es5.ts, 0, 24)) + +declare let a: any; +>a : Symbol(a, Decl(asyncFunctionDeclaration15_es5.ts, 1, 11)) + +declare let obj: { then: string; }; +>obj : Symbol(obj, Decl(asyncFunctionDeclaration15_es5.ts, 2, 11)) +>then : Symbol(then, Decl(asyncFunctionDeclaration15_es5.ts, 2, 18)) + +declare let thenable: Thenable; +>thenable : Symbol(thenable, Decl(asyncFunctionDeclaration15_es5.ts, 3, 11)) +>Thenable : Symbol(Thenable, Decl(asyncFunctionDeclaration15_es5.ts, 0, 0)) + +async function fn1() { } // valid: Promise +>fn1 : Symbol(fn1, Decl(asyncFunctionDeclaration15_es5.ts, 3, 31)) + +async function fn2(): { } { } // error +>fn2 : Symbol(fn2, Decl(asyncFunctionDeclaration15_es5.ts, 4, 24)) + +async function fn3(): any { } // error +>fn3 : Symbol(fn3, Decl(asyncFunctionDeclaration15_es5.ts, 5, 29)) + +async function fn4(): number { } // error +>fn4 : Symbol(fn4, Decl(asyncFunctionDeclaration15_es5.ts, 6, 29)) + +async function fn5(): PromiseLike { } // error +>fn5 : Symbol(fn5, Decl(asyncFunctionDeclaration15_es5.ts, 7, 32)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +async function fn6(): Thenable { } // error +>fn6 : Symbol(fn6, Decl(asyncFunctionDeclaration15_es5.ts, 8, 43)) +>Thenable : Symbol(Thenable, Decl(asyncFunctionDeclaration15_es5.ts, 0, 0)) + +async function fn7() { return; } // valid: Promise +>fn7 : Symbol(fn7, Decl(asyncFunctionDeclaration15_es5.ts, 9, 34)) + +async function fn8() { return 1; } // valid: Promise +>fn8 : Symbol(fn8, Decl(asyncFunctionDeclaration15_es5.ts, 10, 32)) + +async function fn9() { return null; } // valid: Promise +>fn9 : Symbol(fn9, Decl(asyncFunctionDeclaration15_es5.ts, 11, 34)) + +async function fn10() { return undefined; } // valid: Promise +>fn10 : Symbol(fn10, Decl(asyncFunctionDeclaration15_es5.ts, 12, 37)) +>undefined : Symbol(undefined) + +async function fn11() { return a; } // valid: Promise +>fn11 : Symbol(fn11, Decl(asyncFunctionDeclaration15_es5.ts, 13, 43)) +>a : Symbol(a, Decl(asyncFunctionDeclaration15_es5.ts, 1, 11)) + +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +>fn12 : Symbol(fn12, Decl(asyncFunctionDeclaration15_es5.ts, 14, 35)) +>obj : Symbol(obj, Decl(asyncFunctionDeclaration15_es5.ts, 2, 11)) + +async function fn13() { return thenable; } // error +>fn13 : Symbol(fn13, Decl(asyncFunctionDeclaration15_es5.ts, 15, 37)) +>thenable : Symbol(thenable, Decl(asyncFunctionDeclaration15_es5.ts, 3, 11)) + +async function fn14() { await 1; } // valid: Promise +>fn14 : Symbol(fn14, Decl(asyncFunctionDeclaration15_es5.ts, 16, 42)) + +async function fn15() { await null; } // valid: Promise +>fn15 : Symbol(fn15, Decl(asyncFunctionDeclaration15_es5.ts, 17, 34)) + +async function fn16() { await undefined; } // valid: Promise +>fn16 : Symbol(fn16, Decl(asyncFunctionDeclaration15_es5.ts, 18, 37)) +>undefined : Symbol(undefined) + +async function fn17() { await a; } // valid: Promise +>fn17 : Symbol(fn17, Decl(asyncFunctionDeclaration15_es5.ts, 19, 42)) +>a : Symbol(a, Decl(asyncFunctionDeclaration15_es5.ts, 1, 11)) + +async function fn18() { await obj; } // valid: Promise +>fn18 : Symbol(fn18, Decl(asyncFunctionDeclaration15_es5.ts, 20, 34)) +>obj : Symbol(obj, Decl(asyncFunctionDeclaration15_es5.ts, 2, 11)) + +async function fn19() { await thenable; } // error +>fn19 : Symbol(fn19, Decl(asyncFunctionDeclaration15_es5.ts, 21, 36)) +>thenable : Symbol(thenable, Decl(asyncFunctionDeclaration15_es5.ts, 3, 11)) + diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es5.types b/tests/baselines/reference/asyncFunctionDeclaration15_es5.types new file mode 100644 index 00000000000..5ed68d1ab24 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es5.types @@ -0,0 +1,93 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration15_es5.ts === +declare class Thenable { then(): void; } +>Thenable : Thenable +>then : () => void + +declare let a: any; +>a : any + +declare let obj: { then: string; }; +>obj : { then: string; } +>then : string + +declare let thenable: Thenable; +>thenable : Thenable +>Thenable : Thenable + +async function fn1() { } // valid: Promise +>fn1 : () => Promise + +async function fn2(): { } { } // error +>fn2 : () => {} + +async function fn3(): any { } // error +>fn3 : () => any + +async function fn4(): number { } // error +>fn4 : () => number + +async function fn5(): PromiseLike { } // error +>fn5 : () => PromiseLike +>PromiseLike : PromiseLike + +async function fn6(): Thenable { } // error +>fn6 : () => Thenable +>Thenable : Thenable + +async function fn7() { return; } // valid: Promise +>fn7 : () => Promise + +async function fn8() { return 1; } // valid: Promise +>fn8 : () => Promise +>1 : 1 + +async function fn9() { return null; } // valid: Promise +>fn9 : () => Promise +>null : null + +async function fn10() { return undefined; } // valid: Promise +>fn10 : () => Promise +>undefined : undefined + +async function fn11() { return a; } // valid: Promise +>fn11 : () => Promise +>a : any + +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +>fn12 : () => Promise<{ then: string; }> +>obj : { then: string; } + +async function fn13() { return thenable; } // error +>fn13 : () => Promise +>thenable : Thenable + +async function fn14() { await 1; } // valid: Promise +>fn14 : () => Promise +>await 1 : 1 +>1 : 1 + +async function fn15() { await null; } // valid: Promise +>fn15 : () => Promise +>await null : null +>null : null + +async function fn16() { await undefined; } // valid: Promise +>fn16 : () => Promise +>await undefined : undefined +>undefined : undefined + +async function fn17() { await a; } // valid: Promise +>fn17 : () => Promise +>await a : any +>a : any + +async function fn18() { await obj; } // valid: Promise +>fn18 : () => Promise +>await obj : { then: string; } +>obj : { then: string; } + +async function fn19() { await thenable; } // error +>fn19 : () => Promise +>await thenable : any +>thenable : Thenable + diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration15_es6.symbols new file mode 100644 index 00000000000..daf0d23a7e8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es6.symbols @@ -0,0 +1,83 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts === +declare class Thenable { then(): void; } +>Thenable : Symbol(Thenable, Decl(asyncFunctionDeclaration15_es6.ts, 0, 0)) +>then : Symbol(Thenable.then, Decl(asyncFunctionDeclaration15_es6.ts, 0, 24)) + +declare let a: any; +>a : Symbol(a, Decl(asyncFunctionDeclaration15_es6.ts, 1, 11)) + +declare let obj: { then: string; }; +>obj : Symbol(obj, Decl(asyncFunctionDeclaration15_es6.ts, 2, 11)) +>then : Symbol(then, Decl(asyncFunctionDeclaration15_es6.ts, 2, 18)) + +declare let thenable: Thenable; +>thenable : Symbol(thenable, Decl(asyncFunctionDeclaration15_es6.ts, 3, 11)) +>Thenable : Symbol(Thenable, Decl(asyncFunctionDeclaration15_es6.ts, 0, 0)) + +async function fn1() { } // valid: Promise +>fn1 : Symbol(fn1, Decl(asyncFunctionDeclaration15_es6.ts, 3, 31)) + +async function fn2(): { } { } // error +>fn2 : Symbol(fn2, Decl(asyncFunctionDeclaration15_es6.ts, 4, 24)) + +async function fn3(): any { } // error +>fn3 : Symbol(fn3, Decl(asyncFunctionDeclaration15_es6.ts, 5, 29)) + +async function fn4(): number { } // error +>fn4 : Symbol(fn4, Decl(asyncFunctionDeclaration15_es6.ts, 6, 29)) + +async function fn5(): PromiseLike { } // error +>fn5 : Symbol(fn5, Decl(asyncFunctionDeclaration15_es6.ts, 7, 32)) +>PromiseLike : Symbol(PromiseLike, Decl(lib.es5.d.ts, --, --)) + +async function fn6(): Thenable { } // error +>fn6 : Symbol(fn6, Decl(asyncFunctionDeclaration15_es6.ts, 8, 43)) +>Thenable : Symbol(Thenable, Decl(asyncFunctionDeclaration15_es6.ts, 0, 0)) + +async function fn7() { return; } // valid: Promise +>fn7 : Symbol(fn7, Decl(asyncFunctionDeclaration15_es6.ts, 9, 34)) + +async function fn8() { return 1; } // valid: Promise +>fn8 : Symbol(fn8, Decl(asyncFunctionDeclaration15_es6.ts, 10, 32)) + +async function fn9() { return null; } // valid: Promise +>fn9 : Symbol(fn9, Decl(asyncFunctionDeclaration15_es6.ts, 11, 34)) + +async function fn10() { return undefined; } // valid: Promise +>fn10 : Symbol(fn10, Decl(asyncFunctionDeclaration15_es6.ts, 12, 37)) +>undefined : Symbol(undefined) + +async function fn11() { return a; } // valid: Promise +>fn11 : Symbol(fn11, Decl(asyncFunctionDeclaration15_es6.ts, 13, 43)) +>a : Symbol(a, Decl(asyncFunctionDeclaration15_es6.ts, 1, 11)) + +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +>fn12 : Symbol(fn12, Decl(asyncFunctionDeclaration15_es6.ts, 14, 35)) +>obj : Symbol(obj, Decl(asyncFunctionDeclaration15_es6.ts, 2, 11)) + +async function fn13() { return thenable; } // error +>fn13 : Symbol(fn13, Decl(asyncFunctionDeclaration15_es6.ts, 15, 37)) +>thenable : Symbol(thenable, Decl(asyncFunctionDeclaration15_es6.ts, 3, 11)) + +async function fn14() { await 1; } // valid: Promise +>fn14 : Symbol(fn14, Decl(asyncFunctionDeclaration15_es6.ts, 16, 42)) + +async function fn15() { await null; } // valid: Promise +>fn15 : Symbol(fn15, Decl(asyncFunctionDeclaration15_es6.ts, 17, 34)) + +async function fn16() { await undefined; } // valid: Promise +>fn16 : Symbol(fn16, Decl(asyncFunctionDeclaration15_es6.ts, 18, 37)) +>undefined : Symbol(undefined) + +async function fn17() { await a; } // valid: Promise +>fn17 : Symbol(fn17, Decl(asyncFunctionDeclaration15_es6.ts, 19, 42)) +>a : Symbol(a, Decl(asyncFunctionDeclaration15_es6.ts, 1, 11)) + +async function fn18() { await obj; } // valid: Promise +>fn18 : Symbol(fn18, Decl(asyncFunctionDeclaration15_es6.ts, 20, 34)) +>obj : Symbol(obj, Decl(asyncFunctionDeclaration15_es6.ts, 2, 11)) + +async function fn19() { await thenable; } // error +>fn19 : Symbol(fn19, Decl(asyncFunctionDeclaration15_es6.ts, 21, 36)) +>thenable : Symbol(thenable, Decl(asyncFunctionDeclaration15_es6.ts, 3, 11)) + diff --git a/tests/baselines/reference/asyncFunctionDeclaration15_es6.types b/tests/baselines/reference/asyncFunctionDeclaration15_es6.types new file mode 100644 index 00000000000..b3b176cc812 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration15_es6.types @@ -0,0 +1,93 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration15_es6.ts === +declare class Thenable { then(): void; } +>Thenable : Thenable +>then : () => void + +declare let a: any; +>a : any + +declare let obj: { then: string; }; +>obj : { then: string; } +>then : string + +declare let thenable: Thenable; +>thenable : Thenable +>Thenable : Thenable + +async function fn1() { } // valid: Promise +>fn1 : () => Promise + +async function fn2(): { } { } // error +>fn2 : () => {} + +async function fn3(): any { } // error +>fn3 : () => any + +async function fn4(): number { } // error +>fn4 : () => number + +async function fn5(): PromiseLike { } // error +>fn5 : () => PromiseLike +>PromiseLike : PromiseLike + +async function fn6(): Thenable { } // error +>fn6 : () => Thenable +>Thenable : Thenable + +async function fn7() { return; } // valid: Promise +>fn7 : () => Promise + +async function fn8() { return 1; } // valid: Promise +>fn8 : () => Promise +>1 : 1 + +async function fn9() { return null; } // valid: Promise +>fn9 : () => Promise +>null : null + +async function fn10() { return undefined; } // valid: Promise +>fn10 : () => Promise +>undefined : undefined + +async function fn11() { return a; } // valid: Promise +>fn11 : () => Promise +>a : any + +async function fn12() { return obj; } // valid: Promise<{ then: string; }> +>fn12 : () => Promise<{ then: string; }> +>obj : { then: string; } + +async function fn13() { return thenable; } // error +>fn13 : () => Promise +>thenable : Thenable + +async function fn14() { await 1; } // valid: Promise +>fn14 : () => Promise +>await 1 : 1 +>1 : 1 + +async function fn15() { await null; } // valid: Promise +>fn15 : () => Promise +>await null : null +>null : null + +async function fn16() { await undefined; } // valid: Promise +>fn16 : () => Promise +>await undefined : undefined +>undefined : undefined + +async function fn17() { await a; } // valid: Promise +>fn17 : () => Promise +>await a : any +>a : any + +async function fn18() { await obj; } // valid: Promise +>fn18 : () => Promise +>await obj : { then: string; } +>obj : { then: string; } + +async function fn19() { await thenable; } // error +>fn19 : () => Promise +>await thenable : any +>thenable : Thenable + diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.symbols new file mode 100644 index 00000000000..b444d4e17f1 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts === +function f(await = await) { +>f : Symbol(f, Decl(asyncFunctionDeclaration3_es2017.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration3_es2017.ts, 0, 11)) +>await : Symbol(await, Decl(asyncFunctionDeclaration3_es2017.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.types new file mode 100644 index 00000000000..c7c56f7bfa1 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es2017.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration3_es2017.ts === +function f(await = await) { +>f : (await?: any) => void +>await : any +>await : any +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration3_es5.symbols new file mode 100644 index 00000000000..379fe683815 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es5.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5.ts === +function f(await = await) { +>f : Symbol(f, Decl(asyncFunctionDeclaration3_es5.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration3_es5.ts, 0, 11)) +>await : Symbol(await, Decl(asyncFunctionDeclaration3_es5.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es5.types b/tests/baselines/reference/asyncFunctionDeclaration3_es5.types new file mode 100644 index 00000000000..cec4e59ad86 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es5.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration3_es5.ts === +function f(await = await) { +>f : (await?: any) => void +>await : any +>await : any +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration3_es6.symbols new file mode 100644 index 00000000000..b869e6d7b62 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts === +function f(await = await) { +>f : Symbol(f, Decl(asyncFunctionDeclaration3_es6.ts, 0, 0)) +>await : Symbol(await, Decl(asyncFunctionDeclaration3_es6.ts, 0, 11)) +>await : Symbol(await, Decl(asyncFunctionDeclaration3_es6.ts, 0, 11)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration3_es6.types b/tests/baselines/reference/asyncFunctionDeclaration3_es6.types new file mode 100644 index 00000000000..12677cbe27a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration3_es6.types @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration3_es6.ts === +function f(await = await) { +>f : (await?: any) => void +>await : any +>await : any +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.symbols new file mode 100644 index 00000000000..8b501d4b03f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts === +async function foo(await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration5_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.types new file mode 100644 index 00000000000..fb19a3f5b11 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es2017.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration5_es2017.ts === +async function foo(await): Promise { +>foo : () => any +>await : any +>Promise {} : boolean +>PromisePromise : PromiseConstructor +>void : undefined +> : any +>{} : {} +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration5_es5.symbols new file mode 100644 index 00000000000..1bbc0b3650e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts === +async function foo(await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration5_es5.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es5.types b/tests/baselines/reference/asyncFunctionDeclaration5_es5.types new file mode 100644 index 00000000000..c1a99312825 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es5.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration5_es5.ts === +async function foo(await): Promise { +>foo : () => any +>await : any +>Promise {} : boolean +>PromisePromise : PromiseConstructor +>void : undefined +> : any +>{} : {} +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration5_es6.symbols new file mode 100644 index 00000000000..61f040d2834 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts === +async function foo(await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration5_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration5_es6.types b/tests/baselines/reference/asyncFunctionDeclaration5_es6.types new file mode 100644 index 00000000000..30497fd457a --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration5_es6.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration5_es6.ts === +async function foo(await): Promise { +>foo : () => any +>await : any +>Promise {} : boolean +>PromisePromise : PromiseConstructor +>void : undefined +> : any +>{} : {} +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.symbols new file mode 100644 index 00000000000..7bac561d1e7 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts === +async function foo(a = await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration6_es2017.ts, 0, 0)) +>a : Symbol(a, Decl(asyncFunctionDeclaration6_es2017.ts, 0, 19)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.types new file mode 100644 index 00000000000..5a1b84feae4 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es2017.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration6_es2017.ts === +async function foo(a = await): Promise { +>foo : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration6_es5.symbols new file mode 100644 index 00000000000..8e2533e8cdd --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es5.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration6_es5.ts === +async function foo(a = await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration6_es5.ts, 0, 0)) +>a : Symbol(a, Decl(asyncFunctionDeclaration6_es5.ts, 0, 19)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es5.types b/tests/baselines/reference/asyncFunctionDeclaration6_es5.types new file mode 100644 index 00000000000..02dd3d4be49 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es5.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration6_es5.ts === +async function foo(a = await): Promise { +>foo : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration6_es6.symbols new file mode 100644 index 00000000000..e9e5f97ee0e --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.symbols @@ -0,0 +1,6 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts === +async function foo(a = await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration6_es6.ts, 0, 0)) +>a : Symbol(a, Decl(asyncFunctionDeclaration6_es6.ts, 0, 19)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration6_es6.types b/tests/baselines/reference/asyncFunctionDeclaration6_es6.types new file mode 100644 index 00000000000..b65c4ef61d3 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration6_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration6_es6.ts === +async function foo(a = await): Promise { +>foo : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.symbols new file mode 100644 index 00000000000..1fccc5a1c15 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts === +async function bar(): Promise { +>bar : Symbol(bar, Decl(asyncFunctionDeclaration7_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration7_es2017.ts, 0, 37)) +>a : Symbol(a, Decl(asyncFunctionDeclaration7_es2017.ts, 2, 21)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + } +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.types new file mode 100644 index 00000000000..1d25294f229 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es2017.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration7_es2017.ts === +async function bar(): Promise { +>bar : () => Promise +>Promise : Promise + + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { +>foo : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise + } +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration7_es5.symbols new file mode 100644 index 00000000000..003cc2983e5 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es5.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration7_es5.ts === +async function bar(): Promise { +>bar : Symbol(bar, Decl(asyncFunctionDeclaration7_es5.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration7_es5.ts, 0, 37)) +>a : Symbol(a, Decl(asyncFunctionDeclaration7_es5.ts, 2, 21)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es5.types b/tests/baselines/reference/asyncFunctionDeclaration7_es5.types new file mode 100644 index 00000000000..f3bc39f8019 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es5.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration7_es5.ts === +async function bar(): Promise { +>bar : () => Promise +>Promise : Promise + + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { +>foo : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise + } +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration7_es6.symbols new file mode 100644 index 00000000000..67b117d59f8 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts === +async function bar(): Promise { +>bar : Symbol(bar, Decl(asyncFunctionDeclaration7_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration7_es6.ts, 0, 37)) +>a : Symbol(a, Decl(asyncFunctionDeclaration7_es6.ts, 2, 21)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + } +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration7_es6.types b/tests/baselines/reference/asyncFunctionDeclaration7_es6.types new file mode 100644 index 00000000000..8a55a2377e2 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration7_es6.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration7_es6.ts === +async function bar(): Promise { +>bar : () => Promise +>Promise : Promise + + // 'await' here is an identifier, and not a yield expression. + async function foo(a = await): Promise { +>foo : (a?: any) => Promise +>a : any +>await : any +> : any +>Promise : Promise + } +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.symbols new file mode 100644 index 00000000000..07e6d321196 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts === +var v = { [await]: foo } +>v : Symbol(v, Decl(asyncFunctionDeclaration8_es2017.ts, 0, 3)) + diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.types new file mode 100644 index 00000000000..9f28312a392 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es2017.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration8_es2017.ts === +var v = { [await]: foo } +>v : { [x: number]: any; } +>{ [await]: foo } : { [x: number]: any; } +>await : any +>foo : any + diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration8_es5.symbols new file mode 100644 index 00000000000..f30fa4f94d0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es5.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration8_es5.ts === +var v = { [await]: foo } +>v : Symbol(v, Decl(asyncFunctionDeclaration8_es5.ts, 0, 3)) + diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es5.types b/tests/baselines/reference/asyncFunctionDeclaration8_es5.types new file mode 100644 index 00000000000..d9073611a37 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es5.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration8_es5.ts === +var v = { [await]: foo } +>v : { [x: number]: any; } +>{ [await]: foo } : { [x: number]: any; } +>await : any +>foo : any + diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration8_es6.symbols new file mode 100644 index 00000000000..6c5218b27a6 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts === +var v = { [await]: foo } +>v : Symbol(v, Decl(asyncFunctionDeclaration8_es6.ts, 0, 3)) + diff --git a/tests/baselines/reference/asyncFunctionDeclaration8_es6.types b/tests/baselines/reference/asyncFunctionDeclaration8_es6.types new file mode 100644 index 00000000000..cb5929810e0 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration8_es6.types @@ -0,0 +1,7 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration8_es6.ts === +var v = { [await]: foo } +>v : { [x: number]: any; } +>{ [await]: foo } : { [x: number]: any; } +>await : any +>foo : any + diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es2017.symbols b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.symbols new file mode 100644 index 00000000000..a11944c1d4c --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration9_es2017.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + var v = { [await]: foo } +>v : Symbol(v, Decl(asyncFunctionDeclaration9_es2017.ts, 1, 5)) +>foo : Symbol(foo, Decl(asyncFunctionDeclaration9_es2017.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.types new file mode 100644 index 00000000000..c54a75b49ff --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es2017.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration9_es2017.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + var v = { [await]: foo } +>v : { [x: number]: () => Promise; } +>{ [await]: foo } : { [x: number]: () => Promise; } +>await : any +> : any +>foo : () => Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es5.symbols b/tests/baselines/reference/asyncFunctionDeclaration9_es5.symbols new file mode 100644 index 00000000000..881371f8347 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es5.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration9_es5.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration9_es5.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + + var v = { [await]: foo } +>v : Symbol(v, Decl(asyncFunctionDeclaration9_es5.ts, 1, 5)) +>foo : Symbol(foo, Decl(asyncFunctionDeclaration9_es5.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es5.types b/tests/baselines/reference/asyncFunctionDeclaration9_es5.types new file mode 100644 index 00000000000..ca8382e57b1 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es5.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration9_es5.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + var v = { [await]: foo } +>v : { [x: number]: () => Promise; } +>{ [await]: foo } : { [x: number]: () => Promise; } +>await : any +> : any +>foo : () => Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.symbols b/tests/baselines/reference/asyncFunctionDeclaration9_es6.symbols new file mode 100644 index 00000000000..9d46d6f6d8f --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts === +async function foo(): Promise { +>foo : Symbol(foo, Decl(asyncFunctionDeclaration9_es6.ts, 0, 0)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + + var v = { [await]: foo } +>v : Symbol(v, Decl(asyncFunctionDeclaration9_es6.ts, 1, 5)) +>foo : Symbol(foo, Decl(asyncFunctionDeclaration9_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncFunctionDeclaration9_es6.types b/tests/baselines/reference/asyncFunctionDeclaration9_es6.types new file mode 100644 index 00000000000..4bdf4582509 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclaration9_es6.types @@ -0,0 +1,12 @@ +=== tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration9_es6.ts === +async function foo(): Promise { +>foo : () => Promise +>Promise : Promise + + var v = { [await]: foo } +>v : { [x: number]: () => Promise; } +>{ [await]: foo } : { [x: number]: () => Promise; } +>await : any +> : any +>foo : () => Promise +} diff --git a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5.symbols b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5.symbols new file mode 100644 index 00000000000..39aed2be1fe --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5.symbols @@ -0,0 +1,22 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclarationCapturesArguments_es5.ts === +class C { +>C : Symbol(C, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 0, 0)) + + method() { +>method : Symbol(C.method, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 0, 9)) + + function other() {} +>other : Symbol(other, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 1, 13)) + + async function fn () { +>fn : Symbol(fn, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 2, 25)) + + await other.apply(this, arguments); +>other.apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>other : Symbol(other, Decl(asyncFunctionDeclarationCapturesArguments_es5.ts, 1, 13)) +>apply : Symbol(Function.apply, Decl(lib.es5.d.ts, --, --)) +>arguments : Symbol(arguments) + } + } +} + diff --git a/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5.types b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5.types new file mode 100644 index 00000000000..a93094991df --- /dev/null +++ b/tests/baselines/reference/asyncFunctionDeclarationCapturesArguments_es5.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclarationCapturesArguments_es5.ts === +class C { +>C : C + + method() { +>method : () => void + + function other() {} +>other : () => void + + async function fn () { +>fn : () => Promise + + await other.apply(this, arguments); +>await other.apply(this, arguments) : any +>other.apply(this, arguments) : any +>other.apply : (this: Function, thisArg: any, argArray?: any) => any +>other : () => void +>apply : (this: Function, thisArg: any, argArray?: any) => any +>this : any +>arguments : IArguments + } + } +} + diff --git a/tests/baselines/reference/asyncFunctionNoReturnType.symbols b/tests/baselines/reference/asyncFunctionNoReturnType.symbols new file mode 100644 index 00000000000..da7167599c9 --- /dev/null +++ b/tests/baselines/reference/asyncFunctionNoReturnType.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/asyncFunctionNoReturnType.ts === +async () => { +No type information for this code. if (window) +No type information for this code. return; +No type information for this code.} +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/asyncFunctionNoReturnType.types b/tests/baselines/reference/asyncFunctionNoReturnType.types new file mode 100644 index 00000000000..48f8b33c39d --- /dev/null +++ b/tests/baselines/reference/asyncFunctionNoReturnType.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/asyncFunctionNoReturnType.ts === +async () => { +>async () => { if (window) return;} : () => Promise + + if (window) +>window : any + + return; +} + diff --git a/tests/baselines/reference/asyncGetter_es5.symbols b/tests/baselines/reference/asyncGetter_es5.symbols new file mode 100644 index 00000000000..c29c2e8dd3c --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es5.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es5/asyncGetter_es5.ts === +class C { +>C : Symbol(C, Decl(asyncGetter_es5.ts, 0, 0)) + + async get foo() { +>foo : Symbol(C.foo, Decl(asyncGetter_es5.ts, 0, 9)) + } +} diff --git a/tests/baselines/reference/asyncGetter_es5.types b/tests/baselines/reference/asyncGetter_es5.types new file mode 100644 index 00000000000..071de68c9d7 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es5.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es5/asyncGetter_es5.ts === +class C { +>C : C + + async get foo() { +>foo : void + } +} diff --git a/tests/baselines/reference/asyncGetter_es6.symbols b/tests/baselines/reference/asyncGetter_es6.symbols new file mode 100644 index 00000000000..ee96c939468 --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es6.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/asyncGetter_es6.ts === +class C { +>C : Symbol(C, Decl(asyncGetter_es6.ts, 0, 0)) + + async get foo() { +>foo : Symbol(C.foo, Decl(asyncGetter_es6.ts, 0, 9)) + } +} diff --git a/tests/baselines/reference/asyncGetter_es6.types b/tests/baselines/reference/asyncGetter_es6.types new file mode 100644 index 00000000000..e71c16c4a8b --- /dev/null +++ b/tests/baselines/reference/asyncGetter_es6.types @@ -0,0 +1,8 @@ +=== tests/cases/conformance/async/es6/asyncGetter_es6.ts === +class C { +>C : C + + async get foo() { +>foo : void + } +} diff --git a/tests/baselines/reference/asyncImportedPromise_es6.symbols b/tests/baselines/reference/asyncImportedPromise_es6.symbols new file mode 100644 index 00000000000..86f037946e2 --- /dev/null +++ b/tests/baselines/reference/asyncImportedPromise_es6.symbols @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es6/task.ts === +export class Task extends Promise { } +>Task : Symbol(Task, Decl(task.ts, 0, 0)) +>T : Symbol(T, Decl(task.ts, 0, 18)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>T : Symbol(T, Decl(task.ts, 0, 18)) + +=== tests/cases/conformance/async/es6/test.ts === +import { Task } from "./task"; +>Task : Symbol(Task, Decl(test.ts, 0, 8)) + +class Test { +>Test : Symbol(Test, Decl(test.ts, 0, 30)) + + async example(): Task { return; } +>example : Symbol(Test.example, Decl(test.ts, 1, 12)) +>T : Symbol(T, Decl(test.ts, 2, 18)) +>Task : Symbol(Task, Decl(test.ts, 0, 8)) +>T : Symbol(T, Decl(test.ts, 2, 18)) +} diff --git a/tests/baselines/reference/asyncImportedPromise_es6.types b/tests/baselines/reference/asyncImportedPromise_es6.types new file mode 100644 index 00000000000..424f14b34d3 --- /dev/null +++ b/tests/baselines/reference/asyncImportedPromise_es6.types @@ -0,0 +1,20 @@ +=== tests/cases/conformance/async/es6/task.ts === +export class Task extends Promise { } +>Task : Task +>T : T +>Promise : Promise +>T : T + +=== tests/cases/conformance/async/es6/test.ts === +import { Task } from "./task"; +>Task : typeof Task + +class Test { +>Test : Test + + async example(): Task { return; } +>example : () => Task +>T : T +>Task : Task +>T : T +} diff --git a/tests/baselines/reference/asyncInterface_es5.symbols b/tests/baselines/reference/asyncInterface_es5.symbols new file mode 100644 index 00000000000..d12228581dc --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es5.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es5/asyncInterface_es5.ts === +async interface I { +>I : Symbol(I, Decl(asyncInterface_es5.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncInterface_es5.types b/tests/baselines/reference/asyncInterface_es5.types new file mode 100644 index 00000000000..37b780a19ad --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es5.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es5/asyncInterface_es5.ts === +async interface I { +>I : I +} diff --git a/tests/baselines/reference/asyncInterface_es6.symbols b/tests/baselines/reference/asyncInterface_es6.symbols new file mode 100644 index 00000000000..9a09798a755 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncInterface_es6.ts === +async interface I { +>I : Symbol(I, Decl(asyncInterface_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncInterface_es6.types b/tests/baselines/reference/asyncInterface_es6.types new file mode 100644 index 00000000000..b770cafdb96 --- /dev/null +++ b/tests/baselines/reference/asyncInterface_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncInterface_es6.ts === +async interface I { +>I : I +} diff --git a/tests/baselines/reference/asyncModule_es5.symbols b/tests/baselines/reference/asyncModule_es5.symbols new file mode 100644 index 00000000000..521d6e26b23 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es5.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es5/asyncModule_es5.ts === +async module M { +>M : Symbol(M, Decl(asyncModule_es5.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncModule_es5.types b/tests/baselines/reference/asyncModule_es5.types new file mode 100644 index 00000000000..ee956e48eb3 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es5.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es5/asyncModule_es5.ts === +async module M { +>M : any +} diff --git a/tests/baselines/reference/asyncModule_es6.symbols b/tests/baselines/reference/asyncModule_es6.symbols new file mode 100644 index 00000000000..3a1ebc8fcf6 --- /dev/null +++ b/tests/baselines/reference/asyncModule_es6.symbols @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncModule_es6.ts === +async module M { +>M : Symbol(M, Decl(asyncModule_es6.ts, 0, 0)) +} diff --git a/tests/baselines/reference/asyncModule_es6.types b/tests/baselines/reference/asyncModule_es6.types new file mode 100644 index 00000000000..b502433758a --- /dev/null +++ b/tests/baselines/reference/asyncModule_es6.types @@ -0,0 +1,4 @@ +=== tests/cases/conformance/async/es6/asyncModule_es6.ts === +async module M { +>M : any +} diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es6.symbols b/tests/baselines/reference/asyncQualifiedReturnType_es6.symbols new file mode 100644 index 00000000000..86f14f2da74 --- /dev/null +++ b/tests/baselines/reference/asyncQualifiedReturnType_es6.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/async/es6/asyncQualifiedReturnType_es6.ts === +namespace X { +>X : Symbol(X, Decl(asyncQualifiedReturnType_es6.ts, 0, 0)) + + export class MyPromise extends Promise { +>MyPromise : Symbol(MyPromise, Decl(asyncQualifiedReturnType_es6.ts, 0, 13)) +>T : Symbol(T, Decl(asyncQualifiedReturnType_es6.ts, 1, 27)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>T : Symbol(T, Decl(asyncQualifiedReturnType_es6.ts, 1, 27)) + } +} + +async function f(): X.MyPromise { +>f : Symbol(f, Decl(asyncQualifiedReturnType_es6.ts, 3, 1)) +>X : Symbol(X, Decl(asyncQualifiedReturnType_es6.ts, 0, 0)) +>MyPromise : Symbol(X.MyPromise, Decl(asyncQualifiedReturnType_es6.ts, 0, 13)) +} diff --git a/tests/baselines/reference/asyncQualifiedReturnType_es6.types b/tests/baselines/reference/asyncQualifiedReturnType_es6.types new file mode 100644 index 00000000000..3b438eb93b6 --- /dev/null +++ b/tests/baselines/reference/asyncQualifiedReturnType_es6.types @@ -0,0 +1,17 @@ +=== tests/cases/conformance/async/es6/asyncQualifiedReturnType_es6.ts === +namespace X { +>X : typeof X + + export class MyPromise extends Promise { +>MyPromise : MyPromise +>T : T +>Promise : Promise +>T : T + } +} + +async function f(): X.MyPromise { +>f : () => X.MyPromise +>X : any +>MyPromise : X.MyPromise +} diff --git a/tests/baselines/reference/asyncSetter_es5.symbols b/tests/baselines/reference/asyncSetter_es5.symbols new file mode 100644 index 00000000000..c07af2778c5 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es5.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es5/asyncSetter_es5.ts === +class C { +>C : Symbol(C, Decl(asyncSetter_es5.ts, 0, 0)) + + async set foo(value) { +>foo : Symbol(C.foo, Decl(asyncSetter_es5.ts, 0, 9)) +>value : Symbol(value, Decl(asyncSetter_es5.ts, 1, 16)) + } +} diff --git a/tests/baselines/reference/asyncSetter_es5.types b/tests/baselines/reference/asyncSetter_es5.types new file mode 100644 index 00000000000..cd6c0b6677f --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es5.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es5/asyncSetter_es5.ts === +class C { +>C : C + + async set foo(value) { +>foo : any +>value : any + } +} diff --git a/tests/baselines/reference/asyncSetter_es6.symbols b/tests/baselines/reference/asyncSetter_es6.symbols new file mode 100644 index 00000000000..fa37e5bacc0 --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es6.symbols @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es6/asyncSetter_es6.ts === +class C { +>C : Symbol(C, Decl(asyncSetter_es6.ts, 0, 0)) + + async set foo(value) { +>foo : Symbol(C.foo, Decl(asyncSetter_es6.ts, 0, 9)) +>value : Symbol(value, Decl(asyncSetter_es6.ts, 1, 16)) + } +} diff --git a/tests/baselines/reference/asyncSetter_es6.types b/tests/baselines/reference/asyncSetter_es6.types new file mode 100644 index 00000000000..99a4a25cbda --- /dev/null +++ b/tests/baselines/reference/asyncSetter_es6.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/async/es6/asyncSetter_es6.ts === +class C { +>C : C + + async set foo(value) { +>foo : any +>value : any + } +} diff --git a/tests/baselines/reference/augmentExportEquals1.symbols b/tests/baselines/reference/augmentExportEquals1.symbols new file mode 100644 index 00000000000..84ec06ca7fe --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals1.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/file3.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file3.ts, 0, 0)) + +import "./file2"; +let a: x.A; // should not work +>a : Symbol(a, Decl(file3.ts, 2, 3)) + +=== tests/cases/compiler/file1.ts === +var x = 1; +>x : Symbol(x, Decl(file1.ts, 0, 3)) + +export = x; +>x : Symbol(x, Decl(file1.ts, 0, 3)) + +=== tests/cases/compiler/file2.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file2.ts, 0, 0)) + +// augmentation for './file1' +// should error since './file1' does not have namespace meaning +declare module "./file1" { + interface A { a } +>A : Symbol(A, Decl(file2.ts, 4, 26)) +>a : Symbol(A.a, Decl(file2.ts, 5, 17)) +} + diff --git a/tests/baselines/reference/augmentExportEquals1.types b/tests/baselines/reference/augmentExportEquals1.types new file mode 100644 index 00000000000..afb5dd1edc9 --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals1.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/file3.ts === +import x = require("./file1"); +>x : number + +import "./file2"; +let a: x.A; // should not work +>a : any +>x : any +>A : No type information available! + +=== tests/cases/compiler/file1.ts === +var x = 1; +>x : number +>1 : 1 + +export = x; +>x : number + +=== tests/cases/compiler/file2.ts === +import x = require("./file1"); +>x : number + +// augmentation for './file1' +// should error since './file1' does not have namespace meaning +declare module "./file1" { + interface A { a } +>A : A +>a : any +} + diff --git a/tests/baselines/reference/augmentExportEquals1_1.symbols b/tests/baselines/reference/augmentExportEquals1_1.symbols new file mode 100644 index 00000000000..df793ca841c --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals1_1.symbols @@ -0,0 +1,30 @@ +=== tests/cases/compiler/file3.ts === +import x = require("file1"); +>x : Symbol(x, Decl(file3.ts, 0, 0)) + +import "file2"; +let a: x.A; // should not work +>a : Symbol(a, Decl(file3.ts, 2, 3)) + +=== tests/cases/compiler/file1.d.ts === +declare module "file1" { + var x: number; +>x : Symbol(x, Decl(file1.d.ts, 1, 7)) + + export = x; +>x : Symbol(x, Decl(file1.d.ts, 1, 7)) +} + +=== tests/cases/compiler/file2.ts === +/// +import x = require("file1"); +>x : Symbol(x, Decl(file2.ts, 0, 0)) + +// augmentation for 'file1' +// should error since 'file1' does not have namespace meaning +declare module "file1" { + interface A { a } +>A : Symbol(A, Decl(file2.ts, 5, 24)) +>a : Symbol(A.a, Decl(file2.ts, 6, 17)) +} + diff --git a/tests/baselines/reference/augmentExportEquals1_1.types b/tests/baselines/reference/augmentExportEquals1_1.types new file mode 100644 index 00000000000..f771e815743 --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals1_1.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/file3.ts === +import x = require("file1"); +>x : number + +import "file2"; +let a: x.A; // should not work +>a : any +>x : any +>A : No type information available! + +=== tests/cases/compiler/file1.d.ts === +declare module "file1" { + var x: number; +>x : number + + export = x; +>x : number +} + +=== tests/cases/compiler/file2.ts === +/// +import x = require("file1"); +>x : number + +// augmentation for 'file1' +// should error since 'file1' does not have namespace meaning +declare module "file1" { + interface A { a } +>A : A +>a : any +} + diff --git a/tests/baselines/reference/augmentExportEquals2.symbols b/tests/baselines/reference/augmentExportEquals2.symbols new file mode 100644 index 00000000000..29f85da0e1f --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals2.symbols @@ -0,0 +1,26 @@ +=== tests/cases/compiler/file3.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file3.ts, 0, 0)) + +import "./file2"; +let a: x.A; // should not work +>a : Symbol(a, Decl(file3.ts, 2, 3)) + +=== tests/cases/compiler/file1.ts === +function foo() {} +>foo : Symbol(foo, Decl(file1.ts, 0, 0)) + +export = foo; +>foo : Symbol(foo, Decl(file1.ts, 0, 0)) + +=== tests/cases/compiler/file2.ts === +import x = require("./file1"); +>x : Symbol(x, Decl(file2.ts, 0, 0)) + +// should error since './file1' does not have namespace meaning +declare module "./file1" { + interface A { a } +>A : Symbol(A, Decl(file2.ts, 3, 26)) +>a : Symbol(A.a, Decl(file2.ts, 4, 17)) +} + diff --git a/tests/baselines/reference/augmentExportEquals2.types b/tests/baselines/reference/augmentExportEquals2.types new file mode 100644 index 00000000000..658579598ae --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals2.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/file3.ts === +import x = require("./file1"); +>x : () => void + +import "./file2"; +let a: x.A; // should not work +>a : any +>x : any +>A : No type information available! + +=== tests/cases/compiler/file1.ts === +function foo() {} +>foo : () => void + +export = foo; +>foo : () => void + +=== tests/cases/compiler/file2.ts === +import x = require("./file1"); +>x : () => void + +// should error since './file1' does not have namespace meaning +declare module "./file1" { + interface A { a } +>A : A +>a : any +} + diff --git a/tests/baselines/reference/augmentExportEquals2_1.symbols b/tests/baselines/reference/augmentExportEquals2_1.symbols new file mode 100644 index 00000000000..99ce1e5c85c --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals2_1.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/file3.ts === +import x = require("file1"); +>x : Symbol(x, Decl(file3.ts, 0, 0)) + +import "file2"; +let a: x.A; // should not work +>a : Symbol(a, Decl(file3.ts, 2, 3)) + +=== tests/cases/compiler/file1.d.ts === +declare module "file1" { + function foo(): void; +>foo : Symbol(foo, Decl(file1.d.ts, 0, 24)) + + export = foo; +>foo : Symbol(foo, Decl(file1.d.ts, 0, 24)) +} + +=== tests/cases/compiler/file2.ts === +/// +import x = require("file1"); +>x : Symbol(x, Decl(file2.ts, 0, 0)) + +// should error since './file1' does not have namespace meaning +declare module "file1" { + interface A { a } +>A : Symbol(A, Decl(file2.ts, 4, 24)) +>a : Symbol(A.a, Decl(file2.ts, 5, 17)) +} + diff --git a/tests/baselines/reference/augmentExportEquals2_1.types b/tests/baselines/reference/augmentExportEquals2_1.types new file mode 100644 index 00000000000..e47ed79f584 --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals2_1.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/file3.ts === +import x = require("file1"); +>x : () => void + +import "file2"; +let a: x.A; // should not work +>a : any +>x : any +>A : No type information available! + +=== tests/cases/compiler/file1.d.ts === +declare module "file1" { + function foo(): void; +>foo : () => void + + export = foo; +>foo : () => void +} + +=== tests/cases/compiler/file2.ts === +/// +import x = require("file1"); +>x : () => void + +// should error since './file1' does not have namespace meaning +declare module "file1" { + interface A { a } +>A : A +>a : any +} + diff --git a/tests/baselines/reference/augmentExportEquals7.symbols b/tests/baselines/reference/augmentExportEquals7.symbols new file mode 100644 index 00000000000..42156dafaed --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals7.symbols @@ -0,0 +1,19 @@ +=== /node_modules/lib/index.d.ts === +declare var lib: () => void; +>lib : Symbol(lib, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 28)) + +declare namespace lib {} +>lib : Symbol(lib, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 28)) + +export = lib; +>lib : Symbol(lib, Decl(index.d.ts, 0, 11), Decl(index.d.ts, 0, 28)) + +=== /node_modules/@types/lib-extender/index.d.ts === +import * as lib from "lib"; +>lib : Symbol(lib, Decl(index.d.ts, 0, 6)) + +declare module "lib" { + export function fn(): void; +>fn : Symbol(fn, Decl(index.d.ts, 1, 22)) +} + diff --git a/tests/baselines/reference/augmentExportEquals7.types b/tests/baselines/reference/augmentExportEquals7.types new file mode 100644 index 00000000000..f2870eab8df --- /dev/null +++ b/tests/baselines/reference/augmentExportEquals7.types @@ -0,0 +1,19 @@ +=== /node_modules/lib/index.d.ts === +declare var lib: () => void; +>lib : () => void + +declare namespace lib {} +>lib : () => void + +export = lib; +>lib : () => void + +=== /node_modules/@types/lib-extender/index.d.ts === +import * as lib from "lib"; +>lib : () => void + +declare module "lib" { + export function fn(): void; +>fn : () => void +} + diff --git a/tests/baselines/reference/augmentedClassWithPrototypePropertyOnModule.symbols b/tests/baselines/reference/augmentedClassWithPrototypePropertyOnModule.symbols new file mode 100644 index 00000000000..ddb2f9cb85c --- /dev/null +++ b/tests/baselines/reference/augmentedClassWithPrototypePropertyOnModule.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/augmentedClassWithPrototypePropertyOnModule.ts === +declare module m { +>m : Symbol(m, Decl(augmentedClassWithPrototypePropertyOnModule.ts, 0, 0), Decl(augmentedClassWithPrototypePropertyOnModule.ts, 3, 1)) + + var f; +>f : Symbol(f, Decl(augmentedClassWithPrototypePropertyOnModule.ts, 1, 7)) + + var prototype; // This should be error since prototype would be static property on class m +>prototype : Symbol(m.prototype, Decl(augmentedClassWithPrototypePropertyOnModule.ts, 2, 7)) +} +declare class m { +>m : Symbol(m, Decl(augmentedClassWithPrototypePropertyOnModule.ts, 0, 0), Decl(augmentedClassWithPrototypePropertyOnModule.ts, 3, 1)) +} diff --git a/tests/baselines/reference/augmentedClassWithPrototypePropertyOnModule.types b/tests/baselines/reference/augmentedClassWithPrototypePropertyOnModule.types new file mode 100644 index 00000000000..4437ab706f6 --- /dev/null +++ b/tests/baselines/reference/augmentedClassWithPrototypePropertyOnModule.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/augmentedClassWithPrototypePropertyOnModule.ts === +declare module m { +>m : typeof m + + var f; +>f : any + + var prototype; // This should be error since prototype would be static property on class m +>prototype : any +} +declare class m { +>m : m +} diff --git a/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.symbols b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.symbols new file mode 100644 index 00000000000..6057cef5c8f --- /dev/null +++ b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts === +interface Foo { a } +>Foo : Symbol(Foo, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 0, 0)) +>a : Symbol(Foo.a, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 0, 15)) + +interface Bar { b } +>Bar : Symbol(Bar, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 0, 19)) +>b : Symbol(Bar.b, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 1, 15)) + +interface Object { +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 1, 19)) + + [n: number]: Foo; +>n : Symbol(n, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 4, 5)) +>Foo : Symbol(Foo, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 0, 0)) +} + +interface Function { +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 5, 1)) + + [n: number]: Bar; +>n : Symbol(n, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 8, 5)) +>Bar : Symbol(Bar, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 0, 19)) +} + +var o = {}; +>o : Symbol(o, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 11, 3)) + +var f = () => { }; +>f : Symbol(f, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 12, 3)) + +var v1: { +>v1 : Symbol(v1, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 14, 3)) + + [n: number]: Foo +>n : Symbol(n, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 15, 5)) +>Foo : Symbol(Foo, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 0, 0)) + +} = o; // Should be allowed +>o : Symbol(o, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 11, 3)) + +var v2: { +>v2 : Symbol(v2, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 18, 3)) + + [n: number]: Bar +>n : Symbol(n, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 19, 5)) +>Bar : Symbol(Bar, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 0, 19)) + +} = f; // Should be allowed +>f : Symbol(f, Decl(augmentedTypeAssignmentCompatIndexSignature.ts, 12, 3)) + diff --git a/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.types b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.types new file mode 100644 index 00000000000..fc19672442a --- /dev/null +++ b/tests/baselines/reference/augmentedTypeAssignmentCompatIndexSignature.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/types/members/augmentedTypeAssignmentCompatIndexSignature.ts === +interface Foo { a } +>Foo : Foo +>a : any + +interface Bar { b } +>Bar : Bar +>b : any + +interface Object { +>Object : Object + + [n: number]: Foo; +>n : number +>Foo : Foo +} + +interface Function { +>Function : Function + + [n: number]: Bar; +>n : number +>Bar : Bar +} + +var o = {}; +>o : {} +>{} : {} + +var f = () => { }; +>f : () => void +>() => { } : () => void + +var v1: { +>v1 : { [n: number]: Foo; } + + [n: number]: Foo +>n : number +>Foo : Foo + +} = o; // Should be allowed +>o : {} + +var v2: { +>v2 : { [n: number]: Bar; } + + [n: number]: Bar +>n : number +>Bar : Bar + +} = f; // Should be allowed +>f : () => void + diff --git a/tests/baselines/reference/augmentedTypesClass.symbols b/tests/baselines/reference/augmentedTypesClass.symbols new file mode 100644 index 00000000000..0f867f3dead --- /dev/null +++ b/tests/baselines/reference/augmentedTypesClass.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/augmentedTypesClass.ts === +//// class then var +class c1 { public foo() { } } +>c1 : Symbol(c1, Decl(augmentedTypesClass.ts, 0, 0)) +>foo : Symbol(c1.foo, Decl(augmentedTypesClass.ts, 1, 10)) + +var c1 = 1; // error +>c1 : Symbol(c1, Decl(augmentedTypesClass.ts, 2, 3)) + +//// class then enum +class c4 { public foo() { } } +>c4 : Symbol(c4, Decl(augmentedTypesClass.ts, 2, 11)) +>foo : Symbol(c4.foo, Decl(augmentedTypesClass.ts, 5, 10)) + +enum c4 { One } // error +>c4 : Symbol(c4, Decl(augmentedTypesClass.ts, 5, 29)) +>One : Symbol(c4.One, Decl(augmentedTypesClass.ts, 6, 9)) + diff --git a/tests/baselines/reference/augmentedTypesClass.types b/tests/baselines/reference/augmentedTypesClass.types new file mode 100644 index 00000000000..6bee329d24e --- /dev/null +++ b/tests/baselines/reference/augmentedTypesClass.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/augmentedTypesClass.ts === +//// class then var +class c1 { public foo() { } } +>c1 : c1 +>foo : () => void + +var c1 = 1; // error +>c1 : number +>1 : 1 + +//// class then enum +class c4 { public foo() { } } +>c4 : c4 +>foo : () => void + +enum c4 { One } // error +>c4 : c4 +>One : c4 + diff --git a/tests/baselines/reference/augmentedTypesClass2.symbols b/tests/baselines/reference/augmentedTypesClass2.symbols new file mode 100644 index 00000000000..a9fbf1a4a13 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesClass2.symbols @@ -0,0 +1,48 @@ +=== tests/cases/compiler/augmentedTypesClass2.ts === +// Checking class with other things in type space not value space + +// class then interface +class c11 { +>c11 : Symbol(c11, Decl(augmentedTypesClass2.ts, 0, 0), Decl(augmentedTypesClass2.ts, 7, 1)) + + foo() { +>foo : Symbol(c11.foo, Decl(augmentedTypesClass2.ts, 3, 11)) + + return 1; + } +} + +interface c11 { +>c11 : Symbol(c11, Decl(augmentedTypesClass2.ts, 0, 0), Decl(augmentedTypesClass2.ts, 7, 1)) + + bar(): void; +>bar : Symbol(c11.bar, Decl(augmentedTypesClass2.ts, 9, 15)) +} + +// class then class - covered +// class then enum +class c33 { +>c33 : Symbol(c33, Decl(augmentedTypesClass2.ts, 11, 1)) + + foo() { +>foo : Symbol(c33.foo, Decl(augmentedTypesClass2.ts, 15, 11)) + + return 1; + } +} +enum c33 { One }; +>c33 : Symbol(c33, Decl(augmentedTypesClass2.ts, 19, 1)) +>One : Symbol(c33.One, Decl(augmentedTypesClass2.ts, 20, 10)) + +// class then import +class c44 { +>c44 : Symbol(c44, Decl(augmentedTypesClass2.ts, 20, 17)) + + foo() { +>foo : Symbol(c44.foo, Decl(augmentedTypesClass2.ts, 23, 11)) + + return 1; + } +} + + diff --git a/tests/baselines/reference/augmentedTypesClass2.types b/tests/baselines/reference/augmentedTypesClass2.types new file mode 100644 index 00000000000..dd3263cc0a2 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesClass2.types @@ -0,0 +1,51 @@ +=== tests/cases/compiler/augmentedTypesClass2.ts === +// Checking class with other things in type space not value space + +// class then interface +class c11 { +>c11 : c11 + + foo() { +>foo : () => number + + return 1; +>1 : 1 + } +} + +interface c11 { +>c11 : c11 + + bar(): void; +>bar : () => void +} + +// class then class - covered +// class then enum +class c33 { +>c33 : c33 + + foo() { +>foo : () => number + + return 1; +>1 : 1 + } +} +enum c33 { One }; +>c33 : c33 +>One : c33 + +// class then import +class c44 { +>c44 : c44 + + foo() { +>foo : () => number + + return 1; +>1 : 1 + } +} + + diff --git a/tests/baselines/reference/augmentedTypesClass2a.symbols b/tests/baselines/reference/augmentedTypesClass2a.symbols new file mode 100644 index 00000000000..78acabbbb4f --- /dev/null +++ b/tests/baselines/reference/augmentedTypesClass2a.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/augmentedTypesClass2a.ts === +//// class then function +class c2 { public foo() { } } // error +>c2 : Symbol(c2, Decl(augmentedTypesClass2a.ts, 0, 0)) +>foo : Symbol(c2.foo, Decl(augmentedTypesClass2a.ts, 1, 10)) + +function c2() { } // error +>c2 : Symbol(c2, Decl(augmentedTypesClass2a.ts, 1, 29)) + +var c2 = () => { } +>c2 : Symbol(c2, Decl(augmentedTypesClass2a.ts, 3, 3)) + diff --git a/tests/baselines/reference/augmentedTypesClass2a.types b/tests/baselines/reference/augmentedTypesClass2a.types new file mode 100644 index 00000000000..156d4975d04 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesClass2a.types @@ -0,0 +1,13 @@ +=== tests/cases/compiler/augmentedTypesClass2a.ts === +//// class then function +class c2 { public foo() { } } // error +>c2 : c2 +>foo : () => void + +function c2() { } // error +>c2 : () => void + +var c2 = () => { } +>c2 : () => void +>() => { } : () => void + diff --git a/tests/baselines/reference/augmentedTypesClass4.symbols b/tests/baselines/reference/augmentedTypesClass4.symbols new file mode 100644 index 00000000000..220545b6e00 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesClass4.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/augmentedTypesClass4.ts === +//// class then class +class c3 { public foo() { } } // error +>c3 : Symbol(c3, Decl(augmentedTypesClass4.ts, 0, 0)) +>foo : Symbol(c3.foo, Decl(augmentedTypesClass4.ts, 1, 10)) + +class c3 { public bar() { } } // error +>c3 : Symbol(c3, Decl(augmentedTypesClass4.ts, 1, 29)) +>bar : Symbol(c3.bar, Decl(augmentedTypesClass4.ts, 2, 10)) + diff --git a/tests/baselines/reference/augmentedTypesClass4.types b/tests/baselines/reference/augmentedTypesClass4.types new file mode 100644 index 00000000000..934d2314464 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesClass4.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/augmentedTypesClass4.ts === +//// class then class +class c3 { public foo() { } } // error +>c3 : c3 +>foo : () => void + +class c3 { public bar() { } } // error +>c3 : c3 +>bar : () => void + diff --git a/tests/baselines/reference/augmentedTypesEnum.symbols b/tests/baselines/reference/augmentedTypesEnum.symbols new file mode 100644 index 00000000000..b0d24b1be39 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesEnum.symbols @@ -0,0 +1,77 @@ +=== tests/cases/compiler/augmentedTypesEnum.ts === +// enum then var +enum e1111 { One } // error +>e1111 : Symbol(e1111, Decl(augmentedTypesEnum.ts, 0, 0)) +>One : Symbol(e1111.One, Decl(augmentedTypesEnum.ts, 1, 12)) + +var e1111 = 1; // error +>e1111 : Symbol(e1111, Decl(augmentedTypesEnum.ts, 2, 3)) + +// enum then function +enum e2 { One } // error +>e2 : Symbol(e2, Decl(augmentedTypesEnum.ts, 2, 14)) +>One : Symbol(e2.One, Decl(augmentedTypesEnum.ts, 5, 9)) + +function e2() { } // error +>e2 : Symbol(e2, Decl(augmentedTypesEnum.ts, 5, 15)) + +enum e3 { One } // error +>e3 : Symbol(e3, Decl(augmentedTypesEnum.ts, 6, 17)) +>One : Symbol(e3.One, Decl(augmentedTypesEnum.ts, 8, 9)) + +var e3 = () => { } // error +>e3 : Symbol(e3, Decl(augmentedTypesEnum.ts, 9, 3)) + +// enum then class +enum e4 { One } // error +>e4 : Symbol(e4, Decl(augmentedTypesEnum.ts, 9, 18)) +>One : Symbol(e4.One, Decl(augmentedTypesEnum.ts, 12, 9)) + +class e4 { public foo() { } } // error +>e4 : Symbol(e4, Decl(augmentedTypesEnum.ts, 12, 15)) +>foo : Symbol(e4.foo, Decl(augmentedTypesEnum.ts, 13, 10)) + +// enum then enum +enum e5 { One } +>e5 : Symbol(e5, Decl(augmentedTypesEnum.ts, 13, 29), Decl(augmentedTypesEnum.ts, 16, 15)) +>One : Symbol(e5.One, Decl(augmentedTypesEnum.ts, 16, 9)) + +enum e5 { Two } // error +>e5 : Symbol(e5, Decl(augmentedTypesEnum.ts, 13, 29), Decl(augmentedTypesEnum.ts, 16, 15)) +>Two : Symbol(e5.Two, Decl(augmentedTypesEnum.ts, 17, 9)) + +enum e5a { One } // error +>e5a : Symbol(e5a, Decl(augmentedTypesEnum.ts, 17, 15), Decl(augmentedTypesEnum.ts, 19, 16)) +>One : Symbol(e5a.One, Decl(augmentedTypesEnum.ts, 19, 10)) + +enum e5a { One } // error +>e5a : Symbol(e5a, Decl(augmentedTypesEnum.ts, 17, 15), Decl(augmentedTypesEnum.ts, 19, 16)) +>One : Symbol(e5a.One, Decl(augmentedTypesEnum.ts, 20, 10)) + +// enum then internal module +enum e6 { One } +>e6 : Symbol(e6, Decl(augmentedTypesEnum.ts, 20, 16), Decl(augmentedTypesEnum.ts, 23, 15)) +>One : Symbol(e6.One, Decl(augmentedTypesEnum.ts, 23, 9)) + +module e6 { } // ok +>e6 : Symbol(e6, Decl(augmentedTypesEnum.ts, 20, 16), Decl(augmentedTypesEnum.ts, 23, 15)) + +enum e6a { One } +>e6a : Symbol(e6a, Decl(augmentedTypesEnum.ts, 24, 13), Decl(augmentedTypesEnum.ts, 26, 16)) +>One : Symbol(e6a.One, Decl(augmentedTypesEnum.ts, 26, 10)) + +module e6a { var y = 2; } // should be error +>e6a : Symbol(e6a, Decl(augmentedTypesEnum.ts, 24, 13), Decl(augmentedTypesEnum.ts, 26, 16)) +>y : Symbol(y, Decl(augmentedTypesEnum.ts, 27, 16)) + +enum e6b { One } +>e6b : Symbol(e6b, Decl(augmentedTypesEnum.ts, 27, 25), Decl(augmentedTypesEnum.ts, 29, 16)) +>One : Symbol(e6b.One, Decl(augmentedTypesEnum.ts, 29, 10)) + +module e6b { export var y = 2; } // should be error +>e6b : Symbol(e6b, Decl(augmentedTypesEnum.ts, 27, 25), Decl(augmentedTypesEnum.ts, 29, 16)) +>y : Symbol(y, Decl(augmentedTypesEnum.ts, 30, 23)) + +// enum then import, messes with error reporting +//enum e7 { One } +//import e7 = require(''); // should be error diff --git a/tests/baselines/reference/augmentedTypesEnum.types b/tests/baselines/reference/augmentedTypesEnum.types new file mode 100644 index 00000000000..36ac647e4a1 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesEnum.types @@ -0,0 +1,81 @@ +=== tests/cases/compiler/augmentedTypesEnum.ts === +// enum then var +enum e1111 { One } // error +>e1111 : e1111 +>One : e1111 + +var e1111 = 1; // error +>e1111 : number +>1 : 1 + +// enum then function +enum e2 { One } // error +>e2 : e2 +>One : e2 + +function e2() { } // error +>e2 : () => void + +enum e3 { One } // error +>e3 : e3 +>One : e3 + +var e3 = () => { } // error +>e3 : () => void +>() => { } : () => void + +// enum then class +enum e4 { One } // error +>e4 : e4 +>One : e4 + +class e4 { public foo() { } } // error +>e4 : e4 +>foo : () => void + +// enum then enum +enum e5 { One } +>e5 : e5 +>One : e5 + +enum e5 { Two } // error +>e5 : e5 +>Two : e5 + +enum e5a { One } // error +>e5a : e5a +>One : e5a + +enum e5a { One } // error +>e5a : e5a +>One : e5a + +// enum then internal module +enum e6 { One } +>e6 : e6 +>One : e6 + +module e6 { } // ok +>e6 : typeof e6 + +enum e6a { One } +>e6a : e6a +>One : e6a + +module e6a { var y = 2; } // should be error +>e6a : typeof e6a +>y : number +>2 : 2 + +enum e6b { One } +>e6b : e6b +>One : e6b + +module e6b { export var y = 2; } // should be error +>e6b : typeof e6b +>y : number +>2 : 2 + +// enum then import, messes with error reporting +//enum e7 { One } +//import e7 = require(''); // should be error diff --git a/tests/baselines/reference/augmentedTypesEnum2.symbols b/tests/baselines/reference/augmentedTypesEnum2.symbols new file mode 100644 index 00000000000..eb65b4bab62 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesEnum2.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/augmentedTypesEnum2.ts === +// enum then interface +enum e1 { One } // error +>e1 : Symbol(e1, Decl(augmentedTypesEnum2.ts, 0, 0)) +>One : Symbol(e1.One, Decl(augmentedTypesEnum2.ts, 1, 9)) + +interface e1 { // error +>e1 : Symbol(e1, Decl(augmentedTypesEnum2.ts, 1, 15)) + + foo(): void; +>foo : Symbol(e1.foo, Decl(augmentedTypesEnum2.ts, 3, 14)) +} + +// interface then enum works + +// enum then class +enum e2 { One }; // error +>e2 : Symbol(e2, Decl(augmentedTypesEnum2.ts, 5, 1)) +>One : Symbol(e2.One, Decl(augmentedTypesEnum2.ts, 10, 9)) + +class e2 { // error +>e2 : Symbol(e2, Decl(augmentedTypesEnum2.ts, 10, 16)) + + foo() { +>foo : Symbol(e2.foo, Decl(augmentedTypesEnum2.ts, 11, 10)) + + return 1; + } +} + +//enum then enum - covered +//enum then import - covered diff --git a/tests/baselines/reference/augmentedTypesEnum2.types b/tests/baselines/reference/augmentedTypesEnum2.types new file mode 100644 index 00000000000..9949862b147 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesEnum2.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/augmentedTypesEnum2.ts === +// enum then interface +enum e1 { One } // error +>e1 : e1 +>One : e1 + +interface e1 { // error +>e1 : e1 + + foo(): void; +>foo : () => void +} + +// interface then enum works + +// enum then class +enum e2 { One }; // error +>e2 : e2 +>One : e2 + +class e2 { // error +>e2 : e2 + + foo() { +>foo : () => number + + return 1; +>1 : 1 + } +} + +//enum then enum - covered +//enum then import - covered diff --git a/tests/baselines/reference/augmentedTypesEnum3.symbols b/tests/baselines/reference/augmentedTypesEnum3.symbols new file mode 100644 index 00000000000..d5e6155969d --- /dev/null +++ b/tests/baselines/reference/augmentedTypesEnum3.symbols @@ -0,0 +1,41 @@ +=== tests/cases/compiler/augmentedTypesEnum3.ts === +module E { +>E : Symbol(E, Decl(augmentedTypesEnum3.ts, 0, 0), Decl(augmentedTypesEnum3.ts, 2, 1)) + + var t; +>t : Symbol(t, Decl(augmentedTypesEnum3.ts, 1, 7)) +} +enum E { } +>E : Symbol(E, Decl(augmentedTypesEnum3.ts, 0, 0), Decl(augmentedTypesEnum3.ts, 2, 1)) + +enum F { } +>F : Symbol(F, Decl(augmentedTypesEnum3.ts, 3, 10), Decl(augmentedTypesEnum3.ts, 5, 10)) + +module F { var t; } +>F : Symbol(F, Decl(augmentedTypesEnum3.ts, 3, 10), Decl(augmentedTypesEnum3.ts, 5, 10)) +>t : Symbol(t, Decl(augmentedTypesEnum3.ts, 6, 14)) + +module A { +>A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 13, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) + + var o; +>o : Symbol(o, Decl(augmentedTypesEnum3.ts, 9, 7)) +} +enum A { +>A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 13, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) + + b +>b : Symbol(A.b, Decl(augmentedTypesEnum3.ts, 11, 8)) +} +enum A { +>A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 13, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) + + c +>c : Symbol(A.c, Decl(augmentedTypesEnum3.ts, 14, 8)) +} +module A { +>A : Symbol(A, Decl(augmentedTypesEnum3.ts, 6, 19), Decl(augmentedTypesEnum3.ts, 10, 1), Decl(augmentedTypesEnum3.ts, 13, 1), Decl(augmentedTypesEnum3.ts, 16, 1)) + + var p; +>p : Symbol(p, Decl(augmentedTypesEnum3.ts, 18, 7)) +} diff --git a/tests/baselines/reference/augmentedTypesEnum3.types b/tests/baselines/reference/augmentedTypesEnum3.types new file mode 100644 index 00000000000..d3c2e933506 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesEnum3.types @@ -0,0 +1,41 @@ +=== tests/cases/compiler/augmentedTypesEnum3.ts === +module E { +>E : typeof E + + var t; +>t : any +} +enum E { } +>E : E + +enum F { } +>F : F + +module F { var t; } +>F : typeof F +>t : any + +module A { +>A : typeof A + + var o; +>o : any +} +enum A { +>A : A + + b +>b : A +} +enum A { +>A : A + + c +>c : A +} +module A { +>A : typeof A + + var p; +>p : any +} diff --git a/tests/baselines/reference/augmentedTypesFunction.symbols b/tests/baselines/reference/augmentedTypesFunction.symbols new file mode 100644 index 00000000000..8f202847cd3 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesFunction.symbols @@ -0,0 +1,75 @@ +=== tests/cases/compiler/augmentedTypesFunction.ts === +// function then var +function y1() { } // error +>y1 : Symbol(y1, Decl(augmentedTypesFunction.ts, 0, 0)) + +var y1 = 1; // error +>y1 : Symbol(y1, Decl(augmentedTypesFunction.ts, 2, 3)) + +// function then function +function y2() { } // error +>y2 : Symbol(y2, Decl(augmentedTypesFunction.ts, 2, 11), Decl(augmentedTypesFunction.ts, 5, 17)) + +function y2() { } // error +>y2 : Symbol(y2, Decl(augmentedTypesFunction.ts, 2, 11), Decl(augmentedTypesFunction.ts, 5, 17)) + +function y2a() { } // error +>y2a : Symbol(y2a, Decl(augmentedTypesFunction.ts, 6, 17)) + +var y2a = () => { } // error +>y2a : Symbol(y2a, Decl(augmentedTypesFunction.ts, 9, 3)) + +// function then class +function y3() { } // error +>y3 : Symbol(y3, Decl(augmentedTypesFunction.ts, 9, 19)) + +class y3 { } // error +>y3 : Symbol(y3, Decl(augmentedTypesFunction.ts, 12, 17)) + +function y3a() { } // error +>y3a : Symbol(y3a, Decl(augmentedTypesFunction.ts, 13, 12)) + +class y3a { public foo() { } } // error +>y3a : Symbol(y3a, Decl(augmentedTypesFunction.ts, 15, 18)) +>foo : Symbol(y3a.foo, Decl(augmentedTypesFunction.ts, 16, 11)) + +// function then enum +function y4() { } // error +>y4 : Symbol(y4, Decl(augmentedTypesFunction.ts, 16, 30)) + +enum y4 { One } // error +>y4 : Symbol(y4, Decl(augmentedTypesFunction.ts, 19, 17)) +>One : Symbol(y4.One, Decl(augmentedTypesFunction.ts, 20, 9)) + +// function then internal module +function y5() { } +>y5 : Symbol(y5, Decl(augmentedTypesFunction.ts, 20, 15), Decl(augmentedTypesFunction.ts, 23, 17)) + +module y5 { } // ok since module is not instantiated +>y5 : Symbol(y5, Decl(augmentedTypesFunction.ts, 20, 15), Decl(augmentedTypesFunction.ts, 23, 17)) + +function y5a() { } +>y5a : Symbol(y5a, Decl(augmentedTypesFunction.ts, 24, 13), Decl(augmentedTypesFunction.ts, 26, 18)) + +module y5a { var y = 2; } // should be an error +>y5a : Symbol(y5a, Decl(augmentedTypesFunction.ts, 24, 13), Decl(augmentedTypesFunction.ts, 26, 18)) +>y : Symbol(y, Decl(augmentedTypesFunction.ts, 27, 16)) + +function y5b() { } +>y5b : Symbol(y5b, Decl(augmentedTypesFunction.ts, 27, 25), Decl(augmentedTypesFunction.ts, 29, 18)) + +module y5b { export var y = 3; } // should be an error +>y5b : Symbol(y5b, Decl(augmentedTypesFunction.ts, 27, 25), Decl(augmentedTypesFunction.ts, 29, 18)) +>y : Symbol(y, Decl(augmentedTypesFunction.ts, 30, 23)) + +function y5c() { } +>y5c : Symbol(y5c, Decl(augmentedTypesFunction.ts, 30, 32), Decl(augmentedTypesFunction.ts, 32, 18)) + +module y5c { export interface I { foo(): void } } // should be an error +>y5c : Symbol(y5c, Decl(augmentedTypesFunction.ts, 30, 32), Decl(augmentedTypesFunction.ts, 32, 18)) +>I : Symbol(I, Decl(augmentedTypesFunction.ts, 33, 12)) +>foo : Symbol(I.foo, Decl(augmentedTypesFunction.ts, 33, 33)) + +// function then import, messes with other errors +//function y6() { } +//import y6 = require(''); diff --git a/tests/baselines/reference/augmentedTypesFunction.types b/tests/baselines/reference/augmentedTypesFunction.types new file mode 100644 index 00000000000..a977761c83f --- /dev/null +++ b/tests/baselines/reference/augmentedTypesFunction.types @@ -0,0 +1,79 @@ +=== tests/cases/compiler/augmentedTypesFunction.ts === +// function then var +function y1() { } // error +>y1 : () => void + +var y1 = 1; // error +>y1 : number +>1 : 1 + +// function then function +function y2() { } // error +>y2 : () => void + +function y2() { } // error +>y2 : () => void + +function y2a() { } // error +>y2a : () => void + +var y2a = () => { } // error +>y2a : () => void +>() => { } : () => void + +// function then class +function y3() { } // error +>y3 : () => void + +class y3 { } // error +>y3 : y3 + +function y3a() { } // error +>y3a : () => void + +class y3a { public foo() { } } // error +>y3a : y3a +>foo : () => void + +// function then enum +function y4() { } // error +>y4 : () => void + +enum y4 { One } // error +>y4 : y4 +>One : y4 + +// function then internal module +function y5() { } +>y5 : () => void + +module y5 { } // ok since module is not instantiated +>y5 : () => void + +function y5a() { } +>y5a : typeof y5a + +module y5a { var y = 2; } // should be an error +>y5a : typeof y5a +>y : number +>2 : 2 + +function y5b() { } +>y5b : typeof y5b + +module y5b { export var y = 3; } // should be an error +>y5b : typeof y5b +>y : number +>3 : 3 + +function y5c() { } +>y5c : () => void + +module y5c { export interface I { foo(): void } } // should be an error +>y5c : () => void +>I : I +>foo : () => void + +// function then import, messes with other errors +//function y6() { } +//import y6 = require(''); diff --git a/tests/baselines/reference/augmentedTypesInterface.symbols b/tests/baselines/reference/augmentedTypesInterface.symbols new file mode 100644 index 00000000000..602823e27c9 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesInterface.symbols @@ -0,0 +1,55 @@ +=== tests/cases/compiler/augmentedTypesInterface.ts === +// interface then interface + +interface i { +>i : Symbol(i, Decl(augmentedTypesInterface.ts, 0, 0), Decl(augmentedTypesInterface.ts, 4, 1)) + + foo(): void; +>foo : Symbol(i.foo, Decl(augmentedTypesInterface.ts, 2, 13)) +} + +interface i { +>i : Symbol(i, Decl(augmentedTypesInterface.ts, 0, 0), Decl(augmentedTypesInterface.ts, 4, 1)) + + bar(): number; +>bar : Symbol(i.bar, Decl(augmentedTypesInterface.ts, 6, 13)) +} + +// interface then class +interface i2 { +>i2 : Symbol(i2, Decl(augmentedTypesInterface.ts, 8, 1), Decl(augmentedTypesInterface.ts, 13, 1)) + + foo(): void; +>foo : Symbol(i2.foo, Decl(augmentedTypesInterface.ts, 11, 14)) +} + +class i2 { +>i2 : Symbol(i2, Decl(augmentedTypesInterface.ts, 8, 1), Decl(augmentedTypesInterface.ts, 13, 1)) + + bar() { +>bar : Symbol(i2.bar, Decl(augmentedTypesInterface.ts, 15, 10)) + + return 1; + } +} + +// interface then enum +interface i3 { // error +>i3 : Symbol(i3, Decl(augmentedTypesInterface.ts, 19, 1)) + + foo(): void; +>foo : Symbol(i3.foo, Decl(augmentedTypesInterface.ts, 22, 14)) +} +enum i3 { One }; // error +>i3 : Symbol(i3, Decl(augmentedTypesInterface.ts, 24, 1)) +>One : Symbol(i3.One, Decl(augmentedTypesInterface.ts, 25, 9)) + +// interface then import +interface i4 { +>i4 : Symbol(i4, Decl(augmentedTypesInterface.ts, 25, 16)) + + foo(): void; +>foo : Symbol(i4.foo, Decl(augmentedTypesInterface.ts, 28, 14)) +} + +//import i4 = require(''); // error diff --git a/tests/baselines/reference/augmentedTypesInterface.types b/tests/baselines/reference/augmentedTypesInterface.types new file mode 100644 index 00000000000..412d4795131 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesInterface.types @@ -0,0 +1,56 @@ +=== tests/cases/compiler/augmentedTypesInterface.ts === +// interface then interface + +interface i { +>i : i + + foo(): void; +>foo : () => void +} + +interface i { +>i : i + + bar(): number; +>bar : () => number +} + +// interface then class +interface i2 { +>i2 : i2 + + foo(): void; +>foo : () => void +} + +class i2 { +>i2 : i2 + + bar() { +>bar : () => number + + return 1; +>1 : 1 + } +} + +// interface then enum +interface i3 { // error +>i3 : i3 + + foo(): void; +>foo : () => void +} +enum i3 { One }; // error +>i3 : i3 +>One : i3 + +// interface then import +interface i4 { +>i4 : i4 + + foo(): void; +>foo : () => void +} + +//import i4 = require(''); // error diff --git a/tests/baselines/reference/augmentedTypesModules.symbols b/tests/baselines/reference/augmentedTypesModules.symbols new file mode 100644 index 00000000000..70ab734c9a6 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesModules.symbols @@ -0,0 +1,224 @@ +=== tests/cases/compiler/augmentedTypesModules.ts === +// module then var +module m1 { } +>m1 : Symbol(m1, Decl(augmentedTypesModules.ts, 0, 0), Decl(augmentedTypesModules.ts, 2, 3)) + +var m1 = 1; // Should be allowed +>m1 : Symbol(m1, Decl(augmentedTypesModules.ts, 0, 0), Decl(augmentedTypesModules.ts, 2, 3)) + +module m1a { var y = 2; } // error +>m1a : Symbol(m1a, Decl(augmentedTypesModules.ts, 2, 11)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 4, 16)) + +var m1a = 1; // error +>m1a : Symbol(m1a, Decl(augmentedTypesModules.ts, 5, 3)) + +module m1b { export var y = 2; } // error +>m1b : Symbol(m1b, Decl(augmentedTypesModules.ts, 5, 12)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 7, 23)) + +var m1b = 1; // error +>m1b : Symbol(m1b, Decl(augmentedTypesModules.ts, 8, 3)) + +module m1c { +>m1c : Symbol(m1c, Decl(augmentedTypesModules.ts, 8, 12), Decl(augmentedTypesModules.ts, 13, 3)) + + export interface I { foo(): void; } +>I : Symbol(I, Decl(augmentedTypesModules.ts, 10, 12)) +>foo : Symbol(I.foo, Decl(augmentedTypesModules.ts, 11, 24)) +} +var m1c = 1; // Should be allowed +>m1c : Symbol(m1c, Decl(augmentedTypesModules.ts, 8, 12), Decl(augmentedTypesModules.ts, 13, 3)) + +module m1d { // error +>m1d : Symbol(m1d, Decl(augmentedTypesModules.ts, 13, 12)) + + export class I { foo() { } } +>I : Symbol(I, Decl(augmentedTypesModules.ts, 15, 12)) +>foo : Symbol(I.foo, Decl(augmentedTypesModules.ts, 16, 20)) +} +var m1d = 1; // error +>m1d : Symbol(m1d, Decl(augmentedTypesModules.ts, 18, 3)) + +// module then function +module m2 { } +>m2 : Symbol(m2, Decl(augmentedTypesModules.ts, 18, 12), Decl(augmentedTypesModules.ts, 21, 13)) + +function m2() { }; // ok since the module is not instantiated +>m2 : Symbol(m2, Decl(augmentedTypesModules.ts, 18, 12), Decl(augmentedTypesModules.ts, 21, 13)) + +module m2a { var y = 2; } +>m2a : Symbol(m2a, Decl(augmentedTypesModules.ts, 22, 18), Decl(augmentedTypesModules.ts, 24, 25)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 24, 16)) + +function m2a() { }; // error since the module is instantiated +>m2a : Symbol(m2a, Decl(augmentedTypesModules.ts, 22, 18), Decl(augmentedTypesModules.ts, 24, 25)) + +module m2b { export var y = 2; } +>m2b : Symbol(m2b, Decl(augmentedTypesModules.ts, 25, 19), Decl(augmentedTypesModules.ts, 27, 32)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 27, 23)) + +function m2b() { }; // error since the module is instantiated +>m2b : Symbol(m2b, Decl(augmentedTypesModules.ts, 25, 19), Decl(augmentedTypesModules.ts, 27, 32)) + +// should be errors to have function first +function m2c() { }; +>m2c : Symbol(m2c, Decl(augmentedTypesModules.ts, 28, 19), Decl(augmentedTypesModules.ts, 31, 19)) + +module m2c { export var y = 2; } +>m2c : Symbol(m2c, Decl(augmentedTypesModules.ts, 28, 19), Decl(augmentedTypesModules.ts, 31, 19)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 32, 23)) + +module m2d { } +>m2d : Symbol(m2d, Decl(augmentedTypesModules.ts, 32, 32), Decl(augmentedTypesModules.ts, 34, 14)) + +declare function m2d(): void; +>m2d : Symbol(m2d, Decl(augmentedTypesModules.ts, 32, 32), Decl(augmentedTypesModules.ts, 34, 14)) + +declare function m2e(): void; +>m2e : Symbol(m2e, Decl(augmentedTypesModules.ts, 35, 29), Decl(augmentedTypesModules.ts, 37, 29)) + +module m2e { } +>m2e : Symbol(m2e, Decl(augmentedTypesModules.ts, 35, 29), Decl(augmentedTypesModules.ts, 37, 29)) + +function m2f() { }; +>m2f : Symbol(m2f, Decl(augmentedTypesModules.ts, 38, 14), Decl(augmentedTypesModules.ts, 40, 19)) + +module m2f { export interface I { foo(): void } } +>m2f : Symbol(m2f, Decl(augmentedTypesModules.ts, 38, 14), Decl(augmentedTypesModules.ts, 40, 19)) +>I : Symbol(I, Decl(augmentedTypesModules.ts, 41, 12)) +>foo : Symbol(I.foo, Decl(augmentedTypesModules.ts, 41, 33)) + +function m2g() { }; +>m2g : Symbol(m2g, Decl(augmentedTypesModules.ts, 41, 49), Decl(augmentedTypesModules.ts, 43, 19)) + +module m2g { export class C { foo() { } } } +>m2g : Symbol(m2g, Decl(augmentedTypesModules.ts, 41, 49), Decl(augmentedTypesModules.ts, 43, 19)) +>C : Symbol(C, Decl(augmentedTypesModules.ts, 44, 12)) +>foo : Symbol(C.foo, Decl(augmentedTypesModules.ts, 44, 29)) + +// module then class +module m3 { } +>m3 : Symbol(m3, Decl(augmentedTypesModules.ts, 44, 43), Decl(augmentedTypesModules.ts, 47, 13)) + +class m3 { } // ok since the module is not instantiated +>m3 : Symbol(m3, Decl(augmentedTypesModules.ts, 44, 43), Decl(augmentedTypesModules.ts, 47, 13)) + +module m3a { var y = 2; } +>m3a : Symbol(m3a, Decl(augmentedTypesModules.ts, 48, 12), Decl(augmentedTypesModules.ts, 50, 25)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 50, 16)) + +class m3a { foo() { } } // error, class isn't ambient or declared before the module +>m3a : Symbol(m3a, Decl(augmentedTypesModules.ts, 48, 12), Decl(augmentedTypesModules.ts, 50, 25)) +>foo : Symbol(m3a.foo, Decl(augmentedTypesModules.ts, 51, 11)) + +class m3b { foo() { } } +>m3b : Symbol(m3b, Decl(augmentedTypesModules.ts, 51, 23), Decl(augmentedTypesModules.ts, 53, 23)) +>foo : Symbol(m3b.foo, Decl(augmentedTypesModules.ts, 53, 11)) + +module m3b { var y = 2; } +>m3b : Symbol(m3b, Decl(augmentedTypesModules.ts, 51, 23), Decl(augmentedTypesModules.ts, 53, 23)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 54, 16)) + +class m3c { foo() { } } +>m3c : Symbol(m3c, Decl(augmentedTypesModules.ts, 54, 25), Decl(augmentedTypesModules.ts, 56, 23)) +>foo : Symbol(m3c.foo, Decl(augmentedTypesModules.ts, 56, 11)) + +module m3c { export var y = 2; } +>m3c : Symbol(m3c, Decl(augmentedTypesModules.ts, 54, 25), Decl(augmentedTypesModules.ts, 56, 23)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 57, 23)) + +declare class m3d { foo(): void } +>m3d : Symbol(m3d, Decl(augmentedTypesModules.ts, 57, 32), Decl(augmentedTypesModules.ts, 59, 33)) +>foo : Symbol(m3d.foo, Decl(augmentedTypesModules.ts, 59, 19)) + +module m3d { export var y = 2; } +>m3d : Symbol(m3d, Decl(augmentedTypesModules.ts, 57, 32), Decl(augmentedTypesModules.ts, 59, 33)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 60, 23)) + +module m3e { export var y = 2; } +>m3e : Symbol(m3e, Decl(augmentedTypesModules.ts, 60, 32), Decl(augmentedTypesModules.ts, 62, 32)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 62, 23)) + +declare class m3e { foo(): void } +>m3e : Symbol(m3e, Decl(augmentedTypesModules.ts, 60, 32), Decl(augmentedTypesModules.ts, 62, 32)) +>foo : Symbol(m3e.foo, Decl(augmentedTypesModules.ts, 63, 19)) + +declare class m3f { foo(): void } +>m3f : Symbol(m3f, Decl(augmentedTypesModules.ts, 63, 33), Decl(augmentedTypesModules.ts, 65, 33)) +>foo : Symbol(m3f.foo, Decl(augmentedTypesModules.ts, 65, 19)) + +module m3f { export interface I { foo(): void } } +>m3f : Symbol(m3f, Decl(augmentedTypesModules.ts, 63, 33), Decl(augmentedTypesModules.ts, 65, 33)) +>I : Symbol(I, Decl(augmentedTypesModules.ts, 66, 12)) +>foo : Symbol(I.foo, Decl(augmentedTypesModules.ts, 66, 33)) + +declare class m3g { foo(): void } +>m3g : Symbol(m3g, Decl(augmentedTypesModules.ts, 66, 49), Decl(augmentedTypesModules.ts, 68, 33)) +>foo : Symbol(m3g.foo, Decl(augmentedTypesModules.ts, 68, 19)) + +module m3g { export class C { foo() { } } } +>m3g : Symbol(m3g, Decl(augmentedTypesModules.ts, 66, 49), Decl(augmentedTypesModules.ts, 68, 33)) +>C : Symbol(C, Decl(augmentedTypesModules.ts, 69, 12)) +>foo : Symbol(C.foo, Decl(augmentedTypesModules.ts, 69, 29)) + +// module then enum +// should be errors +module m4 { } +>m4 : Symbol(m4, Decl(augmentedTypesModules.ts, 69, 43), Decl(augmentedTypesModules.ts, 73, 13)) + +enum m4 { } +>m4 : Symbol(m4, Decl(augmentedTypesModules.ts, 69, 43), Decl(augmentedTypesModules.ts, 73, 13)) + +module m4a { var y = 2; } +>m4a : Symbol(m4a, Decl(augmentedTypesModules.ts, 74, 11), Decl(augmentedTypesModules.ts, 76, 25)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 76, 16)) + +enum m4a { One } +>m4a : Symbol(m4a, Decl(augmentedTypesModules.ts, 74, 11), Decl(augmentedTypesModules.ts, 76, 25)) +>One : Symbol(m4a.One, Decl(augmentedTypesModules.ts, 77, 10)) + +module m4b { export var y = 2; } +>m4b : Symbol(m4b, Decl(augmentedTypesModules.ts, 77, 16), Decl(augmentedTypesModules.ts, 79, 32)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 79, 23)) + +enum m4b { One } +>m4b : Symbol(m4b, Decl(augmentedTypesModules.ts, 77, 16), Decl(augmentedTypesModules.ts, 79, 32)) +>One : Symbol(m4b.One, Decl(augmentedTypesModules.ts, 80, 10)) + +module m4c { interface I { foo(): void } } +>m4c : Symbol(m4c, Decl(augmentedTypesModules.ts, 80, 16), Decl(augmentedTypesModules.ts, 82, 42)) +>I : Symbol(I, Decl(augmentedTypesModules.ts, 82, 12)) +>foo : Symbol(I.foo, Decl(augmentedTypesModules.ts, 82, 26)) + +enum m4c { One } +>m4c : Symbol(m4c, Decl(augmentedTypesModules.ts, 80, 16), Decl(augmentedTypesModules.ts, 82, 42)) +>One : Symbol(m4c.One, Decl(augmentedTypesModules.ts, 83, 10)) + +module m4d { class C { foo() { } } } +>m4d : Symbol(m4d, Decl(augmentedTypesModules.ts, 83, 16), Decl(augmentedTypesModules.ts, 85, 36)) +>C : Symbol(C, Decl(augmentedTypesModules.ts, 85, 12)) +>foo : Symbol(C.foo, Decl(augmentedTypesModules.ts, 85, 22)) + +enum m4d { One } +>m4d : Symbol(m4d, Decl(augmentedTypesModules.ts, 83, 16), Decl(augmentedTypesModules.ts, 85, 36)) +>One : Symbol(m4d.One, Decl(augmentedTypesModules.ts, 86, 10)) + +//// module then module + +module m5 { export var y = 2; } +>m5 : Symbol(m5, Decl(augmentedTypesModules.ts, 86, 16), Decl(augmentedTypesModules.ts, 90, 31)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 90, 22)) + +module m5 { export interface I { foo(): void } } // should already be reasonably well covered +>m5 : Symbol(m5, Decl(augmentedTypesModules.ts, 86, 16), Decl(augmentedTypesModules.ts, 90, 31)) +>I : Symbol(I, Decl(augmentedTypesModules.ts, 91, 11)) +>foo : Symbol(I.foo, Decl(augmentedTypesModules.ts, 91, 32)) + +// module then import +module m6 { export var y = 2; } +>m6 : Symbol(m6, Decl(augmentedTypesModules.ts, 91, 48)) +>y : Symbol(y, Decl(augmentedTypesModules.ts, 94, 22)) + +//import m6 = require(''); + diff --git a/tests/baselines/reference/augmentedTypesModules.types b/tests/baselines/reference/augmentedTypesModules.types new file mode 100644 index 00000000000..4dc23acd66f --- /dev/null +++ b/tests/baselines/reference/augmentedTypesModules.types @@ -0,0 +1,243 @@ +=== tests/cases/compiler/augmentedTypesModules.ts === +// module then var +module m1 { } +>m1 : number + +var m1 = 1; // Should be allowed +>m1 : number +>1 : 1 + +module m1a { var y = 2; } // error +>m1a : typeof m1a +>y : number +>2 : 2 + +var m1a = 1; // error +>m1a : number +>1 : 1 + +module m1b { export var y = 2; } // error +>m1b : typeof m1b +>y : number +>2 : 2 + +var m1b = 1; // error +>m1b : number +>1 : 1 + +module m1c { +>m1c : number + + export interface I { foo(): void; } +>I : I +>foo : () => void +} +var m1c = 1; // Should be allowed +>m1c : number +>1 : 1 + +module m1d { // error +>m1d : typeof m1d + + export class I { foo() { } } +>I : I +>foo : () => void +} +var m1d = 1; // error +>m1d : number +>1 : 1 + +// module then function +module m2 { } +>m2 : () => void + +function m2() { }; // ok since the module is not instantiated +>m2 : () => void + +module m2a { var y = 2; } +>m2a : typeof m2a +>y : number +>2 : 2 + +function m2a() { }; // error since the module is instantiated +>m2a : typeof m2a + +module m2b { export var y = 2; } +>m2b : typeof m2b +>y : number +>2 : 2 + +function m2b() { }; // error since the module is instantiated +>m2b : typeof m2b + +// should be errors to have function first +function m2c() { }; +>m2c : typeof m2c + +module m2c { export var y = 2; } +>m2c : typeof m2c +>y : number +>2 : 2 + +module m2d { } +>m2d : () => void + +declare function m2d(): void; +>m2d : () => void + +declare function m2e(): void; +>m2e : () => void + +module m2e { } +>m2e : () => void + +function m2f() { }; +>m2f : () => void + +module m2f { export interface I { foo(): void } } +>m2f : () => void +>I : I +>foo : () => void + +function m2g() { }; +>m2g : typeof m2g + +module m2g { export class C { foo() { } } } +>m2g : typeof m2g +>C : C +>foo : () => void + +// module then class +module m3 { } +>m3 : typeof m3 + +class m3 { } // ok since the module is not instantiated +>m3 : m3 + +module m3a { var y = 2; } +>m3a : typeof m3a +>y : number +>2 : 2 + +class m3a { foo() { } } // error, class isn't ambient or declared before the module +>m3a : m3a +>foo : () => void + +class m3b { foo() { } } +>m3b : m3b +>foo : () => void + +module m3b { var y = 2; } +>m3b : typeof m3b +>y : number +>2 : 2 + +class m3c { foo() { } } +>m3c : m3c +>foo : () => void + +module m3c { export var y = 2; } +>m3c : typeof m3c +>y : number +>2 : 2 + +declare class m3d { foo(): void } +>m3d : m3d +>foo : () => void + +module m3d { export var y = 2; } +>m3d : typeof m3d +>y : number +>2 : 2 + +module m3e { export var y = 2; } +>m3e : typeof m3e +>y : number +>2 : 2 + +declare class m3e { foo(): void } +>m3e : m3e +>foo : () => void + +declare class m3f { foo(): void } +>m3f : m3f +>foo : () => void + +module m3f { export interface I { foo(): void } } +>m3f : typeof m3f +>I : I +>foo : () => void + +declare class m3g { foo(): void } +>m3g : m3g +>foo : () => void + +module m3g { export class C { foo() { } } } +>m3g : typeof m3g +>C : C +>foo : () => void + +// module then enum +// should be errors +module m4 { } +>m4 : typeof m4 + +enum m4 { } +>m4 : m4 + +module m4a { var y = 2; } +>m4a : typeof m4a +>y : number +>2 : 2 + +enum m4a { One } +>m4a : m4a +>One : m4a + +module m4b { export var y = 2; } +>m4b : typeof m4b +>y : number +>2 : 2 + +enum m4b { One } +>m4b : m4b +>One : m4b + +module m4c { interface I { foo(): void } } +>m4c : typeof m4c +>I : I +>foo : () => void + +enum m4c { One } +>m4c : m4c +>One : m4c + +module m4d { class C { foo() { } } } +>m4d : typeof m4d +>C : C +>foo : () => void + +enum m4d { One } +>m4d : m4d +>One : m4d + +//// module then module + +module m5 { export var y = 2; } +>m5 : typeof m5 +>y : number +>2 : 2 + +module m5 { export interface I { foo(): void } } // should already be reasonably well covered +>m5 : typeof m5 +>I : I +>foo : () => void + +// module then import +module m6 { export var y = 2; } +>m6 : typeof m6 +>y : number +>2 : 2 + +//import m6 = require(''); + diff --git a/tests/baselines/reference/augmentedTypesModules2.symbols b/tests/baselines/reference/augmentedTypesModules2.symbols new file mode 100644 index 00000000000..79d6bff4d50 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesModules2.symbols @@ -0,0 +1,64 @@ +=== tests/cases/compiler/augmentedTypesModules2.ts === +// module then function +module m2 { } +>m2 : Symbol(m2, Decl(augmentedTypesModules2.ts, 0, 0), Decl(augmentedTypesModules2.ts, 1, 13)) + +function m2() { }; // ok since the module is not instantiated +>m2 : Symbol(m2, Decl(augmentedTypesModules2.ts, 0, 0), Decl(augmentedTypesModules2.ts, 1, 13)) + +module m2a { var y = 2; } +>m2a : Symbol(m2a, Decl(augmentedTypesModules2.ts, 2, 18), Decl(augmentedTypesModules2.ts, 4, 25)) +>y : Symbol(y, Decl(augmentedTypesModules2.ts, 4, 16)) + +function m2a() { }; // error since the module is instantiated +>m2a : Symbol(m2a, Decl(augmentedTypesModules2.ts, 2, 18), Decl(augmentedTypesModules2.ts, 4, 25)) + +module m2b { export var y = 2; } +>m2b : Symbol(m2b, Decl(augmentedTypesModules2.ts, 5, 19), Decl(augmentedTypesModules2.ts, 7, 32)) +>y : Symbol(y, Decl(augmentedTypesModules2.ts, 7, 23)) + +function m2b() { }; // error since the module is instantiated +>m2b : Symbol(m2b, Decl(augmentedTypesModules2.ts, 5, 19), Decl(augmentedTypesModules2.ts, 7, 32)) + +function m2c() { }; +>m2c : Symbol(m2c, Decl(augmentedTypesModules2.ts, 8, 19), Decl(augmentedTypesModules2.ts, 10, 19)) + +module m2c { export var y = 2; } +>m2c : Symbol(m2c, Decl(augmentedTypesModules2.ts, 8, 19), Decl(augmentedTypesModules2.ts, 10, 19)) +>y : Symbol(y, Decl(augmentedTypesModules2.ts, 11, 23)) + +module m2cc { export var y = 2; } +>m2cc : Symbol(m2cc, Decl(augmentedTypesModules2.ts, 11, 32), Decl(augmentedTypesModules2.ts, 13, 33)) +>y : Symbol(y, Decl(augmentedTypesModules2.ts, 13, 24)) + +function m2cc() { }; // error to have module first +>m2cc : Symbol(m2cc, Decl(augmentedTypesModules2.ts, 11, 32), Decl(augmentedTypesModules2.ts, 13, 33)) + +module m2d { } +>m2d : Symbol(m2d, Decl(augmentedTypesModules2.ts, 14, 20), Decl(augmentedTypesModules2.ts, 16, 14)) + +declare function m2d(): void; +>m2d : Symbol(m2d, Decl(augmentedTypesModules2.ts, 14, 20), Decl(augmentedTypesModules2.ts, 16, 14)) + +declare function m2e(): void; +>m2e : Symbol(m2e, Decl(augmentedTypesModules2.ts, 17, 29), Decl(augmentedTypesModules2.ts, 19, 29)) + +module m2e { } +>m2e : Symbol(m2e, Decl(augmentedTypesModules2.ts, 17, 29), Decl(augmentedTypesModules2.ts, 19, 29)) + +function m2f() { }; +>m2f : Symbol(m2f, Decl(augmentedTypesModules2.ts, 20, 14), Decl(augmentedTypesModules2.ts, 22, 19)) + +module m2f { export interface I { foo(): void } } +>m2f : Symbol(m2f, Decl(augmentedTypesModules2.ts, 20, 14), Decl(augmentedTypesModules2.ts, 22, 19)) +>I : Symbol(I, Decl(augmentedTypesModules2.ts, 23, 12)) +>foo : Symbol(I.foo, Decl(augmentedTypesModules2.ts, 23, 33)) + +function m2g() { }; +>m2g : Symbol(m2g, Decl(augmentedTypesModules2.ts, 23, 49), Decl(augmentedTypesModules2.ts, 25, 19)) + +module m2g { export class C { foo() { } } } +>m2g : Symbol(m2g, Decl(augmentedTypesModules2.ts, 23, 49), Decl(augmentedTypesModules2.ts, 25, 19)) +>C : Symbol(C, Decl(augmentedTypesModules2.ts, 26, 12)) +>foo : Symbol(C.foo, Decl(augmentedTypesModules2.ts, 26, 29)) + diff --git a/tests/baselines/reference/augmentedTypesModules2.types b/tests/baselines/reference/augmentedTypesModules2.types new file mode 100644 index 00000000000..e2c9f7a3cb5 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesModules2.types @@ -0,0 +1,68 @@ +=== tests/cases/compiler/augmentedTypesModules2.ts === +// module then function +module m2 { } +>m2 : () => void + +function m2() { }; // ok since the module is not instantiated +>m2 : () => void + +module m2a { var y = 2; } +>m2a : typeof m2a +>y : number +>2 : 2 + +function m2a() { }; // error since the module is instantiated +>m2a : typeof m2a + +module m2b { export var y = 2; } +>m2b : typeof m2b +>y : number +>2 : 2 + +function m2b() { }; // error since the module is instantiated +>m2b : typeof m2b + +function m2c() { }; +>m2c : typeof m2c + +module m2c { export var y = 2; } +>m2c : typeof m2c +>y : number +>2 : 2 + +module m2cc { export var y = 2; } +>m2cc : typeof m2cc +>y : number +>2 : 2 + +function m2cc() { }; // error to have module first +>m2cc : typeof m2cc + +module m2d { } +>m2d : () => void + +declare function m2d(): void; +>m2d : () => void + +declare function m2e(): void; +>m2e : () => void + +module m2e { } +>m2e : () => void + +function m2f() { }; +>m2f : () => void + +module m2f { export interface I { foo(): void } } +>m2f : () => void +>I : I +>foo : () => void + +function m2g() { }; +>m2g : typeof m2g + +module m2g { export class C { foo() { } } } +>m2g : typeof m2g +>C : C +>foo : () => void + diff --git a/tests/baselines/reference/augmentedTypesModules3.symbols b/tests/baselines/reference/augmentedTypesModules3.symbols new file mode 100644 index 00000000000..e5519b21a98 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesModules3.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/augmentedTypesModules3.ts === +//// module then class +module m3 { } +>m3 : Symbol(m3, Decl(augmentedTypesModules3.ts, 0, 0), Decl(augmentedTypesModules3.ts, 1, 13)) + +class m3 { } // ok since the module is not instantiated +>m3 : Symbol(m3, Decl(augmentedTypesModules3.ts, 0, 0), Decl(augmentedTypesModules3.ts, 1, 13)) + +module m3a { var y = 2; } +>m3a : Symbol(m3a, Decl(augmentedTypesModules3.ts, 2, 12), Decl(augmentedTypesModules3.ts, 4, 25)) +>y : Symbol(y, Decl(augmentedTypesModules3.ts, 4, 16)) + +class m3a { foo() { } } // error, class isn't ambient or declared before the module +>m3a : Symbol(m3a, Decl(augmentedTypesModules3.ts, 2, 12), Decl(augmentedTypesModules3.ts, 4, 25)) +>foo : Symbol(m3a.foo, Decl(augmentedTypesModules3.ts, 5, 11)) + diff --git a/tests/baselines/reference/augmentedTypesModules3.types b/tests/baselines/reference/augmentedTypesModules3.types new file mode 100644 index 00000000000..bf8f275a777 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesModules3.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/augmentedTypesModules3.ts === +//// module then class +module m3 { } +>m3 : typeof m3 + +class m3 { } // ok since the module is not instantiated +>m3 : m3 + +module m3a { var y = 2; } +>m3a : typeof m3a +>y : number +>2 : 2 + +class m3a { foo() { } } // error, class isn't ambient or declared before the module +>m3a : m3a +>foo : () => void + diff --git a/tests/baselines/reference/augmentedTypesVar.symbols b/tests/baselines/reference/augmentedTypesVar.symbols new file mode 100644 index 00000000000..1b9e9be1231 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesVar.symbols @@ -0,0 +1,68 @@ +=== tests/cases/compiler/augmentedTypesVar.ts === +// var then var +var x1 = 1; +>x1 : Symbol(x1, Decl(augmentedTypesVar.ts, 1, 3), Decl(augmentedTypesVar.ts, 2, 3)) + +var x1 = 2; +>x1 : Symbol(x1, Decl(augmentedTypesVar.ts, 1, 3), Decl(augmentedTypesVar.ts, 2, 3)) + +// var then function +var x2 = 1; // error +>x2 : Symbol(x2, Decl(augmentedTypesVar.ts, 5, 3)) + +function x2() { } // error +>x2 : Symbol(x2, Decl(augmentedTypesVar.ts, 5, 11)) + +var x3 = 1; +>x3 : Symbol(x3, Decl(augmentedTypesVar.ts, 8, 3), Decl(augmentedTypesVar.ts, 9, 3)) + +var x3 = () => { } // error +>x3 : Symbol(x3, Decl(augmentedTypesVar.ts, 8, 3), Decl(augmentedTypesVar.ts, 9, 3)) + +// var then class +var x4 = 1; // error +>x4 : Symbol(x4, Decl(augmentedTypesVar.ts, 12, 3)) + +class x4 { } // error +>x4 : Symbol(x4, Decl(augmentedTypesVar.ts, 12, 11)) + +var x4a = 1; // error +>x4a : Symbol(x4a, Decl(augmentedTypesVar.ts, 15, 3)) + +class x4a { public foo() { } } // error +>x4a : Symbol(x4a, Decl(augmentedTypesVar.ts, 15, 12)) +>foo : Symbol(x4a.foo, Decl(augmentedTypesVar.ts, 16, 11)) + +// var then enum +var x5 = 1; +>x5 : Symbol(x5, Decl(augmentedTypesVar.ts, 19, 3)) + +enum x5 { One } // error +>x5 : Symbol(x5, Decl(augmentedTypesVar.ts, 19, 11)) +>One : Symbol(x5.One, Decl(augmentedTypesVar.ts, 20, 9)) + +// var then module +var x6 = 1; +>x6 : Symbol(x6, Decl(augmentedTypesVar.ts, 23, 3), Decl(augmentedTypesVar.ts, 23, 11)) + +module x6 { } // ok since non-instantiated +>x6 : Symbol(x6, Decl(augmentedTypesVar.ts, 23, 3), Decl(augmentedTypesVar.ts, 23, 11)) + +var x6a = 1; // error +>x6a : Symbol(x6a, Decl(augmentedTypesVar.ts, 26, 3)) + +module x6a { var y = 2; } // error since instantiated +>x6a : Symbol(x6a, Decl(augmentedTypesVar.ts, 26, 12)) +>y : Symbol(y, Decl(augmentedTypesVar.ts, 27, 16)) + +var x6b = 1; // error +>x6b : Symbol(x6b, Decl(augmentedTypesVar.ts, 29, 3)) + +module x6b { export var y = 2; } // error +>x6b : Symbol(x6b, Decl(augmentedTypesVar.ts, 29, 12)) +>y : Symbol(y, Decl(augmentedTypesVar.ts, 30, 23)) + +// var then import, messes with other error reporting +//var x7 = 1; +//import x7 = require(''); + diff --git a/tests/baselines/reference/augmentedTypesVar.types b/tests/baselines/reference/augmentedTypesVar.types new file mode 100644 index 00000000000..f666a3ca5a4 --- /dev/null +++ b/tests/baselines/reference/augmentedTypesVar.types @@ -0,0 +1,81 @@ +=== tests/cases/compiler/augmentedTypesVar.ts === +// var then var +var x1 = 1; +>x1 : number +>1 : 1 + +var x1 = 2; +>x1 : number +>2 : 2 + +// var then function +var x2 = 1; // error +>x2 : number +>1 : 1 + +function x2() { } // error +>x2 : () => void + +var x3 = 1; +>x3 : number +>1 : 1 + +var x3 = () => { } // error +>x3 : number +>() => { } : () => void + +// var then class +var x4 = 1; // error +>x4 : number +>1 : 1 + +class x4 { } // error +>x4 : x4 + +var x4a = 1; // error +>x4a : number +>1 : 1 + +class x4a { public foo() { } } // error +>x4a : x4a +>foo : () => void + +// var then enum +var x5 = 1; +>x5 : number +>1 : 1 + +enum x5 { One } // error +>x5 : x5 +>One : x5 + +// var then module +var x6 = 1; +>x6 : number +>1 : 1 + +module x6 { } // ok since non-instantiated +>x6 : number + +var x6a = 1; // error +>x6a : number +>1 : 1 + +module x6a { var y = 2; } // error since instantiated +>x6a : typeof x6a +>y : number +>2 : 2 + +var x6b = 1; // error +>x6b : number +>1 : 1 + +module x6b { export var y = 2; } // error +>x6b : typeof x6b +>y : number +>2 : 2 + +// var then import, messes with other error reporting +//var x7 = 1; +//import x7 = require(''); + diff --git a/tests/baselines/reference/autoLift2.symbols b/tests/baselines/reference/autoLift2.symbols new file mode 100644 index 00000000000..bcb45998d46 --- /dev/null +++ b/tests/baselines/reference/autoLift2.symbols @@ -0,0 +1,52 @@ +=== tests/cases/compiler/autoLift2.ts === +class A +>A : Symbol(A, Decl(autoLift2.ts, 0, 0)) + +{ + constructor() { + this.foo: any; +>this : Symbol(A, Decl(autoLift2.ts, 0, 0)) + + this.bar: any; +>this : Symbol(A, Decl(autoLift2.ts, 0, 0)) + } + + + baz() { +>baz : Symbol(A.baz, Decl(autoLift2.ts, 6, 5)) + + this.foo = "foo"; +>this : Symbol(A, Decl(autoLift2.ts, 0, 0)) + + this.bar = "bar"; +>this : Symbol(A, Decl(autoLift2.ts, 0, 0)) + + [1, 2].forEach((p) => this.foo); +>[1, 2].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>p : Symbol(p, Decl(autoLift2.ts, 15, 21)) +>this : Symbol(A, Decl(autoLift2.ts, 0, 0)) + + [1, 2].forEach((p) => this.bar); +>[1, 2].forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>p : Symbol(p, Decl(autoLift2.ts, 17, 21)) +>this : Symbol(A, Decl(autoLift2.ts, 0, 0)) + + } + +} + + + +var a = new A(); +>a : Symbol(a, Decl(autoLift2.ts, 25, 3)) +>A : Symbol(A, Decl(autoLift2.ts, 0, 0)) + +a.baz(); +>a.baz : Symbol(A.baz, Decl(autoLift2.ts, 6, 5)) +>a : Symbol(a, Decl(autoLift2.ts, 25, 3)) +>baz : Symbol(A.baz, Decl(autoLift2.ts, 6, 5)) + + + diff --git a/tests/baselines/reference/autoLift2.types b/tests/baselines/reference/autoLift2.types new file mode 100644 index 00000000000..fe2f34ad8a2 --- /dev/null +++ b/tests/baselines/reference/autoLift2.types @@ -0,0 +1,82 @@ +=== tests/cases/compiler/autoLift2.ts === +class A +>A : A + +{ + constructor() { + this.foo: any; +>this.foo : any +>this : this +>foo : any +>any : any + + this.bar: any; +>this.bar : any +>this : this +>bar : any +>any : any + } + + + baz() { +>baz : () => void + + this.foo = "foo"; +>this.foo = "foo" : "foo" +>this.foo : any +>this : this +>foo : any +>"foo" : "foo" + + this.bar = "bar"; +>this.bar = "bar" : "bar" +>this.bar : any +>this : this +>bar : any +>"bar" : "bar" + + [1, 2].forEach((p) => this.foo); +>[1, 2].forEach((p) => this.foo) : void +>[1, 2].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>[1, 2] : number[] +>1 : 1 +>2 : 2 +>forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>(p) => this.foo : (p: number) => any +>p : number +>this.foo : any +>this : this +>foo : any + + [1, 2].forEach((p) => this.bar); +>[1, 2].forEach((p) => this.bar) : void +>[1, 2].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>[1, 2] : number[] +>1 : 1 +>2 : 2 +>forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void +>(p) => this.bar : (p: number) => any +>p : number +>this.bar : any +>this : this +>bar : any + + } + +} + + + +var a = new A(); +>a : A +>new A() : A +>A : typeof A + +a.baz(); +>a.baz() : void +>a.baz : () => void +>a : A +>baz : () => void + + + diff --git a/tests/baselines/reference/autolift3.symbols b/tests/baselines/reference/autolift3.symbols new file mode 100644 index 00000000000..0277ececf08 --- /dev/null +++ b/tests/baselines/reference/autolift3.symbols @@ -0,0 +1,52 @@ +=== tests/cases/compiler/autolift3.ts === +class B { +>B : Symbol(B, Decl(autolift3.ts, 0, 0)) + + constructor() { + function foo() { } +>foo : Symbol(foo, Decl(autolift3.ts, 2, 19)) + + foo(); +>foo : Symbol(foo, Decl(autolift3.ts, 2, 19)) + + var a = 0; +>a : Symbol(a, Decl(autolift3.ts, 7, 11)) + + var inner: any = (function() { +>inner : Symbol(inner, Decl(autolift3.ts, 8, 11)) + + var CScriptIO = (function() { +>CScriptIO : Symbol(CScriptIO, Decl(autolift3.ts, 9, 15)) + + var fso = 0 +>fso : Symbol(fso, Decl(autolift3.ts, 10, 19)) + + return { + readFile: function(path: string): string { +>readFile : Symbol(readFile, Decl(autolift3.ts, 12, 24)) +>path : Symbol(path, Decl(autolift3.ts, 13, 39)) + + return fso.toString(); +>fso.toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) +>fso : Symbol(fso, Decl(autolift3.ts, 10, 19)) +>toString : Symbol(Number.toString, Decl(lib.d.ts, --, --)) + } + } + })(); + return inner; +>inner : Symbol(inner, Decl(autolift3.ts, 8, 11)) + + })(); + } +} + +var b = new B(); +>b : Symbol(b, Decl(autolift3.ts, 23, 3)) +>B : Symbol(B, Decl(autolift3.ts, 0, 0)) + +b.foo(); +>b : Symbol(b, Decl(autolift3.ts, 23, 3)) + + + + diff --git a/tests/baselines/reference/autolift3.types b/tests/baselines/reference/autolift3.types new file mode 100644 index 00000000000..6a4faebdf52 --- /dev/null +++ b/tests/baselines/reference/autolift3.types @@ -0,0 +1,69 @@ +=== tests/cases/compiler/autolift3.ts === +class B { +>B : B + + constructor() { + function foo() { } +>foo : () => void + + foo(); +>foo() : void +>foo : () => void + + var a = 0; +>a : number +>0 : 0 + + var inner: any = (function() { +>inner : any +>(function() { var CScriptIO = (function() { var fso = 0 return { readFile: function(path: string): string { return fso.toString(); } } })(); return inner; })() : any +>(function() { var CScriptIO = (function() { var fso = 0 return { readFile: function(path: string): string { return fso.toString(); } } })(); return inner; }) : () => any +>function() { var CScriptIO = (function() { var fso = 0 return { readFile: function(path: string): string { return fso.toString(); } } })(); return inner; } : () => any + + var CScriptIO = (function() { +>CScriptIO : { readFile: (path: string) => string; } +>(function() { var fso = 0 return { readFile: function(path: string): string { return fso.toString(); } } })() : { readFile: (path: string) => string; } +>(function() { var fso = 0 return { readFile: function(path: string): string { return fso.toString(); } } }) : () => { readFile: (path: string) => string; } +>function() { var fso = 0 return { readFile: function(path: string): string { return fso.toString(); } } } : () => { readFile: (path: string) => string; } + + var fso = 0 +>fso : number +>0 : 0 + + return { +>{ readFile: function(path: string): string { return fso.toString(); } } : { readFile: (path: string) => string; } + + readFile: function(path: string): string { +>readFile : (path: string) => string +>function(path: string): string { return fso.toString(); } : (path: string) => string +>path : string + + return fso.toString(); +>fso.toString() : string +>fso.toString : (radix?: number) => string +>fso : number +>toString : (radix?: number) => string + } + } + })(); + return inner; +>inner : any + + })(); + } +} + +var b = new B(); +>b : B +>new B() : B +>B : typeof B + +b.foo(); +>b.foo() : any +>b.foo : any +>b : B +>foo : any + + + + diff --git a/tests/baselines/reference/autolift4.symbols b/tests/baselines/reference/autolift4.symbols new file mode 100644 index 00000000000..9fc5d6370ba --- /dev/null +++ b/tests/baselines/reference/autolift4.symbols @@ -0,0 +1,77 @@ +=== tests/cases/compiler/autolift4.ts === +class Point { +>Point : Symbol(Point, Decl(autolift4.ts, 0, 0)) + + constructor(public x: number, public y: number) { +>x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) + + } + getDist() { +>getDist : Symbol(Point.getDist, Decl(autolift4.ts, 4, 5)) + + return Math.sqrt(this.x*this.x + this.y*this.y); +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --)) +>this.x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>this : Symbol(Point, Decl(autolift4.ts, 0, 0)) +>x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>this.x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>this : Symbol(Point, Decl(autolift4.ts, 0, 0)) +>x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>this.y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) +>this : Symbol(Point, Decl(autolift4.ts, 0, 0)) +>y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) +>this.y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) +>this : Symbol(Point, Decl(autolift4.ts, 0, 0)) +>y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) + } + static origin = new Point(0,0); +>origin : Symbol(Point.origin, Decl(autolift4.ts, 7, 5)) +>Point : Symbol(Point, Decl(autolift4.ts, 0, 0)) +} + +class Point3D extends Point { +>Point3D : Symbol(Point3D, Decl(autolift4.ts, 9, 1)) +>Point : Symbol(Point, Decl(autolift4.ts, 0, 0)) + + constructor(x: number, y: number, public z: number, m:number) { +>x : Symbol(x, Decl(autolift4.ts, 13, 16)) +>y : Symbol(y, Decl(autolift4.ts, 13, 26)) +>z : Symbol(Point3D.z, Decl(autolift4.ts, 13, 37)) +>m : Symbol(m, Decl(autolift4.ts, 13, 55)) + + super(x, y); +>super : Symbol(Point, Decl(autolift4.ts, 0, 0)) +>x : Symbol(x, Decl(autolift4.ts, 13, 16)) +>y : Symbol(y, Decl(autolift4.ts, 13, 26)) + } + + getDist() { +>getDist : Symbol(Point3D.getDist, Decl(autolift4.ts, 15, 5)) + + return Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.m); +>Math.sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --)) +>Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>sqrt : Symbol(Math.sqrt, Decl(lib.d.ts, --, --)) +>this.x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>this : Symbol(Point3D, Decl(autolift4.ts, 9, 1)) +>x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>this.x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>this : Symbol(Point3D, Decl(autolift4.ts, 9, 1)) +>x : Symbol(Point.x, Decl(autolift4.ts, 2, 16)) +>this.y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) +>this : Symbol(Point3D, Decl(autolift4.ts, 9, 1)) +>y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) +>this.y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) +>this : Symbol(Point3D, Decl(autolift4.ts, 9, 1)) +>y : Symbol(Point.y, Decl(autolift4.ts, 2, 33)) +>this.z : Symbol(Point3D.z, Decl(autolift4.ts, 13, 37)) +>this : Symbol(Point3D, Decl(autolift4.ts, 9, 1)) +>z : Symbol(Point3D.z, Decl(autolift4.ts, 13, 37)) +>this : Symbol(Point3D, Decl(autolift4.ts, 9, 1)) + } +} + + diff --git a/tests/baselines/reference/autolift4.types b/tests/baselines/reference/autolift4.types new file mode 100644 index 00000000000..dc34da815fc --- /dev/null +++ b/tests/baselines/reference/autolift4.types @@ -0,0 +1,93 @@ +=== tests/cases/compiler/autolift4.ts === +class Point { +>Point : Point + + constructor(public x: number, public y: number) { +>x : number +>y : number + + } + getDist() { +>getDist : () => number + + return Math.sqrt(this.x*this.x + this.y*this.y); +>Math.sqrt(this.x*this.x + this.y*this.y) : number +>Math.sqrt : (x: number) => number +>Math : Math +>sqrt : (x: number) => number +>this.x*this.x + this.y*this.y : number +>this.x*this.x : number +>this.x : number +>this : this +>x : number +>this.x : number +>this : this +>x : number +>this.y*this.y : number +>this.y : number +>this : this +>y : number +>this.y : number +>this : this +>y : number + } + static origin = new Point(0,0); +>origin : Point +>new Point(0,0) : Point +>Point : typeof Point +>0 : 0 +>0 : 0 +} + +class Point3D extends Point { +>Point3D : Point3D +>Point : Point + + constructor(x: number, y: number, public z: number, m:number) { +>x : number +>y : number +>z : number +>m : number + + super(x, y); +>super(x, y) : void +>super : typeof Point +>x : number +>y : number + } + + getDist() { +>getDist : () => number + + return Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.m); +>Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.m) : number +>Math.sqrt : (x: number) => number +>Math : Math +>sqrt : (x: number) => number +>this.x*this.x + this.y*this.y + this.z*this.m : number +>this.x*this.x + this.y*this.y : number +>this.x*this.x : number +>this.x : number +>this : this +>x : number +>this.x : number +>this : this +>x : number +>this.y*this.y : number +>this.y : number +>this : this +>y : number +>this.y : number +>this : this +>y : number +>this.z*this.m : number +>this.z : number +>this : this +>z : number +>this.m : any +>this : this +>m : any + } +} + + diff --git a/tests/baselines/reference/awaitLiteralValues.symbols b/tests/baselines/reference/awaitLiteralValues.symbols new file mode 100644 index 00000000000..2f5e8191b20 --- /dev/null +++ b/tests/baselines/reference/awaitLiteralValues.symbols @@ -0,0 +1,38 @@ +=== tests/cases/compiler/awaitLiteralValues.ts === +function awaitString() { +>awaitString : Symbol(awaitString, Decl(awaitLiteralValues.ts, 0, 0)) + + await 'literal'; +} + +function awaitNumber() { +>awaitNumber : Symbol(awaitNumber, Decl(awaitLiteralValues.ts, 2, 1)) + + await 1; +} + +function awaitTrue() { +>awaitTrue : Symbol(awaitTrue, Decl(awaitLiteralValues.ts, 6, 1)) + + await true; +} + +function awaitFalse() { +>awaitFalse : Symbol(awaitFalse, Decl(awaitLiteralValues.ts, 10, 1)) + + await false; +} + +function awaitNull() { +>awaitNull : Symbol(awaitNull, Decl(awaitLiteralValues.ts, 14, 1)) + + await null; +} + +function awaitUndefined() { +>awaitUndefined : Symbol(awaitUndefined, Decl(awaitLiteralValues.ts, 18, 1)) + + await undefined; +>undefined : Symbol(undefined) +} + diff --git a/tests/baselines/reference/awaitLiteralValues.types b/tests/baselines/reference/awaitLiteralValues.types new file mode 100644 index 00000000000..da436d83bd0 --- /dev/null +++ b/tests/baselines/reference/awaitLiteralValues.types @@ -0,0 +1,49 @@ +=== tests/cases/compiler/awaitLiteralValues.ts === +function awaitString() { +>awaitString : () => void + + await 'literal'; +>await 'literal' : "literal" +>'literal' : "literal" +} + +function awaitNumber() { +>awaitNumber : () => void + + await 1; +>await 1 : 1 +>1 : 1 +} + +function awaitTrue() { +>awaitTrue : () => void + + await true; +>await true : true +>true : true +} + +function awaitFalse() { +>awaitFalse : () => void + + await false; +>await false : false +>false : false +} + +function awaitNull() { +>awaitNull : () => void + + await null; +>await null : null +>null : null +} + +function awaitUndefined() { +>awaitUndefined : () => void + + await undefined; +>await undefined : undefined +>undefined : undefined +} + diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.symbols b/tests/baselines/reference/await_unaryExpression_es2017_1.symbols index 81bb31a7efd..75c3ad6dddd 100644 --- a/tests/baselines/reference/await_unaryExpression_es2017_1.symbols +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.symbols @@ -1,5 +1,4 @@ === tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts === - async function bar() { >bar : Symbol(bar, Decl(await_unaryExpression_es2017_1.ts, 0, 0)) @@ -7,25 +6,25 @@ async function bar() { } async function bar1() { ->bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017_1.ts, 3, 1)) +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017_1.ts, 2, 1)) delete await 42; // OK } async function bar2() { ->bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_1.ts, 7, 1)) +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_1.ts, 6, 1)) delete await 42; // OK } async function bar3() { ->bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_1.ts, 11, 1)) +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_1.ts, 10, 1)) void await 42; } async function bar4() { ->bar4 : Symbol(bar4, Decl(await_unaryExpression_es2017_1.ts, 15, 1)) +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es2017_1.ts, 14, 1)) +await 42; } diff --git a/tests/baselines/reference/await_unaryExpression_es2017_1.types b/tests/baselines/reference/await_unaryExpression_es2017_1.types index 7afa4fe9001..40b84797069 100644 --- a/tests/baselines/reference/await_unaryExpression_es2017_1.types +++ b/tests/baselines/reference/await_unaryExpression_es2017_1.types @@ -1,5 +1,4 @@ === tests/cases/conformance/async/es2017/await_unaryExpression_es2017_1.ts === - async function bar() { >bar : () => Promise diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.symbols b/tests/baselines/reference/await_unaryExpression_es2017_2.symbols index d4b8a7493d9..93ff1c1d94f 100644 --- a/tests/baselines/reference/await_unaryExpression_es2017_2.symbols +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.symbols @@ -1,5 +1,4 @@ === tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts === - async function bar1() { >bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017_2.ts, 0, 0)) @@ -7,13 +6,13 @@ async function bar1() { } async function bar2() { ->bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_2.ts, 3, 1)) +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_2.ts, 2, 1)) delete await 42; } async function bar3() { ->bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_2.ts, 7, 1)) +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_2.ts, 6, 1)) void await 42; } diff --git a/tests/baselines/reference/await_unaryExpression_es2017_2.types b/tests/baselines/reference/await_unaryExpression_es2017_2.types index acaa76d2d67..2c46832d574 100644 --- a/tests/baselines/reference/await_unaryExpression_es2017_2.types +++ b/tests/baselines/reference/await_unaryExpression_es2017_2.types @@ -1,5 +1,4 @@ === tests/cases/conformance/async/es2017/await_unaryExpression_es2017_2.ts === - async function bar1() { >bar1 : () => Promise diff --git a/tests/baselines/reference/await_unaryExpression_es2017_3.symbols b/tests/baselines/reference/await_unaryExpression_es2017_3.symbols new file mode 100644 index 00000000000..05a4cb4c8ea --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_3.symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts === +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es2017_3.ts, 0, 0)) + + ++await 42; // Error +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es2017_3.ts, 2, 1)) + + --await 42; // Error +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es2017_3.ts, 6, 1)) + + var x = 42; +>x : Symbol(x, Decl(await_unaryExpression_es2017_3.ts, 9, 7)) + + await x++; // OK but shouldn't need parenthesis +>x : Symbol(x, Decl(await_unaryExpression_es2017_3.ts, 9, 7)) +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es2017_3.ts, 11, 1)) + + var x = 42; +>x : Symbol(x, Decl(await_unaryExpression_es2017_3.ts, 14, 7)) + + await x--; // OK but shouldn't need parenthesis +>x : Symbol(x, Decl(await_unaryExpression_es2017_3.ts, 14, 7)) +} diff --git a/tests/baselines/reference/await_unaryExpression_es2017_3.types b/tests/baselines/reference/await_unaryExpression_es2017_3.types new file mode 100644 index 00000000000..b60ea42b2a0 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es2017_3.types @@ -0,0 +1,46 @@ +=== tests/cases/conformance/async/es2017/await_unaryExpression_es2017_3.ts === +async function bar1() { +>bar1 : () => Promise + + ++await 42; // Error +>++ : number +> : any +>await 42 : 42 +>42 : 42 +} + +async function bar2() { +>bar2 : () => Promise + + --await 42; // Error +>-- : number +> : any +>await 42 : 42 +>42 : 42 +} + +async function bar3() { +>bar3 : () => Promise + + var x = 42; +>x : number +>42 : 42 + + await x++; // OK but shouldn't need parenthesis +>await x++ : number +>x++ : number +>x : number +} + +async function bar4() { +>bar4 : () => Promise + + var x = 42; +>x : number +>42 : 42 + + await x--; // OK but shouldn't need parenthesis +>await x-- : number +>x-- : number +>x : number +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.symbols b/tests/baselines/reference/await_unaryExpression_es6_1.symbols index ed7d7e4ed02..a4c33ee825c 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_1.symbols +++ b/tests/baselines/reference/await_unaryExpression_es6_1.symbols @@ -1,5 +1,4 @@ === tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts === - async function bar() { >bar : Symbol(bar, Decl(await_unaryExpression_es6_1.ts, 0, 0)) @@ -7,25 +6,25 @@ async function bar() { } async function bar1() { ->bar1 : Symbol(bar1, Decl(await_unaryExpression_es6_1.ts, 3, 1)) +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es6_1.ts, 2, 1)) delete await 42; // OK } async function bar2() { ->bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_1.ts, 7, 1)) +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_1.ts, 6, 1)) delete await 42; // OK } async function bar3() { ->bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_1.ts, 11, 1)) +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_1.ts, 10, 1)) void await 42; } async function bar4() { ->bar4 : Symbol(bar4, Decl(await_unaryExpression_es6_1.ts, 15, 1)) +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es6_1.ts, 14, 1)) +await 42; } diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.types b/tests/baselines/reference/await_unaryExpression_es6_1.types index 15544420189..a5887f4e472 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_1.types +++ b/tests/baselines/reference/await_unaryExpression_es6_1.types @@ -1,5 +1,4 @@ === tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts === - async function bar() { >bar : () => Promise diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.symbols b/tests/baselines/reference/await_unaryExpression_es6_2.symbols index 574ea4d433a..54a48e43ea6 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_2.symbols +++ b/tests/baselines/reference/await_unaryExpression_es6_2.symbols @@ -1,5 +1,4 @@ === tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts === - async function bar1() { >bar1 : Symbol(bar1, Decl(await_unaryExpression_es6_2.ts, 0, 0)) @@ -7,13 +6,13 @@ async function bar1() { } async function bar2() { ->bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_2.ts, 3, 1)) +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_2.ts, 2, 1)) delete await 42; } async function bar3() { ->bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_2.ts, 7, 1)) +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_2.ts, 6, 1)) void await 42; } diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.types b/tests/baselines/reference/await_unaryExpression_es6_2.types index 6142eec825b..15dc820bbbb 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_2.types +++ b/tests/baselines/reference/await_unaryExpression_es6_2.types @@ -1,5 +1,4 @@ === tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts === - async function bar1() { >bar1 : () => Promise diff --git a/tests/baselines/reference/await_unaryExpression_es6_3.symbols b/tests/baselines/reference/await_unaryExpression_es6_3.symbols new file mode 100644 index 00000000000..4d61bfde3c1 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_3.symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts === +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es6_3.ts, 0, 0)) + + ++await 42; // Error +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_3.ts, 2, 1)) + + --await 42; // Error +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_3.ts, 6, 1)) + + var x = 42; +>x : Symbol(x, Decl(await_unaryExpression_es6_3.ts, 9, 7)) + + await x++; // OK but shouldn't need parenthesis +>x : Symbol(x, Decl(await_unaryExpression_es6_3.ts, 9, 7)) +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es6_3.ts, 11, 1)) + + var x = 42; +>x : Symbol(x, Decl(await_unaryExpression_es6_3.ts, 14, 7)) + + await x--; // OK but shouldn't need parenthesis +>x : Symbol(x, Decl(await_unaryExpression_es6_3.ts, 14, 7)) +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_3.types b/tests/baselines/reference/await_unaryExpression_es6_3.types new file mode 100644 index 00000000000..db18c889553 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_3.types @@ -0,0 +1,46 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts === +async function bar1() { +>bar1 : () => Promise + + ++await 42; // Error +>++ : number +> : any +>await 42 : 42 +>42 : 42 +} + +async function bar2() { +>bar2 : () => Promise + + --await 42; // Error +>-- : number +> : any +>await 42 : 42 +>42 : 42 +} + +async function bar3() { +>bar3 : () => Promise + + var x = 42; +>x : number +>42 : 42 + + await x++; // OK but shouldn't need parenthesis +>await x++ : number +>x++ : number +>x : number +} + +async function bar4() { +>bar4 : () => Promise + + var x = 42; +>x : number +>42 : 42 + + await x--; // OK but shouldn't need parenthesis +>await x-- : number +>x-- : number +>x : number +} diff --git a/tests/baselines/reference/badArrayIndex.symbols b/tests/baselines/reference/badArrayIndex.symbols new file mode 100644 index 00000000000..3ea300fca50 --- /dev/null +++ b/tests/baselines/reference/badArrayIndex.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/badArrayIndex.ts === +var results = number[]; +>results : Symbol(results, Decl(badArrayIndex.ts, 0, 3)) + diff --git a/tests/baselines/reference/badArrayIndex.types b/tests/baselines/reference/badArrayIndex.types new file mode 100644 index 00000000000..a8b541124b6 --- /dev/null +++ b/tests/baselines/reference/badArrayIndex.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/badArrayIndex.ts === +var results = number[]; +>results : any +>number[] : any +>number : any + diff --git a/tests/baselines/reference/badArraySyntax.symbols b/tests/baselines/reference/badArraySyntax.symbols new file mode 100644 index 00000000000..7b8f96124b0 --- /dev/null +++ b/tests/baselines/reference/badArraySyntax.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/badArraySyntax.ts === +class Z { +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) + + public x = ""; +>x : Symbol(Z.x, Decl(badArraySyntax.ts, 0, 9)) +} + +var a1: Z[] = []; +>a1 : Symbol(a1, Decl(badArraySyntax.ts, 4, 3)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) + +var a2 = new Z[]; +>a2 : Symbol(a2, Decl(badArraySyntax.ts, 5, 3)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) + +var a3 = new Z[](); +>a3 : Symbol(a3, Decl(badArraySyntax.ts, 6, 3)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) + +var a4: Z[] = new Z[]; +>a4 : Symbol(a4, Decl(badArraySyntax.ts, 7, 3)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) + +var a5: Z[] = new Z[](); +>a5 : Symbol(a5, Decl(badArraySyntax.ts, 8, 3)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) + +var a6: Z[][] = new Z [ ] [ ]; +>a6 : Symbol(a6, Decl(badArraySyntax.ts, 9, 3)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) +>Z : Symbol(Z, Decl(badArraySyntax.ts, 0, 0)) + diff --git a/tests/baselines/reference/badArraySyntax.types b/tests/baselines/reference/badArraySyntax.types new file mode 100644 index 00000000000..f7982034d71 --- /dev/null +++ b/tests/baselines/reference/badArraySyntax.types @@ -0,0 +1,48 @@ +=== tests/cases/compiler/badArraySyntax.ts === +class Z { +>Z : Z + + public x = ""; +>x : string +>"" : "" +} + +var a1: Z[] = []; +>a1 : Z[] +>Z : Z +>[] : undefined[] + +var a2 = new Z[]; +>a2 : any +>new Z[] : any +>Z[] : any +>Z : typeof Z + +var a3 = new Z[](); +>a3 : any +>new Z[]() : any +>Z[] : any +>Z : typeof Z + +var a4: Z[] = new Z[]; +>a4 : Z[] +>Z : Z +>new Z[] : any +>Z[] : any +>Z : typeof Z + +var a5: Z[] = new Z[](); +>a5 : Z[] +>Z : Z +>new Z[]() : any +>Z[] : any +>Z : typeof Z + +var a6: Z[][] = new Z [ ] [ ]; +>a6 : Z[][] +>Z : Z +>new Z [ ] [ ] : any +>Z [ ] [ ] : any +>Z [ ] : any +>Z : typeof Z + diff --git a/tests/baselines/reference/badExternalModuleReference.symbols b/tests/baselines/reference/badExternalModuleReference.symbols new file mode 100644 index 00000000000..3e6d6a80e84 --- /dev/null +++ b/tests/baselines/reference/badExternalModuleReference.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/badExternalModuleReference.ts === +import a1 = require("garbage"); +>a1 : Symbol(a1, Decl(badExternalModuleReference.ts, 0, 0)) + +export declare var a: { +>a : Symbol(a, Decl(badExternalModuleReference.ts, 1, 18)) + + test1: a1.connectModule; +>test1 : Symbol(test1, Decl(badExternalModuleReference.ts, 1, 23)) +>a1 : Symbol(a1, Decl(badExternalModuleReference.ts, 0, 0)) +>connectModule : Symbol(a1) + + (): a1.connectExport; +>a1 : Symbol(a1, Decl(badExternalModuleReference.ts, 0, 0)) +>connectExport : Symbol(a1) + +}; + diff --git a/tests/baselines/reference/badExternalModuleReference.types b/tests/baselines/reference/badExternalModuleReference.types new file mode 100644 index 00000000000..61314d8abb8 --- /dev/null +++ b/tests/baselines/reference/badExternalModuleReference.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/badExternalModuleReference.ts === +import a1 = require("garbage"); +>a1 : any + +export declare var a: { +>a : { (): any; test1: any; } + + test1: a1.connectModule; +>test1 : any +>a1 : any +>connectModule : any + + (): a1.connectExport; +>a1 : any +>connectExport : any + +}; + diff --git a/tests/baselines/reference/baseCheck.symbols b/tests/baselines/reference/baseCheck.symbols new file mode 100644 index 00000000000..3fe3616009c --- /dev/null +++ b/tests/baselines/reference/baseCheck.symbols @@ -0,0 +1,75 @@ +=== tests/cases/compiler/baseCheck.ts === +class C { constructor(x: number, y: number) { } } +>C : Symbol(C, Decl(baseCheck.ts, 0, 0)) +>x : Symbol(x, Decl(baseCheck.ts, 0, 22)) +>y : Symbol(y, Decl(baseCheck.ts, 0, 32)) + +class ELoc extends C { +>ELoc : Symbol(ELoc, Decl(baseCheck.ts, 0, 49)) +>C : Symbol(C, Decl(baseCheck.ts, 0, 0)) + + constructor(x: number) { +>x : Symbol(x, Decl(baseCheck.ts, 2, 16)) + + super(0, x); +>super : Symbol(C, Decl(baseCheck.ts, 0, 0)) +>x : Symbol(x, Decl(baseCheck.ts, 2, 16)) + } +} +class ELocVar extends C { +>ELocVar : Symbol(ELocVar, Decl(baseCheck.ts, 5, 1)) +>C : Symbol(C, Decl(baseCheck.ts, 0, 0)) + + constructor(x: number) { +>x : Symbol(x, Decl(baseCheck.ts, 7, 16)) + + super(0, loc); +>super : Symbol(C, Decl(baseCheck.ts, 0, 0)) + } + + m() { +>m : Symbol(ELocVar.m, Decl(baseCheck.ts, 9, 5)) + + var loc=10; +>loc : Symbol(loc, Decl(baseCheck.ts, 12, 11)) + } +} + +class D extends C { constructor(public z: number) { super(this.z) } } // too few params +>D : Symbol(D, Decl(baseCheck.ts, 14, 1)) +>C : Symbol(C, Decl(baseCheck.ts, 0, 0)) +>z : Symbol(D.z, Decl(baseCheck.ts, 16, 32)) +>super : Symbol(C, Decl(baseCheck.ts, 0, 0)) +>this.z : Symbol(D.z, Decl(baseCheck.ts, 16, 32)) +>this : Symbol(D, Decl(baseCheck.ts, 14, 1)) +>z : Symbol(D.z, Decl(baseCheck.ts, 16, 32)) + +class E extends C { constructor(public z: number) { super(0, this.z) } } +>E : Symbol(E, Decl(baseCheck.ts, 16, 70)) +>C : Symbol(C, Decl(baseCheck.ts, 0, 0)) +>z : Symbol(E.z, Decl(baseCheck.ts, 17, 32)) +>super : Symbol(C, Decl(baseCheck.ts, 0, 0)) +>this.z : Symbol(E.z, Decl(baseCheck.ts, 17, 32)) +>this : Symbol(E, Decl(baseCheck.ts, 16, 70)) +>z : Symbol(E.z, Decl(baseCheck.ts, 17, 32)) + +class F extends C { constructor(public z: number) { super("hello", this.z) } } // first param type +>F : Symbol(F, Decl(baseCheck.ts, 17, 72)) +>C : Symbol(C, Decl(baseCheck.ts, 0, 0)) +>z : Symbol(F.z, Decl(baseCheck.ts, 18, 32)) +>super : Symbol(C, Decl(baseCheck.ts, 0, 0)) +>this.z : Symbol(F.z, Decl(baseCheck.ts, 18, 32)) +>this : Symbol(F, Decl(baseCheck.ts, 17, 72)) +>z : Symbol(F.z, Decl(baseCheck.ts, 18, 32)) + +function f() { +>f : Symbol(f, Decl(baseCheck.ts, 18, 78)) + + if (x<10) { + x=11; + } + else { + x=12; + } +} + diff --git a/tests/baselines/reference/baseCheck.types b/tests/baselines/reference/baseCheck.types new file mode 100644 index 00000000000..a5e3976d0ea --- /dev/null +++ b/tests/baselines/reference/baseCheck.types @@ -0,0 +1,96 @@ +=== tests/cases/compiler/baseCheck.ts === +class C { constructor(x: number, y: number) { } } +>C : C +>x : number +>y : number + +class ELoc extends C { +>ELoc : ELoc +>C : C + + constructor(x: number) { +>x : number + + super(0, x); +>super(0, x) : void +>super : typeof C +>0 : 0 +>x : number + } +} +class ELocVar extends C { +>ELocVar : ELocVar +>C : C + + constructor(x: number) { +>x : number + + super(0, loc); +>super(0, loc) : void +>super : typeof C +>0 : 0 +>loc : any + } + + m() { +>m : () => void + + var loc=10; +>loc : number +>10 : 10 + } +} + +class D extends C { constructor(public z: number) { super(this.z) } } // too few params +>D : D +>C : C +>z : number +>super(this.z) : void +>super : typeof C +>this.z : number +>this : this +>z : number + +class E extends C { constructor(public z: number) { super(0, this.z) } } +>E : E +>C : C +>z : number +>super(0, this.z) : void +>super : typeof C +>0 : 0 +>this.z : number +>this : this +>z : number + +class F extends C { constructor(public z: number) { super("hello", this.z) } } // first param type +>F : F +>C : C +>z : number +>super("hello", this.z) : void +>super : typeof C +>"hello" : "hello" +>this.z : number +>this : this +>z : number + +function f() { +>f : () => void + + if (x<10) { +>x<10 : boolean +>x : any +>10 : 10 + + x=11; +>x=11 : 11 +>x : any +>11 : 11 + } + else { + x=12; +>x=12 : 12 +>x : any +>12 : 12 + } +} + diff --git a/tests/baselines/reference/baseConstraintOfDecorator.symbols b/tests/baselines/reference/baseConstraintOfDecorator.symbols new file mode 100644 index 00000000000..71d7773a7cf --- /dev/null +++ b/tests/baselines/reference/baseConstraintOfDecorator.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/baseConstraintOfDecorator.ts === +export function classExtender(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction { +>classExtender : Symbol(classExtender, Decl(baseConstraintOfDecorator.ts, 0, 0)) +>TFunction : Symbol(TFunction, Decl(baseConstraintOfDecorator.ts, 0, 30)) +>superClass : Symbol(superClass, Decl(baseConstraintOfDecorator.ts, 0, 41)) +>TFunction : Symbol(TFunction, Decl(baseConstraintOfDecorator.ts, 0, 30)) +>_instanceModifier : Symbol(_instanceModifier, Decl(baseConstraintOfDecorator.ts, 0, 63)) +>instance : Symbol(instance, Decl(baseConstraintOfDecorator.ts, 0, 84)) +>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 0, 98)) +>TFunction : Symbol(TFunction, Decl(baseConstraintOfDecorator.ts, 0, 30)) + + return class decoratorFunc extends superClass { +>decoratorFunc : Symbol(decoratorFunc, Decl(baseConstraintOfDecorator.ts, 1, 10)) +>superClass : Symbol(superClass, Decl(baseConstraintOfDecorator.ts, 0, 41)) + + constructor(...args: any[]) { +>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 2, 20)) + + super(...args); +>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 2, 20)) + + _instanceModifier(this, args); +>_instanceModifier : Symbol(_instanceModifier, Decl(baseConstraintOfDecorator.ts, 0, 63)) +>this : Symbol(decoratorFunc, Decl(baseConstraintOfDecorator.ts, 1, 10)) +>args : Symbol(args, Decl(baseConstraintOfDecorator.ts, 2, 20)) + } + }; +} + diff --git a/tests/baselines/reference/baseConstraintOfDecorator.types b/tests/baselines/reference/baseConstraintOfDecorator.types new file mode 100644 index 00000000000..f1af8a8d503 --- /dev/null +++ b/tests/baselines/reference/baseConstraintOfDecorator.types @@ -0,0 +1,34 @@ +=== tests/cases/compiler/baseConstraintOfDecorator.ts === +export function classExtender(superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void): TFunction { +>classExtender : (superClass: TFunction, _instanceModifier: (instance: any, args: any[]) => void) => TFunction +>TFunction : TFunction +>superClass : TFunction +>TFunction : TFunction +>_instanceModifier : (instance: any, args: any[]) => void +>instance : any +>args : any[] +>TFunction : TFunction + + return class decoratorFunc extends superClass { +>class decoratorFunc extends superClass { constructor(...args: any[]) { super(...args); _instanceModifier(this, args); } } : typeof decoratorFunc +>decoratorFunc : typeof decoratorFunc +>superClass : TFunction + + constructor(...args: any[]) { +>args : any[] + + super(...args); +>super(...args) : void +>super : any +>...args : any +>args : any[] + + _instanceModifier(this, args); +>_instanceModifier(this, args) : void +>_instanceModifier : (instance: any, args: any[]) => void +>this : this +>args : any[] + } + }; +} + diff --git a/tests/baselines/reference/baseExpressionTypeParameters.symbols b/tests/baselines/reference/baseExpressionTypeParameters.symbols new file mode 100644 index 00000000000..22f716a0a1c --- /dev/null +++ b/tests/baselines/reference/baseExpressionTypeParameters.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/baseExpressionTypeParameters.ts === +// Repro from #17829 + +function base() { +>base : Symbol(base, Decl(baseExpressionTypeParameters.ts, 0, 0)) +>T : Symbol(T, Decl(baseExpressionTypeParameters.ts, 2, 14)) + + class Base { +>Base : Symbol(Base, Decl(baseExpressionTypeParameters.ts, 2, 20)) + + static prop: T; +>prop : Symbol(Base.prop, Decl(baseExpressionTypeParameters.ts, 3, 16)) +>T : Symbol(T, Decl(baseExpressionTypeParameters.ts, 2, 14)) + } + return Base; +>Base : Symbol(Base, Decl(baseExpressionTypeParameters.ts, 2, 20)) +} + +class Gen extends base() {} // Error, T not in scope +>Gen : Symbol(Gen, Decl(baseExpressionTypeParameters.ts, 7, 1)) +>T : Symbol(T, Decl(baseExpressionTypeParameters.ts, 9, 10)) +>base : Symbol(base, Decl(baseExpressionTypeParameters.ts, 0, 0)) + +class Spec extends Gen {} +>Spec : Symbol(Spec, Decl(baseExpressionTypeParameters.ts, 9, 33)) +>Gen : Symbol(Gen, Decl(baseExpressionTypeParameters.ts, 7, 1)) + +Spec.prop; +>Spec.prop : Symbol(Base.prop, Decl(baseExpressionTypeParameters.ts, 3, 16)) +>Spec : Symbol(Spec, Decl(baseExpressionTypeParameters.ts, 9, 33)) +>prop : Symbol(Base.prop, Decl(baseExpressionTypeParameters.ts, 3, 16)) + diff --git a/tests/baselines/reference/baseExpressionTypeParameters.types b/tests/baselines/reference/baseExpressionTypeParameters.types new file mode 100644 index 00000000000..252d39e5e36 --- /dev/null +++ b/tests/baselines/reference/baseExpressionTypeParameters.types @@ -0,0 +1,35 @@ +=== tests/cases/compiler/baseExpressionTypeParameters.ts === +// Repro from #17829 + +function base() { +>base : () => typeof Base +>T : T + + class Base { +>Base : Base + + static prop: T; +>prop : T +>T : T + } + return Base; +>Base : typeof Base +} + +class Gen extends base() {} // Error, T not in scope +>Gen : Gen +>T : T +>base() : base.Base +>base : () => typeof Base +>T : No type information available! + +class Spec extends Gen {} +>Spec : Spec +>Gen : Gen + +Spec.prop; +>Spec.prop : string +>Spec.prop : any +>Spec : typeof Spec +>prop : any + diff --git a/tests/baselines/reference/baseTypePrivateMemberClash.symbols b/tests/baselines/reference/baseTypePrivateMemberClash.symbols new file mode 100644 index 00000000000..ede8869f96f --- /dev/null +++ b/tests/baselines/reference/baseTypePrivateMemberClash.symbols @@ -0,0 +1,19 @@ +=== tests/cases/compiler/baseTypePrivateMemberClash.ts === +class X { +>X : Symbol(X, Decl(baseTypePrivateMemberClash.ts, 0, 0)) + + private m: number; +>m : Symbol(X.m, Decl(baseTypePrivateMemberClash.ts, 0, 9)) +} +class Y { +>Y : Symbol(Y, Decl(baseTypePrivateMemberClash.ts, 2, 1)) + + private m: string; +>m : Symbol(Y.m, Decl(baseTypePrivateMemberClash.ts, 3, 9)) +} + +interface Z extends X, Y { } +>Z : Symbol(Z, Decl(baseTypePrivateMemberClash.ts, 5, 1)) +>X : Symbol(X, Decl(baseTypePrivateMemberClash.ts, 0, 0)) +>Y : Symbol(Y, Decl(baseTypePrivateMemberClash.ts, 2, 1)) + diff --git a/tests/baselines/reference/baseTypePrivateMemberClash.types b/tests/baselines/reference/baseTypePrivateMemberClash.types new file mode 100644 index 00000000000..6cd8b89628a --- /dev/null +++ b/tests/baselines/reference/baseTypePrivateMemberClash.types @@ -0,0 +1,19 @@ +=== tests/cases/compiler/baseTypePrivateMemberClash.ts === +class X { +>X : X + + private m: number; +>m : number +} +class Y { +>Y : Y + + private m: string; +>m : string +} + +interface Z extends X, Y { } +>Z : Z +>X : X +>Y : Y + diff --git a/tests/baselines/reference/bases.symbols b/tests/baselines/reference/bases.symbols new file mode 100644 index 00000000000..204205e20e8 --- /dev/null +++ b/tests/baselines/reference/bases.symbols @@ -0,0 +1,35 @@ +=== tests/cases/compiler/bases.ts === +interface I { +>I : Symbol(I, Decl(bases.ts, 0, 0)) + + x; +>x : Symbol(I.x, Decl(bases.ts, 0, 13)) +} + +class B { +>B : Symbol(B, Decl(bases.ts, 2, 1)) + + constructor() { + this.y: any; +>this : Symbol(B, Decl(bases.ts, 2, 1)) + } +} + +class C extends B implements I { +>C : Symbol(C, Decl(bases.ts, 8, 1)) +>B : Symbol(B, Decl(bases.ts, 2, 1)) +>I : Symbol(I, Decl(bases.ts, 0, 0)) + + constructor() { + this.x: any; +>this : Symbol(C, Decl(bases.ts, 8, 1)) + } +} + +new C().x; +>C : Symbol(C, Decl(bases.ts, 8, 1)) + +new C().y; +>C : Symbol(C, Decl(bases.ts, 8, 1)) + + diff --git a/tests/baselines/reference/bases.types b/tests/baselines/reference/bases.types new file mode 100644 index 00000000000..46a641a1881 --- /dev/null +++ b/tests/baselines/reference/bases.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/bases.ts === +interface I { +>I : I + + x; +>x : any +} + +class B { +>B : B + + constructor() { + this.y: any; +>this.y : any +>this : this +>y : any +>any : any + } +} + +class C extends B implements I { +>C : C +>B : B +>I : I + + constructor() { + this.x: any; +>this.x : any +>this : this +>x : any +>any : any + } +} + +new C().x; +>new C().x : any +>new C() : C +>C : typeof C +>x : any + +new C().y; +>new C().y : any +>new C() : C +>C : typeof C +>y : any + + diff --git a/tests/baselines/reference/binaryArithmatic3.symbols b/tests/baselines/reference/binaryArithmatic3.symbols new file mode 100644 index 00000000000..66ca1a70b75 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic3.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/binaryArithmatic3.ts === +var v = undefined | undefined; +>v : Symbol(v, Decl(binaryArithmatic3.ts, 0, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + diff --git a/tests/baselines/reference/binaryArithmatic3.types b/tests/baselines/reference/binaryArithmatic3.types new file mode 100644 index 00000000000..2cb7161fd14 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic3.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/binaryArithmatic3.ts === +var v = undefined | undefined; +>v : number +>undefined | undefined : number +>undefined : undefined +>undefined : undefined + diff --git a/tests/baselines/reference/binaryArithmatic4.symbols b/tests/baselines/reference/binaryArithmatic4.symbols new file mode 100644 index 00000000000..4dab72c58d1 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic4.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/binaryArithmatic4.ts === +var v = null | null; +>v : Symbol(v, Decl(binaryArithmatic4.ts, 0, 3)) + diff --git a/tests/baselines/reference/binaryArithmatic4.types b/tests/baselines/reference/binaryArithmatic4.types new file mode 100644 index 00000000000..c876d76e1c4 --- /dev/null +++ b/tests/baselines/reference/binaryArithmatic4.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/binaryArithmatic4.ts === +var v = null | null; +>v : number +>null | null : number +>null : null +>null : null + diff --git a/tests/baselines/reference/binaryIntegerLiteralError.symbols b/tests/baselines/reference/binaryIntegerLiteralError.symbols new file mode 100644 index 00000000000..bd40cecff8d --- /dev/null +++ b/tests/baselines/reference/binaryIntegerLiteralError.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts === +// error +var bin1 = 0B1102110; +>bin1 : Symbol(bin1, Decl(binaryIntegerLiteralError.ts, 1, 3), Decl(binaryIntegerLiteralError.ts, 2, 3)) + +var bin1 = 0b11023410; +>bin1 : Symbol(bin1, Decl(binaryIntegerLiteralError.ts, 1, 3), Decl(binaryIntegerLiteralError.ts, 2, 3)) + +var obj1 = { +>obj1 : Symbol(obj1, Decl(binaryIntegerLiteralError.ts, 4, 3)) + + 0b11010: "hi", + 26: "Hello", + "26": "world", +}; + diff --git a/tests/baselines/reference/binaryIntegerLiteralError.types b/tests/baselines/reference/binaryIntegerLiteralError.types new file mode 100644 index 00000000000..5ab51f74666 --- /dev/null +++ b/tests/baselines/reference/binaryIntegerLiteralError.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralError.ts === +// error +var bin1 = 0B1102110; +>bin1 : number +>0B110 : 6 +>2110 : 2110 + +var bin1 = 0b11023410; +>bin1 : number +>0b110 : 6 +>23410 : 23410 + +var obj1 = { +>obj1 : { 0b11010: string; } +>{ 0b11010: "hi", 26: "Hello", "26": "world",} : { 0b11010: string; } + + 0b11010: "hi", +>"hi" : "hi" + + 26: "Hello", +>"Hello" : "Hello" + + "26": "world", +>"world" : "world" + +}; + diff --git a/tests/baselines/reference/bind1.symbols b/tests/baselines/reference/bind1.symbols new file mode 100644 index 00000000000..c985a283932 --- /dev/null +++ b/tests/baselines/reference/bind1.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/bind1.ts === +module M { +>M : Symbol(M, Decl(bind1.ts, 0, 0)) + + export class C implements I {} // this should be an unresolved symbol I error +>C : Symbol(C, Decl(bind1.ts, 0, 10)) +} + + diff --git a/tests/baselines/reference/bind1.types b/tests/baselines/reference/bind1.types new file mode 100644 index 00000000000..7502febacca --- /dev/null +++ b/tests/baselines/reference/bind1.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/bind1.ts === +module M { +>M : typeof M + + export class C implements I {} // this should be an unresolved symbol I error +>C : C +>I : No type information available! +} + + diff --git a/tests/baselines/reference/bindingPatternInParameter01.symbols b/tests/baselines/reference/bindingPatternInParameter01.symbols new file mode 100644 index 00000000000..466c7a0bc70 --- /dev/null +++ b/tests/baselines/reference/bindingPatternInParameter01.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/bindingPatternInParameter01.ts === +const nestedArray = [[[1, 2]], [[3, 4]]]; +>nestedArray : Symbol(nestedArray, Decl(bindingPatternInParameter01.ts, 0, 5)) + +nestedArray.forEach(([[a, b]]) => { +>nestedArray.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>nestedArray : Symbol(nestedArray, Decl(bindingPatternInParameter01.ts, 0, 5)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(bindingPatternInParameter01.ts, 2, 23)) +>b : Symbol(b, Decl(bindingPatternInParameter01.ts, 2, 25)) + + console.log(a, b); +>a : Symbol(a, Decl(bindingPatternInParameter01.ts, 2, 23)) +>b : Symbol(b, Decl(bindingPatternInParameter01.ts, 2, 25)) + +}); + diff --git a/tests/baselines/reference/bindingPatternInParameter01.types b/tests/baselines/reference/bindingPatternInParameter01.types new file mode 100644 index 00000000000..927deae8c07 --- /dev/null +++ b/tests/baselines/reference/bindingPatternInParameter01.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/bindingPatternInParameter01.ts === +const nestedArray = [[[1, 2]], [[3, 4]]]; +>nestedArray : number[][][] +>[[[1, 2]], [[3, 4]]] : number[][][] +>[[1, 2]] : number[][] +>[1, 2] : number[] +>1 : 1 +>2 : 2 +>[[3, 4]] : number[][] +>[3, 4] : number[] +>3 : 3 +>4 : 4 + +nestedArray.forEach(([[a, b]]) => { +>nestedArray.forEach(([[a, b]]) => { console.log(a, b);}) : void +>nestedArray.forEach : (callbackfn: (value: number[][], index: number, array: number[][][]) => void, thisArg?: any) => void +>nestedArray : number[][][] +>forEach : (callbackfn: (value: number[][], index: number, array: number[][][]) => void, thisArg?: any) => void +>([[a, b]]) => { console.log(a, b);} : ([[a, b]]: number[][]) => void +>a : number +>b : number + + console.log(a, b); +>console.log(a, b) : any +>console.log : any +>console : any +>log : any +>a : number +>b : number + +}); + diff --git a/tests/baselines/reference/bitwiseCompoundAssignmentOperators.symbols b/tests/baselines/reference/bitwiseCompoundAssignmentOperators.symbols new file mode 100644 index 00000000000..87a24424787 --- /dev/null +++ b/tests/baselines/reference/bitwiseCompoundAssignmentOperators.symbols @@ -0,0 +1,98 @@ +=== tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts === +var a = true; +>a : Symbol(a, Decl(bitwiseCompoundAssignmentOperators.ts, 0, 3)) + +var b = 1; +>b : Symbol(b, Decl(bitwiseCompoundAssignmentOperators.ts, 1, 3)) + +a ^= a; +>a : Symbol(a, Decl(bitwiseCompoundAssignmentOperators.ts, 0, 3)) +>a : Symbol(a, Decl(bitwiseCompoundAssignmentOperators.ts, 0, 3)) + +a = true; +>a : Symbol(a, Decl(bitwiseCompoundAssignmentOperators.ts, 0, 3)) + +b ^= b; +>b : Symbol(b, Decl(bitwiseCompoundAssignmentOperators.ts, 1, 3)) +>b : Symbol(b, Decl(bitwiseCompoundAssignmentOperators.ts, 1, 3)) + +b = 1; +>b : Symbol(b, Decl(bitwiseCompoundAssignmentOperators.ts, 1, 3)) + +a ^= b; +>a : Symbol(a, Decl(bitwiseCompoundAssignmentOperators.ts, 0, 3)) +>b : Symbol(b, Decl(bitwiseCompoundAssignmentOperators.ts, 1, 3)) + +a = true; +>a : Symbol(a, Decl(bitwiseCompoundAssignmentOperators.ts, 0, 3)) + +b ^= a; +>b : Symbol(b, Decl(bitwiseCompoundAssignmentOperators.ts, 1, 3)) +>a : Symbol(a, Decl(bitwiseCompoundAssignmentOperators.ts, 0, 3)) + +b = 1; +>b : Symbol(b, Decl(bitwiseCompoundAssignmentOperators.ts, 1, 3)) + +var c = false; +>c : Symbol(c, Decl(bitwiseCompoundAssignmentOperators.ts, 11, 3)) + +var d = 2; +>d : Symbol(d, Decl(bitwiseCompoundAssignmentOperators.ts, 12, 3)) + +c &= c; +>c : Symbol(c, Decl(bitwiseCompoundAssignmentOperators.ts, 11, 3)) +>c : Symbol(c, Decl(bitwiseCompoundAssignmentOperators.ts, 11, 3)) + +c = false; +>c : Symbol(c, Decl(bitwiseCompoundAssignmentOperators.ts, 11, 3)) + +d &= d; +>d : Symbol(d, Decl(bitwiseCompoundAssignmentOperators.ts, 12, 3)) +>d : Symbol(d, Decl(bitwiseCompoundAssignmentOperators.ts, 12, 3)) + +d = 2; +>d : Symbol(d, Decl(bitwiseCompoundAssignmentOperators.ts, 12, 3)) + +c &= d; +>c : Symbol(c, Decl(bitwiseCompoundAssignmentOperators.ts, 11, 3)) +>d : Symbol(d, Decl(bitwiseCompoundAssignmentOperators.ts, 12, 3)) + +c = false; +>c : Symbol(c, Decl(bitwiseCompoundAssignmentOperators.ts, 11, 3)) + +d &= c; +>d : Symbol(d, Decl(bitwiseCompoundAssignmentOperators.ts, 12, 3)) +>c : Symbol(c, Decl(bitwiseCompoundAssignmentOperators.ts, 11, 3)) + +var e = true; +>e : Symbol(e, Decl(bitwiseCompoundAssignmentOperators.ts, 21, 3)) + +var f = 0; +>f : Symbol(f, Decl(bitwiseCompoundAssignmentOperators.ts, 22, 3)) + +e |= e; +>e : Symbol(e, Decl(bitwiseCompoundAssignmentOperators.ts, 21, 3)) +>e : Symbol(e, Decl(bitwiseCompoundAssignmentOperators.ts, 21, 3)) + +e = true; +>e : Symbol(e, Decl(bitwiseCompoundAssignmentOperators.ts, 21, 3)) + +f |= f; +>f : Symbol(f, Decl(bitwiseCompoundAssignmentOperators.ts, 22, 3)) +>f : Symbol(f, Decl(bitwiseCompoundAssignmentOperators.ts, 22, 3)) + +f = 0; +>f : Symbol(f, Decl(bitwiseCompoundAssignmentOperators.ts, 22, 3)) + +e |= f; +>e : Symbol(e, Decl(bitwiseCompoundAssignmentOperators.ts, 21, 3)) +>f : Symbol(f, Decl(bitwiseCompoundAssignmentOperators.ts, 22, 3)) + +e = true; +>e : Symbol(e, Decl(bitwiseCompoundAssignmentOperators.ts, 21, 3)) + +f |= f; +>f : Symbol(f, Decl(bitwiseCompoundAssignmentOperators.ts, 22, 3)) +>f : Symbol(f, Decl(bitwiseCompoundAssignmentOperators.ts, 22, 3)) + + diff --git a/tests/baselines/reference/bitwiseCompoundAssignmentOperators.types b/tests/baselines/reference/bitwiseCompoundAssignmentOperators.types new file mode 100644 index 00000000000..dd71bb1e6c2 --- /dev/null +++ b/tests/baselines/reference/bitwiseCompoundAssignmentOperators.types @@ -0,0 +1,136 @@ +=== tests/cases/compiler/bitwiseCompoundAssignmentOperators.ts === +var a = true; +>a : boolean +>true : true + +var b = 1; +>b : number +>1 : 1 + +a ^= a; +>a ^= a : number +>a : boolean +>a : true + +a = true; +>a = true : true +>a : boolean +>true : true + +b ^= b; +>b ^= b : number +>b : number +>b : number + +b = 1; +>b = 1 : 1 +>b : number +>1 : 1 + +a ^= b; +>a ^= b : number +>a : boolean +>b : number + +a = true; +>a = true : true +>a : boolean +>true : true + +b ^= a; +>b ^= a : number +>b : number +>a : true + +b = 1; +>b = 1 : 1 +>b : number +>1 : 1 + +var c = false; +>c : boolean +>false : false + +var d = 2; +>d : number +>2 : 2 + +c &= c; +>c &= c : number +>c : boolean +>c : false + +c = false; +>c = false : false +>c : boolean +>false : false + +d &= d; +>d &= d : number +>d : number +>d : number + +d = 2; +>d = 2 : 2 +>d : number +>2 : 2 + +c &= d; +>c &= d : number +>c : boolean +>d : number + +c = false; +>c = false : false +>c : boolean +>false : false + +d &= c; +>d &= c : number +>d : number +>c : false + +var e = true; +>e : boolean +>true : true + +var f = 0; +>f : number +>0 : 0 + +e |= e; +>e |= e : number +>e : boolean +>e : true + +e = true; +>e = true : true +>e : boolean +>true : true + +f |= f; +>f |= f : number +>f : number +>f : number + +f = 0; +>f = 0 : 0 +>f : number +>0 : 0 + +e |= f; +>e |= f : number +>e : boolean +>f : number + +e = true; +>e = true : true +>e : boolean +>true : true + +f |= f; +>f |= f : number +>f : number +>f : number + + diff --git a/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.symbols b/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.symbols new file mode 100644 index 00000000000..69965f071ca --- /dev/null +++ b/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorInvalidOperations.ts === +// Unary operator ~ +var q; +>q : Symbol(q, Decl(bitwiseNotOperatorInvalidOperations.ts, 1, 3)) + +// operand before ~ +var a = q~; //expect error +>a : Symbol(a, Decl(bitwiseNotOperatorInvalidOperations.ts, 4, 3)) +>q : Symbol(q, Decl(bitwiseNotOperatorInvalidOperations.ts, 1, 3)) + +// multiple operands after ~ +var mul = ~[1, 2, "abc"], ""; //expect error +>mul : Symbol(mul, Decl(bitwiseNotOperatorInvalidOperations.ts, 7, 3)) + +// miss an operand +var b =~; +>b : Symbol(b, Decl(bitwiseNotOperatorInvalidOperations.ts, 10, 3)) + diff --git a/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.types b/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.types new file mode 100644 index 00000000000..01a51be84e9 --- /dev/null +++ b/tests/baselines/reference/bitwiseNotOperatorInvalidOperations.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorInvalidOperations.ts === +// Unary operator ~ +var q; +>q : any + +// operand before ~ +var a = q~; //expect error +>a : any +>q : any +>~ : number +> : any + +// multiple operands after ~ +var mul = ~[1, 2, "abc"], ""; //expect error +>mul : number +>~[1, 2, "abc"] : number +>[1, 2, "abc"] : (string | number)[] +>1 : 1 +>2 : 2 +>"abc" : "abc" +>"" : "" + +// miss an operand +var b =~; +>b : number +>~ : number +> : any + diff --git a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.symbols b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.symbols new file mode 100644 index 00000000000..c4ca5a5252b --- /dev/null +++ b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.symbols @@ -0,0 +1,188 @@ +=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts === +// ~ operator on any type + +var ANY: any; +>ANY : Symbol(ANY, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 2, 3)) + +var ANY1; +>ANY1 : Symbol(ANY1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 3, 3)) + +var ANY2: any[] = ["", ""]; +>ANY2 : Symbol(ANY2, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 4, 3)) + +var obj: () => {} +>obj : Symbol(obj, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 5, 3)) + +var obj1 = { x:"", y: () => { }}; +>obj1 : Symbol(obj1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 3)) +>x : Symbol(x, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 12)) +>y : Symbol(y, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 18)) + +function foo(): any { +>foo : Symbol(foo, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 33)) + + var a; +>a : Symbol(a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 9, 7)) + + return a; +>a : Symbol(a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 9, 7)) +} +class A { +>A : Symbol(A, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 11, 1)) + + public a: any; +>a : Symbol(A.a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 12, 9)) + + static foo() { +>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 13, 18)) + + var a; +>a : Symbol(a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 15, 11)) + + return a; +>a : Symbol(a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 15, 11)) + } +} +module M { +>M : Symbol(M, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 18, 1)) + + export var n: any; +>n : Symbol(n, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 20, 14)) +} +var objA = new A(); +>objA : Symbol(objA, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 22, 3)) +>A : Symbol(A, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 11, 1)) + +// any other type var +var ResultIsNumber = ~ANY1; +>ResultIsNumber : Symbol(ResultIsNumber, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 25, 3)) +>ANY1 : Symbol(ANY1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 3, 3)) + +var ResultIsNumber1 = ~ANY2; +>ResultIsNumber1 : Symbol(ResultIsNumber1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 26, 3)) +>ANY2 : Symbol(ANY2, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 4, 3)) + +var ResultIsNumber2 = ~A; +>ResultIsNumber2 : Symbol(ResultIsNumber2, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 27, 3)) +>A : Symbol(A, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 11, 1)) + +var ResultIsNumber3 = ~M; +>ResultIsNumber3 : Symbol(ResultIsNumber3, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 28, 3)) +>M : Symbol(M, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 18, 1)) + +var ResultIsNumber4 = ~obj; +>ResultIsNumber4 : Symbol(ResultIsNumber4, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 29, 3)) +>obj : Symbol(obj, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 5, 3)) + +var ResultIsNumber5 = ~obj1; +>ResultIsNumber5 : Symbol(ResultIsNumber5, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 30, 3)) +>obj1 : Symbol(obj1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 3)) + +// any type literal +var ResultIsNumber6 = ~undefined; +>ResultIsNumber6 : Symbol(ResultIsNumber6, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 33, 3)) +>undefined : Symbol(undefined) + +var ResultIsNumber7 = ~null; +>ResultIsNumber7 : Symbol(ResultIsNumber7, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 34, 3)) + +// any type expressions +var ResultIsNumber8 = ~ANY2[0] +>ResultIsNumber8 : Symbol(ResultIsNumber8, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 37, 3)) +>ANY2 : Symbol(ANY2, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 4, 3)) + +var ResultIsNumber9 = ~obj1.x; +>ResultIsNumber9 : Symbol(ResultIsNumber9, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 38, 3)) +>obj1.x : Symbol(x, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 12)) +>obj1 : Symbol(obj1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 3)) +>x : Symbol(x, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 12)) + +var ResultIsNumber10 = ~obj1.y; +>ResultIsNumber10 : Symbol(ResultIsNumber10, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 39, 3)) +>obj1.y : Symbol(y, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 18)) +>obj1 : Symbol(obj1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 3)) +>y : Symbol(y, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 18)) + +var ResultIsNumber11 = ~objA.a; +>ResultIsNumber11 : Symbol(ResultIsNumber11, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 40, 3)) +>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 12, 9)) +>objA : Symbol(objA, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 22, 3)) +>a : Symbol(A.a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 12, 9)) + +var ResultIsNumber12 = ~M.n; +>ResultIsNumber12 : Symbol(ResultIsNumber12, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 41, 3)) +>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 20, 14)) +>M : Symbol(M, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 18, 1)) +>n : Symbol(M.n, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 20, 14)) + +var ResultIsNumber13 = ~foo(); +>ResultIsNumber13 : Symbol(ResultIsNumber13, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 42, 3)) +>foo : Symbol(foo, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 33)) + +var ResultIsNumber14 = ~A.foo(); +>ResultIsNumber14 : Symbol(ResultIsNumber14, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 43, 3)) +>A.foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 13, 18)) +>A : Symbol(A, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 11, 1)) +>foo : Symbol(A.foo, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 13, 18)) + +var ResultIsNumber15 = ~(ANY + ANY1); +>ResultIsNumber15 : Symbol(ResultIsNumber15, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 44, 3)) +>ANY : Symbol(ANY, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 2, 3)) +>ANY1 : Symbol(ANY1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 3, 3)) + +var ResultIsNumber16 = ~(null + undefined); +>ResultIsNumber16 : Symbol(ResultIsNumber16, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 45, 3)) +>undefined : Symbol(undefined) + +var ResultIsNumber17 = ~(null + null); +>ResultIsNumber17 : Symbol(ResultIsNumber17, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 46, 3)) + +var ResultIsNumber18 = ~(undefined + undefined); +>ResultIsNumber18 : Symbol(ResultIsNumber18, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 47, 3)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +// multiple ~ operators +var ResultIsNumber19 = ~~ANY; +>ResultIsNumber19 : Symbol(ResultIsNumber19, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 50, 3)) +>ANY : Symbol(ANY, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 2, 3)) + +var ResultIsNumber20 = ~~~(ANY + ANY1); +>ResultIsNumber20 : Symbol(ResultIsNumber20, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 51, 3)) +>ANY : Symbol(ANY, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 2, 3)) +>ANY1 : Symbol(ANY1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 3, 3)) + +//miss assignment operators +~ANY; +>ANY : Symbol(ANY, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 2, 3)) + +~ANY1; +>ANY1 : Symbol(ANY1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 3, 3)) + +~ANY2[0]; +>ANY2 : Symbol(ANY2, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 4, 3)) + +~ANY, ANY1; +>ANY : Symbol(ANY, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 2, 3)) +>ANY1 : Symbol(ANY1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 3, 3)) + +~obj1.y; +>obj1.y : Symbol(y, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 18)) +>obj1 : Symbol(obj1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 3)) +>y : Symbol(y, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 18)) + +~objA.a; +>objA.a : Symbol(A.a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 12, 9)) +>objA : Symbol(objA, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 22, 3)) +>a : Symbol(A.a, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 12, 9)) + +~M.n; +>M.n : Symbol(M.n, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 20, 14)) +>M : Symbol(M, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 18, 1)) +>n : Symbol(M.n, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 20, 14)) + +~~obj1.x; +>obj1.x : Symbol(x, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 12)) +>obj1 : Symbol(obj1, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 3)) +>x : Symbol(x, Decl(bitwiseNotOperatorWithAnyOtherType.ts, 6, 12)) + diff --git a/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.types b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.types new file mode 100644 index 00000000000..6f691ca92f5 --- /dev/null +++ b/tests/baselines/reference/bitwiseNotOperatorWithAnyOtherType.types @@ -0,0 +1,249 @@ +=== tests/cases/conformance/expressions/unaryOperators/bitwiseNotOperator/bitwiseNotOperatorWithAnyOtherType.ts === +// ~ operator on any type + +var ANY: any; +>ANY : any + +var ANY1; +>ANY1 : any + +var ANY2: any[] = ["", ""]; +>ANY2 : any[] +>["", ""] : string[] +>"" : "" +>"" : "" + +var obj: () => {} +>obj : () => {} + +var obj1 = { x:"", y: () => { }}; +>obj1 : { x: string; y: () => void; } +>{ x:"", y: () => { }} : { x: string; y: () => void; } +>x : string +>"" : "" +>y : () => void +>() => { } : () => void + +function foo(): any { +>foo : () => any + + var a; +>a : any + + return a; +>a : any +} +class A { +>A : A + + public a: any; +>a : any + + static foo() { +>foo : () => any + + var a; +>a : any + + return a; +>a : any + } +} +module M { +>M : typeof M + + export var n: any; +>n : any +} +var objA = new A(); +>objA : A +>new A() : A +>A : typeof A + +// any other type var +var ResultIsNumber = ~ANY1; +>ResultIsNumber : number +>~ANY1 : number +>ANY1 : any + +var ResultIsNumber1 = ~ANY2; +>ResultIsNumber1 : number +>~ANY2 : number +>ANY2 : any[] + +var ResultIsNumber2 = ~A; +>ResultIsNumber2 : number +>~A : number +>A : typeof A + +var ResultIsNumber3 = ~M; +>ResultIsNumber3 : number +>~M : number +>M : typeof M + +var ResultIsNumber4 = ~obj; +>ResultIsNumber4 : number +>~obj : number +>obj : () => {} + +var ResultIsNumber5 = ~obj1; +>ResultIsNumber5 : number +>~obj1 : number +>obj1 : { x: string; y: () => void; } + +// any type literal +var ResultIsNumber6 = ~undefined; +>ResultIsNumber6 : number +>~undefined : number +>undefined : undefined + +var ResultIsNumber7 = ~null; +>ResultIsNumber7 : number +>~null : number +>null : null + +// any type expressions +var ResultIsNumber8 = ~ANY2[0] +>ResultIsNumber8 : number +>~ANY2[0] : number +>ANY2[0] : any +>ANY2 : any[] +>0 : 0 + +var ResultIsNumber9 = ~obj1.x; +>ResultIsNumber9 : number +>~obj1.x : number +>obj1.x : string +>obj1 : { x: string; y: () => void; } +>x : string + +var ResultIsNumber10 = ~obj1.y; +>ResultIsNumber10 : number +>~obj1.y : number +>obj1.y : () => void +>obj1 : { x: string; y: () => void; } +>y : () => void + +var ResultIsNumber11 = ~objA.a; +>ResultIsNumber11 : number +>~objA.a : number +>objA.a : any +>objA : A +>a : any + +var ResultIsNumber12 = ~M.n; +>ResultIsNumber12 : number +>~M.n : number +>M.n : any +>M : typeof M +>n : any + +var ResultIsNumber13 = ~foo(); +>ResultIsNumber13 : number +>~foo() : number +>foo() : any +>foo : () => any + +var ResultIsNumber14 = ~A.foo(); +>ResultIsNumber14 : number +>~A.foo() : number +>A.foo() : any +>A.foo : () => any +>A : typeof A +>foo : () => any + +var ResultIsNumber15 = ~(ANY + ANY1); +>ResultIsNumber15 : number +>~(ANY + ANY1) : number +>(ANY + ANY1) : any +>ANY + ANY1 : any +>ANY : any +>ANY1 : any + +var ResultIsNumber16 = ~(null + undefined); +>ResultIsNumber16 : number +>~(null + undefined) : number +>(null + undefined) : any +>null + undefined : any +>null : null +>undefined : undefined + +var ResultIsNumber17 = ~(null + null); +>ResultIsNumber17 : number +>~(null + null) : number +>(null + null) : any +>null + null : any +>null : null +>null : null + +var ResultIsNumber18 = ~(undefined + undefined); +>ResultIsNumber18 : number +>~(undefined + undefined) : number +>(undefined + undefined) : any +>undefined + undefined : any +>undefined : undefined +>undefined : undefined + +// multiple ~ operators +var ResultIsNumber19 = ~~ANY; +>ResultIsNumber19 : number +>~~ANY : number +>~ANY : number +>ANY : any + +var ResultIsNumber20 = ~~~(ANY + ANY1); +>ResultIsNumber20 : number +>~~~(ANY + ANY1) : number +>~~(ANY + ANY1) : number +>~(ANY + ANY1) : number +>(ANY + ANY1) : any +>ANY + ANY1 : any +>ANY : any +>ANY1 : any + +//miss assignment operators +~ANY; +>~ANY : number +>ANY : any + +~ANY1; +>~ANY1 : number +>ANY1 : any + +~ANY2[0]; +>~ANY2[0] : number +>ANY2[0] : any +>ANY2 : any[] +>0 : 0 + +~ANY, ANY1; +>~ANY, ANY1 : any +>~ANY : number +>ANY : any +>ANY1 : any + +~obj1.y; +>~obj1.y : number +>obj1.y : () => void +>obj1 : { x: string; y: () => void; } +>y : () => void + +~objA.a; +>~objA.a : number +>objA.a : any +>objA : A +>a : any + +~M.n; +>~M.n : number +>M.n : any +>M : typeof M +>n : any + +~~obj1.x; +>~~obj1.x : number +>~obj1.x : number +>obj1.x : string +>obj1 : { x: string; y: () => void; } +>x : string + diff --git a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.symbols b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.symbols new file mode 100644 index 00000000000..26c07aee531 --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts === +// 1: +for (let {[a]: a} of [{ }]) continue; +>a : Symbol(a, Decl(blockScopedBindingUsedBeforeDef.ts, 1, 10)) +>a : Symbol(a, Decl(blockScopedBindingUsedBeforeDef.ts, 1, 10)) + +// 2: +for (let {[a]: a} = { }; false; ) continue; +>a : Symbol(a, Decl(blockScopedBindingUsedBeforeDef.ts, 4, 10)) +>a : Symbol(a, Decl(blockScopedBindingUsedBeforeDef.ts, 4, 10)) + +// 3: +let {[b]: b} = { }; +>b : Symbol(b, Decl(blockScopedBindingUsedBeforeDef.ts, 7, 5)) +>b : Symbol(b, Decl(blockScopedBindingUsedBeforeDef.ts, 7, 5)) + diff --git a/tests/baselines/reference/blockScopedBindingUsedBeforeDef.types b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.types new file mode 100644 index 00000000000..9548aa7735d --- /dev/null +++ b/tests/baselines/reference/blockScopedBindingUsedBeforeDef.types @@ -0,0 +1,21 @@ +=== tests/cases/compiler/blockScopedBindingUsedBeforeDef.ts === +// 1: +for (let {[a]: a} of [{ }]) continue; +>a : any +>a : any +>[{ }] : {}[] +>{ } : {} + +// 2: +for (let {[a]: a} = { }; false; ) continue; +>a : any +>a : any +>{ } : {} +>false : false + +// 3: +let {[b]: b} = { }; +>b : any +>b : any +>{ } : {} + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationInStrictClass.symbols b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictClass.symbols new file mode 100644 index 00000000000..f4358dc158a --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictClass.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationInStrictClass.ts === +class c { +>c : Symbol(c, Decl(blockScopedFunctionDeclarationInStrictClass.ts, 0, 0)) + + method() { +>method : Symbol(c.method, Decl(blockScopedFunctionDeclarationInStrictClass.ts, 0, 9)) + + if (true) { + function foo() { } +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationInStrictClass.ts, 2, 19)) + + foo(); // ok +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationInStrictClass.ts, 2, 19)) + } + foo(); // not ok + } +} diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationInStrictClass.types b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictClass.types new file mode 100644 index 00000000000..4d16941aff0 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictClass.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationInStrictClass.ts === +class c { +>c : c + + method() { +>method : () => void + + if (true) { +>true : true + + function foo() { } +>foo : () => void + + foo(); // ok +>foo() : void +>foo : () => void + } + foo(); // not ok +>foo() : any +>foo : any + } +} diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.symbols b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.symbols new file mode 100644 index 00000000000..95f22f59563 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationInStrictModule.ts === +if (true) { + function foo() { } +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationInStrictModule.ts, 0, 11)) + + foo(); // ok +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationInStrictModule.ts, 0, 11)) +} + +export = foo; // not ok diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.types b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.types new file mode 100644 index 00000000000..f0b9693ed70 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationInStrictModule.ts === +if (true) { +>true : true + + function foo() { } +>foo : () => void + + foo(); // ok +>foo() : void +>foo : () => void +} + +export = foo; // not ok +>foo : No type information available! + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.symbols b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.symbols new file mode 100644 index 00000000000..f72d7b2b5b8 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts === +"use strict"; +if (true) { + function foo() { } // Error to declare function in block scope +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES5.ts, 1, 11)) + + foo(); // This call should be ok +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES5.ts, 1, 11)) +} +foo(); // Error to find name foo diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.types b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.types new file mode 100644 index 00000000000..1c87ccf9227 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES5.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationStrictES5.ts === +"use strict"; +>"use strict" : "use strict" + +if (true) { +>true : true + + function foo() { } // Error to declare function in block scope +>foo : () => void + + foo(); // This call should be ok +>foo() : void +>foo : () => void +} +foo(); // Error to find name foo +>foo() : any +>foo : any + diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.symbols b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.symbols new file mode 100644 index 00000000000..fc8693231af --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts === +"use strict"; +if (true) { + function foo() { } // Allowed to declare block scope function +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES6.ts, 1, 11)) + + foo(); // This call should be ok +>foo : Symbol(foo, Decl(blockScopedFunctionDeclarationStrictES6.ts, 1, 11)) +} +foo(); // Cannot find name since foo is block scoped diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.types b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.types new file mode 100644 index 00000000000..174644fd610 --- /dev/null +++ b/tests/baselines/reference/blockScopedFunctionDeclarationStrictES6.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/blockScopedFunctionDeclarationStrictES6.ts === +"use strict"; +>"use strict" : "use strict" + +if (true) { +>true : true + + function foo() { } // Allowed to declare block scope function +>foo : () => void + + foo(); // This call should be ok +>foo() : void +>foo : () => void +} +foo(); // Cannot find name since foo is block scoped +>foo() : any +>foo : any + diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.symbols b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.symbols new file mode 100644 index 00000000000..23df33b8ba4 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts === +function foo(a: number) { +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 0, 0)) +>a : Symbol(a, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 0, 13)) + + if (a === 1) { +>a : Symbol(a, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 0, 13)) + + function foo() { } // duplicate function +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 1, 18), Decl(blockScopedSameNameFunctionDeclarationES5.ts, 6, 10)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 1, 18), Decl(blockScopedSameNameFunctionDeclarationES5.ts, 6, 10)) + + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 1, 18), Decl(blockScopedSameNameFunctionDeclarationES5.ts, 6, 10)) + } + else { + function foo() { } // duplicate function +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 1, 18), Decl(blockScopedSameNameFunctionDeclarationES5.ts, 6, 10)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 1, 18), Decl(blockScopedSameNameFunctionDeclarationES5.ts, 6, 10)) + + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 1, 18), Decl(blockScopedSameNameFunctionDeclarationES5.ts, 6, 10)) + } + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 1, 18), Decl(blockScopedSameNameFunctionDeclarationES5.ts, 6, 10)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 1, 18), Decl(blockScopedSameNameFunctionDeclarationES5.ts, 6, 10)) +} +foo(10); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 0, 0)) + +foo(); // not ok - needs number +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES5.ts, 0, 0)) + diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.types b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.types new file mode 100644 index 00000000000..ca53002f949 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts === +function foo(a: number) { +>foo : (a: number) => void +>a : number + + if (a === 1) { +>a === 1 : boolean +>a : number +>1 : 1 + + function foo() { } // duplicate function +>foo : { (): void; (): void; } + + foo(); +>foo() : void +>foo : { (): void; (): void; } + + foo(10); // not ok +>foo(10) : any +>foo : { (): void; (): void; } +>10 : 10 + } + else { + function foo() { } // duplicate function +>foo : { (): void; (): void; } + + foo(); +>foo() : void +>foo : { (): void; (): void; } + + foo(10); // not ok +>foo(10) : any +>foo : { (): void; (): void; } +>10 : 10 + } + foo(10); // not ok +>foo(10) : any +>foo : { (): void; (): void; } +>10 : 10 + + foo(); +>foo() : void +>foo : { (): void; (): void; } +} +foo(10); +>foo(10) : void +>foo : (a: number) => void +>10 : 10 + +foo(); // not ok - needs number +>foo() : void +>foo : (a: number) => void + diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.symbols b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.symbols new file mode 100644 index 00000000000..551d5dd413a --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts === +function foo(a: number) { +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 0, 0)) +>a : Symbol(a, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 0, 13)) + + if (a === 10) { +>a : Symbol(a, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 0, 13)) + + function foo() { } // duplicate +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 1, 19), Decl(blockScopedSameNameFunctionDeclarationES6.ts, 6, 10)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 1, 19), Decl(blockScopedSameNameFunctionDeclarationES6.ts, 6, 10)) + + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 1, 19), Decl(blockScopedSameNameFunctionDeclarationES6.ts, 6, 10)) + } + else { + function foo() { } // duplicate +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 1, 19), Decl(blockScopedSameNameFunctionDeclarationES6.ts, 6, 10)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 1, 19), Decl(blockScopedSameNameFunctionDeclarationES6.ts, 6, 10)) + + foo(10);// not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 1, 19), Decl(blockScopedSameNameFunctionDeclarationES6.ts, 6, 10)) + } + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 1, 19), Decl(blockScopedSameNameFunctionDeclarationES6.ts, 6, 10)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 1, 19), Decl(blockScopedSameNameFunctionDeclarationES6.ts, 6, 10)) +} +foo(10); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 0, 0)) + +foo(); // not ok - needs number +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationES6.ts, 0, 0)) + diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.types b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.types new file mode 100644 index 00000000000..982ace6809c --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts === +function foo(a: number) { +>foo : (a: number) => void +>a : number + + if (a === 10) { +>a === 10 : boolean +>a : number +>10 : 10 + + function foo() { } // duplicate +>foo : { (): void; (): void; } + + foo(); +>foo() : void +>foo : { (): void; (): void; } + + foo(10); // not ok +>foo(10) : any +>foo : { (): void; (): void; } +>10 : 10 + } + else { + function foo() { } // duplicate +>foo : { (): void; (): void; } + + foo(); +>foo() : void +>foo : { (): void; (): void; } + + foo(10);// not ok +>foo(10) : any +>foo : { (): void; (): void; } +>10 : 10 + } + foo(10); // not ok +>foo(10) : any +>foo : { (): void; (): void; } +>10 : 10 + + foo(); +>foo() : void +>foo : { (): void; (): void; } +} +foo(10); +>foo(10) : void +>foo : (a: number) => void +>10 : 10 + +foo(); // not ok - needs number +>foo() : void +>foo : (a: number) => void + diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.symbols b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.symbols new file mode 100644 index 00000000000..b7603713a41 --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts === +"use strict"; +function foo(a: number) { +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 0, 13)) +>a : Symbol(a, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 1, 13)) + + if (a === 1) { +>a : Symbol(a, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 1, 13)) + + function foo() { } // Error to declare function in block scope +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 2, 18)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 2, 18)) + + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 2, 18)) + } + else { + function foo() { } // Error to declare function in block scope +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 7, 10)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 7, 10)) + + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 7, 10)) + } + foo(10); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 0, 13)) + + foo(); // not ok - needs number +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 0, 13)) +} +foo(10); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 0, 13)) + +foo(); // not ok - needs number +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES5.ts, 0, 13)) + diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.types b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.types new file mode 100644 index 00000000000..d3f4ff88f6e --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.types @@ -0,0 +1,56 @@ +=== tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts === +"use strict"; +>"use strict" : "use strict" + +function foo(a: number) { +>foo : (a: number) => void +>a : number + + if (a === 1) { +>a === 1 : boolean +>a : number +>1 : 1 + + function foo() { } // Error to declare function in block scope +>foo : () => void + + foo(); +>foo() : void +>foo : () => void + + foo(10); // not ok +>foo(10) : void +>foo : () => void +>10 : 10 + } + else { + function foo() { } // Error to declare function in block scope +>foo : () => void + + foo(); +>foo() : void +>foo : () => void + + foo(10); // not ok +>foo(10) : void +>foo : () => void +>10 : 10 + } + foo(10); +>foo(10) : void +>foo : (a: number) => void +>10 : 10 + + foo(); // not ok - needs number +>foo() : void +>foo : (a: number) => void +} +foo(10); +>foo(10) : void +>foo : (a: number) => void +>10 : 10 + +foo(); // not ok - needs number +>foo() : void +>foo : (a: number) => void + diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.symbols b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.symbols new file mode 100644 index 00000000000..65adc9fcb1f --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.symbols @@ -0,0 +1,40 @@ +=== tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts === +"use strict"; +function foo(a: number) { +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 0, 13)) +>a : Symbol(a, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 1, 13)) + + if (a === 10) { +>a : Symbol(a, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 1, 13)) + + function foo() { } +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 2, 19)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 2, 19)) + + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 2, 19)) + } + else { + function foo() { } +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 7, 10)) + + foo(); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 7, 10)) + + foo(10); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 7, 10)) + } + foo(10); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 0, 13)) + + foo(); // not ok +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 0, 13)) +} +foo(10); +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 0, 13)) + +foo(); // not ok - needs number +>foo : Symbol(foo, Decl(blockScopedSameNameFunctionDeclarationStrictES6.ts, 0, 13)) + diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.types b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.types new file mode 100644 index 00000000000..c80d4d1372a --- /dev/null +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.types @@ -0,0 +1,56 @@ +=== tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts === +"use strict"; +>"use strict" : "use strict" + +function foo(a: number) { +>foo : (a: number) => void +>a : number + + if (a === 10) { +>a === 10 : boolean +>a : number +>10 : 10 + + function foo() { } +>foo : () => void + + foo(); +>foo() : void +>foo : () => void + + foo(10); // not ok +>foo(10) : void +>foo : () => void +>10 : 10 + } + else { + function foo() { } +>foo : () => void + + foo(); +>foo() : void +>foo : () => void + + foo(10); // not ok +>foo(10) : void +>foo : () => void +>10 : 10 + } + foo(10); +>foo(10) : void +>foo : (a: number) => void +>10 : 10 + + foo(); // not ok +>foo() : void +>foo : (a: number) => void +} +foo(10); +>foo(10) : void +>foo : (a: number) => void +>10 : 10 + +foo(); // not ok - needs number +>foo() : void +>foo : (a: number) => void + diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.symbols b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.symbols new file mode 100644 index 00000000000..9dcb26712fb --- /dev/null +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.symbols @@ -0,0 +1,214 @@ +=== tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts === +function foo0() { +>foo0 : Symbol(foo0, Decl(blockScopedVariablesUseBeforeDef.ts, 0, 0)) + + let a = x; +>a : Symbol(a, Decl(blockScopedVariablesUseBeforeDef.ts, 1, 7)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 2, 7)) + + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 2, 7)) +} + +function foo1() { +>foo1 : Symbol(foo1, Decl(blockScopedVariablesUseBeforeDef.ts, 3, 1)) + + let a = () => x; +>a : Symbol(a, Decl(blockScopedVariablesUseBeforeDef.ts, 6, 7)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 7, 7)) + + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 7, 7)) +} + +function foo2() { +>foo2 : Symbol(foo2, Decl(blockScopedVariablesUseBeforeDef.ts, 8, 1)) + + let a = function () { return x; } +>a : Symbol(a, Decl(blockScopedVariablesUseBeforeDef.ts, 11, 7)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 12, 7)) + + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 12, 7)) +} + +function foo3() { +>foo3 : Symbol(foo3, Decl(blockScopedVariablesUseBeforeDef.ts, 13, 1)) + + class X { +>X : Symbol(X, Decl(blockScopedVariablesUseBeforeDef.ts, 15, 17)) + + m() { return x;} +>m : Symbol(X.m, Decl(blockScopedVariablesUseBeforeDef.ts, 16, 13)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 19, 7)) + } + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 19, 7)) +} + +function foo4() { +>foo4 : Symbol(foo4, Decl(blockScopedVariablesUseBeforeDef.ts, 20, 1)) + + let y = class { +>y : Symbol(y, Decl(blockScopedVariablesUseBeforeDef.ts, 23, 7)) + + m() { return x; } +>m : Symbol(y.m, Decl(blockScopedVariablesUseBeforeDef.ts, 23, 19)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 26, 7)) + + }; + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 26, 7)) +} + +function foo5() { +>foo5 : Symbol(foo5, Decl(blockScopedVariablesUseBeforeDef.ts, 27, 1)) + + let x = () => y; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 30, 7)) +>y : Symbol(y, Decl(blockScopedVariablesUseBeforeDef.ts, 31, 7)) + + let y = () => x; +>y : Symbol(y, Decl(blockScopedVariablesUseBeforeDef.ts, 31, 7)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 30, 7)) +} + +function foo6() { +>foo6 : Symbol(foo6, Decl(blockScopedVariablesUseBeforeDef.ts, 32, 1)) + + function f() { +>f : Symbol(f, Decl(blockScopedVariablesUseBeforeDef.ts, 34, 17)) + + return x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 38, 7)) + } + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 38, 7)) +} + +function foo7() { +>foo7 : Symbol(foo7, Decl(blockScopedVariablesUseBeforeDef.ts, 39, 1)) + + class A { +>A : Symbol(A, Decl(blockScopedVariablesUseBeforeDef.ts, 41, 17)) + + a = x; +>a : Symbol(A.a, Decl(blockScopedVariablesUseBeforeDef.ts, 42, 13)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 45, 7)) + } + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 45, 7)) +} + +function foo8() { +>foo8 : Symbol(foo8, Decl(blockScopedVariablesUseBeforeDef.ts, 46, 1)) + + let y = class { +>y : Symbol(y, Decl(blockScopedVariablesUseBeforeDef.ts, 49, 7)) + + a = x; +>a : Symbol(y.a, Decl(blockScopedVariablesUseBeforeDef.ts, 49, 19)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 52, 7)) + } + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 52, 7)) +} + +function foo9() { +>foo9 : Symbol(foo9, Decl(blockScopedVariablesUseBeforeDef.ts, 53, 1)) + + let y = class { +>y : Symbol(y, Decl(blockScopedVariablesUseBeforeDef.ts, 56, 7)) + + static a = x; +>a : Symbol(y.a, Decl(blockScopedVariablesUseBeforeDef.ts, 56, 19)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 59, 7)) + } + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 59, 7)) +} + +function foo10() { +>foo10 : Symbol(foo10, Decl(blockScopedVariablesUseBeforeDef.ts, 60, 1)) + + class A { +>A : Symbol(A, Decl(blockScopedVariablesUseBeforeDef.ts, 62, 18)) + + static a = x; +>a : Symbol(A.a, Decl(blockScopedVariablesUseBeforeDef.ts, 63, 13)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 66, 7)) + } + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 66, 7)) +} + +function foo11() { +>foo11 : Symbol(foo11, Decl(blockScopedVariablesUseBeforeDef.ts, 67, 1)) + + function f () { +>f : Symbol(f, Decl(blockScopedVariablesUseBeforeDef.ts, 69, 18)) + + let y = class { +>y : Symbol(y, Decl(blockScopedVariablesUseBeforeDef.ts, 71, 11)) + + static a = x; +>a : Symbol(y.a, Decl(blockScopedVariablesUseBeforeDef.ts, 71, 23)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 75, 7)) + } + } + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 75, 7)) +} + +function foo12() { +>foo12 : Symbol(foo12, Decl(blockScopedVariablesUseBeforeDef.ts, 76, 1)) + + function f () { +>f : Symbol(f, Decl(blockScopedVariablesUseBeforeDef.ts, 78, 18)) + + let y = class { +>y : Symbol(y, Decl(blockScopedVariablesUseBeforeDef.ts, 80, 11)) + + a; +>a : Symbol(y.a, Decl(blockScopedVariablesUseBeforeDef.ts, 80, 23)) + + constructor() { + this.a = x; +>this.a : Symbol(y.a, Decl(blockScopedVariablesUseBeforeDef.ts, 80, 23)) +>this : Symbol(y, Decl(blockScopedVariablesUseBeforeDef.ts, 80, 15)) +>a : Symbol(y.a, Decl(blockScopedVariablesUseBeforeDef.ts, 80, 23)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 87, 7)) + } + } + } + let x; +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 87, 7)) +} + +function foo13() { +>foo13 : Symbol(foo13, Decl(blockScopedVariablesUseBeforeDef.ts, 88, 1)) + + let a = { +>a : Symbol(a, Decl(blockScopedVariablesUseBeforeDef.ts, 91, 7)) + + get a() { return x } +>a : Symbol(a, Decl(blockScopedVariablesUseBeforeDef.ts, 91, 13)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 94, 7)) + } + let x +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 94, 7)) +} + +function foo14() { +>foo14 : Symbol(foo14, Decl(blockScopedVariablesUseBeforeDef.ts, 95, 1)) + + let a = { +>a : Symbol(a, Decl(blockScopedVariablesUseBeforeDef.ts, 98, 7)) + + a: x +>a : Symbol(a, Decl(blockScopedVariablesUseBeforeDef.ts, 98, 13)) +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 101, 7)) + } + let x +>x : Symbol(x, Decl(blockScopedVariablesUseBeforeDef.ts, 101, 7)) +} diff --git a/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types new file mode 100644 index 00000000000..771518e5901 --- /dev/null +++ b/tests/baselines/reference/blockScopedVariablesUseBeforeDef.types @@ -0,0 +1,226 @@ +=== tests/cases/compiler/blockScopedVariablesUseBeforeDef.ts === +function foo0() { +>foo0 : () => void + + let a = x; +>a : any +>x : any + + let x; +>x : any +} + +function foo1() { +>foo1 : () => void + + let a = () => x; +>a : () => any +>() => x : () => any +>x : any + + let x; +>x : any +} + +function foo2() { +>foo2 : () => void + + let a = function () { return x; } +>a : () => any +>function () { return x; } : () => any +>x : any + + let x; +>x : any +} + +function foo3() { +>foo3 : () => void + + class X { +>X : X + + m() { return x;} +>m : () => any +>x : any + } + let x; +>x : any +} + +function foo4() { +>foo4 : () => void + + let y = class { +>y : typeof y +>class { m() { return x; } } : typeof y + + m() { return x; } +>m : () => any +>x : any + + }; + let x; +>x : any +} + +function foo5() { +>foo5 : () => void + + let x = () => y; +>x : () => () => any +>() => y : () => () => any +>y : () => () => any + + let y = () => x; +>y : () => () => any +>() => x : () => () => any +>x : () => () => any +} + +function foo6() { +>foo6 : () => void + + function f() { +>f : () => any + + return x; +>x : any + } + let x; +>x : any +} + +function foo7() { +>foo7 : () => void + + class A { +>A : A + + a = x; +>a : any +>x : any + } + let x; +>x : any +} + +function foo8() { +>foo8 : () => void + + let y = class { +>y : typeof y +>class { a = x; } : typeof y + + a = x; +>a : any +>x : any + } + let x; +>x : any +} + +function foo9() { +>foo9 : () => void + + let y = class { +>y : typeof y +>class { static a = x; } : typeof y + + static a = x; +>a : any +>x : any + } + let x; +>x : any +} + +function foo10() { +>foo10 : () => void + + class A { +>A : A + + static a = x; +>a : any +>x : any + } + let x; +>x : any +} + +function foo11() { +>foo11 : () => void + + function f () { +>f : () => void + + let y = class { +>y : typeof y +>class { static a = x; } : typeof y + + static a = x; +>a : any +>x : any + } + } + let x; +>x : any +} + +function foo12() { +>foo12 : () => void + + function f () { +>f : () => void + + let y = class { +>y : typeof y +>class { a; constructor() { this.a = x; } } : typeof y + + a; +>a : any + + constructor() { + this.a = x; +>this.a = x : any +>this.a : any +>this : this +>a : any +>x : any + } + } + } + let x; +>x : any +} + +function foo13() { +>foo13 : () => void + + let a = { +>a : { readonly a: any; } +>{ get a() { return x } } : { readonly a: any; } + + get a() { return x } +>a : any +>x : any + } + let x +>x : any +} + +function foo14() { +>foo14 : () => void + + let a = { +>a : { a: any; } +>{ a: x } : { a: any; } + + a: x +>a : any +>x : any + } + let x +>x : any +} diff --git a/tests/baselines/reference/bluebirdStaticThis.symbols b/tests/baselines/reference/bluebirdStaticThis.symbols new file mode 100644 index 00000000000..0fc0cb41bb9 --- /dev/null +++ b/tests/baselines/reference/bluebirdStaticThis.symbols @@ -0,0 +1,1170 @@ +=== tests/cases/compiler/bluebirdStaticThis.ts === +// This version is reduced from the full d.ts by removing almost all the tests +// and all the comments. +// Then it adds explicit `this` arguments to the static members. +// Tests by: Bart van der Schoor +export declare class Promise implements Promise.Thenable { +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 4, 29)) +>Promise.Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 4, 29)) + + constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable) => void, reject: (error: any) => void) => void); +>callback : Symbol(callback, Decl(bluebirdStaticThis.ts, 5, 13)) +>resolve : Symbol(resolve, Decl(bluebirdStaticThis.ts, 5, 24)) +>thenableOrResult : Symbol(thenableOrResult, Decl(bluebirdStaticThis.ts, 5, 34)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 4, 29)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 4, 29)) +>reject : Symbol(reject, Decl(bluebirdStaticThis.ts, 5, 85)) +>error : Symbol(error, Decl(bluebirdStaticThis.ts, 5, 95)) + + static try(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; +>try : Symbol(Promise.try, Decl(bluebirdStaticThis.ts, 5, 125), Decl(bluebirdStaticThis.ts, 6, 107)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 6, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 6, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>fn : Symbol(fn, Decl(bluebirdStaticThis.ts, 6, 38)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 6, 15)) +>args : Symbol(args, Decl(bluebirdStaticThis.ts, 6, 69)) +>ctx : Symbol(ctx, Decl(bluebirdStaticThis.ts, 6, 83)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 6, 15)) + + static try(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; +>try : Symbol(Promise.try, Decl(bluebirdStaticThis.ts, 5, 125), Decl(bluebirdStaticThis.ts, 6, 107)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 7, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 7, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>fn : Symbol(fn, Decl(bluebirdStaticThis.ts, 7, 38)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 7, 15)) +>args : Symbol(args, Decl(bluebirdStaticThis.ts, 7, 51)) +>ctx : Symbol(ctx, Decl(bluebirdStaticThis.ts, 7, 65)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 7, 15)) + + static attempt(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; +>attempt : Symbol(Promise.attempt, Decl(bluebirdStaticThis.ts, 7, 89), Decl(bluebirdStaticThis.ts, 9, 111)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 9, 19)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 9, 22)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>fn : Symbol(fn, Decl(bluebirdStaticThis.ts, 9, 42)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 9, 19)) +>args : Symbol(args, Decl(bluebirdStaticThis.ts, 9, 73)) +>ctx : Symbol(ctx, Decl(bluebirdStaticThis.ts, 9, 87)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 9, 19)) + + static attempt(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; +>attempt : Symbol(Promise.attempt, Decl(bluebirdStaticThis.ts, 7, 89), Decl(bluebirdStaticThis.ts, 9, 111)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 10, 19)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 10, 22)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>fn : Symbol(fn, Decl(bluebirdStaticThis.ts, 10, 42)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 10, 19)) +>args : Symbol(args, Decl(bluebirdStaticThis.ts, 10, 55)) +>ctx : Symbol(ctx, Decl(bluebirdStaticThis.ts, 10, 69)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 10, 19)) + + static method(dit: typeof Promise, fn: Function): Function; +>method : Symbol(Promise.method, Decl(bluebirdStaticThis.ts, 10, 93)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 12, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>fn : Symbol(fn, Decl(bluebirdStaticThis.ts, 12, 38)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + static resolve(dit: typeof Promise): Promise; +>resolve : Symbol(Promise.resolve, Decl(bluebirdStaticThis.ts, 12, 63), Decl(bluebirdStaticThis.ts, 14, 55), Decl(bluebirdStaticThis.ts, 15, 83)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 14, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + static resolve(dit: typeof Promise, value: Promise.Thenable): Promise; +>resolve : Symbol(Promise.resolve, Decl(bluebirdStaticThis.ts, 12, 63), Decl(bluebirdStaticThis.ts, 14, 55), Decl(bluebirdStaticThis.ts, 15, 83)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 15, 19)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 15, 22)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 15, 42)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 15, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 15, 19)) + + static resolve(dit: typeof Promise, value: R): Promise; +>resolve : Symbol(Promise.resolve, Decl(bluebirdStaticThis.ts, 12, 63), Decl(bluebirdStaticThis.ts, 14, 55), Decl(bluebirdStaticThis.ts, 15, 83)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 16, 19)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 16, 22)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 16, 42)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 16, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 16, 19)) + + static reject(dit: typeof Promise, reason: any): Promise; +>reject : Symbol(Promise.reject, Decl(bluebirdStaticThis.ts, 16, 65), Decl(bluebirdStaticThis.ts, 18, 66)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 18, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>reason : Symbol(reason, Decl(bluebirdStaticThis.ts, 18, 38)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + static reject(dit: typeof Promise, reason: any): Promise; +>reject : Symbol(Promise.reject, Decl(bluebirdStaticThis.ts, 16, 65), Decl(bluebirdStaticThis.ts, 18, 66)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 19, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 19, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>reason : Symbol(reason, Decl(bluebirdStaticThis.ts, 19, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 19, 18)) + + static defer(dit: typeof Promise): Promise.Resolver; +>defer : Symbol(Promise.defer, Decl(bluebirdStaticThis.ts, 19, 67)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 21, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 21, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 21, 17)) + + static cast(dit: typeof Promise, value: Promise.Thenable): Promise; +>cast : Symbol(Promise.cast, Decl(bluebirdStaticThis.ts, 21, 62), Decl(bluebirdStaticThis.ts, 23, 80)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 23, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 23, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 23, 39)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 23, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 23, 16)) + + static cast(dit: typeof Promise, value: R): Promise; +>cast : Symbol(Promise.cast, Decl(bluebirdStaticThis.ts, 21, 62), Decl(bluebirdStaticThis.ts, 23, 80)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 24, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 24, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 24, 39)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 24, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 24, 16)) + + static bind(dit: typeof Promise, thisArg: any): Promise; +>bind : Symbol(Promise.bind, Decl(bluebirdStaticThis.ts, 24, 62)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 26, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>thisArg : Symbol(thisArg, Decl(bluebirdStaticThis.ts, 26, 36)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + static is(dit: typeof Promise, value: any): boolean; +>is : Symbol(Promise.is, Decl(bluebirdStaticThis.ts, 26, 66)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 28, 14)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 28, 34)) + + static longStackTraces(dit: typeof Promise): void; +>longStackTraces : Symbol(Promise.longStackTraces, Decl(bluebirdStaticThis.ts, 28, 56)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 30, 27)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + static delay(dit: typeof Promise, value: Promise.Thenable, ms: number): Promise; +>delay : Symbol(Promise.delay, Decl(bluebirdStaticThis.ts, 30, 54), Decl(bluebirdStaticThis.ts, 32, 93), Decl(bluebirdStaticThis.ts, 33, 75)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 32, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 32, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 32, 40)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 32, 17)) +>ms : Symbol(ms, Decl(bluebirdStaticThis.ts, 32, 68)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 32, 17)) + + static delay(dit: typeof Promise, value: R, ms: number): Promise; +>delay : Symbol(Promise.delay, Decl(bluebirdStaticThis.ts, 30, 54), Decl(bluebirdStaticThis.ts, 32, 93), Decl(bluebirdStaticThis.ts, 33, 75)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 33, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 33, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 33, 40)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 33, 17)) +>ms : Symbol(ms, Decl(bluebirdStaticThis.ts, 33, 50)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 33, 17)) + + static delay(dit: typeof Promise, ms: number): Promise; +>delay : Symbol(Promise.delay, Decl(bluebirdStaticThis.ts, 30, 54), Decl(bluebirdStaticThis.ts, 32, 93), Decl(bluebirdStaticThis.ts, 33, 75)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 34, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>ms : Symbol(ms, Decl(bluebirdStaticThis.ts, 34, 37)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + static promisify(dit: typeof Promise, nodeFunction: Function, receiver?: any): Function; +>promisify : Symbol(Promise.promisify, Decl(bluebirdStaticThis.ts, 34, 65)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 36, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>nodeFunction : Symbol(nodeFunction, Decl(bluebirdStaticThis.ts, 36, 41)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>receiver : Symbol(receiver, Decl(bluebirdStaticThis.ts, 36, 65)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + static promisifyAll(dit: typeof Promise, target: Object): Object; +>promisifyAll : Symbol(Promise.promisifyAll, Decl(bluebirdStaticThis.ts, 36, 92)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 38, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>target : Symbol(target, Decl(bluebirdStaticThis.ts, 38, 44)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + static coroutine(dit: typeof Promise, generatorFunction: Function): Function; +>coroutine : Symbol(Promise.coroutine, Decl(bluebirdStaticThis.ts, 38, 69)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 40, 21)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 40, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>generatorFunction : Symbol(generatorFunction, Decl(bluebirdStaticThis.ts, 40, 44)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + static spawn(dit: typeof Promise, generatorFunction: Function): Promise; +>spawn : Symbol(Promise.spawn, Decl(bluebirdStaticThis.ts, 40, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 42, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 42, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>generatorFunction : Symbol(generatorFunction, Decl(bluebirdStaticThis.ts, 42, 40)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 42, 17)) + + static noConflict(dit: typeof Promise): typeof Promise; +>noConflict : Symbol(Promise.noConflict, Decl(bluebirdStaticThis.ts, 42, 82)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 44, 22)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + static onPossiblyUnhandledRejection(dit: typeof Promise, handler: (reason: any) => any): void; +>onPossiblyUnhandledRejection : Symbol(Promise.onPossiblyUnhandledRejection, Decl(bluebirdStaticThis.ts, 44, 59)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 46, 40)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>handler : Symbol(handler, Decl(bluebirdStaticThis.ts, 46, 60)) +>reason : Symbol(reason, Decl(bluebirdStaticThis.ts, 46, 71)) + + static all(dit: typeof Promise, values: Promise.Thenable[]>): Promise; +>all : Symbol(Promise.all, Decl(bluebirdStaticThis.ts, 46, 98), Decl(bluebirdStaticThis.ts, 48, 102), Decl(bluebirdStaticThis.ts, 49, 84), Decl(bluebirdStaticThis.ts, 50, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 48, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 48, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 48, 38)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 48, 15)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 48, 15)) + + static all(dit: typeof Promise, values: Promise.Thenable): Promise; +>all : Symbol(Promise.all, Decl(bluebirdStaticThis.ts, 46, 98), Decl(bluebirdStaticThis.ts, 48, 102), Decl(bluebirdStaticThis.ts, 49, 84), Decl(bluebirdStaticThis.ts, 50, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 49, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 49, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 49, 38)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 49, 15)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 49, 15)) + + static all(dit: typeof Promise, values: Promise.Thenable[]): Promise; +>all : Symbol(Promise.all, Decl(bluebirdStaticThis.ts, 46, 98), Decl(bluebirdStaticThis.ts, 48, 102), Decl(bluebirdStaticThis.ts, 49, 84), Decl(bluebirdStaticThis.ts, 50, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 50, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 50, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 50, 38)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 50, 15)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 50, 15)) + + static all(dit: typeof Promise, values: R[]): Promise; +>all : Symbol(Promise.all, Decl(bluebirdStaticThis.ts, 46, 98), Decl(bluebirdStaticThis.ts, 48, 102), Decl(bluebirdStaticThis.ts, 49, 84), Decl(bluebirdStaticThis.ts, 50, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 51, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 51, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 51, 38)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 51, 15)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 51, 15)) + + static props(dit: typeof Promise, object: Promise): Promise; +>props : Symbol(Promise.props, Decl(bluebirdStaticThis.ts, 51, 66), Decl(bluebirdStaticThis.ts, 53, 80)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 53, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>object : Symbol(object, Decl(bluebirdStaticThis.ts, 53, 37)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + static props(dit: typeof Promise, object: Object): Promise; +>props : Symbol(Promise.props, Decl(bluebirdStaticThis.ts, 51, 66), Decl(bluebirdStaticThis.ts, 53, 80)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 54, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>object : Symbol(object, Decl(bluebirdStaticThis.ts, 54, 37)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + static settle(dit: typeof Promise, values: Promise.Thenable[]>): Promise[]>; +>settle : Symbol(Promise.settle, Decl(bluebirdStaticThis.ts, 54, 71), Decl(bluebirdStaticThis.ts, 56, 125), Decl(bluebirdStaticThis.ts, 57, 107), Decl(bluebirdStaticThis.ts, 58, 107)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 56, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 56, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 56, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 56, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 56, 18)) + + static settle(dit: typeof Promise, values: Promise.Thenable): Promise[]>; +>settle : Symbol(Promise.settle, Decl(bluebirdStaticThis.ts, 54, 71), Decl(bluebirdStaticThis.ts, 56, 125), Decl(bluebirdStaticThis.ts, 57, 107), Decl(bluebirdStaticThis.ts, 58, 107)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 57, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 57, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 57, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 57, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 57, 18)) + + static settle(dit: typeof Promise, values: Promise.Thenable[]): Promise[]>; +>settle : Symbol(Promise.settle, Decl(bluebirdStaticThis.ts, 54, 71), Decl(bluebirdStaticThis.ts, 56, 125), Decl(bluebirdStaticThis.ts, 57, 107), Decl(bluebirdStaticThis.ts, 58, 107)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 58, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 58, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 58, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 58, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 58, 18)) + + static settle(dit: typeof Promise, values: R[]): Promise[]>; +>settle : Symbol(Promise.settle, Decl(bluebirdStaticThis.ts, 54, 71), Decl(bluebirdStaticThis.ts, 56, 125), Decl(bluebirdStaticThis.ts, 57, 107), Decl(bluebirdStaticThis.ts, 58, 107)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 59, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 59, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 59, 41)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 59, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 59, 18)) + + static any(dit: typeof Promise, values: Promise.Thenable[]>): Promise; +>any : Symbol(Promise.any, Decl(bluebirdStaticThis.ts, 59, 89), Decl(bluebirdStaticThis.ts, 61, 100), Decl(bluebirdStaticThis.ts, 62, 82), Decl(bluebirdStaticThis.ts, 63, 82)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 61, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 61, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 61, 38)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 61, 15)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 61, 15)) + + static any(dit: typeof Promise, values: Promise.Thenable): Promise; +>any : Symbol(Promise.any, Decl(bluebirdStaticThis.ts, 59, 89), Decl(bluebirdStaticThis.ts, 61, 100), Decl(bluebirdStaticThis.ts, 62, 82), Decl(bluebirdStaticThis.ts, 63, 82)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 62, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 62, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 62, 38)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 62, 15)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 62, 15)) + + static any(dit: typeof Promise, values: Promise.Thenable[]): Promise; +>any : Symbol(Promise.any, Decl(bluebirdStaticThis.ts, 59, 89), Decl(bluebirdStaticThis.ts, 61, 100), Decl(bluebirdStaticThis.ts, 62, 82), Decl(bluebirdStaticThis.ts, 63, 82)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 63, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 63, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 63, 38)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 63, 15)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 63, 15)) + + static any(dit: typeof Promise, values: R[]): Promise; +>any : Symbol(Promise.any, Decl(bluebirdStaticThis.ts, 59, 89), Decl(bluebirdStaticThis.ts, 61, 100), Decl(bluebirdStaticThis.ts, 62, 82), Decl(bluebirdStaticThis.ts, 63, 82)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 64, 15)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 64, 18)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 64, 38)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 64, 15)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 64, 15)) + + static race(dit: typeof Promise, values: Promise.Thenable[]>): Promise; +>race : Symbol(Promise.race, Decl(bluebirdStaticThis.ts, 64, 64), Decl(bluebirdStaticThis.ts, 66, 101), Decl(bluebirdStaticThis.ts, 67, 83), Decl(bluebirdStaticThis.ts, 68, 83)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 66, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 66, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 66, 39)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 66, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 66, 16)) + + static race(dit: typeof Promise, values: Promise.Thenable): Promise; +>race : Symbol(Promise.race, Decl(bluebirdStaticThis.ts, 64, 64), Decl(bluebirdStaticThis.ts, 66, 101), Decl(bluebirdStaticThis.ts, 67, 83), Decl(bluebirdStaticThis.ts, 68, 83)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 67, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 67, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 67, 39)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 67, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 67, 16)) + + static race(dit: typeof Promise, values: Promise.Thenable[]): Promise; +>race : Symbol(Promise.race, Decl(bluebirdStaticThis.ts, 64, 64), Decl(bluebirdStaticThis.ts, 66, 101), Decl(bluebirdStaticThis.ts, 67, 83), Decl(bluebirdStaticThis.ts, 68, 83)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 68, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 68, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 68, 39)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 68, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 68, 16)) + + static race(dit: typeof Promise, values: R[]): Promise; +>race : Symbol(Promise.race, Decl(bluebirdStaticThis.ts, 64, 64), Decl(bluebirdStaticThis.ts, 66, 101), Decl(bluebirdStaticThis.ts, 67, 83), Decl(bluebirdStaticThis.ts, 68, 83)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 69, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 69, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 69, 39)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 69, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 69, 16)) + + static some(dit: typeof Promise, values: Promise.Thenable[]>, count: number): Promise; +>some : Symbol(Promise.some, Decl(bluebirdStaticThis.ts, 69, 65), Decl(bluebirdStaticThis.ts, 71, 118), Decl(bluebirdStaticThis.ts, 72, 100), Decl(bluebirdStaticThis.ts, 73, 100)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 71, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 71, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 71, 39)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 71, 16)) +>count : Symbol(count, Decl(bluebirdStaticThis.ts, 71, 88)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 71, 16)) + + static some(dit: typeof Promise, values: Promise.Thenable, count: number): Promise; +>some : Symbol(Promise.some, Decl(bluebirdStaticThis.ts, 69, 65), Decl(bluebirdStaticThis.ts, 71, 118), Decl(bluebirdStaticThis.ts, 72, 100), Decl(bluebirdStaticThis.ts, 73, 100)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 72, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 72, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 72, 39)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 72, 16)) +>count : Symbol(count, Decl(bluebirdStaticThis.ts, 72, 70)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 72, 16)) + + static some(dit: typeof Promise, values: Promise.Thenable[], count: number): Promise; +>some : Symbol(Promise.some, Decl(bluebirdStaticThis.ts, 69, 65), Decl(bluebirdStaticThis.ts, 71, 118), Decl(bluebirdStaticThis.ts, 72, 100), Decl(bluebirdStaticThis.ts, 73, 100)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 73, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 73, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 73, 39)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 73, 16)) +>count : Symbol(count, Decl(bluebirdStaticThis.ts, 73, 70)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 73, 16)) + + static some(dit: typeof Promise, values: R[], count: number): Promise; +>some : Symbol(Promise.some, Decl(bluebirdStaticThis.ts, 69, 65), Decl(bluebirdStaticThis.ts, 71, 118), Decl(bluebirdStaticThis.ts, 72, 100), Decl(bluebirdStaticThis.ts, 73, 100)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 74, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 74, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 74, 39)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 74, 16)) +>count : Symbol(count, Decl(bluebirdStaticThis.ts, 74, 52)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 74, 16)) + + static join(dit: typeof Promise, ...values: Promise.Thenable[]): Promise; +>join : Symbol(Promise.join, Decl(bluebirdStaticThis.ts, 74, 82), Decl(bluebirdStaticThis.ts, 76, 88)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 76, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 76, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 76, 39)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 76, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 76, 16)) + + static join(dit: typeof Promise, ...values: R[]): Promise; +>join : Symbol(Promise.join, Decl(bluebirdStaticThis.ts, 74, 82), Decl(bluebirdStaticThis.ts, 76, 88)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 77, 16)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 77, 19)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 77, 39)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 77, 16)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 77, 16)) + + static map(dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>map : Symbol(Promise.map, Decl(bluebirdStaticThis.ts, 77, 70), Decl(bluebirdStaticThis.ts, 79, 183), Decl(bluebirdStaticThis.ts, 80, 165), Decl(bluebirdStaticThis.ts, 81, 165), Decl(bluebirdStaticThis.ts, 82, 147) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 79, 15)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 79, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 79, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 79, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 79, 15)) +>mapper : Symbol(mapper, Decl(bluebirdStaticThis.ts, 79, 90)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 79, 100)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 79, 15)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 79, 108)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 79, 123)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 79, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 79, 17)) + + static map(dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; +>map : Symbol(Promise.map, Decl(bluebirdStaticThis.ts, 77, 70), Decl(bluebirdStaticThis.ts, 79, 183), Decl(bluebirdStaticThis.ts, 80, 165), Decl(bluebirdStaticThis.ts, 81, 165), Decl(bluebirdStaticThis.ts, 82, 147) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 80, 15)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 80, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 80, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 80, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 80, 15)) +>mapper : Symbol(mapper, Decl(bluebirdStaticThis.ts, 80, 90)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 80, 100)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 80, 15)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 80, 108)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 80, 123)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 80, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 80, 17)) + + static map(dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>map : Symbol(Promise.map, Decl(bluebirdStaticThis.ts, 77, 70), Decl(bluebirdStaticThis.ts, 79, 183), Decl(bluebirdStaticThis.ts, 80, 165), Decl(bluebirdStaticThis.ts, 81, 165), Decl(bluebirdStaticThis.ts, 82, 147) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 81, 15)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 81, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 81, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 81, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 81, 15)) +>mapper : Symbol(mapper, Decl(bluebirdStaticThis.ts, 81, 72)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 81, 82)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 81, 15)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 81, 90)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 81, 105)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 81, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 81, 17)) + + static map(dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; +>map : Symbol(Promise.map, Decl(bluebirdStaticThis.ts, 77, 70), Decl(bluebirdStaticThis.ts, 79, 183), Decl(bluebirdStaticThis.ts, 80, 165), Decl(bluebirdStaticThis.ts, 81, 165), Decl(bluebirdStaticThis.ts, 82, 147) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 82, 15)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 82, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 82, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 82, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 82, 15)) +>mapper : Symbol(mapper, Decl(bluebirdStaticThis.ts, 82, 72)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 82, 82)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 82, 15)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 82, 90)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 82, 105)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 82, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 82, 17)) + + static map(dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>map : Symbol(Promise.map, Decl(bluebirdStaticThis.ts, 77, 70), Decl(bluebirdStaticThis.ts, 79, 183), Decl(bluebirdStaticThis.ts, 80, 165), Decl(bluebirdStaticThis.ts, 81, 165), Decl(bluebirdStaticThis.ts, 82, 147) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 83, 15)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 83, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 83, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 83, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 83, 15)) +>mapper : Symbol(mapper, Decl(bluebirdStaticThis.ts, 83, 72)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 83, 82)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 83, 15)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 83, 90)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 83, 105)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 83, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 83, 17)) + + static map(dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; +>map : Symbol(Promise.map, Decl(bluebirdStaticThis.ts, 77, 70), Decl(bluebirdStaticThis.ts, 79, 183), Decl(bluebirdStaticThis.ts, 80, 165), Decl(bluebirdStaticThis.ts, 81, 165), Decl(bluebirdStaticThis.ts, 82, 147) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 84, 15)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 84, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 84, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 84, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 84, 15)) +>mapper : Symbol(mapper, Decl(bluebirdStaticThis.ts, 84, 72)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 84, 82)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 84, 15)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 84, 90)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 84, 105)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 84, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 84, 17)) + + static map(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>map : Symbol(Promise.map, Decl(bluebirdStaticThis.ts, 77, 70), Decl(bluebirdStaticThis.ts, 79, 183), Decl(bluebirdStaticThis.ts, 80, 165), Decl(bluebirdStaticThis.ts, 81, 165), Decl(bluebirdStaticThis.ts, 82, 147) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 85, 15)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 85, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 85, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 85, 41)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 85, 15)) +>mapper : Symbol(mapper, Decl(bluebirdStaticThis.ts, 85, 54)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 85, 64)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 85, 15)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 85, 72)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 85, 87)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 85, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 85, 17)) + + static map(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; +>map : Symbol(Promise.map, Decl(bluebirdStaticThis.ts, 77, 70), Decl(bluebirdStaticThis.ts, 79, 183), Decl(bluebirdStaticThis.ts, 80, 165), Decl(bluebirdStaticThis.ts, 81, 165), Decl(bluebirdStaticThis.ts, 82, 147) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 86, 15)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 86, 17)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 86, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 86, 41)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 86, 15)) +>mapper : Symbol(mapper, Decl(bluebirdStaticThis.ts, 86, 54)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 86, 64)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 86, 15)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 86, 72)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 86, 87)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 86, 17)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 86, 17)) + + static reduce(dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; +>reduce : Symbol(Promise.reduce, Decl(bluebirdStaticThis.ts, 86, 129), Decl(bluebirdStaticThis.ts, 88, 216), Decl(bluebirdStaticThis.ts, 89, 198), Decl(bluebirdStaticThis.ts, 91, 198), Decl(bluebirdStaticThis.ts, 92, 180) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 88, 18)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 88, 20)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 88, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 88, 44)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 88, 18)) +>reducer : Symbol(reducer, Decl(bluebirdStaticThis.ts, 88, 93)) +>total : Symbol(total, Decl(bluebirdStaticThis.ts, 88, 104)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 88, 20)) +>current : Symbol(current, Decl(bluebirdStaticThis.ts, 88, 113)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 88, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 88, 125)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 88, 140)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 88, 20)) +>initialValue : Symbol(initialValue, Decl(bluebirdStaticThis.ts, 88, 185)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 88, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 88, 20)) + + static reduce(dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; +>reduce : Symbol(Promise.reduce, Decl(bluebirdStaticThis.ts, 86, 129), Decl(bluebirdStaticThis.ts, 88, 216), Decl(bluebirdStaticThis.ts, 89, 198), Decl(bluebirdStaticThis.ts, 91, 198), Decl(bluebirdStaticThis.ts, 92, 180) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 89, 18)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 89, 20)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 89, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 89, 44)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 89, 18)) +>reducer : Symbol(reducer, Decl(bluebirdStaticThis.ts, 89, 93)) +>total : Symbol(total, Decl(bluebirdStaticThis.ts, 89, 104)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 89, 20)) +>current : Symbol(current, Decl(bluebirdStaticThis.ts, 89, 113)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 89, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 89, 125)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 89, 140)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 89, 20)) +>initialValue : Symbol(initialValue, Decl(bluebirdStaticThis.ts, 89, 167)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 89, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 89, 20)) + + static reduce(dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; +>reduce : Symbol(Promise.reduce, Decl(bluebirdStaticThis.ts, 86, 129), Decl(bluebirdStaticThis.ts, 88, 216), Decl(bluebirdStaticThis.ts, 89, 198), Decl(bluebirdStaticThis.ts, 91, 198), Decl(bluebirdStaticThis.ts, 92, 180) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 91, 18)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 91, 20)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 91, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 91, 44)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 91, 18)) +>reducer : Symbol(reducer, Decl(bluebirdStaticThis.ts, 91, 75)) +>total : Symbol(total, Decl(bluebirdStaticThis.ts, 91, 86)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 91, 20)) +>current : Symbol(current, Decl(bluebirdStaticThis.ts, 91, 95)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 91, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 91, 107)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 91, 122)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 91, 20)) +>initialValue : Symbol(initialValue, Decl(bluebirdStaticThis.ts, 91, 167)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 91, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 91, 20)) + + static reduce(dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; +>reduce : Symbol(Promise.reduce, Decl(bluebirdStaticThis.ts, 86, 129), Decl(bluebirdStaticThis.ts, 88, 216), Decl(bluebirdStaticThis.ts, 89, 198), Decl(bluebirdStaticThis.ts, 91, 198), Decl(bluebirdStaticThis.ts, 92, 180) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 92, 18)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 92, 20)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 92, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 92, 44)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 92, 18)) +>reducer : Symbol(reducer, Decl(bluebirdStaticThis.ts, 92, 75)) +>total : Symbol(total, Decl(bluebirdStaticThis.ts, 92, 86)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 92, 20)) +>current : Symbol(current, Decl(bluebirdStaticThis.ts, 92, 95)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 92, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 92, 107)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 92, 122)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 92, 20)) +>initialValue : Symbol(initialValue, Decl(bluebirdStaticThis.ts, 92, 149)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 92, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 92, 20)) + + static reduce(dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; +>reduce : Symbol(Promise.reduce, Decl(bluebirdStaticThis.ts, 86, 129), Decl(bluebirdStaticThis.ts, 88, 216), Decl(bluebirdStaticThis.ts, 89, 198), Decl(bluebirdStaticThis.ts, 91, 198), Decl(bluebirdStaticThis.ts, 92, 180) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 94, 18)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 94, 20)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 94, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 94, 44)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 94, 18)) +>reducer : Symbol(reducer, Decl(bluebirdStaticThis.ts, 94, 75)) +>total : Symbol(total, Decl(bluebirdStaticThis.ts, 94, 86)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 94, 20)) +>current : Symbol(current, Decl(bluebirdStaticThis.ts, 94, 95)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 94, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 94, 107)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 94, 122)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 94, 20)) +>initialValue : Symbol(initialValue, Decl(bluebirdStaticThis.ts, 94, 167)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 94, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 94, 20)) + + static reduce(dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; +>reduce : Symbol(Promise.reduce, Decl(bluebirdStaticThis.ts, 86, 129), Decl(bluebirdStaticThis.ts, 88, 216), Decl(bluebirdStaticThis.ts, 89, 198), Decl(bluebirdStaticThis.ts, 91, 198), Decl(bluebirdStaticThis.ts, 92, 180) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 95, 18)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 95, 20)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 95, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 95, 44)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 95, 18)) +>reducer : Symbol(reducer, Decl(bluebirdStaticThis.ts, 95, 75)) +>total : Symbol(total, Decl(bluebirdStaticThis.ts, 95, 86)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 95, 20)) +>current : Symbol(current, Decl(bluebirdStaticThis.ts, 95, 95)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 95, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 95, 107)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 95, 122)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 95, 20)) +>initialValue : Symbol(initialValue, Decl(bluebirdStaticThis.ts, 95, 149)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 95, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 95, 20)) + + static reduce(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; +>reduce : Symbol(Promise.reduce, Decl(bluebirdStaticThis.ts, 86, 129), Decl(bluebirdStaticThis.ts, 88, 216), Decl(bluebirdStaticThis.ts, 89, 198), Decl(bluebirdStaticThis.ts, 91, 198), Decl(bluebirdStaticThis.ts, 92, 180) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 97, 18)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 97, 20)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 97, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 97, 44)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 97, 18)) +>reducer : Symbol(reducer, Decl(bluebirdStaticThis.ts, 97, 57)) +>total : Symbol(total, Decl(bluebirdStaticThis.ts, 97, 68)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 97, 20)) +>current : Symbol(current, Decl(bluebirdStaticThis.ts, 97, 77)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 97, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 97, 89)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 97, 104)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 97, 20)) +>initialValue : Symbol(initialValue, Decl(bluebirdStaticThis.ts, 97, 149)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 97, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 97, 20)) + + static reduce(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; +>reduce : Symbol(Promise.reduce, Decl(bluebirdStaticThis.ts, 86, 129), Decl(bluebirdStaticThis.ts, 88, 216), Decl(bluebirdStaticThis.ts, 89, 198), Decl(bluebirdStaticThis.ts, 91, 198), Decl(bluebirdStaticThis.ts, 92, 180) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 98, 18)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 98, 20)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 98, 24)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 98, 44)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 98, 18)) +>reducer : Symbol(reducer, Decl(bluebirdStaticThis.ts, 98, 57)) +>total : Symbol(total, Decl(bluebirdStaticThis.ts, 98, 68)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 98, 20)) +>current : Symbol(current, Decl(bluebirdStaticThis.ts, 98, 77)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 98, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 98, 89)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 98, 104)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 98, 20)) +>initialValue : Symbol(initialValue, Decl(bluebirdStaticThis.ts, 98, 131)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 98, 20)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 98, 20)) + + static filter(dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>filter : Symbol(Promise.filter, Decl(bluebirdStaticThis.ts, 98, 162), Decl(bluebirdStaticThis.ts, 100, 191), Decl(bluebirdStaticThis.ts, 101, 173), Decl(bluebirdStaticThis.ts, 102, 173), Decl(bluebirdStaticThis.ts, 103, 155) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 100, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 100, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 100, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 100, 18)) +>filterer : Symbol(filterer, Decl(bluebirdStaticThis.ts, 100, 90)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 100, 102)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 100, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 100, 110)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 100, 125)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 100, 18)) + + static filter(dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +>filter : Symbol(Promise.filter, Decl(bluebirdStaticThis.ts, 98, 162), Decl(bluebirdStaticThis.ts, 100, 191), Decl(bluebirdStaticThis.ts, 101, 173), Decl(bluebirdStaticThis.ts, 102, 173), Decl(bluebirdStaticThis.ts, 103, 155) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 101, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 101, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 101, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 101, 18)) +>filterer : Symbol(filterer, Decl(bluebirdStaticThis.ts, 101, 90)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 101, 102)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 101, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 101, 110)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 101, 125)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 101, 18)) + + static filter(dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>filter : Symbol(Promise.filter, Decl(bluebirdStaticThis.ts, 98, 162), Decl(bluebirdStaticThis.ts, 100, 191), Decl(bluebirdStaticThis.ts, 101, 173), Decl(bluebirdStaticThis.ts, 102, 173), Decl(bluebirdStaticThis.ts, 103, 155) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 102, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 102, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 102, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 102, 18)) +>filterer : Symbol(filterer, Decl(bluebirdStaticThis.ts, 102, 72)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 102, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 102, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 102, 92)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 102, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 102, 18)) + + static filter(dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +>filter : Symbol(Promise.filter, Decl(bluebirdStaticThis.ts, 98, 162), Decl(bluebirdStaticThis.ts, 100, 191), Decl(bluebirdStaticThis.ts, 101, 173), Decl(bluebirdStaticThis.ts, 102, 173), Decl(bluebirdStaticThis.ts, 103, 155) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 103, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 103, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 103, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 103, 18)) +>filterer : Symbol(filterer, Decl(bluebirdStaticThis.ts, 103, 72)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 103, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 103, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 103, 92)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 103, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 103, 18)) + + static filter(dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>filter : Symbol(Promise.filter, Decl(bluebirdStaticThis.ts, 98, 162), Decl(bluebirdStaticThis.ts, 100, 191), Decl(bluebirdStaticThis.ts, 101, 173), Decl(bluebirdStaticThis.ts, 102, 173), Decl(bluebirdStaticThis.ts, 103, 155) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 104, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 104, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 104, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 104, 18)) +>filterer : Symbol(filterer, Decl(bluebirdStaticThis.ts, 104, 72)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 104, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 104, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 104, 92)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 104, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 104, 18)) + + static filter(dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +>filter : Symbol(Promise.filter, Decl(bluebirdStaticThis.ts, 98, 162), Decl(bluebirdStaticThis.ts, 100, 191), Decl(bluebirdStaticThis.ts, 101, 173), Decl(bluebirdStaticThis.ts, 102, 173), Decl(bluebirdStaticThis.ts, 103, 155) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 105, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 105, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 105, 41)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 105, 18)) +>filterer : Symbol(filterer, Decl(bluebirdStaticThis.ts, 105, 72)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 105, 84)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 105, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 105, 92)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 105, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 105, 18)) + + static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>filter : Symbol(Promise.filter, Decl(bluebirdStaticThis.ts, 98, 162), Decl(bluebirdStaticThis.ts, 100, 191), Decl(bluebirdStaticThis.ts, 101, 173), Decl(bluebirdStaticThis.ts, 102, 173), Decl(bluebirdStaticThis.ts, 103, 155) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 106, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 106, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 106, 41)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 106, 18)) +>filterer : Symbol(filterer, Decl(bluebirdStaticThis.ts, 106, 54)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 106, 66)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 106, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 106, 74)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 106, 89)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Thenable : Symbol(Promise.Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 106, 18)) + + static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +>filter : Symbol(Promise.filter, Decl(bluebirdStaticThis.ts, 98, 162), Decl(bluebirdStaticThis.ts, 100, 191), Decl(bluebirdStaticThis.ts, 101, 173), Decl(bluebirdStaticThis.ts, 102, 173), Decl(bluebirdStaticThis.ts, 103, 155) ... and 3 more) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 107, 18)) +>dit : Symbol(dit, Decl(bluebirdStaticThis.ts, 107, 21)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>values : Symbol(values, Decl(bluebirdStaticThis.ts, 107, 41)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 107, 18)) +>filterer : Symbol(filterer, Decl(bluebirdStaticThis.ts, 107, 54)) +>item : Symbol(item, Decl(bluebirdStaticThis.ts, 107, 66)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 107, 18)) +>index : Symbol(index, Decl(bluebirdStaticThis.ts, 107, 74)) +>arrayLength : Symbol(arrayLength, Decl(bluebirdStaticThis.ts, 107, 89)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 107, 18)) +} + +export declare module Promise { +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + export interface Thenable { +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 111, 27)) + + then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; +>then : Symbol(Thenable.then, Decl(bluebirdStaticThis.ts, 111, 31), Decl(bluebirdStaticThis.ts, 112, 104), Decl(bluebirdStaticThis.ts, 113, 95), Decl(bluebirdStaticThis.ts, 114, 94)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 112, 7)) +>onFulfilled : Symbol(onFulfilled, Decl(bluebirdStaticThis.ts, 112, 10)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 112, 24)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 111, 27)) +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 112, 7)) +>onRejected : Symbol(onRejected, Decl(bluebirdStaticThis.ts, 112, 49)) +>error : Symbol(error, Decl(bluebirdStaticThis.ts, 112, 63)) +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 112, 7)) +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 112, 7)) + + then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; +>then : Symbol(Thenable.then, Decl(bluebirdStaticThis.ts, 111, 31), Decl(bluebirdStaticThis.ts, 112, 104), Decl(bluebirdStaticThis.ts, 113, 95), Decl(bluebirdStaticThis.ts, 114, 94)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 113, 7)) +>onFulfilled : Symbol(onFulfilled, Decl(bluebirdStaticThis.ts, 113, 10)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 113, 24)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 111, 27)) +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 113, 7)) +>onRejected : Symbol(onRejected, Decl(bluebirdStaticThis.ts, 113, 49)) +>error : Symbol(error, Decl(bluebirdStaticThis.ts, 113, 64)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 113, 7)) +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 113, 7)) + + then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; +>then : Symbol(Thenable.then, Decl(bluebirdStaticThis.ts, 111, 31), Decl(bluebirdStaticThis.ts, 112, 104), Decl(bluebirdStaticThis.ts, 113, 95), Decl(bluebirdStaticThis.ts, 114, 94)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 114, 7)) +>onFulfilled : Symbol(onFulfilled, Decl(bluebirdStaticThis.ts, 114, 10)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 114, 24)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 111, 27)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 114, 7)) +>onRejected : Symbol(onRejected, Decl(bluebirdStaticThis.ts, 114, 39)) +>error : Symbol(error, Decl(bluebirdStaticThis.ts, 114, 53)) +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 114, 7)) +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 114, 7)) + + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; +>then : Symbol(Thenable.then, Decl(bluebirdStaticThis.ts, 111, 31), Decl(bluebirdStaticThis.ts, 112, 104), Decl(bluebirdStaticThis.ts, 113, 95), Decl(bluebirdStaticThis.ts, 114, 94)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 115, 7)) +>onFulfilled : Symbol(onFulfilled, Decl(bluebirdStaticThis.ts, 115, 10)) +>value : Symbol(value, Decl(bluebirdStaticThis.ts, 115, 25)) +>R : Symbol(R, Decl(bluebirdStaticThis.ts, 111, 27)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 115, 7)) +>onRejected : Symbol(onRejected, Decl(bluebirdStaticThis.ts, 115, 40)) +>error : Symbol(error, Decl(bluebirdStaticThis.ts, 115, 55)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 115, 7)) +>Thenable : Symbol(Thenable, Decl(bluebirdStaticThis.ts, 110, 31)) +>U : Symbol(U, Decl(bluebirdStaticThis.ts, 115, 7)) + } + +} + +interface Foo { +>Foo : Symbol(Foo, Decl(bluebirdStaticThis.ts, 118, 1)) + + a: number; +>a : Symbol(Foo.a, Decl(bluebirdStaticThis.ts, 120, 15)) + + b: string; +>b : Symbol(Foo.b, Decl(bluebirdStaticThis.ts, 121, 14)) +} +var x: any; +>x : Symbol(x, Decl(bluebirdStaticThis.ts, 124, 3)) + +var arr: any[]; +>arr : Symbol(arr, Decl(bluebirdStaticThis.ts, 125, 3)) + +var foo: Foo; +>foo : Symbol(foo, Decl(bluebirdStaticThis.ts, 126, 3)) +>Foo : Symbol(Foo, Decl(bluebirdStaticThis.ts, 118, 1)) + +var fooProm: Promise; +>fooProm : Symbol(fooProm, Decl(bluebirdStaticThis.ts, 127, 3)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>Foo : Symbol(Foo, Decl(bluebirdStaticThis.ts, 118, 1)) + +fooProm = Promise.try(Promise, () => { +>fooProm : Symbol(fooProm, Decl(bluebirdStaticThis.ts, 127, 3)) +>Promise.try : Symbol(Promise.try, Decl(bluebirdStaticThis.ts, 5, 125), Decl(bluebirdStaticThis.ts, 6, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>try : Symbol(Promise.try, Decl(bluebirdStaticThis.ts, 5, 125), Decl(bluebirdStaticThis.ts, 6, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + return foo; +>foo : Symbol(foo, Decl(bluebirdStaticThis.ts, 126, 3)) + +}); +fooProm = Promise.try(Promise, () => { +>fooProm : Symbol(fooProm, Decl(bluebirdStaticThis.ts, 127, 3)) +>Promise.try : Symbol(Promise.try, Decl(bluebirdStaticThis.ts, 5, 125), Decl(bluebirdStaticThis.ts, 6, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>try : Symbol(Promise.try, Decl(bluebirdStaticThis.ts, 5, 125), Decl(bluebirdStaticThis.ts, 6, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + return foo; +>foo : Symbol(foo, Decl(bluebirdStaticThis.ts, 126, 3)) + +}, arr); +>arr : Symbol(arr, Decl(bluebirdStaticThis.ts, 125, 3)) + +fooProm = Promise.try(Promise, () => { +>fooProm : Symbol(fooProm, Decl(bluebirdStaticThis.ts, 127, 3)) +>Promise.try : Symbol(Promise.try, Decl(bluebirdStaticThis.ts, 5, 125), Decl(bluebirdStaticThis.ts, 6, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) +>try : Symbol(Promise.try, Decl(bluebirdStaticThis.ts, 5, 125), Decl(bluebirdStaticThis.ts, 6, 107)) +>Promise : Symbol(Promise, Decl(bluebirdStaticThis.ts, 0, 0), Decl(bluebirdStaticThis.ts, 108, 1)) + + return foo; +>foo : Symbol(foo, Decl(bluebirdStaticThis.ts, 126, 3)) + +}, arr, x); +>arr : Symbol(arr, Decl(bluebirdStaticThis.ts, 125, 3)) +>x : Symbol(x, Decl(bluebirdStaticThis.ts, 124, 3)) + diff --git a/tests/baselines/reference/bluebirdStaticThis.types b/tests/baselines/reference/bluebirdStaticThis.types new file mode 100644 index 00000000000..a3a968cd828 --- /dev/null +++ b/tests/baselines/reference/bluebirdStaticThis.types @@ -0,0 +1,1184 @@ +=== tests/cases/compiler/bluebirdStaticThis.ts === +// This version is reduced from the full d.ts by removing almost all the tests +// and all the comments. +// Then it adds explicit `this` arguments to the static members. +// Tests by: Bart van der Schoor +export declare class Promise implements Promise.Thenable { +>Promise : Promise +>R : R +>Promise.Thenable : any +>Promise : typeof Promise +>Thenable : Promise.Thenable +>R : R + + constructor(callback: (resolve: (thenableOrResult: R | Promise.Thenable) => void, reject: (error: any) => void) => void); +>callback : (resolve: (thenableOrResult: R | Promise.Thenable) => void, reject: (error: any) => void) => void +>resolve : (thenableOrResult: R | Promise.Thenable) => void +>thenableOrResult : R | Promise.Thenable +>R : R +>Promise : any +>Thenable : Promise.Thenable +>R : R +>reject : (error: any) => void +>error : any + + static try(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; +>try : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>fn : () => Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>args : any[] +>ctx : any +>Promise : Promise +>R : R + + static try(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; +>try : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>fn : () => R +>R : R +>args : any[] +>ctx : any +>Promise : Promise +>R : R + + static attempt(dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; +>attempt : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>fn : () => Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>args : any[] +>ctx : any +>Promise : Promise +>R : R + + static attempt(dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; +>attempt : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>fn : () => R +>R : R +>args : any[] +>ctx : any +>Promise : Promise +>R : R + + static method(dit: typeof Promise, fn: Function): Function; +>method : (dit: typeof Promise, fn: Function) => Function +>dit : typeof Promise +>Promise : typeof Promise +>fn : Function +>Function : Function +>Function : Function + + static resolve(dit: typeof Promise): Promise; +>resolve : { (dit: typeof Promise): Promise; (dit: typeof Promise, value: Promise.Thenable): Promise; (dit: typeof Promise, value: R): Promise; } +>dit : typeof Promise +>Promise : typeof Promise +>Promise : Promise + + static resolve(dit: typeof Promise, value: Promise.Thenable): Promise; +>resolve : { (dit: typeof Promise): Promise; (dit: typeof Promise, value: Promise.Thenable): Promise; (dit: typeof Promise, value: R): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>value : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static resolve(dit: typeof Promise, value: R): Promise; +>resolve : { (dit: typeof Promise): Promise; (dit: typeof Promise, value: Promise.Thenable): Promise; (dit: typeof Promise, value: R): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>value : R +>R : R +>Promise : Promise +>R : R + + static reject(dit: typeof Promise, reason: any): Promise; +>reject : { (dit: typeof Promise, reason: any): Promise; (dit: typeof Promise, reason: any): Promise; } +>dit : typeof Promise +>Promise : typeof Promise +>reason : any +>Promise : Promise + + static reject(dit: typeof Promise, reason: any): Promise; +>reject : { (dit: typeof Promise, reason: any): Promise; (dit: typeof Promise, reason: any): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>reason : any +>Promise : Promise +>R : R + + static defer(dit: typeof Promise): Promise.Resolver; +>defer : (dit: typeof Promise) => any +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>Promise : any +>Resolver : No type information available! +>R : R + + static cast(dit: typeof Promise, value: Promise.Thenable): Promise; +>cast : { (dit: typeof Promise, value: Promise.Thenable): Promise; (dit: typeof Promise, value: R): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>value : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static cast(dit: typeof Promise, value: R): Promise; +>cast : { (dit: typeof Promise, value: Promise.Thenable): Promise; (dit: typeof Promise, value: R): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>value : R +>R : R +>Promise : Promise +>R : R + + static bind(dit: typeof Promise, thisArg: any): Promise; +>bind : (dit: typeof Promise, thisArg: any) => Promise +>dit : typeof Promise +>Promise : typeof Promise +>thisArg : any +>Promise : Promise + + static is(dit: typeof Promise, value: any): boolean; +>is : (dit: typeof Promise, value: any) => boolean +>dit : typeof Promise +>Promise : typeof Promise +>value : any + + static longStackTraces(dit: typeof Promise): void; +>longStackTraces : (dit: typeof Promise) => void +>dit : typeof Promise +>Promise : typeof Promise + + static delay(dit: typeof Promise, value: Promise.Thenable, ms: number): Promise; +>delay : { (dit: typeof Promise, value: Promise.Thenable, ms: number): Promise; (dit: typeof Promise, value: R, ms: number): Promise; (dit: typeof Promise, ms: number): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>value : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>ms : number +>Promise : Promise +>R : R + + static delay(dit: typeof Promise, value: R, ms: number): Promise; +>delay : { (dit: typeof Promise, value: Promise.Thenable, ms: number): Promise; (dit: typeof Promise, value: R, ms: number): Promise; (dit: typeof Promise, ms: number): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>value : R +>R : R +>ms : number +>Promise : Promise +>R : R + + static delay(dit: typeof Promise, ms: number): Promise; +>delay : { (dit: typeof Promise, value: Promise.Thenable, ms: number): Promise; (dit: typeof Promise, value: R, ms: number): Promise; (dit: typeof Promise, ms: number): Promise; } +>dit : typeof Promise +>Promise : typeof Promise +>ms : number +>Promise : Promise + + static promisify(dit: typeof Promise, nodeFunction: Function, receiver?: any): Function; +>promisify : (dit: typeof Promise, nodeFunction: Function, receiver?: any) => Function +>dit : typeof Promise +>Promise : typeof Promise +>nodeFunction : Function +>Function : Function +>receiver : any +>Function : Function + + static promisifyAll(dit: typeof Promise, target: Object): Object; +>promisifyAll : (dit: typeof Promise, target: Object) => Object +>dit : typeof Promise +>Promise : typeof Promise +>target : Object +>Object : Object +>Object : Object + + static coroutine(dit: typeof Promise, generatorFunction: Function): Function; +>coroutine : (dit: typeof Promise, generatorFunction: Function) => Function +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>generatorFunction : Function +>Function : Function +>Function : Function + + static spawn(dit: typeof Promise, generatorFunction: Function): Promise; +>spawn : (dit: typeof Promise, generatorFunction: Function) => Promise +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>generatorFunction : Function +>Function : Function +>Promise : Promise +>R : R + + static noConflict(dit: typeof Promise): typeof Promise; +>noConflict : (dit: typeof Promise) => typeof Promise +>dit : typeof Promise +>Promise : typeof Promise +>Promise : typeof Promise + + static onPossiblyUnhandledRejection(dit: typeof Promise, handler: (reason: any) => any): void; +>onPossiblyUnhandledRejection : (dit: typeof Promise, handler: (reason: any) => any) => void +>dit : typeof Promise +>Promise : typeof Promise +>handler : (reason: any) => any +>reason : any + + static all(dit: typeof Promise, values: Promise.Thenable[]>): Promise; +>all : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static all(dit: typeof Promise, values: Promise.Thenable): Promise; +>all : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static all(dit: typeof Promise, values: Promise.Thenable[]): Promise; +>all : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static all(dit: typeof Promise, values: R[]): Promise; +>all : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>Promise : Promise +>R : R + + static props(dit: typeof Promise, object: Promise): Promise; +>props : { (dit: typeof Promise, object: Promise): Promise; (dit: typeof Promise, object: Object): Promise; } +>dit : typeof Promise +>Promise : typeof Promise +>object : Promise +>Promise : Promise +>Object : Object +>Promise : Promise +>Object : Object + + static props(dit: typeof Promise, object: Object): Promise; +>props : { (dit: typeof Promise, object: Promise): Promise; (dit: typeof Promise, object: Object): Promise; } +>dit : typeof Promise +>Promise : typeof Promise +>object : Object +>Object : Object +>Promise : Promise +>Object : Object + + static settle(dit: typeof Promise, values: Promise.Thenable[]>): Promise[]>; +>settle : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>Promise : any +>Inspection : No type information available! +>R : R + + static settle(dit: typeof Promise, values: Promise.Thenable): Promise[]>; +>settle : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>Promise : any +>Inspection : No type information available! +>R : R + + static settle(dit: typeof Promise, values: Promise.Thenable[]): Promise[]>; +>settle : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>Promise : any +>Inspection : No type information available! +>R : R + + static settle(dit: typeof Promise, values: R[]): Promise[]>; +>settle : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>Promise : Promise +>Promise : any +>Inspection : No type information available! +>R : R + + static any(dit: typeof Promise, values: Promise.Thenable[]>): Promise; +>any : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static any(dit: typeof Promise, values: Promise.Thenable): Promise; +>any : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static any(dit: typeof Promise, values: Promise.Thenable[]): Promise; +>any : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static any(dit: typeof Promise, values: R[]): Promise; +>any : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>Promise : Promise +>R : R + + static race(dit: typeof Promise, values: Promise.Thenable[]>): Promise; +>race : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static race(dit: typeof Promise, values: Promise.Thenable): Promise; +>race : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static race(dit: typeof Promise, values: Promise.Thenable[]): Promise; +>race : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static race(dit: typeof Promise, values: R[]): Promise; +>race : { (dit: typeof Promise, values: Promise.Thenable[]>): Promise; (dit: typeof Promise, values: Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]): Promise; (dit: typeof Promise, values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>Promise : Promise +>R : R + + static some(dit: typeof Promise, values: Promise.Thenable[]>, count: number): Promise; +>some : { (dit: typeof Promise, values: Promise.Thenable[]>, count: number): Promise; (dit: typeof Promise, values: Promise.Thenable, count: number): Promise; (dit: typeof Promise, values: Promise.Thenable[], count: number): Promise; (dit: typeof Promise, values: R[], count: number): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>count : number +>Promise : Promise +>R : R + + static some(dit: typeof Promise, values: Promise.Thenable, count: number): Promise; +>some : { (dit: typeof Promise, values: Promise.Thenable[]>, count: number): Promise; (dit: typeof Promise, values: Promise.Thenable, count: number): Promise; (dit: typeof Promise, values: Promise.Thenable[], count: number): Promise; (dit: typeof Promise, values: R[], count: number): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>count : number +>Promise : Promise +>R : R + + static some(dit: typeof Promise, values: Promise.Thenable[], count: number): Promise; +>some : { (dit: typeof Promise, values: Promise.Thenable[]>, count: number): Promise; (dit: typeof Promise, values: Promise.Thenable, count: number): Promise; (dit: typeof Promise, values: Promise.Thenable[], count: number): Promise; (dit: typeof Promise, values: R[], count: number): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>count : number +>Promise : Promise +>R : R + + static some(dit: typeof Promise, values: R[], count: number): Promise; +>some : { (dit: typeof Promise, values: Promise.Thenable[]>, count: number): Promise; (dit: typeof Promise, values: Promise.Thenable, count: number): Promise; (dit: typeof Promise, values: Promise.Thenable[], count: number): Promise; (dit: typeof Promise, values: R[], count: number): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>count : number +>Promise : Promise +>R : R + + static join(dit: typeof Promise, ...values: Promise.Thenable[]): Promise; +>join : { (dit: typeof Promise, ...values: Promise.Thenable[]): Promise; (dit: typeof Promise, ...values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>Promise : Promise +>R : R + + static join(dit: typeof Promise, ...values: R[]): Promise; +>join : { (dit: typeof Promise, ...values: Promise.Thenable[]): Promise; (dit: typeof Promise, ...values: R[]): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>Promise : Promise +>R : R + + static map(dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>map : { (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>mapper : (item: R, index: number, arrayLength: number) => Promise.Thenable +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>U : U +>Promise : Promise +>U : U + + static map(dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; +>map : { (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>mapper : (item: R, index: number, arrayLength: number) => U +>item : R +>R : R +>index : number +>arrayLength : number +>U : U +>Promise : Promise +>U : U + + static map(dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>map : { (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>mapper : (item: R, index: number, arrayLength: number) => Promise.Thenable +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>U : U +>Promise : Promise +>U : U + + static map(dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; +>map : { (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>mapper : (item: R, index: number, arrayLength: number) => U +>item : R +>R : R +>index : number +>arrayLength : number +>U : U +>Promise : Promise +>U : U + + static map(dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>map : { (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>mapper : (item: R, index: number, arrayLength: number) => Promise.Thenable +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>U : U +>Promise : Promise +>U : U + + static map(dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; +>map : { (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>mapper : (item: R, index: number, arrayLength: number) => U +>item : R +>R : R +>index : number +>arrayLength : number +>U : U +>Promise : Promise +>U : U + + static map(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>map : { (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>mapper : (item: R, index: number, arrayLength: number) => Promise.Thenable +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>U : U +>Promise : Promise +>U : U + + static map(dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; +>map : { (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>mapper : (item: R, index: number, arrayLength: number) => U +>item : R +>R : R +>index : number +>arrayLength : number +>U : U +>Promise : Promise +>U : U + + static reduce(dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; +>reduce : { (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>reducer : (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable +>total : U +>U : U +>current : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>U : U +>initialValue : U +>U : U +>Promise : Promise +>U : U + + static reduce(dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; +>reduce : { (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>reducer : (total: U, current: R, index: number, arrayLength: number) => U +>total : U +>U : U +>current : R +>R : R +>index : number +>arrayLength : number +>U : U +>initialValue : U +>U : U +>Promise : Promise +>U : U + + static reduce(dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; +>reduce : { (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>reducer : (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable +>total : U +>U : U +>current : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>U : U +>initialValue : U +>U : U +>Promise : Promise +>U : U + + static reduce(dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; +>reduce : { (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>reducer : (total: U, current: R, index: number, arrayLength: number) => U +>total : U +>U : U +>current : R +>R : R +>index : number +>arrayLength : number +>U : U +>initialValue : U +>U : U +>Promise : Promise +>U : U + + static reduce(dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; +>reduce : { (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>reducer : (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable +>total : U +>U : U +>current : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>U : U +>initialValue : U +>U : U +>Promise : Promise +>U : U + + static reduce(dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; +>reduce : { (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>reducer : (total: U, current: R, index: number, arrayLength: number) => U +>total : U +>U : U +>current : R +>R : R +>index : number +>arrayLength : number +>U : U +>initialValue : U +>U : U +>Promise : Promise +>U : U + + static reduce(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; +>reduce : { (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>reducer : (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable +>total : U +>U : U +>current : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>U : U +>initialValue : U +>U : U +>Promise : Promise +>U : U + + static reduce(dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; +>reduce : { (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: Promise.Thenable[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Promise.Thenable, initialValue?: U): Promise; (dit: typeof Promise, values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise; } +>R : R +>U : U +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>reducer : (total: U, current: R, index: number, arrayLength: number) => U +>total : U +>U : U +>current : R +>R : R +>index : number +>arrayLength : number +>U : U +>initialValue : U +>U : U +>Promise : Promise +>U : U + + static filter(dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>filter : { (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>filterer : (item: R, index: number, arrayLength: number) => Promise.Thenable +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>Promise : Promise +>R : R + + static filter(dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +>filter : { (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[]> +>Promise : any +>Thenable : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>filterer : (item: R, index: number, arrayLength: number) => boolean +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : Promise +>R : R + + static filter(dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>filter : { (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>filterer : (item: R, index: number, arrayLength: number) => Promise.Thenable +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>Promise : Promise +>R : R + + static filter(dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +>filter : { (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable +>Promise : any +>Thenable : Promise.Thenable +>R : R +>filterer : (item: R, index: number, arrayLength: number) => boolean +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : Promise +>R : R + + static filter(dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>filter : { (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>filterer : (item: R, index: number, arrayLength: number) => Promise.Thenable +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>Promise : Promise +>R : R + + static filter(dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +>filter : { (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : Promise.Thenable[] +>Promise : any +>Thenable : Promise.Thenable +>R : R +>filterer : (item: R, index: number, arrayLength: number) => boolean +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : Promise +>R : R + + static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; +>filter : { (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>filterer : (item: R, index: number, arrayLength: number) => Promise.Thenable +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : any +>Thenable : Promise.Thenable +>Promise : Promise +>R : R + + static filter(dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; +>filter : { (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: Promise.Thenable[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable): Promise; (dit: typeof Promise, values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise; } +>R : R +>dit : typeof Promise +>Promise : typeof Promise +>values : R[] +>R : R +>filterer : (item: R, index: number, arrayLength: number) => boolean +>item : R +>R : R +>index : number +>arrayLength : number +>Promise : Promise +>R : R +} + +export declare module Promise { +>Promise : typeof Promise + + export interface Thenable { +>Thenable : Thenable +>R : R + + then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; +>then : { (onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; (onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; (onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; (onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; } +>U : U +>onFulfilled : (value: R) => Thenable +>value : R +>R : R +>Thenable : Thenable +>U : U +>onRejected : (error: any) => Thenable +>error : any +>Thenable : Thenable +>U : U +>Thenable : Thenable +>U : U + + then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; +>then : { (onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; (onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; (onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; (onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; } +>U : U +>onFulfilled : (value: R) => Thenable +>value : R +>R : R +>Thenable : Thenable +>U : U +>onRejected : (error: any) => U +>error : any +>U : U +>Thenable : Thenable +>U : U + + then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; +>then : { (onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; (onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; (onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; (onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; } +>U : U +>onFulfilled : (value: R) => U +>value : R +>R : R +>U : U +>onRejected : (error: any) => Thenable +>error : any +>Thenable : Thenable +>U : U +>Thenable : Thenable +>U : U + + then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; +>then : { (onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; (onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; (onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; (onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; } +>U : U +>onFulfilled : (value: R) => U +>value : R +>R : R +>U : U +>onRejected : (error: any) => U +>error : any +>U : U +>Thenable : Thenable +>U : U + } + +} + +interface Foo { +>Foo : Foo + + a: number; +>a : number + + b: string; +>b : string +} +var x: any; +>x : any + +var arr: any[]; +>arr : any[] + +var foo: Foo; +>foo : Foo +>Foo : Foo + +var fooProm: Promise; +>fooProm : Promise +>Promise : Promise +>Foo : Foo + +fooProm = Promise.try(Promise, () => { +>fooProm = Promise.try(Promise, () => { return foo;}) : Promise +>fooProm : Promise +>Promise.try(Promise, () => { return foo;}) : Promise +>Promise.try : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>Promise : typeof Promise +>try : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>Promise : typeof Promise +>() => { return foo;} : () => Foo + + return foo; +>foo : Foo + +}); +fooProm = Promise.try(Promise, () => { +>fooProm = Promise.try(Promise, () => { return foo;}, arr) : Promise +>fooProm : Promise +>Promise.try(Promise, () => { return foo;}, arr) : Promise +>Promise.try : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>Promise : typeof Promise +>try : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>Promise : typeof Promise +>() => { return foo;} : () => Foo + + return foo; +>foo : Foo + +}, arr); +>arr : any[] + +fooProm = Promise.try(Promise, () => { +>fooProm = Promise.try(Promise, () => { return foo;}, arr, x) : Promise +>fooProm : Promise +>Promise.try(Promise, () => { return foo;}, arr, x) : Promise +>Promise.try : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>Promise : typeof Promise +>try : { (dit: typeof Promise, fn: () => Promise.Thenable, args?: any[], ctx?: any): Promise; (dit: typeof Promise, fn: () => R, args?: any[], ctx?: any): Promise; } +>Promise : typeof Promise +>() => { return foo;} : () => Foo + + return foo; +>foo : Foo + +}, arr, x); +>arr : any[] +>x : any + diff --git a/tests/baselines/reference/boolInsteadOfBoolean.symbols b/tests/baselines/reference/boolInsteadOfBoolean.symbols new file mode 100644 index 00000000000..dcfced8fe77 --- /dev/null +++ b/tests/baselines/reference/boolInsteadOfBoolean.symbols @@ -0,0 +1,12 @@ +=== tests/cases/conformance/types/primitives/boolean/boolInsteadOfBoolean.ts === +var x: bool; +>x : Symbol(x, Decl(boolInsteadOfBoolean.ts, 0, 3)) + +var a: boolean = x; +>a : Symbol(a, Decl(boolInsteadOfBoolean.ts, 1, 3)) +>x : Symbol(x, Decl(boolInsteadOfBoolean.ts, 0, 3)) + +x = a; +>x : Symbol(x, Decl(boolInsteadOfBoolean.ts, 0, 3)) +>a : Symbol(a, Decl(boolInsteadOfBoolean.ts, 1, 3)) + diff --git a/tests/baselines/reference/boolInsteadOfBoolean.types b/tests/baselines/reference/boolInsteadOfBoolean.types new file mode 100644 index 00000000000..b22e09393c0 --- /dev/null +++ b/tests/baselines/reference/boolInsteadOfBoolean.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/types/primitives/boolean/boolInsteadOfBoolean.ts === +var x: bool; +>x : any +>bool : No type information available! + +var a: boolean = x; +>a : boolean +>x : any + +x = a; +>x = a : boolean +>x : any +>a : boolean + diff --git a/tests/baselines/reference/booleanAssignment.symbols b/tests/baselines/reference/booleanAssignment.symbols new file mode 100644 index 00000000000..bc9da786c8d --- /dev/null +++ b/tests/baselines/reference/booleanAssignment.symbols @@ -0,0 +1,31 @@ +=== tests/cases/compiler/booleanAssignment.ts === +var b = new Boolean(); +>b : Symbol(b, Decl(booleanAssignment.ts, 0, 3)) +>Boolean : Symbol(Boolean, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +b = 1; // Error +>b : Symbol(b, Decl(booleanAssignment.ts, 0, 3)) + +b = "a"; // Error +>b : Symbol(b, Decl(booleanAssignment.ts, 0, 3)) + +b = {}; // Error +>b : Symbol(b, Decl(booleanAssignment.ts, 0, 3)) + +var o = {}; +>o : Symbol(o, Decl(booleanAssignment.ts, 5, 3)) + +o = b; // OK +>o : Symbol(o, Decl(booleanAssignment.ts, 5, 3)) +>b : Symbol(b, Decl(booleanAssignment.ts, 0, 3)) + +b = true; // OK +>b : Symbol(b, Decl(booleanAssignment.ts, 0, 3)) + +var b2:boolean; +>b2 : Symbol(b2, Decl(booleanAssignment.ts, 10, 3)) + +b = b2; // OK +>b : Symbol(b, Decl(booleanAssignment.ts, 0, 3)) +>b2 : Symbol(b2, Decl(booleanAssignment.ts, 10, 3)) + diff --git a/tests/baselines/reference/booleanAssignment.types b/tests/baselines/reference/booleanAssignment.types new file mode 100644 index 00000000000..8af64f59bb3 --- /dev/null +++ b/tests/baselines/reference/booleanAssignment.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/booleanAssignment.ts === +var b = new Boolean(); +>b : Boolean +>new Boolean() : Boolean +>Boolean : BooleanConstructor + +b = 1; // Error +>b = 1 : 1 +>b : Boolean +>1 : 1 + +b = "a"; // Error +>b = "a" : "a" +>b : Boolean +>"a" : "a" + +b = {}; // Error +>b = {} : {} +>b : Boolean +>{} : {} + +var o = {}; +>o : {} +>{} : {} + +o = b; // OK +>o = b : Boolean +>o : {} +>b : Boolean + +b = true; // OK +>b = true : true +>b : Boolean +>true : true + +var b2:boolean; +>b2 : boolean + +b = b2; // OK +>b = b2 : boolean +>b : Boolean +>b2 : boolean + diff --git a/tests/baselines/reference/breakInIterationOrSwitchStatement4.symbols b/tests/baselines/reference/breakInIterationOrSwitchStatement4.symbols new file mode 100644 index 00000000000..f7d0661c163 --- /dev/null +++ b/tests/baselines/reference/breakInIterationOrSwitchStatement4.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/breakInIterationOrSwitchStatement4.ts === +for (var i in something) { +>i : Symbol(i, Decl(breakInIterationOrSwitchStatement4.ts, 0, 8)) + + break; +} diff --git a/tests/baselines/reference/breakInIterationOrSwitchStatement4.types b/tests/baselines/reference/breakInIterationOrSwitchStatement4.types new file mode 100644 index 00000000000..e38a44a3abb --- /dev/null +++ b/tests/baselines/reference/breakInIterationOrSwitchStatement4.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/breakInIterationOrSwitchStatement4.ts === +for (var i in something) { +>i : string +>something : any + + break; +} diff --git a/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.symbols b/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.symbols new file mode 100644 index 00000000000..2537ee25771 --- /dev/null +++ b/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.symbols @@ -0,0 +1,3 @@ +=== tests/cases/compiler/breakNotInIterationOrSwitchStatement1.ts === +break; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.types b/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.types new file mode 100644 index 00000000000..2537ee25771 --- /dev/null +++ b/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.types @@ -0,0 +1,3 @@ +=== tests/cases/compiler/breakNotInIterationOrSwitchStatement1.ts === +break; +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.symbols b/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.symbols new file mode 100644 index 00000000000..2c9d766ee46 --- /dev/null +++ b/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/breakNotInIterationOrSwitchStatement2.ts === +while (true) { + function f() { +>f : Symbol(f, Decl(breakNotInIterationOrSwitchStatement2.ts, 0, 14)) + + break; + } +} diff --git a/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.types b/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.types new file mode 100644 index 00000000000..3b471271884 --- /dev/null +++ b/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/breakNotInIterationOrSwitchStatement2.ts === +while (true) { +>true : true + + function f() { +>f : () => void + + break; + } +} diff --git a/tests/baselines/reference/breakTarget5.symbols b/tests/baselines/reference/breakTarget5.symbols new file mode 100644 index 00000000000..ffdfc87eff1 --- /dev/null +++ b/tests/baselines/reference/breakTarget5.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/breakTarget5.ts === +target: +while (true) { + function f() { +>f : Symbol(f, Decl(breakTarget5.ts, 1, 14)) + + while (true) { + break target; + } + } +} diff --git a/tests/baselines/reference/breakTarget5.types b/tests/baselines/reference/breakTarget5.types new file mode 100644 index 00000000000..efb5703e0ee --- /dev/null +++ b/tests/baselines/reference/breakTarget5.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/breakTarget5.ts === +target: +>target : any + +while (true) { +>true : true + + function f() { +>f : () => void + + while (true) { +>true : true + + break target; +>target : any + } + } +} diff --git a/tests/baselines/reference/breakTarget6.symbols b/tests/baselines/reference/breakTarget6.symbols new file mode 100644 index 00000000000..2c5ebfae3f7 --- /dev/null +++ b/tests/baselines/reference/breakTarget6.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/breakTarget6.ts === +while (true) { +No type information for this code. break target; +No type information for this code.} +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/breakTarget6.types b/tests/baselines/reference/breakTarget6.types new file mode 100644 index 00000000000..afc1e917acd --- /dev/null +++ b/tests/baselines/reference/breakTarget6.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/breakTarget6.ts === +while (true) { +>true : true + + break target; +>target : any +} diff --git a/tests/baselines/reference/cachedModuleResolution6.symbols b/tests/baselines/reference/cachedModuleResolution6.symbols new file mode 100644 index 00000000000..87948f86b0b --- /dev/null +++ b/tests/baselines/reference/cachedModuleResolution6.symbols @@ -0,0 +1,8 @@ +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(app.ts, 0, 8)) + +=== /a/b/c/lib.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(lib.ts, 0, 8)) + diff --git a/tests/baselines/reference/cachedModuleResolution6.types b/tests/baselines/reference/cachedModuleResolution6.types new file mode 100644 index 00000000000..638d2aefb69 --- /dev/null +++ b/tests/baselines/reference/cachedModuleResolution6.types @@ -0,0 +1,8 @@ +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : any + +=== /a/b/c/lib.ts === +import {x} from "foo"; +>x : any + diff --git a/tests/baselines/reference/cachedModuleResolution7.symbols b/tests/baselines/reference/cachedModuleResolution7.symbols new file mode 100644 index 00000000000..b6a0ad02ff5 --- /dev/null +++ b/tests/baselines/reference/cachedModuleResolution7.symbols @@ -0,0 +1,8 @@ +=== /a/b/c/lib.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(lib.ts, 0, 8)) + +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(app.ts, 0, 8)) + diff --git a/tests/baselines/reference/cachedModuleResolution7.types b/tests/baselines/reference/cachedModuleResolution7.types new file mode 100644 index 00000000000..3ed9aea6856 --- /dev/null +++ b/tests/baselines/reference/cachedModuleResolution7.types @@ -0,0 +1,8 @@ +=== /a/b/c/lib.ts === +import {x} from "foo"; +>x : any + +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : any + diff --git a/tests/baselines/reference/cachedModuleResolution8.symbols b/tests/baselines/reference/cachedModuleResolution8.symbols new file mode 100644 index 00000000000..87948f86b0b --- /dev/null +++ b/tests/baselines/reference/cachedModuleResolution8.symbols @@ -0,0 +1,8 @@ +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(app.ts, 0, 8)) + +=== /a/b/c/lib.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(lib.ts, 0, 8)) + diff --git a/tests/baselines/reference/cachedModuleResolution8.types b/tests/baselines/reference/cachedModuleResolution8.types new file mode 100644 index 00000000000..638d2aefb69 --- /dev/null +++ b/tests/baselines/reference/cachedModuleResolution8.types @@ -0,0 +1,8 @@ +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : any + +=== /a/b/c/lib.ts === +import {x} from "foo"; +>x : any + diff --git a/tests/baselines/reference/cachedModuleResolution9.symbols b/tests/baselines/reference/cachedModuleResolution9.symbols new file mode 100644 index 00000000000..acf7ef51142 --- /dev/null +++ b/tests/baselines/reference/cachedModuleResolution9.symbols @@ -0,0 +1,9 @@ +=== /a/b/c/lib.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(lib.ts, 0, 8)) + + +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : Symbol(x, Decl(app.ts, 0, 8)) + diff --git a/tests/baselines/reference/cachedModuleResolution9.types b/tests/baselines/reference/cachedModuleResolution9.types new file mode 100644 index 00000000000..8a14f19e1b1 --- /dev/null +++ b/tests/baselines/reference/cachedModuleResolution9.types @@ -0,0 +1,9 @@ +=== /a/b/c/lib.ts === +import {x} from "foo"; +>x : any + + +=== /a/b/c/d/e/app.ts === +import {x} from "foo"; +>x : any + diff --git a/tests/baselines/reference/callConstructAssignment.symbols b/tests/baselines/reference/callConstructAssignment.symbols new file mode 100644 index 00000000000..8780e6466af --- /dev/null +++ b/tests/baselines/reference/callConstructAssignment.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/callConstructAssignment.ts === +var foo:{ ( ):void; } +>foo : Symbol(foo, Decl(callConstructAssignment.ts, 0, 3)) + +var bar:{ new ( ):any; } +>bar : Symbol(bar, Decl(callConstructAssignment.ts, 2, 3)) + +foo = bar; // error +>foo : Symbol(foo, Decl(callConstructAssignment.ts, 0, 3)) +>bar : Symbol(bar, Decl(callConstructAssignment.ts, 2, 3)) + +bar = foo; // error +>bar : Symbol(bar, Decl(callConstructAssignment.ts, 2, 3)) +>foo : Symbol(foo, Decl(callConstructAssignment.ts, 0, 3)) + diff --git a/tests/baselines/reference/callConstructAssignment.types b/tests/baselines/reference/callConstructAssignment.types new file mode 100644 index 00000000000..c0708ed33cc --- /dev/null +++ b/tests/baselines/reference/callConstructAssignment.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/callConstructAssignment.ts === +var foo:{ ( ):void; } +>foo : () => void + +var bar:{ new ( ):any; } +>bar : new () => any + +foo = bar; // error +>foo = bar : new () => any +>foo : () => void +>bar : new () => any + +bar = foo; // error +>bar = foo : () => void +>bar : new () => any +>foo : () => void + diff --git a/tests/baselines/reference/callExpressionWithMissingTypeArgument1.symbols b/tests/baselines/reference/callExpressionWithMissingTypeArgument1.symbols new file mode 100644 index 00000000000..b794252928d --- /dev/null +++ b/tests/baselines/reference/callExpressionWithMissingTypeArgument1.symbols @@ -0,0 +1,3 @@ +=== tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts === +Foo(); +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/callExpressionWithMissingTypeArgument1.types b/tests/baselines/reference/callExpressionWithMissingTypeArgument1.types new file mode 100644 index 00000000000..bd07bb31cac --- /dev/null +++ b/tests/baselines/reference/callExpressionWithMissingTypeArgument1.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts === +Foo(); +>Foo() : any +>Foo : any +>a : No type information available! +> : No type information available! +>b : No type information available! + diff --git a/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.symbols b/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.symbols new file mode 100644 index 00000000000..9eb87881f44 --- /dev/null +++ b/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.symbols @@ -0,0 +1,172 @@ +=== tests/cases/conformance/types/typeParameters/typeArgumentLists/callGenericFunctionWithIncorrectNumberOfTypeArguments.ts === +// type parameter lists must exactly match type argument lists +// all of these invocations are errors + +function f(x: T, y: U): T { return null; } +>f : Symbol(f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 0, 0)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 3, 11)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 3, 13)) +>x : Symbol(x, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 3, 17)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 3, 11)) +>y : Symbol(y, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 3, 22)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 3, 13)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 3, 11)) + +var r1 = f(1, ''); +>r1 : Symbol(r1, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 4, 3)) +>f : Symbol(f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 0, 0)) + +var r1b = f(1, ''); +>r1b : Symbol(r1b, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 5, 3)) +>f : Symbol(f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 0, 0)) + +var f2 = (x: T, y: U): T => { return null; } +>f2 : Symbol(f2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 3)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 10)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 12)) +>x : Symbol(x, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 16)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 10)) +>y : Symbol(y, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 21)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 12)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 10)) + +var r2 = f2(1, ''); +>r2 : Symbol(r2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 8, 3)) +>f2 : Symbol(f2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 3)) + +var r2b = f2(1, ''); +>r2b : Symbol(r2b, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 9, 3)) +>f2 : Symbol(f2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 7, 3)) + +var f3: { (x: T, y: U): T; } +>f3 : Symbol(f3, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 3)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 11)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 13)) +>x : Symbol(x, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 17)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 11)) +>y : Symbol(y, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 22)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 13)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 11)) + +var r3 = f3(1, ''); +>r3 : Symbol(r3, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 12, 3)) +>f3 : Symbol(f3, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 3)) + +var r3b = f3(1, ''); +>r3b : Symbol(r3b, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 13, 3)) +>f3 : Symbol(f3, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 11, 3)) + +class C { +>C : Symbol(C, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 13, 44)) + + f(x: T, y: U): T { +>f : Symbol(C.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 15, 9)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 16, 6)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 16, 8)) +>x : Symbol(x, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 16, 12)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 16, 6)) +>y : Symbol(y, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 16, 17)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 16, 8)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 16, 6)) + + return null; + } +} +var r4 = (new C()).f(1, ''); +>r4 : Symbol(r4, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 20, 3)) +>(new C()).f : Symbol(C.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 15, 9)) +>C : Symbol(C, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 13, 44)) +>f : Symbol(C.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 15, 9)) + +var r4b = (new C()).f(1, ''); +>r4b : Symbol(r4b, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 21, 3)) +>(new C()).f : Symbol(C.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 15, 9)) +>C : Symbol(C, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 13, 44)) +>f : Symbol(C.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 15, 9)) + +interface I { +>I : Symbol(I, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 21, 53)) + + f(x: T, y: U): T; +>f : Symbol(I.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 23, 13)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 24, 6)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 24, 8)) +>x : Symbol(x, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 24, 12)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 24, 6)) +>y : Symbol(y, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 24, 17)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 24, 8)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 24, 6)) +} +var i: I; +>i : Symbol(i, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 26, 3)) +>I : Symbol(I, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 21, 53)) + +var r5 = i.f(1, ''); +>r5 : Symbol(r5, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 27, 3)) +>i.f : Symbol(I.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 23, 13)) +>i : Symbol(i, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 26, 3)) +>f : Symbol(I.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 23, 13)) + +var r5b = i.f(1, ''); +>r5b : Symbol(r5b, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 28, 3)) +>i.f : Symbol(I.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 23, 13)) +>i : Symbol(i, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 26, 3)) +>f : Symbol(I.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 23, 13)) + +class C2 { +>C2 : Symbol(C2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 28, 45)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 9)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 11)) + + f(x: T, y: U): T { +>f : Symbol(C2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 16)) +>x : Symbol(x, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 31, 6)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 9)) +>y : Symbol(y, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 31, 11)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 11)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 9)) + + return null; + } +} +var r6 = (new C2()).f(1, ''); +>r6 : Symbol(r6, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 35, 3)) +>(new C2()).f : Symbol(C2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 16)) +>C2 : Symbol(C2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 28, 45)) +>f : Symbol(C2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 16)) + +var r6b = (new C2()).f(1, ''); +>r6b : Symbol(r6b, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 36, 3)) +>(new C2()).f : Symbol(C2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 16)) +>C2 : Symbol(C2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 28, 45)) +>f : Symbol(C2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 30, 16)) + +interface I2 { +>I2 : Symbol(I2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 36, 54)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 13)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 15)) + + f(x: T, y: U): T; +>f : Symbol(I2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 20)) +>x : Symbol(x, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 39, 6)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 13)) +>y : Symbol(y, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 39, 11)) +>U : Symbol(U, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 15)) +>T : Symbol(T, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 13)) +} +var i2: I2; +>i2 : Symbol(i2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 41, 3)) +>I2 : Symbol(I2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 36, 54)) + +var r7 = i2.f(1, ''); +>r7 : Symbol(r7, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 42, 3)) +>i2.f : Symbol(I2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 20)) +>i2 : Symbol(i2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 41, 3)) +>f : Symbol(I2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 20)) + +var r7b = i2.f(1, ''); +>r7b : Symbol(r7b, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 43, 3)) +>i2.f : Symbol(I2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 20)) +>i2 : Symbol(i2, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 41, 3)) +>f : Symbol(I2.f, Decl(callGenericFunctionWithIncorrectNumberOfTypeArguments.ts, 38, 20)) + diff --git a/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.types b/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.types new file mode 100644 index 00000000000..da8a4a339b5 --- /dev/null +++ b/tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.types @@ -0,0 +1,227 @@ +=== tests/cases/conformance/types/typeParameters/typeArgumentLists/callGenericFunctionWithIncorrectNumberOfTypeArguments.ts === +// type parameter lists must exactly match type argument lists +// all of these invocations are errors + +function f(x: T, y: U): T { return null; } +>f : (x: T, y: U) => T +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U +>T : T +>null : null + +var r1 = f(1, ''); +>r1 : any +>f(1, '') : any +>f : (x: T, y: U) => T +>1 : 1 +>'' : "" + +var r1b = f(1, ''); +>r1b : any +>f(1, '') : any +>f : (x: T, y: U) => T +>1 : 1 +>'' : "" + +var f2 = (x: T, y: U): T => { return null; } +>f2 : (x: T, y: U) => T +>(x: T, y: U): T => { return null; } : (x: T, y: U) => T +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U +>T : T +>null : null + +var r2 = f2(1, ''); +>r2 : any +>f2(1, '') : any +>f2 : (x: T, y: U) => T +>1 : 1 +>'' : "" + +var r2b = f2(1, ''); +>r2b : any +>f2(1, '') : any +>f2 : (x: T, y: U) => T +>1 : 1 +>'' : "" + +var f3: { (x: T, y: U): T; } +>f3 : (x: T, y: U) => T +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U +>T : T + +var r3 = f3(1, ''); +>r3 : any +>f3(1, '') : any +>f3 : (x: T, y: U) => T +>1 : 1 +>'' : "" + +var r3b = f3(1, ''); +>r3b : any +>f3(1, '') : any +>f3 : (x: T, y: U) => T +>1 : 1 +>'' : "" + +class C { +>C : C + + f(x: T, y: U): T { +>f : (x: T, y: U) => T +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U +>T : T + + return null; +>null : null + } +} +var r4 = (new C()).f(1, ''); +>r4 : any +>(new C()).f(1, '') : any +>(new C()).f : (x: T, y: U) => T +>(new C()) : C +>new C() : C +>C : typeof C +>f : (x: T, y: U) => T +>1 : 1 +>'' : "" + +var r4b = (new C()).f(1, ''); +>r4b : any +>(new C()).f(1, '') : any +>(new C()).f : (x: T, y: U) => T +>(new C()) : C +>new C() : C +>C : typeof C +>f : (x: T, y: U) => T +>1 : 1 +>'' : "" + +interface I { +>I : I + + f(x: T, y: U): T; +>f : (x: T, y: U) => T +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U +>T : T +} +var i: I; +>i : I +>I : I + +var r5 = i.f(1, ''); +>r5 : any +>i.f(1, '') : any +>i.f : (x: T, y: U) => T +>i : I +>f : (x: T, y: U) => T +>1 : 1 +>'' : "" + +var r5b = i.f(1, ''); +>r5b : any +>i.f(1, '') : any +>i.f : (x: T, y: U) => T +>i : I +>f : (x: T, y: U) => T +>1 : 1 +>'' : "" + +class C2 { +>C2 : C2 +>T : T +>U : U + + f(x: T, y: U): T { +>f : (x: T, y: U) => T +>x : T +>T : T +>y : U +>U : U +>T : T + + return null; +>null : null + } +} +var r6 = (new C2()).f(1, ''); +>r6 : {} +>(new C2()).f(1, '') : {} +>(new C2()).f : (x: {}, y: {}) => {} +>(new C2()) : C2<{}, {}> +>new C2() : C2<{}, {}> +>C2 : typeof C2 +>f : (x: {}, y: {}) => {} +>1 : 1 +>'' : "" + +var r6b = (new C2()).f(1, ''); +>r6b : {} +>(new C2()).f(1, '') : {} +>(new C2()).f : (x: {}, y: {}) => {} +>(new C2()) : C2<{}, {}> +>new C2() : C2<{}, {}> +>C2 : typeof C2 +>f : (x: {}, y: {}) => {} +>1 : 1 +>'' : "" + +interface I2 { +>I2 : I2 +>T : T +>U : U + + f(x: T, y: U): T; +>f : (x: T, y: U) => T +>x : T +>T : T +>y : U +>U : U +>T : T +} +var i2: I2; +>i2 : I2 +>I2 : I2 + +var r7 = i2.f(1, ''); +>r7 : number +>i2.f(1, '') : number +>i2.f : (x: number, y: string) => number +>i2 : I2 +>f : (x: number, y: string) => number +>1 : 1 +>'' : "" + +var r7b = i2.f(1, ''); +>r7b : number +>i2.f(1, '') : number +>i2.f : (x: number, y: string) => number +>i2 : I2 +>f : (x: number, y: string) => number +>1 : 1 +>'' : "" + diff --git a/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.symbols b/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.symbols new file mode 100644 index 00000000000..4bfa3655841 --- /dev/null +++ b/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.symbols @@ -0,0 +1,108 @@ +=== tests/cases/conformance/types/typeParameters/typeArgumentLists/callNonGenericFunctionWithTypeArguments.ts === +// it is always illegal to provide type arguments to a non-generic function +// all invocations here are illegal + +function f(x: number) { return null; } +>f : Symbol(f, Decl(callNonGenericFunctionWithTypeArguments.ts, 0, 0)) +>x : Symbol(x, Decl(callNonGenericFunctionWithTypeArguments.ts, 3, 11)) + +var r = f(1); +>r : Symbol(r, Decl(callNonGenericFunctionWithTypeArguments.ts, 4, 3)) +>f : Symbol(f, Decl(callNonGenericFunctionWithTypeArguments.ts, 0, 0)) + +var f2 = (x: number) => { return null; } +>f2 : Symbol(f2, Decl(callNonGenericFunctionWithTypeArguments.ts, 6, 3)) +>x : Symbol(x, Decl(callNonGenericFunctionWithTypeArguments.ts, 6, 10)) + +var r2 = f2(1); +>r2 : Symbol(r2, Decl(callNonGenericFunctionWithTypeArguments.ts, 7, 3)) +>f2 : Symbol(f2, Decl(callNonGenericFunctionWithTypeArguments.ts, 6, 3)) + +var f3: { (x: number): any; } +>f3 : Symbol(f3, Decl(callNonGenericFunctionWithTypeArguments.ts, 9, 3)) +>x : Symbol(x, Decl(callNonGenericFunctionWithTypeArguments.ts, 9, 11)) + +var r3 = f3(1); +>r3 : Symbol(r3, Decl(callNonGenericFunctionWithTypeArguments.ts, 10, 3)) +>f3 : Symbol(f3, Decl(callNonGenericFunctionWithTypeArguments.ts, 9, 3)) + +class C { +>C : Symbol(C, Decl(callNonGenericFunctionWithTypeArguments.ts, 10, 23)) + + f(x: number) { +>f : Symbol(C.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 12, 9)) +>x : Symbol(x, Decl(callNonGenericFunctionWithTypeArguments.ts, 13, 6)) + + return null; + } +} +var r4 = (new C()).f(1); +>r4 : Symbol(r4, Decl(callNonGenericFunctionWithTypeArguments.ts, 17, 3)) +>(new C()).f : Symbol(C.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 12, 9)) +>C : Symbol(C, Decl(callNonGenericFunctionWithTypeArguments.ts, 10, 23)) +>f : Symbol(C.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 12, 9)) + +interface I { +>I : Symbol(I, Decl(callNonGenericFunctionWithTypeArguments.ts, 17, 32)) + + f(x: number): any; +>f : Symbol(I.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 19, 13)) +>x : Symbol(x, Decl(callNonGenericFunctionWithTypeArguments.ts, 20, 6)) +} +var i: I; +>i : Symbol(i, Decl(callNonGenericFunctionWithTypeArguments.ts, 22, 3)) +>I : Symbol(I, Decl(callNonGenericFunctionWithTypeArguments.ts, 17, 32)) + +var r5 = i.f(1); +>r5 : Symbol(r5, Decl(callNonGenericFunctionWithTypeArguments.ts, 23, 3)) +>i.f : Symbol(I.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 19, 13)) +>i : Symbol(i, Decl(callNonGenericFunctionWithTypeArguments.ts, 22, 3)) +>f : Symbol(I.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 19, 13)) + +class C2 { +>C2 : Symbol(C2, Decl(callNonGenericFunctionWithTypeArguments.ts, 23, 24)) + + f(x: number) { +>f : Symbol(C2.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 25, 10)) +>x : Symbol(x, Decl(callNonGenericFunctionWithTypeArguments.ts, 26, 6)) + + return null; + } +} +var r6 = (new C2()).f(1); +>r6 : Symbol(r6, Decl(callNonGenericFunctionWithTypeArguments.ts, 30, 3)) +>(new C2()).f : Symbol(C2.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 25, 10)) +>C2 : Symbol(C2, Decl(callNonGenericFunctionWithTypeArguments.ts, 23, 24)) +>f : Symbol(C2.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 25, 10)) + +interface I2 { +>I2 : Symbol(I2, Decl(callNonGenericFunctionWithTypeArguments.ts, 30, 33)) + + f(x: number); +>f : Symbol(I2.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 32, 14)) +>x : Symbol(x, Decl(callNonGenericFunctionWithTypeArguments.ts, 33, 6)) +} +var i2: I2; +>i2 : Symbol(i2, Decl(callNonGenericFunctionWithTypeArguments.ts, 35, 3)) +>I2 : Symbol(I2, Decl(callNonGenericFunctionWithTypeArguments.ts, 30, 33)) + +var r7 = i2.f(1); +>r7 : Symbol(r7, Decl(callNonGenericFunctionWithTypeArguments.ts, 36, 3)) +>i2.f : Symbol(I2.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 32, 14)) +>i2 : Symbol(i2, Decl(callNonGenericFunctionWithTypeArguments.ts, 35, 3)) +>f : Symbol(I2.f, Decl(callNonGenericFunctionWithTypeArguments.ts, 32, 14)) + +var a; +>a : Symbol(a, Decl(callNonGenericFunctionWithTypeArguments.ts, 38, 3)) + +var r8 = a(); +>r8 : Symbol(r8, Decl(callNonGenericFunctionWithTypeArguments.ts, 39, 3), Decl(callNonGenericFunctionWithTypeArguments.ts, 42, 3)) +>a : Symbol(a, Decl(callNonGenericFunctionWithTypeArguments.ts, 38, 3)) + +var a2: any; +>a2 : Symbol(a2, Decl(callNonGenericFunctionWithTypeArguments.ts, 41, 3)) + +var r8 = a2(); +>r8 : Symbol(r8, Decl(callNonGenericFunctionWithTypeArguments.ts, 39, 3), Decl(callNonGenericFunctionWithTypeArguments.ts, 42, 3)) +>a2 : Symbol(a2, Decl(callNonGenericFunctionWithTypeArguments.ts, 41, 3)) + diff --git a/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.types b/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.types new file mode 100644 index 00000000000..b7155b564ef --- /dev/null +++ b/tests/baselines/reference/callNonGenericFunctionWithTypeArguments.types @@ -0,0 +1,133 @@ +=== tests/cases/conformance/types/typeParameters/typeArgumentLists/callNonGenericFunctionWithTypeArguments.ts === +// it is always illegal to provide type arguments to a non-generic function +// all invocations here are illegal + +function f(x: number) { return null; } +>f : (x: number) => any +>x : number +>null : null + +var r = f(1); +>r : any +>f(1) : any +>f : (x: number) => any +>1 : 1 + +var f2 = (x: number) => { return null; } +>f2 : (x: number) => any +>(x: number) => { return null; } : (x: number) => any +>x : number +>null : null + +var r2 = f2(1); +>r2 : any +>f2(1) : any +>f2 : (x: number) => any +>1 : 1 + +var f3: { (x: number): any; } +>f3 : (x: number) => any +>x : number + +var r3 = f3(1); +>r3 : any +>f3(1) : any +>f3 : (x: number) => any +>1 : 1 + +class C { +>C : C + + f(x: number) { +>f : (x: number) => any +>x : number + + return null; +>null : null + } +} +var r4 = (new C()).f(1); +>r4 : any +>(new C()).f(1) : any +>(new C()).f : (x: number) => any +>(new C()) : C +>new C() : C +>C : typeof C +>f : (x: number) => any +>1 : 1 + +interface I { +>I : I + + f(x: number): any; +>f : (x: number) => any +>x : number +} +var i: I; +>i : I +>I : I + +var r5 = i.f(1); +>r5 : any +>i.f(1) : any +>i.f : (x: number) => any +>i : I +>f : (x: number) => any +>1 : 1 + +class C2 { +>C2 : C2 + + f(x: number) { +>f : (x: number) => any +>x : number + + return null; +>null : null + } +} +var r6 = (new C2()).f(1); +>r6 : any +>(new C2()).f(1) : any +>(new C2()).f : (x: number) => any +>(new C2()) : C2 +>new C2() : C2 +>C2 : typeof C2 +>f : (x: number) => any +>1 : 1 + +interface I2 { +>I2 : I2 + + f(x: number); +>f : (x: number) => any +>x : number +} +var i2: I2; +>i2 : I2 +>I2 : I2 + +var r7 = i2.f(1); +>r7 : any +>i2.f(1) : any +>i2.f : (x: number) => any +>i2 : I2 +>f : (x: number) => any +>1 : 1 + +var a; +>a : any + +var r8 = a(); +>r8 : any +>a() : any +>a : any + +var a2: any; +>a2 : any + +var r8 = a2(); +>r8 : any +>a2() : any +>a2 : any + diff --git a/tests/baselines/reference/callOnClass.symbols b/tests/baselines/reference/callOnClass.symbols new file mode 100644 index 00000000000..49fdbc40592 --- /dev/null +++ b/tests/baselines/reference/callOnClass.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/callOnClass.ts === +class C { } +>C : Symbol(C, Decl(callOnClass.ts, 0, 0)) + +var c = C(); +>c : Symbol(c, Decl(callOnClass.ts, 1, 3)) +>C : Symbol(C, Decl(callOnClass.ts, 0, 0)) + + diff --git a/tests/baselines/reference/callOnClass.types b/tests/baselines/reference/callOnClass.types new file mode 100644 index 00000000000..8b57fdb764e --- /dev/null +++ b/tests/baselines/reference/callOnClass.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/callOnClass.ts === +class C { } +>C : C + +var c = C(); +>c : any +>C() : any +>C : typeof C + + diff --git a/tests/baselines/reference/callOnInstance.symbols b/tests/baselines/reference/callOnInstance.symbols new file mode 100644 index 00000000000..1bf147805fd --- /dev/null +++ b/tests/baselines/reference/callOnInstance.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/callOnInstance.ts === +declare function D(): string; // error +>D : Symbol(D, Decl(callOnInstance.ts, 0, 0)) + +declare class D { constructor (value: number); } // error +>D : Symbol(D, Decl(callOnInstance.ts, 0, 29)) +>value : Symbol(value, Decl(callOnInstance.ts, 2, 31)) + +var s1: string = D(); // OK +>s1 : Symbol(s1, Decl(callOnInstance.ts, 4, 3)) +>D : Symbol(D, Decl(callOnInstance.ts, 0, 0)) + +var s2: string = (new D(1))(); +>s2 : Symbol(s2, Decl(callOnInstance.ts, 6, 3)) +>D : Symbol(D, Decl(callOnInstance.ts, 0, 0)) + +declare class C { constructor(value: number); } +>C : Symbol(C, Decl(callOnInstance.ts, 6, 30)) +>value : Symbol(value, Decl(callOnInstance.ts, 8, 30)) + +(new C(1))(); // Error for calling an instance +>C : Symbol(C, Decl(callOnInstance.ts, 6, 30)) + diff --git a/tests/baselines/reference/callOnInstance.types b/tests/baselines/reference/callOnInstance.types new file mode 100644 index 00000000000..c90954ded07 --- /dev/null +++ b/tests/baselines/reference/callOnInstance.types @@ -0,0 +1,32 @@ +=== tests/cases/compiler/callOnInstance.ts === +declare function D(): string; // error +>D : () => string + +declare class D { constructor (value: number); } // error +>D : D +>value : number + +var s1: string = D(); // OK +>s1 : string +>D() : string +>D : () => string + +var s2: string = (new D(1))(); +>s2 : string +>(new D(1))() : any +>(new D(1)) : any +>new D(1) : any +>D : () => string +>1 : 1 + +declare class C { constructor(value: number); } +>C : C +>value : number + +(new C(1))(); // Error for calling an instance +>(new C(1))() : any +>(new C(1)) : C +>new C(1) : C +>C : typeof C +>1 : 1 + diff --git a/tests/baselines/reference/callOverloadViaElementAccessExpression.symbols b/tests/baselines/reference/callOverloadViaElementAccessExpression.symbols new file mode 100644 index 00000000000..bad58e91cdd --- /dev/null +++ b/tests/baselines/reference/callOverloadViaElementAccessExpression.symbols @@ -0,0 +1,34 @@ +=== tests/cases/compiler/callOverloadViaElementAccessExpression.ts === +class C { +>C : Symbol(C, Decl(callOverloadViaElementAccessExpression.ts, 0, 0)) + + foo(x: number): number; +>foo : Symbol(C.foo, Decl(callOverloadViaElementAccessExpression.ts, 0, 9), Decl(callOverloadViaElementAccessExpression.ts, 1, 27), Decl(callOverloadViaElementAccessExpression.ts, 2, 27)) +>x : Symbol(x, Decl(callOverloadViaElementAccessExpression.ts, 1, 8)) + + foo(x: string): string; +>foo : Symbol(C.foo, Decl(callOverloadViaElementAccessExpression.ts, 0, 9), Decl(callOverloadViaElementAccessExpression.ts, 1, 27), Decl(callOverloadViaElementAccessExpression.ts, 2, 27)) +>x : Symbol(x, Decl(callOverloadViaElementAccessExpression.ts, 2, 8)) + + foo(x: any): any { +>foo : Symbol(C.foo, Decl(callOverloadViaElementAccessExpression.ts, 0, 9), Decl(callOverloadViaElementAccessExpression.ts, 1, 27), Decl(callOverloadViaElementAccessExpression.ts, 2, 27)) +>x : Symbol(x, Decl(callOverloadViaElementAccessExpression.ts, 3, 8)) + + return null; + } +} + +var c = new C(); +>c : Symbol(c, Decl(callOverloadViaElementAccessExpression.ts, 8, 3)) +>C : Symbol(C, Decl(callOverloadViaElementAccessExpression.ts, 0, 0)) + +var r: string = c['foo'](1); +>r : Symbol(r, Decl(callOverloadViaElementAccessExpression.ts, 9, 3)) +>c : Symbol(c, Decl(callOverloadViaElementAccessExpression.ts, 8, 3)) +>'foo' : Symbol(C.foo, Decl(callOverloadViaElementAccessExpression.ts, 0, 9), Decl(callOverloadViaElementAccessExpression.ts, 1, 27), Decl(callOverloadViaElementAccessExpression.ts, 2, 27)) + +var r2: number = c['foo'](''); +>r2 : Symbol(r2, Decl(callOverloadViaElementAccessExpression.ts, 10, 3)) +>c : Symbol(c, Decl(callOverloadViaElementAccessExpression.ts, 8, 3)) +>'foo' : Symbol(C.foo, Decl(callOverloadViaElementAccessExpression.ts, 0, 9), Decl(callOverloadViaElementAccessExpression.ts, 1, 27), Decl(callOverloadViaElementAccessExpression.ts, 2, 27)) + diff --git a/tests/baselines/reference/callOverloadViaElementAccessExpression.types b/tests/baselines/reference/callOverloadViaElementAccessExpression.types new file mode 100644 index 00000000000..a38777734cf --- /dev/null +++ b/tests/baselines/reference/callOverloadViaElementAccessExpression.types @@ -0,0 +1,42 @@ +=== tests/cases/compiler/callOverloadViaElementAccessExpression.ts === +class C { +>C : C + + foo(x: number): number; +>foo : { (x: number): number; (x: string): string; } +>x : number + + foo(x: string): string; +>foo : { (x: number): number; (x: string): string; } +>x : string + + foo(x: any): any { +>foo : { (x: number): number; (x: string): string; } +>x : any + + return null; +>null : null + } +} + +var c = new C(); +>c : C +>new C() : C +>C : typeof C + +var r: string = c['foo'](1); +>r : string +>c['foo'](1) : number +>c['foo'] : { (x: number): number; (x: string): string; } +>c : C +>'foo' : "foo" +>1 : 1 + +var r2: number = c['foo'](''); +>r2 : number +>c['foo']('') : string +>c['foo'] : { (x: number): number; (x: string): string; } +>c : C +>'foo' : "foo" +>'' : "" + diff --git a/tests/baselines/reference/callOverloads1.symbols b/tests/baselines/reference/callOverloads1.symbols new file mode 100644 index 00000000000..569e9dd024d --- /dev/null +++ b/tests/baselines/reference/callOverloads1.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/callOverloads1.ts === +class Foo { // error +>Foo : Symbol(Foo, Decl(callOverloads1.ts, 0, 0)) + + bar1() { /*WScript.Echo("bar1");*/ } +>bar1 : Symbol(Foo.bar1, Decl(callOverloads1.ts, 0, 11)) + + constructor(x: any) { +>x : Symbol(x, Decl(callOverloads1.ts, 3, 16)) + + // WScript.Echo("Constructor function has executed"); + } +} + +function Foo(); // error +>Foo : Symbol(Foo, Decl(callOverloads1.ts, 6, 1)) + +function F1(s:string); +>F1 : Symbol(F1, Decl(callOverloads1.ts, 8, 15), Decl(callOverloads1.ts, 9, 22)) +>s : Symbol(s, Decl(callOverloads1.ts, 9, 12)) + +function F1(a:any) { return a;} +>F1 : Symbol(F1, Decl(callOverloads1.ts, 8, 15), Decl(callOverloads1.ts, 9, 22)) +>a : Symbol(a, Decl(callOverloads1.ts, 10, 12)) +>a : Symbol(a, Decl(callOverloads1.ts, 10, 12)) + +var f1 = new Foo("hey"); +>f1 : Symbol(f1, Decl(callOverloads1.ts, 12, 3)) +>Foo : Symbol(Foo, Decl(callOverloads1.ts, 0, 0)) + + +f1.bar1(); +>f1.bar1 : Symbol(Foo.bar1, Decl(callOverloads1.ts, 0, 11)) +>f1 : Symbol(f1, Decl(callOverloads1.ts, 12, 3)) +>bar1 : Symbol(Foo.bar1, Decl(callOverloads1.ts, 0, 11)) + +Foo(); +>Foo : Symbol(Foo, Decl(callOverloads1.ts, 0, 0)) + diff --git a/tests/baselines/reference/callOverloads1.types b/tests/baselines/reference/callOverloads1.types new file mode 100644 index 00000000000..4352f0eb6b3 --- /dev/null +++ b/tests/baselines/reference/callOverloads1.types @@ -0,0 +1,43 @@ +=== tests/cases/compiler/callOverloads1.ts === +class Foo { // error +>Foo : Foo + + bar1() { /*WScript.Echo("bar1");*/ } +>bar1 : () => void + + constructor(x: any) { +>x : any + + // WScript.Echo("Constructor function has executed"); + } +} + +function Foo(); // error +>Foo : () => any + +function F1(s:string); +>F1 : (s: string) => any +>s : string + +function F1(a:any) { return a;} +>F1 : (s: string) => any +>a : any +>a : any + +var f1 = new Foo("hey"); +>f1 : Foo +>new Foo("hey") : Foo +>Foo : typeof Foo +>"hey" : "hey" + + +f1.bar1(); +>f1.bar1() : void +>f1.bar1 : () => void +>f1 : Foo +>bar1 : () => void + +Foo(); +>Foo() : any +>Foo : typeof Foo + diff --git a/tests/baselines/reference/callOverloads2.symbols b/tests/baselines/reference/callOverloads2.symbols new file mode 100644 index 00000000000..41e5bbff711 --- /dev/null +++ b/tests/baselines/reference/callOverloads2.symbols @@ -0,0 +1,49 @@ +=== tests/cases/compiler/callOverloads2.ts === +class Foo { // error +>Foo : Symbol(Foo, Decl(callOverloads2.ts, 0, 0)) + + bar1() { /*WScript.Echo("bar1");*/ } +>bar1 : Symbol(Foo.bar1, Decl(callOverloads2.ts, 0, 11)) + + constructor(x: any) { +>x : Symbol(x, Decl(callOverloads2.ts, 3, 16)) + + // WScript.Echo("Constructor function has executed"); + } +} + +function Foo(); // error +>Foo : Symbol(Foo, Decl(callOverloads2.ts, 6, 1)) + +function F1(s:string) {return s;} // error +>F1 : Symbol(F1, Decl(callOverloads2.ts, 8, 15), Decl(callOverloads2.ts, 10, 33)) +>s : Symbol(s, Decl(callOverloads2.ts, 10, 12)) +>s : Symbol(s, Decl(callOverloads2.ts, 10, 12)) + +function F1(a:any) { return a;} // error +>F1 : Symbol(F1, Decl(callOverloads2.ts, 8, 15), Decl(callOverloads2.ts, 10, 33)) +>a : Symbol(a, Decl(callOverloads2.ts, 11, 12)) +>a : Symbol(a, Decl(callOverloads2.ts, 11, 12)) + +function Goo(s:string); // error - no implementation +>Goo : Symbol(Goo, Decl(callOverloads2.ts, 11, 31)) +>s : Symbol(s, Decl(callOverloads2.ts, 13, 13)) + +declare function Gar(s:String); // expect no error +>Gar : Symbol(Gar, Decl(callOverloads2.ts, 13, 23)) +>s : Symbol(s, Decl(callOverloads2.ts, 15, 21)) +>String : Symbol(String, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +var f1 = new Foo("hey"); +>f1 : Symbol(f1, Decl(callOverloads2.ts, 17, 3)) +>Foo : Symbol(Foo, Decl(callOverloads2.ts, 0, 0)) + + +f1.bar1(); +>f1.bar1 : Symbol(Foo.bar1, Decl(callOverloads2.ts, 0, 11)) +>f1 : Symbol(f1, Decl(callOverloads2.ts, 17, 3)) +>bar1 : Symbol(Foo.bar1, Decl(callOverloads2.ts, 0, 11)) + +Foo(); +>Foo : Symbol(Foo, Decl(callOverloads2.ts, 0, 0)) + diff --git a/tests/baselines/reference/callOverloads2.types b/tests/baselines/reference/callOverloads2.types new file mode 100644 index 00000000000..5c8e68f29cd --- /dev/null +++ b/tests/baselines/reference/callOverloads2.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/callOverloads2.ts === +class Foo { // error +>Foo : Foo + + bar1() { /*WScript.Echo("bar1");*/ } +>bar1 : () => void + + constructor(x: any) { +>x : any + + // WScript.Echo("Constructor function has executed"); + } +} + +function Foo(); // error +>Foo : () => any + +function F1(s:string) {return s;} // error +>F1 : (s: string) => string +>s : string +>s : string + +function F1(a:any) { return a;} // error +>F1 : (s: string) => string +>a : any +>a : any + +function Goo(s:string); // error - no implementation +>Goo : (s: string) => any +>s : string + +declare function Gar(s:String); // expect no error +>Gar : (s: String) => any +>s : String +>String : String + +var f1 = new Foo("hey"); +>f1 : Foo +>new Foo("hey") : Foo +>Foo : typeof Foo +>"hey" : "hey" + + +f1.bar1(); +>f1.bar1() : void +>f1.bar1 : () => void +>f1 : Foo +>bar1 : () => void + +Foo(); +>Foo() : any +>Foo : typeof Foo + diff --git a/tests/baselines/reference/callOverloads3.symbols b/tests/baselines/reference/callOverloads3.symbols new file mode 100644 index 00000000000..f694684402a --- /dev/null +++ b/tests/baselines/reference/callOverloads3.symbols @@ -0,0 +1,36 @@ +=== tests/cases/compiler/callOverloads3.ts === +function Foo():Foo; // error +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) + +function Foo(s:string):Foo; // error +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) +>s : Symbol(s, Decl(callOverloads3.ts, 1, 13)) + +class Foo { // error +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 1, 27)) + + bar1() { /*WScript.Echo("bar1");*/ } +>bar1 : Symbol(Foo.bar1, Decl(callOverloads3.ts, 2, 11)) + + constructor(x: any) { +>x : Symbol(x, Decl(callOverloads3.ts, 4, 16)) + + // WScript.Echo("Constructor function has executed"); + } +} +//class Foo(s: String); + +var f1 = new Foo("hey"); +>f1 : Symbol(f1, Decl(callOverloads3.ts, 10, 3)) +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) + + +f1.bar1(); +>f1 : Symbol(f1, Decl(callOverloads3.ts, 10, 3)) + +Foo(); +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) + +Foo("s"); +>Foo : Symbol(Foo, Decl(callOverloads3.ts, 0, 0), Decl(callOverloads3.ts, 0, 19)) + diff --git a/tests/baselines/reference/callOverloads3.types b/tests/baselines/reference/callOverloads3.types new file mode 100644 index 00000000000..f8717534cae --- /dev/null +++ b/tests/baselines/reference/callOverloads3.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/callOverloads3.ts === +function Foo():Foo; // error +>Foo : { (): any; (s: string): any; } +>Foo : No type information available! + +function Foo(s:string):Foo; // error +>Foo : { (): any; (s: string): any; } +>s : string +>Foo : No type information available! + +class Foo { // error +>Foo : Foo + + bar1() { /*WScript.Echo("bar1");*/ } +>bar1 : () => void + + constructor(x: any) { +>x : any + + // WScript.Echo("Constructor function has executed"); + } +} +//class Foo(s: String); + +var f1 = new Foo("hey"); +>f1 : any +>new Foo("hey") : any +>Foo : { (): any; (s: string): any; } +>"hey" : "hey" + + +f1.bar1(); +>f1.bar1() : any +>f1.bar1 : any +>f1 : any +>bar1 : any + +Foo(); +>Foo() : any +>Foo : { (): any; (s: string): any; } + +Foo("s"); +>Foo("s") : any +>Foo : { (): any; (s: string): any; } +>"s" : "s" + diff --git a/tests/baselines/reference/callOverloads4.symbols b/tests/baselines/reference/callOverloads4.symbols new file mode 100644 index 00000000000..2d898dbdbcc --- /dev/null +++ b/tests/baselines/reference/callOverloads4.symbols @@ -0,0 +1,38 @@ +=== tests/cases/compiler/callOverloads4.ts === +function Foo():Foo; // error +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) + +function Foo(s:string):Foo; // error +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) +>s : Symbol(s, Decl(callOverloads4.ts, 1, 13)) + +class Foo { // error +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 1, 27)) + + bar1() { /*WScript.Echo("bar1");*/ } +>bar1 : Symbol(Foo.bar1, Decl(callOverloads4.ts, 2, 11)) + + constructor(s: string); +>s : Symbol(s, Decl(callOverloads4.ts, 4, 16)) + + constructor(x: any) { +>x : Symbol(x, Decl(callOverloads4.ts, 5, 16)) + + // WScript.Echo("Constructor function has executed"); + } +} + +var f1 = new Foo("hey"); +>f1 : Symbol(f1, Decl(callOverloads4.ts, 10, 3)) +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) + + +f1.bar1(); +>f1 : Symbol(f1, Decl(callOverloads4.ts, 10, 3)) + +Foo(); +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) + +Foo("s"); +>Foo : Symbol(Foo, Decl(callOverloads4.ts, 0, 0), Decl(callOverloads4.ts, 0, 19)) + diff --git a/tests/baselines/reference/callOverloads4.types b/tests/baselines/reference/callOverloads4.types new file mode 100644 index 00000000000..60d8ced5d1d --- /dev/null +++ b/tests/baselines/reference/callOverloads4.types @@ -0,0 +1,48 @@ +=== tests/cases/compiler/callOverloads4.ts === +function Foo():Foo; // error +>Foo : { (): any; (s: string): any; } +>Foo : No type information available! + +function Foo(s:string):Foo; // error +>Foo : { (): any; (s: string): any; } +>s : string +>Foo : No type information available! + +class Foo { // error +>Foo : Foo + + bar1() { /*WScript.Echo("bar1");*/ } +>bar1 : () => void + + constructor(s: string); +>s : string + + constructor(x: any) { +>x : any + + // WScript.Echo("Constructor function has executed"); + } +} + +var f1 = new Foo("hey"); +>f1 : any +>new Foo("hey") : any +>Foo : { (): any; (s: string): any; } +>"hey" : "hey" + + +f1.bar1(); +>f1.bar1() : any +>f1.bar1 : any +>f1 : any +>bar1 : any + +Foo(); +>Foo() : any +>Foo : { (): any; (s: string): any; } + +Foo("s"); +>Foo("s") : any +>Foo : { (): any; (s: string): any; } +>"s" : "s" + diff --git a/tests/baselines/reference/callOverloads5.symbols b/tests/baselines/reference/callOverloads5.symbols new file mode 100644 index 00000000000..0f63d3edf06 --- /dev/null +++ b/tests/baselines/reference/callOverloads5.symbols @@ -0,0 +1,45 @@ +=== tests/cases/compiler/callOverloads5.ts === +function Foo():Foo; // error +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) + +function Foo(s:string):Foo; // error +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) +>s : Symbol(s, Decl(callOverloads5.ts, 1, 13)) + +class Foo { // error +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 1, 27)) + + bar1(s:string); +>bar1 : Symbol(Foo.bar1, Decl(callOverloads5.ts, 2, 11), Decl(callOverloads5.ts, 3, 16), Decl(callOverloads5.ts, 4, 16)) +>s : Symbol(s, Decl(callOverloads5.ts, 3, 6)) + + bar1(n:number); +>bar1 : Symbol(Foo.bar1, Decl(callOverloads5.ts, 2, 11), Decl(callOverloads5.ts, 3, 16), Decl(callOverloads5.ts, 4, 16)) +>n : Symbol(n, Decl(callOverloads5.ts, 4, 6)) + + bar1(a:any) { /*WScript.Echo(a);*/ } +>bar1 : Symbol(Foo.bar1, Decl(callOverloads5.ts, 2, 11), Decl(callOverloads5.ts, 3, 16), Decl(callOverloads5.ts, 4, 16)) +>a : Symbol(a, Decl(callOverloads5.ts, 5, 9)) + + constructor(x: any) { +>x : Symbol(x, Decl(callOverloads5.ts, 6, 16)) + + // WScript.Echo("Constructor function has executed"); + } +} +//class Foo(s: String); + +var f1 = new Foo("hey"); +>f1 : Symbol(f1, Decl(callOverloads5.ts, 12, 3)) +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) + + +f1.bar1("a"); +>f1 : Symbol(f1, Decl(callOverloads5.ts, 12, 3)) + +Foo(); +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) + +Foo("s"); +>Foo : Symbol(Foo, Decl(callOverloads5.ts, 0, 0), Decl(callOverloads5.ts, 0, 19)) + diff --git a/tests/baselines/reference/callOverloads5.types b/tests/baselines/reference/callOverloads5.types new file mode 100644 index 00000000000..1125fbe0ee1 --- /dev/null +++ b/tests/baselines/reference/callOverloads5.types @@ -0,0 +1,56 @@ +=== tests/cases/compiler/callOverloads5.ts === +function Foo():Foo; // error +>Foo : { (): any; (s: string): any; } +>Foo : No type information available! + +function Foo(s:string):Foo; // error +>Foo : { (): any; (s: string): any; } +>s : string +>Foo : No type information available! + +class Foo { // error +>Foo : Foo + + bar1(s:string); +>bar1 : { (s: string): any; (n: number): any; } +>s : string + + bar1(n:number); +>bar1 : { (s: string): any; (n: number): any; } +>n : number + + bar1(a:any) { /*WScript.Echo(a);*/ } +>bar1 : { (s: string): any; (n: number): any; } +>a : any + + constructor(x: any) { +>x : any + + // WScript.Echo("Constructor function has executed"); + } +} +//class Foo(s: String); + +var f1 = new Foo("hey"); +>f1 : any +>new Foo("hey") : any +>Foo : { (): any; (s: string): any; } +>"hey" : "hey" + + +f1.bar1("a"); +>f1.bar1("a") : any +>f1.bar1 : any +>f1 : any +>bar1 : any +>"a" : "a" + +Foo(); +>Foo() : any +>Foo : { (): any; (s: string): any; } + +Foo("s"); +>Foo("s") : any +>Foo : { (): any; (s: string): any; } +>"s" : "s" + diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance.symbols b/tests/baselines/reference/callSignatureAssignabilityInInheritance.symbols new file mode 100644 index 00000000000..00c48ef82e7 --- /dev/null +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance.symbols @@ -0,0 +1,151 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts === +module CallSignature { +>CallSignature : Symbol(CallSignature, Decl(callSignatureAssignabilityInInheritance.ts, 0, 0)) + + interface Base { // T +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance.ts, 0, 22)) + + // M's + (x: number): void; +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 3, 9)) + + (x: number, y: number): void; +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 4, 9)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance.ts, 4, 19)) + } + + // S's + interface I extends Base { +>I : Symbol(I, Decl(callSignatureAssignabilityInInheritance.ts, 5, 5)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance.ts, 0, 22)) + + // N's + (x: number): number; // ok because base returns void +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 10, 9)) + + (x: number, y: number): boolean; // ok because base returns void +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 11, 9)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance.ts, 11, 19)) + + (x: T): string; // ok because base returns void +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 12, 9)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 12, 12)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 12, 9)) + } + + interface Base2 { // T +>Base2 : Symbol(Base2, Decl(callSignatureAssignabilityInInheritance.ts, 13, 5)) + + // M's + (x: number): number; +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 17, 9)) + } + + // S's + interface I2 extends Base2 { +>I2 : Symbol(I2, Decl(callSignatureAssignabilityInInheritance.ts, 18, 5)) +>Base2 : Symbol(Base2, Decl(callSignatureAssignabilityInInheritance.ts, 13, 5)) + + // N's + (x: number): string; // error because base returns non-void; +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 23, 9)) + } + + // S's + interface I3 extends Base2 { +>I3 : Symbol(I3, Decl(callSignatureAssignabilityInInheritance.ts, 24, 5)) +>Base2 : Symbol(Base2, Decl(callSignatureAssignabilityInInheritance.ts, 13, 5)) + + // N's + (x: T): string; // ok, adds a new call signature +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 29, 9)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 29, 12)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 29, 9)) + } +} + +module MemberWithCallSignature { +>MemberWithCallSignature : Symbol(MemberWithCallSignature, Decl(callSignatureAssignabilityInInheritance.ts, 31, 1)) + + interface Base { // T +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance.ts, 33, 32)) + + // M's + a: (x: number) => void; +>a : Symbol(Base.a, Decl(callSignatureAssignabilityInInheritance.ts, 34, 20)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 36, 12)) + + a2: (x: number, y: number) => void; +>a2 : Symbol(Base.a2, Decl(callSignatureAssignabilityInInheritance.ts, 36, 31)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 37, 13)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance.ts, 37, 23)) + + a3: (x: T) => void; +>a3 : Symbol(Base.a3, Decl(callSignatureAssignabilityInInheritance.ts, 37, 43)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 38, 13)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 38, 16)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 38, 13)) + } + + // S's + interface I extends Base { +>I : Symbol(I, Decl(callSignatureAssignabilityInInheritance.ts, 39, 5)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance.ts, 33, 32)) + + // N's + a: (x: number) => number; // ok because base returns void +>a : Symbol(I.a, Decl(callSignatureAssignabilityInInheritance.ts, 42, 30)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 44, 12)) + + a2: (x: number, y: number) => boolean; // ok because base returns void +>a2 : Symbol(I.a2, Decl(callSignatureAssignabilityInInheritance.ts, 44, 33)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 45, 13)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance.ts, 45, 23)) + + a3: (x: T) => string; // ok because base returns void +>a3 : Symbol(I.a3, Decl(callSignatureAssignabilityInInheritance.ts, 45, 46)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 46, 13)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 46, 16)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 46, 13)) + } + + interface Base2 { // T +>Base2 : Symbol(Base2, Decl(callSignatureAssignabilityInInheritance.ts, 47, 5)) + + // M's + a: (x: number) => number; +>a : Symbol(Base2.a, Decl(callSignatureAssignabilityInInheritance.ts, 49, 21)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 51, 12)) + + a2: (x: T) => T; +>a2 : Symbol(Base2.a2, Decl(callSignatureAssignabilityInInheritance.ts, 51, 33)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 52, 13)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 52, 16)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 52, 13)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 52, 13)) + } + + // S's + interface I2 extends Base2 { +>I2 : Symbol(I2, Decl(callSignatureAssignabilityInInheritance.ts, 53, 5)) +>Base2 : Symbol(Base2, Decl(callSignatureAssignabilityInInheritance.ts, 47, 5)) + + // N's + a: (x: number) => string; // error because base returns non-void; +>a : Symbol(I2.a, Decl(callSignatureAssignabilityInInheritance.ts, 56, 32)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 58, 12)) + } + + // S's + interface I3 extends Base2 { +>I3 : Symbol(I3, Decl(callSignatureAssignabilityInInheritance.ts, 59, 5)) +>Base2 : Symbol(Base2, Decl(callSignatureAssignabilityInInheritance.ts, 47, 5)) + + // N's + a2: (x: T) => string; // error because base returns non-void; +>a2 : Symbol(I3.a2, Decl(callSignatureAssignabilityInInheritance.ts, 62, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 64, 13)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance.ts, 64, 16)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance.ts, 64, 13)) + } +} diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance.types new file mode 100644 index 00000000000..2463d04b91d --- /dev/null +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance.types @@ -0,0 +1,151 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance.ts === +module CallSignature { +>CallSignature : any + + interface Base { // T +>Base : Base + + // M's + (x: number): void; +>x : number + + (x: number, y: number): void; +>x : number +>y : number + } + + // S's + interface I extends Base { +>I : I +>Base : Base + + // N's + (x: number): number; // ok because base returns void +>x : number + + (x: number, y: number): boolean; // ok because base returns void +>x : number +>y : number + + (x: T): string; // ok because base returns void +>T : T +>x : T +>T : T + } + + interface Base2 { // T +>Base2 : Base2 + + // M's + (x: number): number; +>x : number + } + + // S's + interface I2 extends Base2 { +>I2 : I2 +>Base2 : Base2 + + // N's + (x: number): string; // error because base returns non-void; +>x : number + } + + // S's + interface I3 extends Base2 { +>I3 : I3 +>Base2 : Base2 + + // N's + (x: T): string; // ok, adds a new call signature +>T : T +>x : T +>T : T + } +} + +module MemberWithCallSignature { +>MemberWithCallSignature : any + + interface Base { // T +>Base : Base + + // M's + a: (x: number) => void; +>a : (x: number) => void +>x : number + + a2: (x: number, y: number) => void; +>a2 : (x: number, y: number) => void +>x : number +>y : number + + a3: (x: T) => void; +>a3 : (x: T) => void +>T : T +>x : T +>T : T + } + + // S's + interface I extends Base { +>I : I +>Base : Base + + // N's + a: (x: number) => number; // ok because base returns void +>a : (x: number) => number +>x : number + + a2: (x: number, y: number) => boolean; // ok because base returns void +>a2 : (x: number, y: number) => boolean +>x : number +>y : number + + a3: (x: T) => string; // ok because base returns void +>a3 : (x: T) => string +>T : T +>x : T +>T : T + } + + interface Base2 { // T +>Base2 : Base2 + + // M's + a: (x: number) => number; +>a : (x: number) => number +>x : number + + a2: (x: T) => T; +>a2 : (x: T) => T +>T : T +>x : T +>T : T +>T : T + } + + // S's + interface I2 extends Base2 { +>I2 : I2 +>Base2 : Base2 + + // N's + a: (x: number) => string; // error because base returns non-void; +>a : (x: number) => string +>x : number + } + + // S's + interface I3 extends Base2 { +>I3 : I3 +>Base2 : Base2 + + // N's + a2: (x: T) => string; // error because base returns non-void; +>a2 : (x: T) => string +>T : T +>x : T +>T : T + } +} diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.symbols b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.symbols new file mode 100644 index 00000000000..cbcc4076ffd --- /dev/null +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.symbols @@ -0,0 +1,396 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts === +// checking subtype relations for function types as it relates to contextual signature instantiation +// error cases + +module Errors { +>Errors : Symbol(Errors, Decl(callSignatureAssignabilityInInheritance3.ts, 0, 0)) + + class Base { foo: string; } +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>foo : Symbol(Base.foo, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 16)) + + class Derived extends Base { bar: string; } +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>bar : Symbol(Derived.bar, Decl(callSignatureAssignabilityInInheritance3.ts, 5, 32)) + + class Derived2 extends Derived { baz: string; } +>Derived2 : Symbol(Derived2, Decl(callSignatureAssignabilityInInheritance3.ts, 5, 47)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>baz : Symbol(Derived2.baz, Decl(callSignatureAssignabilityInInheritance3.ts, 6, 36)) + + class OtherDerived extends Base { bing: string; } +>OtherDerived : Symbol(OtherDerived, Decl(callSignatureAssignabilityInInheritance3.ts, 6, 51)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>bing : Symbol(OtherDerived.bing, Decl(callSignatureAssignabilityInInheritance3.ts, 7, 37)) + + module WithNonGenericSignaturesInBaseType { +>WithNonGenericSignaturesInBaseType : Symbol(WithNonGenericSignaturesInBaseType, Decl(callSignatureAssignabilityInInheritance3.ts, 7, 53)) + + // base type with non-generic call signatures + interface A { +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a2: (x: number) => string[]; +>a2 : Symbol(A.a2, Decl(callSignatureAssignabilityInInheritance3.ts, 11, 21)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 12, 17)) + + a7: (x: (arg: Base) => Derived) => (r: Base) => Derived2; +>a7 : Symbol(A.a7, Decl(callSignatureAssignabilityInInheritance3.ts, 12, 40)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 13, 17)) +>arg : Symbol(arg, Decl(callSignatureAssignabilityInInheritance3.ts, 13, 21)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>r : Symbol(r, Decl(callSignatureAssignabilityInInheritance3.ts, 13, 48)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>Derived2 : Symbol(Derived2, Decl(callSignatureAssignabilityInInheritance3.ts, 5, 47)) + + a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; +>a8 : Symbol(A.a8, Decl(callSignatureAssignabilityInInheritance3.ts, 13, 69)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 14, 17)) +>arg : Symbol(arg, Decl(callSignatureAssignabilityInInheritance3.ts, 14, 21)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance3.ts, 14, 43)) +>arg2 : Symbol(arg2, Decl(callSignatureAssignabilityInInheritance3.ts, 14, 48)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>r : Symbol(r, Decl(callSignatureAssignabilityInInheritance3.ts, 14, 76)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) + + a10: (...x: Base[]) => Base; +>a10 : Symbol(A.a10, Decl(callSignatureAssignabilityInInheritance3.ts, 14, 96)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 15, 18)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) + + a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base; +>a11 : Symbol(A.a11, Decl(callSignatureAssignabilityInInheritance3.ts, 15, 40)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 16, 18)) +>foo : Symbol(foo, Decl(callSignatureAssignabilityInInheritance3.ts, 16, 22)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance3.ts, 16, 37)) +>foo : Symbol(foo, Decl(callSignatureAssignabilityInInheritance3.ts, 16, 42)) +>bar : Symbol(bar, Decl(callSignatureAssignabilityInInheritance3.ts, 16, 55)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) + + a12: (x: Array, y: Array) => Array; +>a12 : Symbol(A.a12, Decl(callSignatureAssignabilityInInheritance3.ts, 16, 79)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 17, 18)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance3.ts, 17, 33)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived2 : Symbol(Derived2, Decl(callSignatureAssignabilityInInheritance3.ts, 5, 47)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) + + a14: { +>a14 : Symbol(A.a14, Decl(callSignatureAssignabilityInInheritance3.ts, 17, 72)) + + (x: number): number[]; +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 19, 17)) + + (x: string): string[]; +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 20, 17)) + + }; + a15: (x: { a: string; b: number }) => number; +>a15 : Symbol(A.a15, Decl(callSignatureAssignabilityInInheritance3.ts, 21, 14)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 22, 18)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 22, 22)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance3.ts, 22, 33)) + + a16: { +>a16 : Symbol(A.a16, Decl(callSignatureAssignabilityInInheritance3.ts, 22, 57)) + + // type of parameter is overload set which means we can't do inference based on this type + (x: { +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 25, 17)) + + (a: number): number; +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 26, 21)) + + (a?: number): number; +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 27, 21)) + + }): number[]; + (x: { +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 29, 17)) + + (a: boolean): boolean; +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 30, 21)) + + (a?: boolean): boolean; +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 31, 21)) + + }): boolean[]; + }; + a17: { +>a17 : Symbol(A.a17, Decl(callSignatureAssignabilityInInheritance3.ts, 33, 14)) + + (x: { +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 35, 17)) + + (a: T): T; +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 36, 21)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 36, 40)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 36, 21)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 36, 21)) + + (a: T): T; +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 37, 21)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 37, 37)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 37, 21)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 37, 21)) + + }): any[]; + (x: { +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 39, 17)) + + (a: T): T; +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 40, 21)) +>Derived2 : Symbol(Derived2, Decl(callSignatureAssignabilityInInheritance3.ts, 5, 47)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 40, 41)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 40, 21)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 40, 21)) + + (a: T): T; +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 41, 21)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 41, 37)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 41, 21)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 41, 21)) + + }): any[]; + }; + } + + interface I extends A { +>I : Symbol(I, Decl(callSignatureAssignabilityInInheritance3.ts, 44, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a2: (x: T) => U[]; // error, contextual signature instantiation doesn't relate return types so U is {}, not a subtype of string[] +>a2 : Symbol(I.a2, Decl(callSignatureAssignabilityInInheritance3.ts, 46, 31)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 47, 17)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 47, 19)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 47, 23)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 47, 17)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 47, 19)) + } + + interface I2 extends A { +>I2 : Symbol(I2, Decl(callSignatureAssignabilityInInheritance3.ts, 48, 9)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 50, 21)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 50, 23)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a2: (x: T) => U[]; // error, no contextual signature instantiation since I2.a2 is not generic +>a2 : Symbol(I2.a2, Decl(callSignatureAssignabilityInInheritance3.ts, 50, 38)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 51, 17)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 50, 21)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 50, 23)) + } + + interface I3 extends A { +>I3 : Symbol(I3, Decl(callSignatureAssignabilityInInheritance3.ts, 52, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + // valid, no inferences for V so it defaults to Derived2 + a7: (x: (arg: T) => U) => (r: T) => V; +>a7 : Symbol(I3.a7, Decl(callSignatureAssignabilityInInheritance3.ts, 54, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 17)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 32)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>V : Symbol(V, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 51)) +>Derived2 : Symbol(Derived2, Decl(callSignatureAssignabilityInInheritance3.ts, 5, 47)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 72)) +>arg : Symbol(arg, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 76)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 17)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 32)) +>r : Symbol(r, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 94)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 17)) +>V : Symbol(V, Decl(callSignatureAssignabilityInInheritance3.ts, 56, 51)) + } + + interface I4 extends A { +>I4 : Symbol(I4, Decl(callSignatureAssignabilityInInheritance3.ts, 57, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a8: (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; // error, type mismatch +>a8 : Symbol(I4.a8, Decl(callSignatureAssignabilityInInheritance3.ts, 59, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 17)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 32)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 52)) +>arg : Symbol(arg, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 56)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 17)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 32)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 69)) +>arg2 : Symbol(arg2, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 74)) +>foo : Symbol(foo, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 81)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 32)) +>r : Symbol(r, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 108)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 17)) +>U : Symbol(U, Decl(callSignatureAssignabilityInInheritance3.ts, 60, 32)) + } + + interface I4B extends A { +>I4B : Symbol(I4B, Decl(callSignatureAssignabilityInInheritance3.ts, 61, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a10: (...x: T[]) => T; // valid, parameter covariance works even after contextual signature instantiation +>a10 : Symbol(I4B.a10, Decl(callSignatureAssignabilityInInheritance3.ts, 63, 33)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 64, 18)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 64, 37)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 64, 18)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 64, 18)) + } + + interface I4C extends A { +>I4C : Symbol(I4C, Decl(callSignatureAssignabilityInInheritance3.ts, 65, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a11: (x: T, y: T) => T; // valid, even though x is a Base, parameter covariance works even after contextual signature instantiation +>a11 : Symbol(I4C.a11, Decl(callSignatureAssignabilityInInheritance3.ts, 67, 33)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 68, 18)) +>Derived : Symbol(Derived, Decl(callSignatureAssignabilityInInheritance3.ts, 4, 31)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 68, 37)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 68, 18)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance3.ts, 68, 42)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 68, 18)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 68, 18)) + } + + interface I4E extends A { +>I4E : Symbol(I4E, Decl(callSignatureAssignabilityInInheritance3.ts, 69, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a12: >(x: Array, y: Array) => T; // valid, no inferences for T, defaults to Array +>a12 : Symbol(I4E.a12, Decl(callSignatureAssignabilityInInheritance3.ts, 71, 33)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 72, 18)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Derived2 : Symbol(Derived2, Decl(callSignatureAssignabilityInInheritance3.ts, 5, 47)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 72, 45)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>y : Symbol(y, Decl(callSignatureAssignabilityInInheritance3.ts, 72, 60)) +>Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 72, 18)) + } + + interface I6 extends A { +>I6 : Symbol(I6, Decl(callSignatureAssignabilityInInheritance3.ts, 73, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a15: (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type +>a15 : Symbol(I6.a15, Decl(callSignatureAssignabilityInInheritance3.ts, 75, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 76, 18)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 76, 21)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 76, 25)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 76, 18)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance3.ts, 76, 31)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 76, 18)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 76, 18)) + } + + interface I7 extends A { +>I7 : Symbol(I7, Decl(callSignatureAssignabilityInInheritance3.ts, 77, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a15: (x: { a: T; b: T }) => number; // error, T defaults to Base, which is not compatible with number or string +>a15 : Symbol(I7.a15, Decl(callSignatureAssignabilityInInheritance3.ts, 79, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 80, 18)) +>Base : Symbol(Base, Decl(callSignatureAssignabilityInInheritance3.ts, 3, 15)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 80, 34)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 80, 38)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 80, 18)) +>b : Symbol(b, Decl(callSignatureAssignabilityInInheritance3.ts, 80, 44)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 80, 18)) + } + + interface I8 extends A { +>I8 : Symbol(I8, Decl(callSignatureAssignabilityInInheritance3.ts, 81, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + // ok, we relate each signature of a16 to b16, and within that, we make inferences from two different signatures in the respective A.a16 signature + a16: (x: (a: T) => T) => T[]; +>a16 : Symbol(I8.a16, Decl(callSignatureAssignabilityInInheritance3.ts, 83, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 85, 18)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 85, 21)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 85, 25)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 85, 18)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 85, 18)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 85, 18)) + } + + interface I9 extends A { +>I9 : Symbol(I9, Decl(callSignatureAssignabilityInInheritance3.ts, 86, 9)) +>A : Symbol(A, Decl(callSignatureAssignabilityInInheritance3.ts, 9, 47)) + + a17: (x: (a: T) => T) => any[]; // valid, target is more constrained than source, so it is safe in the traditional constraint-contravariant fashion +>a17 : Symbol(I9.a17, Decl(callSignatureAssignabilityInInheritance3.ts, 88, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 89, 18)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 89, 21)) +>a : Symbol(a, Decl(callSignatureAssignabilityInInheritance3.ts, 89, 25)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 89, 18)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 89, 18)) + } + } + + module WithGenericSignaturesInBaseType { +>WithGenericSignaturesInBaseType : Symbol(WithGenericSignaturesInBaseType, Decl(callSignatureAssignabilityInInheritance3.ts, 91, 5)) + + // base type has generic call signature + interface B { +>B : Symbol(B, Decl(callSignatureAssignabilityInInheritance3.ts, 93, 44)) + + a2: (x: T) => T[]; +>a2 : Symbol(B.a2, Decl(callSignatureAssignabilityInInheritance3.ts, 95, 21)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 96, 17)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 96, 20)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 96, 17)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 96, 17)) + } + + interface I6 extends B { +>I6 : Symbol(I6, Decl(callSignatureAssignabilityInInheritance3.ts, 97, 9)) +>B : Symbol(B, Decl(callSignatureAssignabilityInInheritance3.ts, 93, 44)) + + a2: (x: T) => string[]; // error +>a2 : Symbol(I6.a2, Decl(callSignatureAssignabilityInInheritance3.ts, 99, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 100, 17)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 100, 20)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 100, 17)) + } + + // base type has generic call signature + interface C { +>C : Symbol(C, Decl(callSignatureAssignabilityInInheritance3.ts, 101, 9)) + + a2: (x: T) => string[]; +>a2 : Symbol(C.a2, Decl(callSignatureAssignabilityInInheritance3.ts, 104, 21)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 105, 17)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 105, 20)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 105, 17)) + } + + interface I7 extends C { +>I7 : Symbol(I7, Decl(callSignatureAssignabilityInInheritance3.ts, 106, 9)) +>C : Symbol(C, Decl(callSignatureAssignabilityInInheritance3.ts, 101, 9)) + + a2: (x: T) => T[]; // error +>a2 : Symbol(I7.a2, Decl(callSignatureAssignabilityInInheritance3.ts, 108, 32)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 109, 17)) +>x : Symbol(x, Decl(callSignatureAssignabilityInInheritance3.ts, 109, 20)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 109, 17)) +>T : Symbol(T, Decl(callSignatureAssignabilityInInheritance3.ts, 109, 17)) + } + } +} diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.types b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.types new file mode 100644 index 00000000000..6eb3ddaadea --- /dev/null +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.types @@ -0,0 +1,396 @@ +=== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts === +// checking subtype relations for function types as it relates to contextual signature instantiation +// error cases + +module Errors { +>Errors : typeof Errors + + class Base { foo: string; } +>Base : Base +>foo : string + + class Derived extends Base { bar: string; } +>Derived : Derived +>Base : Base +>bar : string + + class Derived2 extends Derived { baz: string; } +>Derived2 : Derived2 +>Derived : Derived +>baz : string + + class OtherDerived extends Base { bing: string; } +>OtherDerived : OtherDerived +>Base : Base +>bing : string + + module WithNonGenericSignaturesInBaseType { +>WithNonGenericSignaturesInBaseType : any + + // base type with non-generic call signatures + interface A { +>A : A + + a2: (x: number) => string[]; +>a2 : (x: number) => string[] +>x : number + + a7: (x: (arg: Base) => Derived) => (r: Base) => Derived2; +>a7 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 +>x : (arg: Base) => Derived +>arg : Base +>Base : Base +>Derived : Derived +>r : Base +>Base : Base +>Derived2 : Derived2 + + a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; +>a8 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived +>x : (arg: Base) => Derived +>arg : Base +>Base : Base +>Derived : Derived +>y : (arg2: Base) => Derived +>arg2 : Base +>Base : Base +>Derived : Derived +>r : Base +>Base : Base +>Derived : Derived + + a10: (...x: Base[]) => Base; +>a10 : (...x: Base[]) => Base +>x : Base[] +>Base : Base +>Base : Base + + a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base; +>a11 : (x: { foo: string; }, y: { foo: string; bar: string; }) => Base +>x : { foo: string; } +>foo : string +>y : { foo: string; bar: string; } +>foo : string +>bar : string +>Base : Base + + a12: (x: Array, y: Array) => Array; +>a12 : (x: Base[], y: Derived2[]) => Derived[] +>x : Base[] +>Array : T[] +>Base : Base +>y : Derived2[] +>Array : T[] +>Derived2 : Derived2 +>Array : T[] +>Derived : Derived + + a14: { +>a14 : { (x: number): number[]; (x: string): string[]; } + + (x: number): number[]; +>x : number + + (x: string): string[]; +>x : string + + }; + a15: (x: { a: string; b: number }) => number; +>a15 : (x: { a: string; b: number; }) => number +>x : { a: string; b: number; } +>a : string +>b : number + + a16: { +>a16 : { (x: { (a: number): number; (a?: number): number; }): number[]; (x: { (a: boolean): boolean; (a?: boolean): boolean; }): boolean[]; } + + // type of parameter is overload set which means we can't do inference based on this type + (x: { +>x : { (a: number): number; (a?: number): number; } + + (a: number): number; +>a : number + + (a?: number): number; +>a : number + + }): number[]; + (x: { +>x : { (a: boolean): boolean; (a?: boolean): boolean; } + + (a: boolean): boolean; +>a : boolean + + (a?: boolean): boolean; +>a : boolean + + }): boolean[]; + }; + a17: { +>a17 : { (x: { (a: T): T; (a: T): T; }): any[]; (x: { (a: T): T; (a: T): T; }): any[]; } + + (x: { +>x : { (a: T): T; (a: T): T; } + + (a: T): T; +>T : T +>Derived : Derived +>a : T +>T : T +>T : T + + (a: T): T; +>T : T +>Base : Base +>a : T +>T : T +>T : T + + }): any[]; + (x: { +>x : { (a: T): T; (a: T): T; } + + (a: T): T; +>T : T +>Derived2 : Derived2 +>a : T +>T : T +>T : T + + (a: T): T; +>T : T +>Base : Base +>a : T +>T : T +>T : T + + }): any[]; + }; + } + + interface I extends A { +>I : I +>A : A + + a2: (x: T) => U[]; // error, contextual signature instantiation doesn't relate return types so U is {}, not a subtype of string[] +>a2 : (x: T) => U[] +>T : T +>U : U +>x : T +>T : T +>U : U + } + + interface I2 extends A { +>I2 : I2 +>T : T +>U : U +>A : A + + a2: (x: T) => U[]; // error, no contextual signature instantiation since I2.a2 is not generic +>a2 : (x: T) => U[] +>x : T +>T : T +>U : U + } + + interface I3 extends A { +>I3 : I3 +>A : A + + // valid, no inferences for V so it defaults to Derived2 + a7: (x: (arg: T) => U) => (r: T) => V; +>a7 : (x: (arg: T) => U) => (r: T) => V +>T : T +>Base : Base +>U : U +>Derived : Derived +>V : V +>Derived2 : Derived2 +>x : (arg: T) => U +>arg : T +>T : T +>U : U +>r : T +>T : T +>V : V + } + + interface I4 extends A { +>I4 : I4 +>A : A + + a8: (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; // error, type mismatch +>a8 : (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U +>T : T +>Base : Base +>U : U +>Derived : Derived +>x : (arg: T) => U +>arg : T +>T : T +>U : U +>y : (arg2: { foo: number; }) => U +>arg2 : { foo: number; } +>foo : number +>U : U +>r : T +>T : T +>U : U + } + + interface I4B extends A { +>I4B : I4B +>A : A + + a10: (...x: T[]) => T; // valid, parameter covariance works even after contextual signature instantiation +>a10 : (...x: T[]) => T +>T : T +>Derived : Derived +>x : T[] +>T : T +>T : T + } + + interface I4C extends A { +>I4C : I4C +>A : A + + a11: (x: T, y: T) => T; // valid, even though x is a Base, parameter covariance works even after contextual signature instantiation +>a11 : (x: T, y: T) => T +>T : T +>Derived : Derived +>x : T +>T : T +>y : T +>T : T +>T : T + } + + interface I4E extends A { +>I4E : I4E +>A : A + + a12: >(x: Array, y: Array) => T; // valid, no inferences for T, defaults to Array +>a12 : (x: Base[], y: Base[]) => T +>T : T +>Array : T[] +>Derived2 : Derived2 +>x : Base[] +>Array : T[] +>Base : Base +>y : Base[] +>Array : T[] +>Base : Base +>T : T + } + + interface I6 extends A { +>I6 : I6 +>A : A + + a15: (x: { a: T; b: T }) => T; // error, T is {} which isn't an acceptable return type +>a15 : (x: { a: T; b: T; }) => T +>T : T +>x : { a: T; b: T; } +>a : T +>T : T +>b : T +>T : T +>T : T + } + + interface I7 extends A { +>I7 : I7 +>A : A + + a15: (x: { a: T; b: T }) => number; // error, T defaults to Base, which is not compatible with number or string +>a15 : (x: { a: T; b: T; }) => number +>T : T +>Base : Base +>x : { a: T; b: T; } +>a : T +>T : T +>b : T +>T : T + } + + interface I8 extends A { +>I8 : I8 +>A : A + + // ok, we relate each signature of a16 to b16, and within that, we make inferences from two different signatures in the respective A.a16 signature + a16: (x: (a: T) => T) => T[]; +>a16 : (x: (a: T) => T) => T[] +>T : T +>x : (a: T) => T +>a : T +>T : T +>T : T +>T : T + } + + interface I9 extends A { +>I9 : I9 +>A : A + + a17: (x: (a: T) => T) => any[]; // valid, target is more constrained than source, so it is safe in the traditional constraint-contravariant fashion +>a17 : (x: (a: T) => T) => any[] +>T : T +>x : (a: T) => T +>a : T +>T : T +>T : T + } + } + + module WithGenericSignaturesInBaseType { +>WithGenericSignaturesInBaseType : any + + // base type has generic call signature + interface B { +>B : B + + a2: (x: T) => T[]; +>a2 : (x: T) => T[] +>T : T +>x : T +>T : T +>T : T + } + + interface I6 extends B { +>I6 : I6 +>B : B + + a2: (x: T) => string[]; // error +>a2 : (x: T) => string[] +>T : T +>x : T +>T : T + } + + // base type has generic call signature + interface C { +>C : C + + a2: (x: T) => string[]; +>a2 : (x: T) => string[] +>T : T +>x : T +>T : T + } + + interface I7 extends C { +>I7 : I7 +>C : C + + a2: (x: T) => T[]; // error +>a2 : (x: T) => T[] +>T : T +>x : T +>T : T +>T : T + } + } +} diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.symbols b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.symbols new file mode 100644 index 00000000000..1d562856d07 --- /dev/null +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.symbols @@ -0,0 +1,164 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts === +// Optional parameters cannot also have initializer expressions, these are all errors + +function foo(x?: number = 1) { } +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 0, 0)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 2, 13)) + +var f = function foo(x?: number = 1) { } +>f : Symbol(f, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 3, 3)) +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 3, 7)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 3, 21)) + +var f2 = (x: number, y? = 1) => { } +>f2 : Symbol(f2, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 4, 3)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 4, 10)) +>y : Symbol(y, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 4, 20)) + +foo(1); +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 0, 0)) + +foo(); +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 0, 0)) + +f(1); +>f : Symbol(f, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 3, 3)) + +f(); +>f : Symbol(f, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 3, 3)) + +f2(1); +>f2 : Symbol(f2, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 4, 3)) + +f2(1, 2); +>f2 : Symbol(f2, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 4, 3)) + +class C { +>C : Symbol(C, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 11, 9)) + + foo(x?: number = 1) { } +>foo : Symbol(C.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 13, 9)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 14, 8)) +} + +var c: C; +>c : Symbol(c, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 17, 3)) +>C : Symbol(C, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 11, 9)) + +c.foo(); +>c.foo : Symbol(C.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 13, 9)) +>c : Symbol(c, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 17, 3)) +>foo : Symbol(C.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 13, 9)) + +c.foo(1); +>c.foo : Symbol(C.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 13, 9)) +>c : Symbol(c, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 17, 3)) +>foo : Symbol(C.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 13, 9)) + +interface I { +>I : Symbol(I, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 19, 9)) + + (x? = 1); +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 22, 5)) + + foo(x: number, y?: number = 1); +>foo : Symbol(I.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 22, 13)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 23, 8)) +>y : Symbol(y, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 23, 18)) +} + +var i: I; +>i : Symbol(i, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 26, 3)) +>I : Symbol(I, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 19, 9)) + +i(); +>i : Symbol(i, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 26, 3)) + +i(1); +>i : Symbol(i, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 26, 3)) + +i.foo(1); +>i.foo : Symbol(I.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 22, 13)) +>i : Symbol(i, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 26, 3)) +>foo : Symbol(I.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 22, 13)) + +i.foo(1, 2); +>i.foo : Symbol(I.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 22, 13)) +>i : Symbol(i, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 26, 3)) +>foo : Symbol(I.foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 22, 13)) + +var a: { +>a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 32, 3)) + + (x?: number = 1); +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 33, 5)) + + foo(x? = 1); +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 33, 21)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 34, 8)) +} + +a(); +>a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 32, 3)) + +a(1); +>a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 32, 3)) + +a.foo(); +>a.foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 33, 21)) +>a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 32, 3)) +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 33, 21)) + +a.foo(1); +>a.foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 33, 21)) +>a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 32, 3)) +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 33, 21)) + +var b = { +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 3)) + + foo(x?: number = 1) { }, +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 9)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 43, 8)) + + a: function foo(x: number, y?: number = '') { }, +>a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 43, 28)) +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 44, 6)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 44, 20)) +>y : Symbol(y, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 44, 30)) + + b: (x?: any = '') => { } +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 44, 52)) +>x : Symbol(x, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 45, 8)) +} + +b.foo(); +>b.foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 9)) +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 3)) +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 9)) + +b.foo(1); +>b.foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 9)) +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 3)) +>foo : Symbol(foo, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 9)) + +b.a(1); +>b.a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 43, 28)) +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 3)) +>a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 43, 28)) + +b.a(1, 2); +>b.a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 43, 28)) +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 3)) +>a : Symbol(a, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 43, 28)) + +b.b(); +>b.b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 44, 52)) +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 3)) +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 44, 52)) + +b.b(1); +>b.b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 44, 52)) +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 42, 3)) +>b : Symbol(b, Decl(callSignatureWithOptionalParameterAndInitializer.ts, 44, 52)) + diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.types b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.types new file mode 100644 index 00000000000..fa3ddead9e5 --- /dev/null +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.types @@ -0,0 +1,219 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts === +// Optional parameters cannot also have initializer expressions, these are all errors + +function foo(x?: number = 1) { } +>foo : (x?: number) => void +>x : number +>1 : 1 + +var f = function foo(x?: number = 1) { } +>f : (x?: number) => void +>function foo(x?: number = 1) { } : (x?: number) => void +>foo : (x?: number) => void +>x : number +>1 : 1 + +var f2 = (x: number, y? = 1) => { } +>f2 : (x: number, y?: number) => void +>(x: number, y? = 1) => { } : (x: number, y?: number) => void +>x : number +>y : number +>1 : 1 + +foo(1); +>foo(1) : void +>foo : (x?: number) => void +>1 : 1 + +foo(); +>foo() : void +>foo : (x?: number) => void + +f(1); +>f(1) : void +>f : (x?: number) => void +>1 : 1 + +f(); +>f() : void +>f : (x?: number) => void + +f2(1); +>f2(1) : void +>f2 : (x: number, y?: number) => void +>1 : 1 + +f2(1, 2); +>f2(1, 2) : void +>f2 : (x: number, y?: number) => void +>1 : 1 +>2 : 2 + +class C { +>C : C + + foo(x?: number = 1) { } +>foo : (x?: number) => void +>x : number +>1 : 1 +} + +var c: C; +>c : C +>C : C + +c.foo(); +>c.foo() : void +>c.foo : (x?: number) => void +>c : C +>foo : (x?: number) => void + +c.foo(1); +>c.foo(1) : void +>c.foo : (x?: number) => void +>c : C +>foo : (x?: number) => void +>1 : 1 + +interface I { +>I : I + + (x? = 1); +>x : number +>1 : 1 + + foo(x: number, y?: number = 1); +>foo : (x: number, y?: number) => any +>x : number +>y : number +>1 : 1 +} + +var i: I; +>i : I +>I : I + +i(); +>i() : any +>i : I + +i(1); +>i(1) : any +>i : I +>1 : 1 + +i.foo(1); +>i.foo(1) : any +>i.foo : (x: number, y?: number) => any +>i : I +>foo : (x: number, y?: number) => any +>1 : 1 + +i.foo(1, 2); +>i.foo(1, 2) : any +>i.foo : (x: number, y?: number) => any +>i : I +>foo : (x: number, y?: number) => any +>1 : 1 +>2 : 2 + +var a: { +>a : { (x?: number): any; foo(x?: number): any; } + + (x?: number = 1); +>x : number +>1 : 1 + + foo(x? = 1); +>foo : (x?: number) => any +>x : number +>1 : 1 +} + +a(); +>a() : any +>a : { (x?: number): any; foo(x?: number): any; } + +a(1); +>a(1) : any +>a : { (x?: number): any; foo(x?: number): any; } +>1 : 1 + +a.foo(); +>a.foo() : any +>a.foo : (x?: number) => any +>a : { (x?: number): any; foo(x?: number): any; } +>foo : (x?: number) => any + +a.foo(1); +>a.foo(1) : any +>a.foo : (x?: number) => any +>a : { (x?: number): any; foo(x?: number): any; } +>foo : (x?: number) => any +>1 : 1 + +var b = { +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: any) => void; } +>{ foo(x?: number = 1) { }, a: function foo(x: number, y?: number = '') { }, b: (x?: any = '') => { }} : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: any) => void; } + + foo(x?: number = 1) { }, +>foo : (x?: number) => void +>x : number +>1 : 1 + + a: function foo(x: number, y?: number = '') { }, +>a : (x: number, y?: number) => void +>function foo(x: number, y?: number = '') { } : (x: number, y?: number) => void +>foo : (x: number, y?: number) => void +>x : number +>y : number +>'' : "" + + b: (x?: any = '') => { } +>b : (x?: any) => void +>(x?: any = '') => { } : (x?: any) => void +>x : any +>'' : "" +} + +b.foo(); +>b.foo() : void +>b.foo : (x?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: any) => void; } +>foo : (x?: number) => void + +b.foo(1); +>b.foo(1) : void +>b.foo : (x?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: any) => void; } +>foo : (x?: number) => void +>1 : 1 + +b.a(1); +>b.a(1) : void +>b.a : (x: number, y?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: any) => void; } +>a : (x: number, y?: number) => void +>1 : 1 + +b.a(1, 2); +>b.a(1, 2) : void +>b.a : (x: number, y?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: any) => void; } +>a : (x: number, y?: number) => void +>1 : 1 +>2 : 2 + +b.b(); +>b.b() : void +>b.b : (x?: any) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: any) => void; } +>b : (x?: any) => void + +b.b(1); +>b.b(1) : void +>b.b : (x?: any) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: any) => void; } +>b : (x?: any) => void +>1 : 1 + diff --git a/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.symbols b/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.symbols new file mode 100644 index 00000000000..1d0d3c3b6bd --- /dev/null +++ b/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.symbols @@ -0,0 +1,27 @@ +=== tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts === +interface I1 { +>I1 : Symbol(I1, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 0, 0)) +>T : Symbol(T, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 0, 13)) + + (value: T): void; +>value : Symbol(value, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 1, 5)) +>T : Symbol(T, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 0, 13)) + + field1: I1; +>field1 : Symbol(I1.field1, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 1, 21)) +>I1 : Symbol(I1, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 0, 0)) +} + +function foo() { +>foo : Symbol(foo, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 3, 1)) + + var test: I1; +>test : Symbol(test, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 6, 7)) +>I1 : Symbol(I1, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 0, 0)) + + test("expects boolean instead of string"); // should not error - "test" should not expect a boolean +>test : Symbol(test, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 6, 7)) + + test(true); // should error - string expected +>test : Symbol(test, Decl(callSignaturesShouldBeResolvedBeforeSpecialization.ts, 6, 7)) +} diff --git a/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.types b/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.types new file mode 100644 index 00000000000..7c20d48a235 --- /dev/null +++ b/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.types @@ -0,0 +1,31 @@ +=== tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts === +interface I1 { +>I1 : I1 +>T : T + + (value: T): void; +>value : T +>T : T + + field1: I1; +>field1 : I1 +>I1 : I1 +} + +function foo() { +>foo : () => void + + var test: I1; +>test : I1 +>I1 : I1 + + test("expects boolean instead of string"); // should not error - "test" should not expect a boolean +>test("expects boolean instead of string") : void +>test : I1 +>"expects boolean instead of string" : "expects boolean instead of string" + + test(true); // should error - string expected +>test(true) : any +>test : I1 +>true : true +} diff --git a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.symbols b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.symbols new file mode 100644 index 00000000000..7d72abdcb49 --- /dev/null +++ b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.symbols @@ -0,0 +1,36 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType2.ts === +// Normally it is an error to have multiple overloads which differ only by return type in a single type declaration. +// Here the multiple overloads come from multiple bases. + +interface I { +>I : Symbol(I, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 0, 0)) +>T : Symbol(T, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 3, 12)) + + foo(x: number): T; +>foo : Symbol(I.foo, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 3, 16)) +>x : Symbol(x, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 4, 8)) +>T : Symbol(T, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 3, 12)) +} + +interface A extends I, I { } +>A : Symbol(A, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 5, 1)) +>I : Symbol(I, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 0, 0)) +>I : Symbol(I, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 0, 0)) + +var x: A; +>x : Symbol(x, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 9, 3)) +>A : Symbol(A, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 5, 1)) + +// BUG 822524 +var r = x.foo(1); // no error +>r : Symbol(r, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 11, 3)) +>x.foo : Symbol(I.foo, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 3, 16)) +>x : Symbol(x, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 9, 3)) +>foo : Symbol(I.foo, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 3, 16)) + +var r2 = x.foo(''); // error +>r2 : Symbol(r2, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 12, 3)) +>x.foo : Symbol(I.foo, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 3, 16)) +>x : Symbol(x, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 9, 3)) +>foo : Symbol(I.foo, Decl(callSignaturesThatDifferOnlyByReturnType2.ts, 3, 16)) + diff --git a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.types b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.types new file mode 100644 index 00000000000..18b23b2eb93 --- /dev/null +++ b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.types @@ -0,0 +1,40 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType2.ts === +// Normally it is an error to have multiple overloads which differ only by return type in a single type declaration. +// Here the multiple overloads come from multiple bases. + +interface I { +>I : I +>T : T + + foo(x: number): T; +>foo : (x: number) => T +>x : number +>T : T +} + +interface A extends I, I { } +>A : A +>I : I +>I : I + +var x: A; +>x : A +>A : A + +// BUG 822524 +var r = x.foo(1); // no error +>r : number +>x.foo(1) : number +>x.foo : (x: number) => number +>x : A +>foo : (x: number) => number +>1 : 1 + +var r2 = x.foo(''); // error +>r2 : number +>x.foo('') : number +>x.foo : (x: number) => number +>x : A +>foo : (x: number) => number +>'' : "" + diff --git a/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.symbols b/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.symbols new file mode 100644 index 00000000000..66f11181314 --- /dev/null +++ b/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.symbols @@ -0,0 +1,150 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithAccessibilityModifiersOnParameters.ts === +// Call signature parameters do not allow accessibility modifiers + +function foo(public x, private y) { } +>foo : Symbol(foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 0, 0)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 2, 13)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 2, 22)) + +var f = function foo(public x, private y) { } +>f : Symbol(f, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 3, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 3, 7)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 3, 21)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 3, 30)) + +var f2 = function (public x, private y) { } +>f2 : Symbol(f2, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 4, 3)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 4, 19)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 4, 28)) + +var f3 = (x, private y) => { } +>f3 : Symbol(f3, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 5, 3)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 5, 10)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 5, 12)) + +var f4 = (public x: T, y: T) => { } +>f4 : Symbol(f4, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 6, 3)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 6, 10)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 6, 13)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 6, 10)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 6, 25)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 6, 10)) + +function foo2(private x: string, public y: number) { } +>foo2 : Symbol(foo2, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 6, 38)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 8, 14)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 8, 32)) + +var f5 = function foo(private x: string, public y: number) { } +>f5 : Symbol(f5, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 9, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 9, 8)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 9, 22)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 9, 40)) + +var f6 = function (private x: string, public y: number) { } +>f6 : Symbol(f6, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 10, 3)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 10, 19)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 10, 37)) + +var f7 = (private x: string, public y: number) => { } +>f7 : Symbol(f7, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 11, 3)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 11, 10)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 11, 28)) + +var f8 = (private x: T, public y: T) => { } +>f8 : Symbol(f8, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 12, 3)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 12, 10)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 12, 13)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 12, 10)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 12, 26)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 12, 10)) + +class C { +>C : Symbol(C, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 12, 46)) + + foo(public x, private y) { } +>foo : Symbol(C.foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 14, 9)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 15, 8)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 15, 17)) + + foo2(public x: number, private y: string) { } +>foo2 : Symbol(C.foo2, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 15, 32)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 16, 9)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 16, 26)) + + foo3(public x: T, private y: T) { } +>foo3 : Symbol(C.foo3, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 16, 49)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 17, 9)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 17, 12)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 17, 9)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 17, 24)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 17, 9)) +} + +interface I { +>I : Symbol(I, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 18, 1)) + + (private x, public y); +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 21, 5)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 21, 15)) + + (private x: string, public y: number); +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 22, 5)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 22, 23)) + + foo(private x, public y); +>foo : Symbol(I.foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 22, 42), Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 23, 29)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 23, 8)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 23, 18)) + + foo(public x: number, y: string); +>foo : Symbol(I.foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 22, 42), Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 23, 29)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 24, 8)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 24, 25)) + + foo3(x: T, private y: T); +>foo3 : Symbol(I.foo3, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 24, 37)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 25, 9)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 25, 12)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 25, 9)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 25, 17)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 25, 9)) +} + +var a: { +>a : Symbol(a, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 28, 3)) + + foo(public x, private y); +>foo : Symbol(foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 28, 8)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 29, 8)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 29, 17)) + + foo2(private x: number, public y: string); +>foo2 : Symbol(foo2, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 29, 29)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 30, 9)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 30, 27)) + +}; + +var b = { +>b : Symbol(b, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 33, 3)) + + foo(public x, y) { }, +>foo : Symbol(foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 33, 9)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 34, 8)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 34, 17)) + + a: function foo(x: number, private y: string) { }, +>a : Symbol(a, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 34, 25)) +>foo : Symbol(foo, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 35, 6)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 35, 20)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 35, 30)) + + b: (public x: T, private y: T) => { } +>b : Symbol(b, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 35, 54)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 36, 8)) +>x : Symbol(x, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 36, 11)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 36, 8)) +>y : Symbol(y, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 36, 23)) +>T : Symbol(T, Decl(callSignaturesWithAccessibilityModifiersOnParameters.ts, 36, 8)) +} diff --git a/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.types b/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.types new file mode 100644 index 00000000000..af074b5faa0 --- /dev/null +++ b/tests/baselines/reference/callSignaturesWithAccessibilityModifiersOnParameters.types @@ -0,0 +1,161 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithAccessibilityModifiersOnParameters.ts === +// Call signature parameters do not allow accessibility modifiers + +function foo(public x, private y) { } +>foo : (public x: any, private y: any) => void +>x : any +>y : any + +var f = function foo(public x, private y) { } +>f : (public x: any, private y: any) => void +>function foo(public x, private y) { } : (public x: any, private y: any) => void +>foo : (public x: any, private y: any) => void +>x : any +>y : any + +var f2 = function (public x, private y) { } +>f2 : (public x: any, private y: any) => void +>function (public x, private y) { } : (public x: any, private y: any) => void +>x : any +>y : any + +var f3 = (x, private y) => { } +>f3 : (x: any, private y: any) => void +>(x, private y) => { } : (x: any, private y: any) => void +>x : any +>y : any + +var f4 = (public x: T, y: T) => { } +>f4 : (public x: T, y: T) => void +>(public x: T, y: T) => { } : (public x: T, y: T) => void +>T : T +>x : T +>T : T +>y : T +>T : T + +function foo2(private x: string, public y: number) { } +>foo2 : (private x: string, public y: number) => void +>x : string +>y : number + +var f5 = function foo(private x: string, public y: number) { } +>f5 : (private x: string, public y: number) => void +>function foo(private x: string, public y: number) { } : (private x: string, public y: number) => void +>foo : (private x: string, public y: number) => void +>x : string +>y : number + +var f6 = function (private x: string, public y: number) { } +>f6 : (private x: string, public y: number) => void +>function (private x: string, public y: number) { } : (private x: string, public y: number) => void +>x : string +>y : number + +var f7 = (private x: string, public y: number) => { } +>f7 : (private x: string, public y: number) => void +>(private x: string, public y: number) => { } : (private x: string, public y: number) => void +>x : string +>y : number + +var f8 = (private x: T, public y: T) => { } +>f8 : (private x: T, public y: T) => void +>(private x: T, public y: T) => { } : (private x: T, public y: T) => void +>T : T +>x : T +>T : T +>y : T +>T : T + +class C { +>C : C + + foo(public x, private y) { } +>foo : (public x: any, private y: any) => void +>x : any +>y : any + + foo2(public x: number, private y: string) { } +>foo2 : (public x: number, private y: string) => void +>x : number +>y : string + + foo3(public x: T, private y: T) { } +>foo3 : (public x: T, private y: T) => void +>T : T +>x : T +>T : T +>y : T +>T : T +} + +interface I { +>I : I + + (private x, public y); +>x : any +>y : any + + (private x: string, public y: number); +>x : string +>y : number + + foo(private x, public y); +>foo : { (private x: any, public y: any): any; (public x: number, y: string): any; } +>x : any +>y : any + + foo(public x: number, y: string); +>foo : { (private x: any, public y: any): any; (public x: number, y: string): any; } +>x : number +>y : string + + foo3(x: T, private y: T); +>foo3 : (x: T, private y: T) => any +>T : T +>x : T +>T : T +>y : T +>T : T +} + +var a: { +>a : { foo(public x: any, private y: any): any; foo2(private x: number, public y: string): any; } + + foo(public x, private y); +>foo : (public x: any, private y: any) => any +>x : any +>y : any + + foo2(private x: number, public y: string); +>foo2 : (private x: number, public y: string) => any +>x : number +>y : string + +}; + +var b = { +>b : { foo(public x: any, y: any): void; a: (x: number, private y: string) => void; b: (public x: T, private y: T) => void; } +>{ foo(public x, y) { }, a: function foo(x: number, private y: string) { }, b: (public x: T, private y: T) => { }} : { foo(public x: any, y: any): void; a: (x: number, private y: string) => void; b: (public x: T, private y: T) => void; } + + foo(public x, y) { }, +>foo : (public x: any, y: any) => void +>x : any +>y : any + + a: function foo(x: number, private y: string) { }, +>a : (x: number, private y: string) => void +>function foo(x: number, private y: string) { } : (x: number, private y: string) => void +>foo : (x: number, private y: string) => void +>x : number +>y : string + + b: (public x: T, private y: T) => { } +>b : (public x: T, private y: T) => void +>(public x: T, private y: T) => { } : (public x: T, private y: T) => void +>T : T +>x : T +>T : T +>y : T +>T : T +} diff --git a/tests/baselines/reference/callSignaturesWithDuplicateParameters.symbols b/tests/baselines/reference/callSignaturesWithDuplicateParameters.symbols new file mode 100644 index 00000000000..9adebf1a419 --- /dev/null +++ b/tests/baselines/reference/callSignaturesWithDuplicateParameters.symbols @@ -0,0 +1,150 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts === +// Duplicate parameter names are always an error + +function foo(x, x) { } +>foo : Symbol(foo, Decl(callSignaturesWithDuplicateParameters.ts, 0, 0)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 2, 13)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 2, 15)) + +var f = function foo(x, x) { } +>f : Symbol(f, Decl(callSignaturesWithDuplicateParameters.ts, 3, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithDuplicateParameters.ts, 3, 7)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 3, 21)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 3, 23)) + +var f2 = function (x, x) { } +>f2 : Symbol(f2, Decl(callSignaturesWithDuplicateParameters.ts, 4, 3)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 4, 19)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 4, 21)) + +var f3 = (x, x) => { } +>f3 : Symbol(f3, Decl(callSignaturesWithDuplicateParameters.ts, 5, 3)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 5, 10)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 5, 12)) + +var f4 = (x: T, x: T) => { } +>f4 : Symbol(f4, Decl(callSignaturesWithDuplicateParameters.ts, 6, 3)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 6, 10)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 6, 13)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 6, 10)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 6, 18)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 6, 10)) + +function foo2(x: string, x: number) { } +>foo2 : Symbol(foo2, Decl(callSignaturesWithDuplicateParameters.ts, 6, 31)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 8, 14)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 8, 24)) + +var f5 = function foo(x: string, x: number) { } +>f5 : Symbol(f5, Decl(callSignaturesWithDuplicateParameters.ts, 9, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithDuplicateParameters.ts, 9, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 9, 22)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 9, 32)) + +var f6 = function (x: string, x: number) { } +>f6 : Symbol(f6, Decl(callSignaturesWithDuplicateParameters.ts, 10, 3)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 10, 19)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 10, 29)) + +var f7 = (x: string, x: number) => { } +>f7 : Symbol(f7, Decl(callSignaturesWithDuplicateParameters.ts, 11, 3)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 11, 10)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 11, 20)) + +var f8 = (x: T, y: T) => { } +>f8 : Symbol(f8, Decl(callSignaturesWithDuplicateParameters.ts, 12, 3)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 12, 10)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 12, 13)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 12, 10)) +>y : Symbol(y, Decl(callSignaturesWithDuplicateParameters.ts, 12, 18)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 12, 10)) + +class C { +>C : Symbol(C, Decl(callSignaturesWithDuplicateParameters.ts, 12, 31)) + + foo(x, x) { } +>foo : Symbol(C.foo, Decl(callSignaturesWithDuplicateParameters.ts, 14, 9)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 15, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 15, 10)) + + foo2(x: number, x: string) { } +>foo2 : Symbol(C.foo2, Decl(callSignaturesWithDuplicateParameters.ts, 15, 17)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 16, 9)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 16, 19)) + + foo3(x: T, x: T) { } +>foo3 : Symbol(C.foo3, Decl(callSignaturesWithDuplicateParameters.ts, 16, 34)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 17, 9)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 17, 12)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 17, 9)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 17, 17)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 17, 9)) +} + +interface I { +>I : Symbol(I, Decl(callSignaturesWithDuplicateParameters.ts, 18, 1)) + + (x, x); +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 21, 5)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 21, 7)) + + (x: string, x: number); +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 22, 5)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 22, 15)) + + foo(x, x); +>foo : Symbol(I.foo, Decl(callSignaturesWithDuplicateParameters.ts, 22, 27), Decl(callSignaturesWithDuplicateParameters.ts, 23, 14)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 23, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 23, 10)) + + foo(x: number, x: string); +>foo : Symbol(I.foo, Decl(callSignaturesWithDuplicateParameters.ts, 22, 27), Decl(callSignaturesWithDuplicateParameters.ts, 23, 14)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 24, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 24, 18)) + + foo3(x: T, x: T); +>foo3 : Symbol(I.foo3, Decl(callSignaturesWithDuplicateParameters.ts, 24, 30)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 25, 9)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 25, 12)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 25, 9)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 25, 17)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 25, 9)) +} + +var a: { +>a : Symbol(a, Decl(callSignaturesWithDuplicateParameters.ts, 28, 3)) + + foo(x, x); +>foo : Symbol(foo, Decl(callSignaturesWithDuplicateParameters.ts, 28, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 29, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 29, 10)) + + foo2(x: number, x: string); +>foo2 : Symbol(foo2, Decl(callSignaturesWithDuplicateParameters.ts, 29, 14)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 30, 9)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 30, 19)) + +}; + +var b = { +>b : Symbol(b, Decl(callSignaturesWithDuplicateParameters.ts, 33, 3)) + + foo(x, x) { }, +>foo : Symbol(foo, Decl(callSignaturesWithDuplicateParameters.ts, 33, 9)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 34, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 34, 10)) + + a: function foo(x: number, x: string) { }, +>a : Symbol(a, Decl(callSignaturesWithDuplicateParameters.ts, 34, 18)) +>foo : Symbol(foo, Decl(callSignaturesWithDuplicateParameters.ts, 35, 6)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 35, 20)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 35, 30)) + + b: (x: T, x: T) => { } +>b : Symbol(b, Decl(callSignaturesWithDuplicateParameters.ts, 35, 46)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 36, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 36, 11)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 36, 8)) +>x : Symbol(x, Decl(callSignaturesWithDuplicateParameters.ts, 36, 16)) +>T : Symbol(T, Decl(callSignaturesWithDuplicateParameters.ts, 36, 8)) +} diff --git a/tests/baselines/reference/callSignaturesWithDuplicateParameters.types b/tests/baselines/reference/callSignaturesWithDuplicateParameters.types new file mode 100644 index 00000000000..926f1ca3313 --- /dev/null +++ b/tests/baselines/reference/callSignaturesWithDuplicateParameters.types @@ -0,0 +1,161 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithDuplicateParameters.ts === +// Duplicate parameter names are always an error + +function foo(x, x) { } +>foo : (x: any, x: any) => void +>x : any +>x : any + +var f = function foo(x, x) { } +>f : (x: any, x: any) => void +>function foo(x, x) { } : (x: any, x: any) => void +>foo : (x: any, x: any) => void +>x : any +>x : any + +var f2 = function (x, x) { } +>f2 : (x: any, x: any) => void +>function (x, x) { } : (x: any, x: any) => void +>x : any +>x : any + +var f3 = (x, x) => { } +>f3 : (x: any, x: any) => void +>(x, x) => { } : (x: any, x: any) => void +>x : any +>x : any + +var f4 = (x: T, x: T) => { } +>f4 : (x: T, x: T) => void +>(x: T, x: T) => { } : (x: T, x: T) => void +>T : T +>x : T +>T : T +>x : T +>T : T + +function foo2(x: string, x: number) { } +>foo2 : (x: string, x: number) => void +>x : string +>x : number + +var f5 = function foo(x: string, x: number) { } +>f5 : (x: string, x: number) => void +>function foo(x: string, x: number) { } : (x: string, x: number) => void +>foo : (x: string, x: number) => void +>x : string +>x : number + +var f6 = function (x: string, x: number) { } +>f6 : (x: string, x: number) => void +>function (x: string, x: number) { } : (x: string, x: number) => void +>x : string +>x : number + +var f7 = (x: string, x: number) => { } +>f7 : (x: string, x: number) => void +>(x: string, x: number) => { } : (x: string, x: number) => void +>x : string +>x : number + +var f8 = (x: T, y: T) => { } +>f8 : (x: T, y: T) => void +>(x: T, y: T) => { } : (x: T, y: T) => void +>T : T +>x : T +>T : T +>y : T +>T : T + +class C { +>C : C + + foo(x, x) { } +>foo : (x: any, x: any) => void +>x : any +>x : any + + foo2(x: number, x: string) { } +>foo2 : (x: number, x: string) => void +>x : number +>x : string + + foo3(x: T, x: T) { } +>foo3 : (x: T, x: T) => void +>T : T +>x : T +>T : T +>x : T +>T : T +} + +interface I { +>I : I + + (x, x); +>x : any +>x : any + + (x: string, x: number); +>x : string +>x : number + + foo(x, x); +>foo : { (x: any, x: any): any; (x: number, x: string): any; } +>x : any +>x : any + + foo(x: number, x: string); +>foo : { (x: any, x: any): any; (x: number, x: string): any; } +>x : number +>x : string + + foo3(x: T, x: T); +>foo3 : (x: T, x: T) => any +>T : T +>x : T +>T : T +>x : T +>T : T +} + +var a: { +>a : { foo(x: any, x: any): any; foo2(x: number, x: string): any; } + + foo(x, x); +>foo : (x: any, x: any) => any +>x : any +>x : any + + foo2(x: number, x: string); +>foo2 : (x: number, x: string) => any +>x : number +>x : string + +}; + +var b = { +>b : { foo(x: any, x: any): void; a: (x: number, x: string) => void; b: (x: T, x: T) => void; } +>{ foo(x, x) { }, a: function foo(x: number, x: string) { }, b: (x: T, x: T) => { }} : { foo(x: any, x: any): void; a: (x: number, x: string) => void; b: (x: T, x: T) => void; } + + foo(x, x) { }, +>foo : (x: any, x: any) => void +>x : any +>x : any + + a: function foo(x: number, x: string) { }, +>a : (x: number, x: string) => void +>function foo(x: number, x: string) { } : (x: number, x: string) => void +>foo : (x: number, x: string) => void +>x : number +>x : string + + b: (x: T, x: T) => { } +>b : (x: T, x: T) => void +>(x: T, x: T) => { } : (x: T, x: T) => void +>T : T +>x : T +>T : T +>x : T +>T : T +} diff --git a/tests/baselines/reference/callSignaturesWithParameterInitializers.symbols b/tests/baselines/reference/callSignaturesWithParameterInitializers.symbols new file mode 100644 index 00000000000..270d5562a04 --- /dev/null +++ b/tests/baselines/reference/callSignaturesWithParameterInitializers.symbols @@ -0,0 +1,166 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers.ts === +// Optional parameters allow initializers only in implementation signatures + +function foo(x = 1) { } +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 0, 0)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 2, 13)) + +var f = function foo(x = 1) { } +>f : Symbol(f, Decl(callSignaturesWithParameterInitializers.ts, 3, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 3, 7)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 3, 21)) + +var f2 = (x: number, y = 1) => { } +>f2 : Symbol(f2, Decl(callSignaturesWithParameterInitializers.ts, 4, 3)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 4, 10)) +>y : Symbol(y, Decl(callSignaturesWithParameterInitializers.ts, 4, 20)) + +foo(1); +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 0, 0)) + +foo(); +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 0, 0)) + +f(1); +>f : Symbol(f, Decl(callSignaturesWithParameterInitializers.ts, 3, 3)) + +f(); +>f : Symbol(f, Decl(callSignaturesWithParameterInitializers.ts, 3, 3)) + +f2(1); +>f2 : Symbol(f2, Decl(callSignaturesWithParameterInitializers.ts, 4, 3)) + +f2(1, 2); +>f2 : Symbol(f2, Decl(callSignaturesWithParameterInitializers.ts, 4, 3)) + +class C { +>C : Symbol(C, Decl(callSignaturesWithParameterInitializers.ts, 11, 9)) + + foo(x = 1) { } +>foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers.ts, 13, 9)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 14, 8)) +} + +var c: C; +>c : Symbol(c, Decl(callSignaturesWithParameterInitializers.ts, 17, 3)) +>C : Symbol(C, Decl(callSignaturesWithParameterInitializers.ts, 11, 9)) + +c.foo(); +>c.foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers.ts, 13, 9)) +>c : Symbol(c, Decl(callSignaturesWithParameterInitializers.ts, 17, 3)) +>foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers.ts, 13, 9)) + +c.foo(1); +>c.foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers.ts, 13, 9)) +>c : Symbol(c, Decl(callSignaturesWithParameterInitializers.ts, 17, 3)) +>foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers.ts, 13, 9)) + +// these are errors +interface I { +>I : Symbol(I, Decl(callSignaturesWithParameterInitializers.ts, 19, 9)) + + (x = 1); +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 23, 5)) + + foo(x: number, y = 1); +>foo : Symbol(I.foo, Decl(callSignaturesWithParameterInitializers.ts, 23, 12)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 24, 8)) +>y : Symbol(y, Decl(callSignaturesWithParameterInitializers.ts, 24, 18)) +} + +var i: I; +>i : Symbol(i, Decl(callSignaturesWithParameterInitializers.ts, 27, 3)) +>I : Symbol(I, Decl(callSignaturesWithParameterInitializers.ts, 19, 9)) + +i(); +>i : Symbol(i, Decl(callSignaturesWithParameterInitializers.ts, 27, 3)) + +i(1); +>i : Symbol(i, Decl(callSignaturesWithParameterInitializers.ts, 27, 3)) + +i.foo(1); +>i.foo : Symbol(I.foo, Decl(callSignaturesWithParameterInitializers.ts, 23, 12)) +>i : Symbol(i, Decl(callSignaturesWithParameterInitializers.ts, 27, 3)) +>foo : Symbol(I.foo, Decl(callSignaturesWithParameterInitializers.ts, 23, 12)) + +i.foo(1, 2); +>i.foo : Symbol(I.foo, Decl(callSignaturesWithParameterInitializers.ts, 23, 12)) +>i : Symbol(i, Decl(callSignaturesWithParameterInitializers.ts, 27, 3)) +>foo : Symbol(I.foo, Decl(callSignaturesWithParameterInitializers.ts, 23, 12)) + +// these are errors +var a: { +>a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 34, 3)) + + (x = 1); +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 35, 5)) + + foo(x = 1); +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 35, 12)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 36, 8)) +} + +a(); +>a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 34, 3)) + +a(1); +>a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 34, 3)) + +a.foo(); +>a.foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 35, 12)) +>a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 34, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 35, 12)) + +a.foo(1); +>a.foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 35, 12)) +>a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 34, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 35, 12)) + +var b = { +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 44, 3)) + + foo(x = 1) { }, +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 44, 9)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 45, 8)) + + a: function foo(x: number, y = 1) { }, +>a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 45, 19)) +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 46, 6)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 46, 20)) +>y : Symbol(y, Decl(callSignaturesWithParameterInitializers.ts, 46, 30)) + + b: (x = 1) => { } +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 46, 42)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers.ts, 47, 8)) +} + +b.foo(); +>b.foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 44, 9)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 44, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 44, 9)) + +b.foo(1); +>b.foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 44, 9)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 44, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers.ts, 44, 9)) + +b.a(1); +>b.a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 45, 19)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 44, 3)) +>a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 45, 19)) + +b.a(1, 2); +>b.a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 45, 19)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 44, 3)) +>a : Symbol(a, Decl(callSignaturesWithParameterInitializers.ts, 45, 19)) + +b.b(); +>b.b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 46, 42)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 44, 3)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 46, 42)) + +b.b(1); +>b.b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 46, 42)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 44, 3)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers.ts, 46, 42)) + diff --git a/tests/baselines/reference/callSignaturesWithParameterInitializers.types b/tests/baselines/reference/callSignaturesWithParameterInitializers.types new file mode 100644 index 00000000000..41e28dedaab --- /dev/null +++ b/tests/baselines/reference/callSignaturesWithParameterInitializers.types @@ -0,0 +1,221 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers.ts === +// Optional parameters allow initializers only in implementation signatures + +function foo(x = 1) { } +>foo : (x?: number) => void +>x : number +>1 : 1 + +var f = function foo(x = 1) { } +>f : (x?: number) => void +>function foo(x = 1) { } : (x?: number) => void +>foo : (x?: number) => void +>x : number +>1 : 1 + +var f2 = (x: number, y = 1) => { } +>f2 : (x: number, y?: number) => void +>(x: number, y = 1) => { } : (x: number, y?: number) => void +>x : number +>y : number +>1 : 1 + +foo(1); +>foo(1) : void +>foo : (x?: number) => void +>1 : 1 + +foo(); +>foo() : void +>foo : (x?: number) => void + +f(1); +>f(1) : void +>f : (x?: number) => void +>1 : 1 + +f(); +>f() : void +>f : (x?: number) => void + +f2(1); +>f2(1) : void +>f2 : (x: number, y?: number) => void +>1 : 1 + +f2(1, 2); +>f2(1, 2) : void +>f2 : (x: number, y?: number) => void +>1 : 1 +>2 : 2 + +class C { +>C : C + + foo(x = 1) { } +>foo : (x?: number) => void +>x : number +>1 : 1 +} + +var c: C; +>c : C +>C : C + +c.foo(); +>c.foo() : void +>c.foo : (x?: number) => void +>c : C +>foo : (x?: number) => void + +c.foo(1); +>c.foo(1) : void +>c.foo : (x?: number) => void +>c : C +>foo : (x?: number) => void +>1 : 1 + +// these are errors +interface I { +>I : I + + (x = 1); +>x : number +>1 : 1 + + foo(x: number, y = 1); +>foo : (x: number, y?: number) => any +>x : number +>y : number +>1 : 1 +} + +var i: I; +>i : I +>I : I + +i(); +>i() : any +>i : I + +i(1); +>i(1) : any +>i : I +>1 : 1 + +i.foo(1); +>i.foo(1) : any +>i.foo : (x: number, y?: number) => any +>i : I +>foo : (x: number, y?: number) => any +>1 : 1 + +i.foo(1, 2); +>i.foo(1, 2) : any +>i.foo : (x: number, y?: number) => any +>i : I +>foo : (x: number, y?: number) => any +>1 : 1 +>2 : 2 + +// these are errors +var a: { +>a : { (x?: number): any; foo(x?: number): any; } + + (x = 1); +>x : number +>1 : 1 + + foo(x = 1); +>foo : (x?: number) => any +>x : number +>1 : 1 +} + +a(); +>a() : any +>a : { (x?: number): any; foo(x?: number): any; } + +a(1); +>a(1) : any +>a : { (x?: number): any; foo(x?: number): any; } +>1 : 1 + +a.foo(); +>a.foo() : any +>a.foo : (x?: number) => any +>a : { (x?: number): any; foo(x?: number): any; } +>foo : (x?: number) => any + +a.foo(1); +>a.foo(1) : any +>a.foo : (x?: number) => any +>a : { (x?: number): any; foo(x?: number): any; } +>foo : (x?: number) => any +>1 : 1 + +var b = { +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } +>{ foo(x = 1) { }, a: function foo(x: number, y = 1) { }, b: (x = 1) => { }} : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } + + foo(x = 1) { }, +>foo : (x?: number) => void +>x : number +>1 : 1 + + a: function foo(x: number, y = 1) { }, +>a : (x: number, y?: number) => void +>function foo(x: number, y = 1) { } : (x: number, y?: number) => void +>foo : (x: number, y?: number) => void +>x : number +>y : number +>1 : 1 + + b: (x = 1) => { } +>b : (x?: number) => void +>(x = 1) => { } : (x?: number) => void +>x : number +>1 : 1 +} + +b.foo(); +>b.foo() : void +>b.foo : (x?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } +>foo : (x?: number) => void + +b.foo(1); +>b.foo(1) : void +>b.foo : (x?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } +>foo : (x?: number) => void +>1 : 1 + +b.a(1); +>b.a(1) : void +>b.a : (x: number, y?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } +>a : (x: number, y?: number) => void +>1 : 1 + +b.a(1, 2); +>b.a(1, 2) : void +>b.a : (x: number, y?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } +>a : (x: number, y?: number) => void +>1 : 1 +>2 : 2 + +b.b(); +>b.b() : void +>b.b : (x?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } +>b : (x?: number) => void + +b.b(1); +>b.b(1) : void +>b.b : (x?: number) => void +>b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } +>b : (x?: number) => void +>1 : 1 + diff --git a/tests/baselines/reference/callSignaturesWithParameterInitializers2.symbols b/tests/baselines/reference/callSignaturesWithParameterInitializers2.symbols new file mode 100644 index 00000000000..12f4aeb5ed3 --- /dev/null +++ b/tests/baselines/reference/callSignaturesWithParameterInitializers2.symbols @@ -0,0 +1,66 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts === +// Optional parameters allow initializers only in implementation signatures +// All the below declarations are errors + +function foo(x = 2); +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 0, 0), Decl(callSignaturesWithParameterInitializers2.ts, 3, 20)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers2.ts, 3, 13)) + +function foo(x = 1) { } +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 0, 0), Decl(callSignaturesWithParameterInitializers2.ts, 3, 20)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers2.ts, 4, 13)) + +foo(1); +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 0, 0), Decl(callSignaturesWithParameterInitializers2.ts, 3, 20)) + +foo(); +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 0, 0), Decl(callSignaturesWithParameterInitializers2.ts, 3, 20)) + +class C { +>C : Symbol(C, Decl(callSignaturesWithParameterInitializers2.ts, 7, 6)) + + foo(x = 2); +>foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers2.ts, 9, 9), Decl(callSignaturesWithParameterInitializers2.ts, 10, 15)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers2.ts, 10, 8)) + + foo(x = 1) { } +>foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers2.ts, 9, 9), Decl(callSignaturesWithParameterInitializers2.ts, 10, 15)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers2.ts, 11, 8)) +} + +var c: C; +>c : Symbol(c, Decl(callSignaturesWithParameterInitializers2.ts, 14, 3)) +>C : Symbol(C, Decl(callSignaturesWithParameterInitializers2.ts, 7, 6)) + +c.foo(); +>c.foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers2.ts, 9, 9), Decl(callSignaturesWithParameterInitializers2.ts, 10, 15)) +>c : Symbol(c, Decl(callSignaturesWithParameterInitializers2.ts, 14, 3)) +>foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers2.ts, 9, 9), Decl(callSignaturesWithParameterInitializers2.ts, 10, 15)) + +c.foo(1); +>c.foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers2.ts, 9, 9), Decl(callSignaturesWithParameterInitializers2.ts, 10, 15)) +>c : Symbol(c, Decl(callSignaturesWithParameterInitializers2.ts, 14, 3)) +>foo : Symbol(C.foo, Decl(callSignaturesWithParameterInitializers2.ts, 9, 9), Decl(callSignaturesWithParameterInitializers2.ts, 10, 15)) + +var b = { +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers2.ts, 18, 3)) + + foo(x = 1), // error +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 18, 9), Decl(callSignaturesWithParameterInitializers2.ts, 19, 15)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers2.ts, 19, 8)) + + foo(x = 1) { }, // error +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 18, 9), Decl(callSignaturesWithParameterInitializers2.ts, 19, 15)) +>x : Symbol(x, Decl(callSignaturesWithParameterInitializers2.ts, 20, 8)) +} + +b.foo(); +>b.foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 18, 9), Decl(callSignaturesWithParameterInitializers2.ts, 19, 15)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers2.ts, 18, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 18, 9), Decl(callSignaturesWithParameterInitializers2.ts, 19, 15)) + +b.foo(1); +>b.foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 18, 9), Decl(callSignaturesWithParameterInitializers2.ts, 19, 15)) +>b : Symbol(b, Decl(callSignaturesWithParameterInitializers2.ts, 18, 3)) +>foo : Symbol(foo, Decl(callSignaturesWithParameterInitializers2.ts, 18, 9), Decl(callSignaturesWithParameterInitializers2.ts, 19, 15)) + diff --git a/tests/baselines/reference/callSignaturesWithParameterInitializers2.types b/tests/baselines/reference/callSignaturesWithParameterInitializers2.types new file mode 100644 index 00000000000..b83c202eff6 --- /dev/null +++ b/tests/baselines/reference/callSignaturesWithParameterInitializers2.types @@ -0,0 +1,82 @@ +=== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesWithParameterInitializers2.ts === +// Optional parameters allow initializers only in implementation signatures +// All the below declarations are errors + +function foo(x = 2); +>foo : (x?: number) => any +>x : number +>2 : 2 + +function foo(x = 1) { } +>foo : (x?: number) => any +>x : number +>1 : 1 + +foo(1); +>foo(1) : any +>foo : (x?: number) => any +>1 : 1 + +foo(); +>foo() : any +>foo : (x?: number) => any + +class C { +>C : C + + foo(x = 2); +>foo : (x?: number) => any +>x : number +>2 : 2 + + foo(x = 1) { } +>foo : (x?: number) => any +>x : number +>1 : 1 +} + +var c: C; +>c : C +>C : C + +c.foo(); +>c.foo() : any +>c.foo : (x?: number) => any +>c : C +>foo : (x?: number) => any + +c.foo(1); +>c.foo(1) : any +>c.foo : (x?: number) => any +>c : C +>foo : (x?: number) => any +>1 : 1 + +var b = { +>b : { foo(x?: number): any; foo(x?: number): void; } +>{ foo(x = 1), // error foo(x = 1) { }, // error} : { foo(x?: number): any; foo(x?: number): void; } + + foo(x = 1), // error +>foo : { (x?: number): any; (x?: number): void; } +>x : number +>1 : 1 + + foo(x = 1) { }, // error +>foo : { (x?: number): any; (x?: number): void; } +>x : number +>1 : 1 +} + +b.foo(); +>b.foo() : any +>b.foo : { (x?: number): any; (x?: number): void; } +>b : { foo(x?: number): any; foo(x?: number): void; } +>foo : { (x?: number): any; (x?: number): void; } + +b.foo(1); +>b.foo(1) : any +>b.foo : { (x?: number): any; (x?: number): void; } +>b : { foo(x?: number): any; foo(x?: number): void; } +>foo : { (x?: number): any; (x?: number): void; } +>1 : 1 + diff --git a/tests/baselines/reference/callWithSpread2.symbols b/tests/baselines/reference/callWithSpread2.symbols new file mode 100644 index 00000000000..169e8c8d47e --- /dev/null +++ b/tests/baselines/reference/callWithSpread2.symbols @@ -0,0 +1,128 @@ +=== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts === +declare function all(a?: number, b?: number): void; +>all : Symbol(all, Decl(callWithSpread2.ts, 0, 0)) +>a : Symbol(a, Decl(callWithSpread2.ts, 0, 21)) +>b : Symbol(b, Decl(callWithSpread2.ts, 0, 32)) + +declare function weird(a?: number | string, b?: number | string): void; +>weird : Symbol(weird, Decl(callWithSpread2.ts, 0, 51)) +>a : Symbol(a, Decl(callWithSpread2.ts, 1, 23)) +>b : Symbol(b, Decl(callWithSpread2.ts, 1, 43)) + +declare function prefix(s: string, a?: number, b?: number): void; +>prefix : Symbol(prefix, Decl(callWithSpread2.ts, 1, 71)) +>s : Symbol(s, Decl(callWithSpread2.ts, 2, 24)) +>a : Symbol(a, Decl(callWithSpread2.ts, 2, 34)) +>b : Symbol(b, Decl(callWithSpread2.ts, 2, 46)) + +declare function rest(s: string, a?: number, b?: number, ...rest: number[]): void; +>rest : Symbol(rest, Decl(callWithSpread2.ts, 2, 65)) +>s : Symbol(s, Decl(callWithSpread2.ts, 3, 22)) +>a : Symbol(a, Decl(callWithSpread2.ts, 3, 32)) +>b : Symbol(b, Decl(callWithSpread2.ts, 3, 44)) +>rest : Symbol(rest, Decl(callWithSpread2.ts, 3, 56)) + +declare function normal(s: string): void; +>normal : Symbol(normal, Decl(callWithSpread2.ts, 3, 83)) +>s : Symbol(s, Decl(callWithSpread2.ts, 4, 24)) + +declare function thunk(): string; +>thunk : Symbol(thunk, Decl(callWithSpread2.ts, 4, 41)) + +declare var ns: number[]; +>ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) + +declare var mixed: (number | string)[]; +>mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) + +declare var tuple: [number, string]; +>tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) + +// good +all(...ns) +>all : Symbol(all, Decl(callWithSpread2.ts, 0, 0)) +>ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) + +weird(...ns) +>weird : Symbol(weird, Decl(callWithSpread2.ts, 0, 51)) +>ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) + +weird(...mixed) +>weird : Symbol(weird, Decl(callWithSpread2.ts, 0, 51)) +>mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) + +weird(...tuple) +>weird : Symbol(weird, Decl(callWithSpread2.ts, 0, 51)) +>tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) + +prefix("a", ...ns) +>prefix : Symbol(prefix, Decl(callWithSpread2.ts, 1, 71)) +>ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) + +rest("d", ...ns) +>rest : Symbol(rest, Decl(callWithSpread2.ts, 2, 65)) +>ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) + + +// this covers the arguments case +normal("g", ...ns) +>normal : Symbol(normal, Decl(callWithSpread2.ts, 3, 83)) +>ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) + +normal("h", ...mixed) +>normal : Symbol(normal, Decl(callWithSpread2.ts, 3, 83)) +>mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) + +normal("i", ...tuple) +>normal : Symbol(normal, Decl(callWithSpread2.ts, 3, 83)) +>tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) + +thunk(...ns) +>thunk : Symbol(thunk, Decl(callWithSpread2.ts, 4, 41)) +>ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) + +thunk(...mixed) +>thunk : Symbol(thunk, Decl(callWithSpread2.ts, 4, 41)) +>mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) + +thunk(...tuple) +>thunk : Symbol(thunk, Decl(callWithSpread2.ts, 4, 41)) +>tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) + +// bad +all(...mixed) +>all : Symbol(all, Decl(callWithSpread2.ts, 0, 0)) +>mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) + +all(...tuple) +>all : Symbol(all, Decl(callWithSpread2.ts, 0, 0)) +>tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) + +prefix("b", ...mixed) +>prefix : Symbol(prefix, Decl(callWithSpread2.ts, 1, 71)) +>mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) + +prefix("c", ...tuple) +>prefix : Symbol(prefix, Decl(callWithSpread2.ts, 1, 71)) +>tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) + +rest("e", ...mixed) +>rest : Symbol(rest, Decl(callWithSpread2.ts, 2, 65)) +>mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) + +rest("f", ...tuple) +>rest : Symbol(rest, Decl(callWithSpread2.ts, 2, 65)) +>tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) + +prefix(...ns) // required parameters are required +>prefix : Symbol(prefix, Decl(callWithSpread2.ts, 1, 71)) +>ns : Symbol(ns, Decl(callWithSpread2.ts, 7, 11)) + +prefix(...mixed) +>prefix : Symbol(prefix, Decl(callWithSpread2.ts, 1, 71)) +>mixed : Symbol(mixed, Decl(callWithSpread2.ts, 8, 11)) + +prefix(...tuple) +>prefix : Symbol(prefix, Decl(callWithSpread2.ts, 1, 71)) +>tuple : Symbol(tuple, Decl(callWithSpread2.ts, 9, 11)) + diff --git a/tests/baselines/reference/callWithSpread2.types b/tests/baselines/reference/callWithSpread2.types new file mode 100644 index 00000000000..75f0f18d287 --- /dev/null +++ b/tests/baselines/reference/callWithSpread2.types @@ -0,0 +1,179 @@ +=== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts === +declare function all(a?: number, b?: number): void; +>all : (a?: number, b?: number) => void +>a : number +>b : number + +declare function weird(a?: number | string, b?: number | string): void; +>weird : (a?: string | number, b?: string | number) => void +>a : string | number +>b : string | number + +declare function prefix(s: string, a?: number, b?: number): void; +>prefix : (s: string, a?: number, b?: number) => void +>s : string +>a : number +>b : number + +declare function rest(s: string, a?: number, b?: number, ...rest: number[]): void; +>rest : (s: string, a?: number, b?: number, ...rest: number[]) => void +>s : string +>a : number +>b : number +>rest : number[] + +declare function normal(s: string): void; +>normal : (s: string) => void +>s : string + +declare function thunk(): string; +>thunk : () => string + +declare var ns: number[]; +>ns : number[] + +declare var mixed: (number | string)[]; +>mixed : (string | number)[] + +declare var tuple: [number, string]; +>tuple : [number, string] + +// good +all(...ns) +>all(...ns) : void +>all : (a?: number, b?: number) => void +>...ns : number +>ns : number[] + +weird(...ns) +>weird(...ns) : void +>weird : (a?: string | number, b?: string | number) => void +>...ns : number +>ns : number[] + +weird(...mixed) +>weird(...mixed) : void +>weird : (a?: string | number, b?: string | number) => void +>...mixed : string | number +>mixed : (string | number)[] + +weird(...tuple) +>weird(...tuple) : void +>weird : (a?: string | number, b?: string | number) => void +>...tuple : string | number +>tuple : [number, string] + +prefix("a", ...ns) +>prefix("a", ...ns) : void +>prefix : (s: string, a?: number, b?: number) => void +>"a" : "a" +>...ns : number +>ns : number[] + +rest("d", ...ns) +>rest("d", ...ns) : void +>rest : (s: string, a?: number, b?: number, ...rest: number[]) => void +>"d" : "d" +>...ns : number +>ns : number[] + + +// this covers the arguments case +normal("g", ...ns) +>normal("g", ...ns) : void +>normal : (s: string) => void +>"g" : "g" +>...ns : number +>ns : number[] + +normal("h", ...mixed) +>normal("h", ...mixed) : void +>normal : (s: string) => void +>"h" : "h" +>...mixed : string | number +>mixed : (string | number)[] + +normal("i", ...tuple) +>normal("i", ...tuple) : void +>normal : (s: string) => void +>"i" : "i" +>...tuple : string | number +>tuple : [number, string] + +thunk(...ns) +>thunk(...ns) : string +>thunk : () => string +>...ns : number +>ns : number[] + +thunk(...mixed) +>thunk(...mixed) : string +>thunk : () => string +>...mixed : string | number +>mixed : (string | number)[] + +thunk(...tuple) +>thunk(...tuple) : string +>thunk : () => string +>...tuple : string | number +>tuple : [number, string] + +// bad +all(...mixed) +>all(...mixed) : void +>all : (a?: number, b?: number) => void +>...mixed : string | number +>mixed : (string | number)[] + +all(...tuple) +>all(...tuple) : void +>all : (a?: number, b?: number) => void +>...tuple : string | number +>tuple : [number, string] + +prefix("b", ...mixed) +>prefix("b", ...mixed) : void +>prefix : (s: string, a?: number, b?: number) => void +>"b" : "b" +>...mixed : string | number +>mixed : (string | number)[] + +prefix("c", ...tuple) +>prefix("c", ...tuple) : void +>prefix : (s: string, a?: number, b?: number) => void +>"c" : "c" +>...tuple : string | number +>tuple : [number, string] + +rest("e", ...mixed) +>rest("e", ...mixed) : void +>rest : (s: string, a?: number, b?: number, ...rest: number[]) => void +>"e" : "e" +>...mixed : string | number +>mixed : (string | number)[] + +rest("f", ...tuple) +>rest("f", ...tuple) : void +>rest : (s: string, a?: number, b?: number, ...rest: number[]) => void +>"f" : "f" +>...tuple : string | number +>tuple : [number, string] + +prefix(...ns) // required parameters are required +>prefix(...ns) : void +>prefix : (s: string, a?: number, b?: number) => void +>...ns : number +>ns : number[] + +prefix(...mixed) +>prefix(...mixed) : void +>prefix : (s: string, a?: number, b?: number) => void +>...mixed : string | number +>mixed : (string | number)[] + +prefix(...tuple) +>prefix(...tuple) : void +>prefix : (s: string, a?: number, b?: number) => void +>...tuple : string | number +>tuple : [number, string] + diff --git a/tests/baselines/reference/callWithWrongNumberOfTypeArguments.symbols b/tests/baselines/reference/callWithWrongNumberOfTypeArguments.symbols new file mode 100644 index 00000000000..ad721c454b9 --- /dev/null +++ b/tests/baselines/reference/callWithWrongNumberOfTypeArguments.symbols @@ -0,0 +1,15 @@ +=== tests/cases/compiler/callWithWrongNumberOfTypeArguments.ts === +function f() { } +>f : Symbol(f, Decl(callWithWrongNumberOfTypeArguments.ts, 0, 0)) +>T : Symbol(T, Decl(callWithWrongNumberOfTypeArguments.ts, 0, 11)) +>U : Symbol(U, Decl(callWithWrongNumberOfTypeArguments.ts, 0, 13)) + +f(); +>f : Symbol(f, Decl(callWithWrongNumberOfTypeArguments.ts, 0, 0)) + +f(); +>f : Symbol(f, Decl(callWithWrongNumberOfTypeArguments.ts, 0, 0)) + +f(); +>f : Symbol(f, Decl(callWithWrongNumberOfTypeArguments.ts, 0, 0)) + diff --git a/tests/baselines/reference/callWithWrongNumberOfTypeArguments.types b/tests/baselines/reference/callWithWrongNumberOfTypeArguments.types new file mode 100644 index 00000000000..0056a0d3e9a --- /dev/null +++ b/tests/baselines/reference/callWithWrongNumberOfTypeArguments.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/callWithWrongNumberOfTypeArguments.ts === +function f() { } +>f : () => void +>T : T +>U : U + +f(); +>f() : any +>f : () => void + +f(); +>f() : void +>f : () => void + +f(); +>f() : any +>f : () => void + diff --git a/tests/baselines/reference/callbackArgsDifferByOptionality.symbols b/tests/baselines/reference/callbackArgsDifferByOptionality.symbols new file mode 100644 index 00000000000..283d414b61b --- /dev/null +++ b/tests/baselines/reference/callbackArgsDifferByOptionality.symbols @@ -0,0 +1,18 @@ +=== tests/cases/compiler/callbackArgsDifferByOptionality.ts === +function x3(callback: (x?: 'hi') => number); +>x3 : Symbol(x3, Decl(callbackArgsDifferByOptionality.ts, 0, 0), Decl(callbackArgsDifferByOptionality.ts, 0, 44), Decl(callbackArgsDifferByOptionality.ts, 1, 45)) +>callback : Symbol(callback, Decl(callbackArgsDifferByOptionality.ts, 0, 12)) +>x : Symbol(x, Decl(callbackArgsDifferByOptionality.ts, 0, 23)) + +function x3(callback: (x: string) => number); +>x3 : Symbol(x3, Decl(callbackArgsDifferByOptionality.ts, 0, 0), Decl(callbackArgsDifferByOptionality.ts, 0, 44), Decl(callbackArgsDifferByOptionality.ts, 1, 45)) +>callback : Symbol(callback, Decl(callbackArgsDifferByOptionality.ts, 1, 12)) +>x : Symbol(x, Decl(callbackArgsDifferByOptionality.ts, 1, 23)) + +function x3(callback: (x: any) => number) { +>x3 : Symbol(x3, Decl(callbackArgsDifferByOptionality.ts, 0, 0), Decl(callbackArgsDifferByOptionality.ts, 0, 44), Decl(callbackArgsDifferByOptionality.ts, 1, 45)) +>callback : Symbol(callback, Decl(callbackArgsDifferByOptionality.ts, 2, 12)) +>x : Symbol(x, Decl(callbackArgsDifferByOptionality.ts, 2, 23)) + + cb(); +} diff --git a/tests/baselines/reference/callbackArgsDifferByOptionality.types b/tests/baselines/reference/callbackArgsDifferByOptionality.types new file mode 100644 index 00000000000..d54360c0656 --- /dev/null +++ b/tests/baselines/reference/callbackArgsDifferByOptionality.types @@ -0,0 +1,20 @@ +=== tests/cases/compiler/callbackArgsDifferByOptionality.ts === +function x3(callback: (x?: 'hi') => number); +>x3 : { (callback: (x?: "hi") => number): any; (callback: (x: string) => number): any; } +>callback : (x?: "hi") => number +>x : "hi" + +function x3(callback: (x: string) => number); +>x3 : { (callback: (x?: "hi") => number): any; (callback: (x: string) => number): any; } +>callback : (x: string) => number +>x : string + +function x3(callback: (x: any) => number) { +>x3 : { (callback: (x?: "hi") => number): any; (callback: (x: string) => number): any; } +>callback : (x: any) => number +>x : any + + cb(); +>cb() : any +>cb : any +} diff --git a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.symbols b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.symbols new file mode 100644 index 00000000000..fb87705371b --- /dev/null +++ b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts === +module M +>M : Symbol(M, Decl(cannotInvokeNewOnErrorExpression.ts, 0, 0)) +{ + class ClassA {} +>ClassA : Symbol(ClassA, Decl(cannotInvokeNewOnErrorExpression.ts, 1, 1)) +} +var t = new M.ClassA[]; +>t : Symbol(t, Decl(cannotInvokeNewOnErrorExpression.ts, 4, 3)) +>M : Symbol(M, Decl(cannotInvokeNewOnErrorExpression.ts, 0, 0)) + diff --git a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.types b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.types new file mode 100644 index 00000000000..47ccb421623 --- /dev/null +++ b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/cannotInvokeNewOnErrorExpression.ts === +module M +>M : typeof M +{ + class ClassA {} +>ClassA : ClassA +} +var t = new M.ClassA[]; +>t : any +>new M.ClassA[] : any +>M.ClassA[] : any +>M.ClassA : any +>M : typeof M +>ClassA : any + diff --git a/tests/baselines/reference/cannotInvokeNewOnIndexExpression.symbols b/tests/baselines/reference/cannotInvokeNewOnIndexExpression.symbols new file mode 100644 index 00000000000..7ac266b2728 --- /dev/null +++ b/tests/baselines/reference/cannotInvokeNewOnIndexExpression.symbols @@ -0,0 +1,4 @@ +=== tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts === +var test: any[] = new any[1]; +>test : Symbol(test, Decl(cannotInvokeNewOnIndexExpression.ts, 0, 3)) + diff --git a/tests/baselines/reference/cannotInvokeNewOnIndexExpression.types b/tests/baselines/reference/cannotInvokeNewOnIndexExpression.types new file mode 100644 index 00000000000..ec1a2b6dda1 --- /dev/null +++ b/tests/baselines/reference/cannotInvokeNewOnIndexExpression.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts === +var test: any[] = new any[1]; +>test : any[] +>new any[1] : any +>any[1] : any +>any : any +>1 : 1 + diff --git a/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.symbols b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.symbols new file mode 100644 index 00000000000..a2cad82ec4e --- /dev/null +++ b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.symbols @@ -0,0 +1,23 @@ +=== tests/cases/compiler/captureSuperPropertyAccessInSuperCall01.ts === +class A { +>A : Symbol(A, Decl(captureSuperPropertyAccessInSuperCall01.ts, 0, 0)) + + constructor(f: () => string) { +>f : Symbol(f, Decl(captureSuperPropertyAccessInSuperCall01.ts, 1, 13)) + } + public blah(): string { return ""; } +>blah : Symbol(A.blah, Decl(captureSuperPropertyAccessInSuperCall01.ts, 2, 2)) +} + +class B extends A { +>B : Symbol(B, Decl(captureSuperPropertyAccessInSuperCall01.ts, 4, 1)) +>A : Symbol(A, Decl(captureSuperPropertyAccessInSuperCall01.ts, 0, 0)) + + constructor() { + super(() => { return super.blah(); }) +>super : Symbol(A, Decl(captureSuperPropertyAccessInSuperCall01.ts, 0, 0)) +>super.blah : Symbol(A.blah, Decl(captureSuperPropertyAccessInSuperCall01.ts, 2, 2)) +>super : Symbol(A, Decl(captureSuperPropertyAccessInSuperCall01.ts, 0, 0)) +>blah : Symbol(A.blah, Decl(captureSuperPropertyAccessInSuperCall01.ts, 2, 2)) + } +} diff --git a/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.types b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.types new file mode 100644 index 00000000000..154d018eb42 --- /dev/null +++ b/tests/baselines/reference/captureSuperPropertyAccessInSuperCall01.types @@ -0,0 +1,27 @@ +=== tests/cases/compiler/captureSuperPropertyAccessInSuperCall01.ts === +class A { +>A : A + + constructor(f: () => string) { +>f : () => string + } + public blah(): string { return ""; } +>blah : () => string +>"" : "" +} + +class B extends A { +>B : B +>A : A + + constructor() { + super(() => { return super.blah(); }) +>super(() => { return super.blah(); }) : void +>super : typeof A +>() => { return super.blah(); } : () => string +>super.blah() : string +>super.blah : () => string +>super : A +>blah : () => string + } +} diff --git a/tests/baselines/reference/capturedLetConstInLoop5.types b/tests/baselines/reference/capturedLetConstInLoop5.types index 098a1ce70a4..3ec96ca37da 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5.types +++ b/tests/baselines/reference/capturedLetConstInLoop5.types @@ -92,10 +92,10 @@ function foo1(x) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -143,7 +143,7 @@ function foo2(x) { let x = 1; >x : number ->1 : number +>1 : 1 var v = x; >v : number @@ -227,10 +227,10 @@ function foo4(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number @@ -240,7 +240,7 @@ function foo4(x) { let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + v }); >(function() { return x + v }) : () => number @@ -277,12 +277,12 @@ function foo5(x) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -430,16 +430,16 @@ function foo8(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 var v = x; >v : number @@ -566,33 +566,33 @@ function foo1_c(x) { >x : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v = x; >v : number ->x : number +>x : 0 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 0 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 0 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 return; @@ -615,30 +615,30 @@ function foo2_c(x) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 1 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 1 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; @@ -657,8 +657,8 @@ function foo3_c(x) { do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v; >v : any @@ -667,19 +667,19 @@ function foo3_c(x) { >(function() { return x + v }) : () => any >function() { return x + v } : () => any >x + v : any ->x : number +>x : 1 >v : any (() => x + v); >(() => x + v) : () => any >() => x + v : () => any >x + v : any ->x : number +>x : 1 >v : any if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; @@ -700,19 +700,19 @@ function foo4_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 var v = y; >v : number ->y : number +>y : 0 let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + v }); >(function() { return x + v }) : () => number @@ -748,25 +748,25 @@ function foo5_c(x) { >x : any for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v = x; >v : number ->x : number +>x : 0 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v : number (() => x + y + v); @@ -774,13 +774,13 @@ function foo5_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 return; @@ -804,22 +804,22 @@ function foo6_c(x) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number (() => x + y + v); @@ -827,13 +827,13 @@ function foo6_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; @@ -852,22 +852,22 @@ function foo7_c(x) { do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number (() => x + y + v); @@ -875,13 +875,13 @@ function foo7_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; @@ -903,27 +903,27 @@ function foo8_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v : number (() => x + y + v); @@ -931,13 +931,13 @@ function foo8_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.symbols b/tests/baselines/reference/capturedLetConstInLoop5_ES6.symbols index 5b40cb44599..7e3d9a07422 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5_ES6.symbols +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.symbols @@ -1,31 +1,30 @@ === tests/cases/compiler/capturedLetConstInLoop5_ES6.ts === - declare function use(a: any); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->a : Symbol(a, Decl(capturedLetConstInLoop5_ES6.ts, 1, 21)) +>a : Symbol(a, Decl(capturedLetConstInLoop5_ES6.ts, 0, 21)) //====let function foo0(x) { ->foo0 : Symbol(foo0, Decl(capturedLetConstInLoop5_ES6.ts, 1, 29)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 4, 14)) +>foo0 : Symbol(foo0, Decl(capturedLetConstInLoop5_ES6.ts, 0, 29)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 3, 14)) for (let x of []) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 5, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 4, 12)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 6, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 5, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 5, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 4, 12)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 5, 12)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 6, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 4, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 5, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 5, 12)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 6, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 4, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 5, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 5, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 4, 12)) return; } @@ -33,30 +32,30 @@ function foo0(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 6, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 5, 11)) } function foo00(x) { ->foo00 : Symbol(foo00, Decl(capturedLetConstInLoop5_ES6.ts, 15, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 17, 15)) +>foo00 : Symbol(foo00, Decl(capturedLetConstInLoop5_ES6.ts, 14, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 16, 15)) for (let x in []) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 18, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 17, 12)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 19, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 18, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 18, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 17, 12)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 18, 12)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 19, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 17, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 18, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 18, 12)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 19, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 17, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 18, 11)) if (x == "1") { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 18, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 17, 12)) return; } @@ -64,32 +63,32 @@ function foo00(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 19, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 18, 11)) } function foo1(x) { ->foo1 : Symbol(foo1, Decl(capturedLetConstInLoop5_ES6.ts, 28, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 30, 14)) +>foo1 : Symbol(foo1, Decl(capturedLetConstInLoop5_ES6.ts, 27, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 29, 14)) for (let x = 0; x < 1; ++x) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 31, 12)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 31, 12)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 31, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 30, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 30, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 30, 12)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 32, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 31, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 31, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 30, 12)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 31, 12)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 32, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 30, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 31, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 31, 12)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 32, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 30, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 31, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 31, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 30, 12)) return; } @@ -97,31 +96,31 @@ function foo1(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 32, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 31, 11)) } function foo2(x) { ->foo2 : Symbol(foo2, Decl(capturedLetConstInLoop5_ES6.ts, 41, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 43, 14)) +>foo2 : Symbol(foo2, Decl(capturedLetConstInLoop5_ES6.ts, 40, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 42, 14)) while (1 === 1) { let x = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 44, 11)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 46, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 44, 11)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 46, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 44, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 46, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 44, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 44, 11)) return; } @@ -129,30 +128,30 @@ function foo2(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 46, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 45, 11)) } function foo3(x) { ->foo3 : Symbol(foo3, Decl(capturedLetConstInLoop5_ES6.ts, 55, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 57, 14)) +>foo3 : Symbol(foo3, Decl(capturedLetConstInLoop5_ES6.ts, 54, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 56, 14)) do { let x; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 59, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 58, 11)) var v; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 60, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 59, 11)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 59, 11)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 60, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 58, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 59, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 59, 11)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 60, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 58, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 59, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 59, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 58, 11)) return; } @@ -160,35 +159,35 @@ function foo3(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 60, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 59, 11)) } function foo4(x) { ->foo4 : Symbol(foo4, Decl(capturedLetConstInLoop5_ES6.ts, 69, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 71, 14)) +>foo4 : Symbol(foo4, Decl(capturedLetConstInLoop5_ES6.ts, 68, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 70, 14)) for (let y = 0; y < 1; ++y) { ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 72, 12)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 72, 12)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 72, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 71, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 71, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 71, 12)) var v = y; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 73, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 72, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 72, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 71, 12)) let x = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 74, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 73, 11)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 74, 11)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 73, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 73, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 72, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 74, 11)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 73, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 73, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 72, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 74, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 73, 11)) return; } @@ -196,35 +195,35 @@ function foo4(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 73, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 72, 11)) } function foo5(x) { ->foo5 : Symbol(foo5, Decl(capturedLetConstInLoop5_ES6.ts, 83, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 85, 14)) +>foo5 : Symbol(foo5, Decl(capturedLetConstInLoop5_ES6.ts, 82, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 84, 14)) for (let x = 0, y = 1; x < 1; ++x) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 86, 12)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 86, 19)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 86, 12)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 86, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 85, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 85, 19)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 85, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 85, 12)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 87, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 86, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 86, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 85, 12)) (function() { return x + y + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 86, 12)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 86, 19)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 87, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 85, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 85, 19)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 86, 11)) (() => x + y + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 86, 12)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 86, 19)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 87, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 85, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 85, 19)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 86, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 86, 12)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 85, 12)) return; } @@ -232,35 +231,35 @@ function foo5(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 87, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 86, 11)) } function foo6(x) { ->foo6 : Symbol(foo6, Decl(capturedLetConstInLoop5_ES6.ts, 96, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 99, 14)) +>foo6 : Symbol(foo6, Decl(capturedLetConstInLoop5_ES6.ts, 95, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 98, 14)) while (1 === 1) { let x, y; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 101, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 100, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 100, 14)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 102, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 100, 11)) (function() { return x + y + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 101, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 102, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 100, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 100, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) (() => x + y + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 101, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 102, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 100, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 100, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 100, 11)) return; } @@ -268,34 +267,34 @@ function foo6(x) { use(v) >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 102, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 101, 11)) } function foo7(x) { ->foo7 : Symbol(foo7, Decl(capturedLetConstInLoop5_ES6.ts, 111, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 113, 14)) +>foo7 : Symbol(foo7, Decl(capturedLetConstInLoop5_ES6.ts, 110, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 112, 14)) do { let x, y; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 115, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 114, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 114, 14)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 116, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 114, 11)) (function() { return x + y + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 115, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 116, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 114, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 114, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) (() => x + y + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 115, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 116, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 114, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 114, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 114, 11)) return; } @@ -303,38 +302,38 @@ function foo7(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 116, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 115, 11)) } function foo8(x) { ->foo8 : Symbol(foo8, Decl(capturedLetConstInLoop5_ES6.ts, 125, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 128, 14)) +>foo8 : Symbol(foo8, Decl(capturedLetConstInLoop5_ES6.ts, 124, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 127, 14)) for (let y = 0; y < 1; ++y) { ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 129, 12)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 129, 12)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 129, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 128, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 128, 12)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 128, 12)) let x = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 129, 11)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 131, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 129, 11)) (function() { return x + y + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 129, 12)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 131, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 129, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 128, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) (() => x + y + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 129, 12)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 131, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 129, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 128, 12)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 129, 11)) return; } @@ -342,31 +341,31 @@ function foo8(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 131, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 130, 11)) } //====const function foo0_c(x) { ->foo0_c : Symbol(foo0_c, Decl(capturedLetConstInLoop5_ES6.ts, 140, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 143, 16)) +>foo0_c : Symbol(foo0_c, Decl(capturedLetConstInLoop5_ES6.ts, 139, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 142, 16)) for (const x of []) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 144, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 143, 14)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 145, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 144, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 144, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 143, 14)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 144, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 145, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 143, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 144, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 144, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 145, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 143, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 144, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 144, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 143, 14)) return; } @@ -374,30 +373,30 @@ function foo0_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 145, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 144, 11)) } function foo00_c(x) { ->foo00_c : Symbol(foo00_c, Decl(capturedLetConstInLoop5_ES6.ts, 154, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 156, 17)) +>foo00_c : Symbol(foo00_c, Decl(capturedLetConstInLoop5_ES6.ts, 153, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 155, 17)) for (const x in []) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 157, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 156, 14)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 158, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 157, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 157, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 156, 14)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 157, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 158, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 156, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 157, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 157, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 158, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 156, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 157, 11)) if (x == "1") { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 157, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 156, 14)) return; } @@ -405,31 +404,31 @@ function foo00_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 158, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 157, 11)) } function foo1_c(x) { ->foo1_c : Symbol(foo1_c, Decl(capturedLetConstInLoop5_ES6.ts, 167, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 169, 16)) +>foo1_c : Symbol(foo1_c, Decl(capturedLetConstInLoop5_ES6.ts, 166, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 168, 16)) for (const x = 0; x < 1;) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 170, 14)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 170, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 169, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 169, 14)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 171, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 170, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 170, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 169, 14)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 170, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 171, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 169, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 170, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 170, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 171, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 169, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 170, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 170, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 169, 14)) return; } @@ -437,31 +436,31 @@ function foo1_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 171, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 170, 11)) } function foo2_c(x) { ->foo2_c : Symbol(foo2_c, Decl(capturedLetConstInLoop5_ES6.ts, 180, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 182, 16)) +>foo2_c : Symbol(foo2_c, Decl(capturedLetConstInLoop5_ES6.ts, 179, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 181, 16)) while (1 === 1) { const x = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 184, 13)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 183, 13)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 185, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 184, 13)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 184, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 183, 13)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 184, 13)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 185, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 183, 13)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 184, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 184, 13)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 185, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 183, 13)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 184, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 184, 13)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 183, 13)) return; } @@ -469,30 +468,30 @@ function foo2_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 185, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 184, 11)) } function foo3_c(x) { ->foo3_c : Symbol(foo3_c, Decl(capturedLetConstInLoop5_ES6.ts, 194, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 196, 16)) +>foo3_c : Symbol(foo3_c, Decl(capturedLetConstInLoop5_ES6.ts, 193, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 195, 16)) do { const x = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 198, 13)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 197, 13)) var v; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 199, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 198, 11)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 198, 13)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 199, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 197, 13)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 198, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 198, 13)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 199, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 197, 13)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 198, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 198, 13)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 197, 13)) return; } @@ -500,34 +499,34 @@ function foo3_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 199, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 198, 11)) } function foo4_c(x) { ->foo4_c : Symbol(foo4_c, Decl(capturedLetConstInLoop5_ES6.ts, 208, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 210, 16)) +>foo4_c : Symbol(foo4_c, Decl(capturedLetConstInLoop5_ES6.ts, 207, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 209, 16)) for (const y = 0; y < 1;) { ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 211, 14)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 211, 14)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 210, 14)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 210, 14)) var v = y; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 212, 11)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 211, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 211, 11)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 210, 14)) let x = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 213, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 212, 11)) (function() { return x + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 213, 11)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 212, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 212, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 211, 11)) (() => x + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 213, 11)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 212, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 212, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 211, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 213, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 212, 11)) return; } @@ -535,34 +534,34 @@ function foo4_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 212, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 211, 11)) } function foo5_c(x) { ->foo5_c : Symbol(foo5_c, Decl(capturedLetConstInLoop5_ES6.ts, 222, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 224, 16)) +>foo5_c : Symbol(foo5_c, Decl(capturedLetConstInLoop5_ES6.ts, 221, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 223, 16)) for (const x = 0, y = 1; x < 1;) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 225, 14)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 225, 21)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 225, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 224, 14)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 224, 21)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 224, 14)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 226, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 225, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 225, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 224, 14)) (function() { return x + y + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 225, 14)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 225, 21)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 226, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 224, 14)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 224, 21)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 225, 11)) (() => x + y + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 225, 14)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 225, 21)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 226, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 224, 14)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 224, 21)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 225, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 225, 14)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 224, 14)) return; } @@ -570,35 +569,35 @@ function foo5_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 226, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 225, 11)) } function foo6_c(x) { ->foo6_c : Symbol(foo6_c, Decl(capturedLetConstInLoop5_ES6.ts, 235, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 238, 16)) +>foo6_c : Symbol(foo6_c, Decl(capturedLetConstInLoop5_ES6.ts, 234, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 237, 16)) while (1 === 1) { const x = 1, y = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 240, 13)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 240, 20)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 239, 13)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 239, 20)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 241, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 240, 13)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 240, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 239, 13)) (function() { return x + y + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 240, 13)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 240, 20)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 241, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 239, 13)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 239, 20)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 240, 11)) (() => x + y + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 240, 13)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 240, 20)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 241, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 239, 13)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 239, 20)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 240, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 240, 13)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 239, 13)) return; } @@ -606,34 +605,34 @@ function foo6_c(x) { use(v) >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 241, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 240, 11)) } function foo7_c(x) { ->foo7_c : Symbol(foo7_c, Decl(capturedLetConstInLoop5_ES6.ts, 250, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 252, 16)) +>foo7_c : Symbol(foo7_c, Decl(capturedLetConstInLoop5_ES6.ts, 249, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 251, 16)) do { const x = 1, y = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 254, 13)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 254, 20)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 253, 13)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 253, 20)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 255, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 254, 13)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 254, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 253, 13)) (function() { return x + y + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 254, 13)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 254, 20)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 255, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 253, 13)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 253, 20)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 254, 11)) (() => x + y + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 254, 13)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 254, 20)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 255, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 253, 13)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 253, 20)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 254, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 254, 13)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 253, 13)) return; } @@ -641,37 +640,37 @@ function foo7_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 255, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 254, 11)) } function foo8_c(x) { ->foo8_c : Symbol(foo8_c, Decl(capturedLetConstInLoop5_ES6.ts, 264, 1)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 267, 16)) +>foo8_c : Symbol(foo8_c, Decl(capturedLetConstInLoop5_ES6.ts, 263, 1)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 266, 16)) for (const y = 0; y < 1;) { ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 268, 14)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 268, 14)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 267, 14)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 267, 14)) const x = 1; ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 269, 13)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 268, 13)) var v = x; ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 270, 11)) ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 269, 13)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 269, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 268, 13)) (function() { return x + y + v }); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 269, 13)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 268, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 270, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 268, 13)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 267, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 269, 11)) (() => x + y + v); ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 269, 13)) ->y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 268, 14)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 270, 11)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 268, 13)) +>y : Symbol(y, Decl(capturedLetConstInLoop5_ES6.ts, 267, 14)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 269, 11)) if (x == 1) { ->x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 269, 13)) +>x : Symbol(x, Decl(capturedLetConstInLoop5_ES6.ts, 268, 13)) return; } @@ -679,5 +678,5 @@ function foo8_c(x) { use(v); >use : Symbol(use, Decl(capturedLetConstInLoop5_ES6.ts, 0, 0)) ->v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 270, 11)) +>v : Symbol(v, Decl(capturedLetConstInLoop5_ES6.ts, 269, 11)) } diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.types b/tests/baselines/reference/capturedLetConstInLoop5_ES6.types index 78b41d7cdf3..0a59687ebb3 100644 --- a/tests/baselines/reference/capturedLetConstInLoop5_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.types @@ -1,5 +1,4 @@ === tests/cases/compiler/capturedLetConstInLoop5_ES6.ts === - declare function use(a: any); >use : (a: any) => any >a : any @@ -93,10 +92,10 @@ function foo1(x) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -144,7 +143,7 @@ function foo2(x) { let x = 1; >x : number ->1 : number +>1 : 1 var v = x; >v : number @@ -228,10 +227,10 @@ function foo4(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number @@ -241,7 +240,7 @@ function foo4(x) { let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + v }); >(function() { return x + v }) : () => number @@ -278,12 +277,12 @@ function foo5(x) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -431,16 +430,16 @@ function foo8(x) { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 var v = x; >v : number @@ -567,33 +566,33 @@ function foo1_c(x) { >x : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v = x; >v : number ->x : number +>x : 0 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 0 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 0 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 return; @@ -616,30 +615,30 @@ function foo2_c(x) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + v }); >(function() { return x + v }) : () => number >function() { return x + v } : () => number >x + v : number ->x : number +>x : 1 >v : number (() => x + v); >(() => x + v) : () => number >() => x + v : () => number >x + v : number ->x : number +>x : 1 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; @@ -658,8 +657,8 @@ function foo3_c(x) { do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v; >v : any @@ -668,19 +667,19 @@ function foo3_c(x) { >(function() { return x + v }) : () => any >function() { return x + v } : () => any >x + v : any ->x : number +>x : 1 >v : any (() => x + v); >(() => x + v) : () => any >() => x + v : () => any >x + v : any ->x : number +>x : 1 >v : any if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; @@ -701,19 +700,19 @@ function foo4_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 var v = y; >v : number ->y : number +>y : 0 let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + v }); >(function() { return x + v }) : () => number @@ -749,25 +748,25 @@ function foo5_c(x) { >x : any for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 var v = x; >v : number ->x : number +>x : 0 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v : number (() => x + y + v); @@ -775,13 +774,13 @@ function foo5_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 return; @@ -805,22 +804,22 @@ function foo6_c(x) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number (() => x + y + v); @@ -828,13 +827,13 @@ function foo6_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; @@ -853,22 +852,22 @@ function foo7_c(x) { do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number (() => x + y + v); @@ -876,13 +875,13 @@ function foo7_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; @@ -904,27 +903,27 @@ function foo8_c(x) { >x : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 var v = x; >v : number ->x : number +>x : 1 (function() { return x + y + v }); >(function() { return x + y + v }) : () => number >function() { return x + y + v } : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v : number (() => x + y + v); @@ -932,13 +931,13 @@ function foo8_c(x) { >() => x + y + v : () => number >x + y + v : number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 >v : number if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 return; diff --git a/tests/baselines/reference/capturedLetConstInLoop6.types b/tests/baselines/reference/capturedLetConstInLoop6.types index a7d28222bb0..c7f6392139e 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6.types +++ b/tests/baselines/reference/capturedLetConstInLoop6.types @@ -63,10 +63,10 @@ for (let x in []) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -165,16 +165,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x}); >(function() { return x}) : () => number @@ -204,12 +204,12 @@ for (let y = 0; y < 1; ++y) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -322,16 +322,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number @@ -427,32 +427,32 @@ for (const x in []) { for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 0 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 0 if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; @@ -465,29 +465,29 @@ while (1 === 1) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -496,29 +496,29 @@ while (1 === 1) { do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -529,36 +529,36 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -566,38 +566,38 @@ for (const y = 0; y < 1;) { } for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; @@ -610,35 +610,35 @@ while (1 === 1) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -647,35 +647,35 @@ while (1 === 1) { do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -686,40 +686,40 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; diff --git a/tests/baselines/reference/capturedLetConstInLoop6_ES6.types b/tests/baselines/reference/capturedLetConstInLoop6_ES6.types index 14635c0cd1c..79da473e934 100644 --- a/tests/baselines/reference/capturedLetConstInLoop6_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop6_ES6.types @@ -63,10 +63,10 @@ for (let x in []) { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -165,16 +165,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x}); >(function() { return x}) : () => number @@ -204,12 +204,12 @@ for (let y = 0; y < 1; ++y) { for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -322,16 +322,16 @@ do { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number @@ -427,32 +427,32 @@ for (const x in []) { for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 0 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 0 if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; @@ -465,29 +465,29 @@ while (1 === 1) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -496,29 +496,29 @@ while (1 === 1) { do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -529,36 +529,36 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -566,38 +566,38 @@ for (const y = 0; y < 1;) { } for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; @@ -610,35 +610,35 @@ while (1 === 1) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -647,35 +647,35 @@ while (1 === 1) { do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; @@ -686,40 +686,40 @@ do { >1 : 1 for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; diff --git a/tests/baselines/reference/capturedLetConstInLoop7.types b/tests/baselines/reference/capturedLetConstInLoop7.types index 641ccb9dbea..39f09100eeb 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7.types +++ b/tests/baselines/reference/capturedLetConstInLoop7.types @@ -103,10 +103,10 @@ l1: for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -262,16 +262,16 @@ l4: for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x}); >(function() { return x}) : () => number @@ -320,12 +320,12 @@ l5: for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -496,16 +496,16 @@ l8: for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number @@ -656,32 +656,32 @@ l1_c: >l1_c : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 0 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 0 if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break l1_c; @@ -689,14 +689,14 @@ for (const x = 0; x < 1;) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l1_c; @@ -713,29 +713,29 @@ while (1 === 1) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l2_c; @@ -743,14 +743,14 @@ while (1 === 1) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l2_c; @@ -763,29 +763,29 @@ l3_c: do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l3_c; @@ -793,14 +793,14 @@ do { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l3_c; @@ -815,36 +815,36 @@ l4_c: >l4_c : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l4_c; @@ -852,14 +852,14 @@ for (const y = 0; y < 1;) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l4_c; @@ -871,38 +871,38 @@ l5_c: >l5_c : any for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break l5_c; @@ -910,14 +910,14 @@ for (const x = 0, y = 1; x < 1;) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l5_c; @@ -934,35 +934,35 @@ while (1 === 1) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l6_c; @@ -970,14 +970,14 @@ while (1 === 1) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l6_c; @@ -991,35 +991,35 @@ l7_c: do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l7_c; @@ -1027,14 +1027,14 @@ do { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l7_c; @@ -1049,40 +1049,40 @@ l8_c: >l8_c : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l8_c; @@ -1090,14 +1090,14 @@ for (const y = 0; y < 1;) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l8_c; diff --git a/tests/baselines/reference/capturedLetConstInLoop7_ES6.types b/tests/baselines/reference/capturedLetConstInLoop7_ES6.types index 666f3e33e0f..48499659aa3 100644 --- a/tests/baselines/reference/capturedLetConstInLoop7_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop7_ES6.types @@ -103,10 +103,10 @@ l1: for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -262,16 +262,16 @@ l4: for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x}); >(function() { return x}) : () => number @@ -320,12 +320,12 @@ l5: for (let x = 0, y = 1; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >y : number ->1 : number +>1 : 1 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -496,16 +496,16 @@ l8: for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number let x = 1; >x : number ->1 : number +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number @@ -656,32 +656,32 @@ l1_c: >l1_c : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 0 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 0 if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break l1_c; @@ -689,14 +689,14 @@ for (const x = 0; x < 1;) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l1_c; @@ -713,29 +713,29 @@ while (1 === 1) { >1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l2_c; @@ -743,14 +743,14 @@ while (1 === 1) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l2_c; @@ -763,29 +763,29 @@ l3_c: do { const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l3_c; @@ -793,14 +793,14 @@ do { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l3_c; @@ -815,36 +815,36 @@ l4_c: >l4_c : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x}); >(function() { return x}) : () => number >function() { return x} : () => number ->x : number +>x : 1 (() => x); >(() => x) : () => number >() => x : () => number ->x : number +>x : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l4_c; @@ -852,14 +852,14 @@ for (const y = 0; y < 1;) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l4_c; @@ -871,38 +871,38 @@ l5_c: >l5_c : any for (const x = 0, y = 1; x < 1;) { ->x : number ->0 : number ->y : number ->1 : number +>x : 0 +>0 : 0 +>y : 1 +>1 : 1 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break l5_c; @@ -910,14 +910,14 @@ for (const x = 0, y = 1; x < 1;) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l5_c; @@ -934,35 +934,35 @@ while (1 === 1) { >1 : 1 const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l6_c; @@ -970,14 +970,14 @@ while (1 === 1) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l6_c; @@ -991,35 +991,35 @@ l7_c: do { const x = 1, y = 1; ->x : number ->1 : number ->y : number ->1 : number +>x : 1 +>1 : 1 +>y : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 1 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l7_c; @@ -1027,14 +1027,14 @@ do { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l7_c; @@ -1049,40 +1049,40 @@ l8_c: >l8_c : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 (function() { return x + y}); >(function() { return x + y}) : () => number >function() { return x + y} : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 1 +>y : 0 if (x == 1) { >x == 1 : boolean ->x : number +>x : 1 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : never >1 : 1 break l8_c; @@ -1090,14 +1090,14 @@ for (const y = 0; y < 1;) { } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : never >2 : 2 continue l8_c; diff --git a/tests/baselines/reference/capturedLetConstInLoop8.types b/tests/baselines/reference/capturedLetConstInLoop8.types index 618e71038ff..26473308039 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8.types +++ b/tests/baselines/reference/capturedLetConstInLoop8.types @@ -1,16 +1,16 @@ === tests/cases/compiler/capturedLetConstInLoop8.ts === function foo() { ->foo : () => string +>foo : () => "123" | "456" l0: >l0 : any for (let z = 0; z < 1; ++z) { >z : number ->0 : number +>0 : 0 >z < 1 : boolean >z : number ->1 : number +>1 : 1 >++z : number >z : number @@ -19,10 +19,10 @@ function foo() { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -31,10 +31,10 @@ function foo() { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number @@ -113,7 +113,7 @@ function foo() { >2 : 2 return "123" ->"123" : string +>"123" : "123" } if (x == 3) { >x == 3 : boolean @@ -167,7 +167,7 @@ function foo() { >2 : 2 return "456"; ->"456" : string +>"456" : "456" } if (x == 3) { >x == 3 : boolean @@ -181,62 +181,62 @@ function foo() { } function foo_c() { ->foo_c : () => string +>foo_c : () => "123" | "456" l0: >l0 : any for (const z = 0; z < 1;) { ->z : number ->0 : number +>z : 0 +>0 : 0 >z < 1 : boolean ->z : number ->1 : number +>z : 0 +>1 : 1 l1: >l1 : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 ll1: >ll1 : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 (function() { return x + y }); >(function() { return x + y }) : () => number >function() { return x + y } : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 0 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 0 if (y == 1) { >y == 1 : boolean ->y : number +>y : 0 >1 : 1 break; } if (y == 1) { >y == 1 : boolean ->y : number +>y : 0 >1 : 1 break l1; @@ -244,7 +244,7 @@ function foo_c() { } if (y == 1) { >y == 1 : boolean ->y : number +>y : 0 >1 : 1 break ll1; @@ -252,7 +252,7 @@ function foo_c() { } if (y == 1) { >y == 1 : boolean ->y : number +>y : 0 >1 : 1 continue l0; @@ -261,14 +261,14 @@ function foo_c() { if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l1; @@ -276,7 +276,7 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue ll1; @@ -284,15 +284,15 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 return "123" ->"123" : string +>"123" : "123" } if (x == 3) { >x == 3 : boolean ->x : number +>x : 0 >3 : 3 return; @@ -300,14 +300,14 @@ function foo_c() { } if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break l1; @@ -315,14 +315,14 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l1; @@ -330,7 +330,7 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l0; @@ -338,15 +338,15 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 return "456"; ->"456" : string +>"456" : "456" } if (x == 3) { >x == 3 : boolean ->x : number +>x : 0 >3 : 3 return; diff --git a/tests/baselines/reference/capturedLetConstInLoop8_ES6.types b/tests/baselines/reference/capturedLetConstInLoop8_ES6.types index 0b877d27a46..99d07bb99bf 100644 --- a/tests/baselines/reference/capturedLetConstInLoop8_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop8_ES6.types @@ -1,16 +1,16 @@ === tests/cases/compiler/capturedLetConstInLoop8_ES6.ts === function foo() { ->foo : () => string +>foo : () => "123" | "456" l0: >l0 : any for (let z = 0; z < 1; ++z) { >z : number ->0 : number +>0 : 0 >z < 1 : boolean >z : number ->1 : number +>1 : 1 >++z : number >z : number @@ -19,10 +19,10 @@ function foo() { for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -31,10 +31,10 @@ function foo() { for (let y = 0; y < 1; ++y) { >y : number ->0 : number +>0 : 0 >y < 1 : boolean >y : number ->1 : number +>1 : 1 >++y : number >y : number @@ -113,7 +113,7 @@ function foo() { >2 : 2 return "123" ->"123" : string +>"123" : "123" } if (x == 3) { >x == 3 : boolean @@ -167,7 +167,7 @@ function foo() { >2 : 2 return "456"; ->"456" : string +>"456" : "456" } if (x == 3) { >x == 3 : boolean @@ -181,62 +181,62 @@ function foo() { } function foo_c() { ->foo_c : () => string +>foo_c : () => "123" | "456" l0: >l0 : any for (const z = 0; z < 1;) { ->z : number ->0 : number +>z : 0 +>0 : 0 >z < 1 : boolean ->z : number ->1 : number +>z : 0 +>1 : 1 l1: >l1 : any for (const x = 0; x < 1;) { ->x : number ->0 : number +>x : 0 +>0 : 0 >x < 1 : boolean ->x : number ->1 : number +>x : 0 +>1 : 1 ll1: >ll1 : any for (const y = 0; y < 1;) { ->y : number ->0 : number +>y : 0 +>0 : 0 >y < 1 : boolean ->y : number ->1 : number +>y : 0 +>1 : 1 (function() { return x + y }); >(function() { return x + y }) : () => number >function() { return x + y } : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 0 (() => x + y); >(() => x + y) : () => number >() => x + y : () => number >x + y : number ->x : number ->y : number +>x : 0 +>y : 0 if (y == 1) { >y == 1 : boolean ->y : number +>y : 0 >1 : 1 break; } if (y == 1) { >y == 1 : boolean ->y : number +>y : 0 >1 : 1 break l1; @@ -244,7 +244,7 @@ function foo_c() { } if (y == 1) { >y == 1 : boolean ->y : number +>y : 0 >1 : 1 break ll1; @@ -252,7 +252,7 @@ function foo_c() { } if (y == 1) { >y == 1 : boolean ->y : number +>y : 0 >1 : 1 continue l0; @@ -261,14 +261,14 @@ function foo_c() { if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l1; @@ -276,7 +276,7 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue ll1; @@ -284,15 +284,15 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 return "123" ->"123" : string +>"123" : "123" } if (x == 3) { >x == 3 : boolean ->x : number +>x : 0 >3 : 3 return; @@ -300,14 +300,14 @@ function foo_c() { } if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break; } if (x == 1) { >x == 1 : boolean ->x : number +>x : 0 >1 : 1 break l1; @@ -315,14 +315,14 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue; } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l1; @@ -330,7 +330,7 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 continue l0; @@ -338,15 +338,15 @@ function foo_c() { } if (x == 2) { >x == 2 : boolean ->x : number +>x : 0 >2 : 2 return "456"; ->"456" : string +>"456" : "456" } if (x == 3) { >x == 3 : boolean ->x : number +>x : 0 >3 : 3 return; diff --git a/tests/baselines/reference/capturedParametersInInitializers2.symbols b/tests/baselines/reference/capturedParametersInInitializers2.symbols new file mode 100644 index 00000000000..eb87347275f --- /dev/null +++ b/tests/baselines/reference/capturedParametersInInitializers2.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/capturedParametersInInitializers2.ts === +function foo(y = class {static c = x}, x = 1) { +>foo : Symbol(foo, Decl(capturedParametersInInitializers2.ts, 0, 0)) +>y : Symbol(y, Decl(capturedParametersInInitializers2.ts, 0, 13)) +>c : Symbol((Anonymous class).c, Decl(capturedParametersInInitializers2.ts, 0, 24)) +>x : Symbol(x, Decl(capturedParametersInInitializers2.ts, 0, 38)) +>x : Symbol(x, Decl(capturedParametersInInitializers2.ts, 0, 38)) + + y.c +>y.c : Symbol((Anonymous class).c, Decl(capturedParametersInInitializers2.ts, 0, 24)) +>y : Symbol(y, Decl(capturedParametersInInitializers2.ts, 0, 13)) +>c : Symbol((Anonymous class).c, Decl(capturedParametersInInitializers2.ts, 0, 24)) +} +function foo2(y = class {[x] = x}, x = 1) { +>foo2 : Symbol(foo2, Decl(capturedParametersInInitializers2.ts, 2, 1)) +>y : Symbol(y, Decl(capturedParametersInInitializers2.ts, 3, 14)) +>x : Symbol(x, Decl(capturedParametersInInitializers2.ts, 3, 34)) +>x : Symbol(x, Decl(capturedParametersInInitializers2.ts, 3, 34)) +>x : Symbol(x, Decl(capturedParametersInInitializers2.ts, 3, 34)) +} diff --git a/tests/baselines/reference/capturedParametersInInitializers2.types b/tests/baselines/reference/capturedParametersInInitializers2.types new file mode 100644 index 00000000000..d10d3f2b215 --- /dev/null +++ b/tests/baselines/reference/capturedParametersInInitializers2.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/capturedParametersInInitializers2.ts === +function foo(y = class {static c = x}, x = 1) { +>foo : (y?: typeof (Anonymous class), x?: number) => void +>y : typeof (Anonymous class) +>class {static c = x} : typeof (Anonymous class) +>c : number +>x : number +>x : number +>1 : 1 + + y.c +>y.c : number +>y : typeof (Anonymous class) +>c : number +} +function foo2(y = class {[x] = x}, x = 1) { +>foo2 : (y?: typeof (Anonymous class), x?: number) => void +>y : typeof (Anonymous class) +>class {[x] = x} : typeof (Anonymous class) +>x : number +>x : number +>x : number +>1 : 1 +} diff --git a/tests/baselines/reference/castOfYield.symbols b/tests/baselines/reference/castOfYield.symbols new file mode 100644 index 00000000000..b4b495a0a36 --- /dev/null +++ b/tests/baselines/reference/castOfYield.symbols @@ -0,0 +1,9 @@ +=== tests/cases/compiler/castOfYield.ts === +function* f() { +>f : Symbol(f, Decl(castOfYield.ts, 0, 0)) + + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + yield 0; +} + diff --git a/tests/baselines/reference/castOfYield.types b/tests/baselines/reference/castOfYield.types new file mode 100644 index 00000000000..c0052056091 --- /dev/null +++ b/tests/baselines/reference/castOfYield.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/castOfYield.ts === +function* f() { +>f : () => {} + + (yield 0); +> (yield 0) : number +>(yield 0) : any +>yield 0 : any +>0 : 0 + + // Unlike await, yield is not allowed to appear in a simple unary expression. + yield 0; +> : number +> : any +>yield 0 : any +>0 : 0 +} + diff --git a/tests/baselines/reference/castParentheses.symbols b/tests/baselines/reference/castParentheses.symbols index 6447c8721e2..0ef44823f2d 100644 --- a/tests/baselines/reference/castParentheses.symbols +++ b/tests/baselines/reference/castParentheses.symbols @@ -7,36 +7,36 @@ class a { } var b = (a); ->b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3), Decl(castParentheses.ts, 9, 3), Decl(castParentheses.ts, 10, 3)) +>b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3) ... and 2 more) >a : Symbol(a, Decl(castParentheses.ts, 0, 0)) var b = (a).b; ->b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3), Decl(castParentheses.ts, 9, 3), Decl(castParentheses.ts, 10, 3)) +>b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3) ... and 2 more) >a : Symbol(a, Decl(castParentheses.ts, 0, 0)) var b = (a.b).c; ->b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3), Decl(castParentheses.ts, 9, 3), Decl(castParentheses.ts, 10, 3)) +>b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3) ... and 2 more) >a.b : Symbol(a.b, Decl(castParentheses.ts, 0, 9)) >a : Symbol(a, Decl(castParentheses.ts, 0, 0)) >b : Symbol(a.b, Decl(castParentheses.ts, 0, 9)) var b = (a.b()).c; ->b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3), Decl(castParentheses.ts, 9, 3), Decl(castParentheses.ts, 10, 3)) +>b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3) ... and 2 more) >a.b : Symbol(a.b, Decl(castParentheses.ts, 0, 9)) >a : Symbol(a, Decl(castParentheses.ts, 0, 0)) >b : Symbol(a.b, Decl(castParentheses.ts, 0, 9)) var b = (new a); ->b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3), Decl(castParentheses.ts, 9, 3), Decl(castParentheses.ts, 10, 3)) +>b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3) ... and 2 more) >a : Symbol(a, Decl(castParentheses.ts, 0, 0)) var b = (new a.b); ->b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3), Decl(castParentheses.ts, 9, 3), Decl(castParentheses.ts, 10, 3)) +>b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3) ... and 2 more) >a.b : Symbol(a.b, Decl(castParentheses.ts, 0, 9)) >a : Symbol(a, Decl(castParentheses.ts, 0, 0)) >b : Symbol(a.b, Decl(castParentheses.ts, 0, 9)) var b = (new a).b ->b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3), Decl(castParentheses.ts, 9, 3), Decl(castParentheses.ts, 10, 3)) +>b : Symbol(b, Decl(castParentheses.ts, 4, 3), Decl(castParentheses.ts, 5, 3), Decl(castParentheses.ts, 6, 3), Decl(castParentheses.ts, 7, 3), Decl(castParentheses.ts, 8, 3) ... and 2 more) >a : Symbol(a, Decl(castParentheses.ts, 0, 0)) diff --git a/tests/baselines/reference/castingTuple.symbols b/tests/baselines/reference/castingTuple.symbols new file mode 100644 index 00000000000..61edfb4b376 --- /dev/null +++ b/tests/baselines/reference/castingTuple.symbols @@ -0,0 +1,132 @@ +=== tests/cases/conformance/types/tuple/castingTuple.ts === +interface I { } +>I : Symbol(I, Decl(castingTuple.ts, 0, 0)) + +class A { a = 10; } +>A : Symbol(A, Decl(castingTuple.ts, 0, 15)) +>a : Symbol(A.a, Decl(castingTuple.ts, 1, 9)) + +class C implements I { c }; +>C : Symbol(C, Decl(castingTuple.ts, 1, 19)) +>I : Symbol(I, Decl(castingTuple.ts, 0, 0)) +>c : Symbol(C.c, Decl(castingTuple.ts, 2, 22)) + +class D implements I { d }; +>D : Symbol(D, Decl(castingTuple.ts, 2, 27)) +>I : Symbol(I, Decl(castingTuple.ts, 0, 0)) +>d : Symbol(D.d, Decl(castingTuple.ts, 3, 22)) + +class E extends A { e }; +>E : Symbol(E, Decl(castingTuple.ts, 3, 27)) +>A : Symbol(A, Decl(castingTuple.ts, 0, 15)) +>e : Symbol(E.e, Decl(castingTuple.ts, 4, 19)) + +class F extends A { f }; +>F : Symbol(F, Decl(castingTuple.ts, 4, 24)) +>A : Symbol(A, Decl(castingTuple.ts, 0, 15)) +>f : Symbol(F.f, Decl(castingTuple.ts, 5, 19)) + +enum E1 { one } +>E1 : Symbol(E1, Decl(castingTuple.ts, 5, 24)) +>one : Symbol(E1.one, Decl(castingTuple.ts, 6, 9)) + +enum E2 { one } +>E2 : Symbol(E2, Decl(castingTuple.ts, 6, 15)) +>one : Symbol(E2.one, Decl(castingTuple.ts, 7, 9)) + +// no error +var numStrTuple: [number, string] = [5, "foo"]; +>numStrTuple : Symbol(numStrTuple, Decl(castingTuple.ts, 10, 3)) + +var emptyObjTuple = <[{}, {}]>numStrTuple; +>emptyObjTuple : Symbol(emptyObjTuple, Decl(castingTuple.ts, 11, 3)) +>numStrTuple : Symbol(numStrTuple, Decl(castingTuple.ts, 10, 3)) + +var numStrBoolTuple = <[number, string, boolean]>numStrTuple; +>numStrBoolTuple : Symbol(numStrBoolTuple, Decl(castingTuple.ts, 12, 3)) +>numStrTuple : Symbol(numStrTuple, Decl(castingTuple.ts, 10, 3)) + +var classCDTuple: [C, D] = [new C(), new D()]; +>classCDTuple : Symbol(classCDTuple, Decl(castingTuple.ts, 13, 3)) +>C : Symbol(C, Decl(castingTuple.ts, 1, 19)) +>D : Symbol(D, Decl(castingTuple.ts, 2, 27)) +>C : Symbol(C, Decl(castingTuple.ts, 1, 19)) +>D : Symbol(D, Decl(castingTuple.ts, 2, 27)) + +var interfaceIITuple = <[I, I]>classCDTuple; +>interfaceIITuple : Symbol(interfaceIITuple, Decl(castingTuple.ts, 14, 3)) +>I : Symbol(I, Decl(castingTuple.ts, 0, 0)) +>I : Symbol(I, Decl(castingTuple.ts, 0, 0)) +>classCDTuple : Symbol(classCDTuple, Decl(castingTuple.ts, 13, 3)) + +var classCDATuple = <[C, D, A]>classCDTuple; +>classCDATuple : Symbol(classCDATuple, Decl(castingTuple.ts, 15, 3)) +>C : Symbol(C, Decl(castingTuple.ts, 1, 19)) +>D : Symbol(D, Decl(castingTuple.ts, 2, 27)) +>A : Symbol(A, Decl(castingTuple.ts, 0, 15)) +>classCDTuple : Symbol(classCDTuple, Decl(castingTuple.ts, 13, 3)) + +var eleFromCDA1 = classCDATuple[2]; // A +>eleFromCDA1 : Symbol(eleFromCDA1, Decl(castingTuple.ts, 16, 3)) +>classCDATuple : Symbol(classCDATuple, Decl(castingTuple.ts, 15, 3)) +>2 : Symbol(2) + +var eleFromCDA2 = classCDATuple[5]; // C | D | A +>eleFromCDA2 : Symbol(eleFromCDA2, Decl(castingTuple.ts, 17, 3)) +>classCDATuple : Symbol(classCDATuple, Decl(castingTuple.ts, 15, 3)) + +var t10: [E1, E2] = [E1.one, E2.one]; +>t10 : Symbol(t10, Decl(castingTuple.ts, 18, 3)) +>E1 : Symbol(E1, Decl(castingTuple.ts, 5, 24)) +>E2 : Symbol(E2, Decl(castingTuple.ts, 6, 15)) +>E1.one : Symbol(E1.one, Decl(castingTuple.ts, 6, 9)) +>E1 : Symbol(E1, Decl(castingTuple.ts, 5, 24)) +>one : Symbol(E1.one, Decl(castingTuple.ts, 6, 9)) +>E2.one : Symbol(E2.one, Decl(castingTuple.ts, 7, 9)) +>E2 : Symbol(E2, Decl(castingTuple.ts, 6, 15)) +>one : Symbol(E2.one, Decl(castingTuple.ts, 7, 9)) + +var t11 = <[number, number]>t10; +>t11 : Symbol(t11, Decl(castingTuple.ts, 19, 3)) +>t10 : Symbol(t10, Decl(castingTuple.ts, 18, 3)) + +var array1 = <{}[]>emptyObjTuple; +>array1 : Symbol(array1, Decl(castingTuple.ts, 20, 3), Decl(castingTuple.ts, 29, 3)) +>emptyObjTuple : Symbol(emptyObjTuple, Decl(castingTuple.ts, 11, 3)) + +var unionTuple: [C, string | number] = [new C(), "foo"]; +>unionTuple : Symbol(unionTuple, Decl(castingTuple.ts, 21, 3)) +>C : Symbol(C, Decl(castingTuple.ts, 1, 19)) +>C : Symbol(C, Decl(castingTuple.ts, 1, 19)) + +var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()]; +>unionTuple2 : Symbol(unionTuple2, Decl(castingTuple.ts, 22, 3)) +>C : Symbol(C, Decl(castingTuple.ts, 1, 19)) +>D : Symbol(D, Decl(castingTuple.ts, 2, 27)) +>C : Symbol(C, Decl(castingTuple.ts, 1, 19)) +>D : Symbol(D, Decl(castingTuple.ts, 2, 27)) + +var unionTuple3: [number, string| number] = [10, "foo"]; +>unionTuple3 : Symbol(unionTuple3, Decl(castingTuple.ts, 23, 3)) + +var unionTuple4 = <[number, number]>unionTuple3; +>unionTuple4 : Symbol(unionTuple4, Decl(castingTuple.ts, 24, 3)) +>unionTuple3 : Symbol(unionTuple3, Decl(castingTuple.ts, 23, 3)) + +// error +var t3 = <[number, number]>numStrTuple; +>t3 : Symbol(t3, Decl(castingTuple.ts, 27, 3)) +>numStrTuple : Symbol(numStrTuple, Decl(castingTuple.ts, 10, 3)) + +var t9 = <[A, I]>classCDTuple; +>t9 : Symbol(t9, Decl(castingTuple.ts, 28, 3)) +>A : Symbol(A, Decl(castingTuple.ts, 0, 15)) +>I : Symbol(I, Decl(castingTuple.ts, 0, 0)) +>classCDTuple : Symbol(classCDTuple, Decl(castingTuple.ts, 13, 3)) + +var array1 = numStrTuple; +>array1 : Symbol(array1, Decl(castingTuple.ts, 20, 3), Decl(castingTuple.ts, 29, 3)) +>numStrTuple : Symbol(numStrTuple, Decl(castingTuple.ts, 10, 3)) + +t4[2] = 10; + diff --git a/tests/baselines/reference/castingTuple.types b/tests/baselines/reference/castingTuple.types new file mode 100644 index 00000000000..23d2e51a576 --- /dev/null +++ b/tests/baselines/reference/castingTuple.types @@ -0,0 +1,168 @@ +=== tests/cases/conformance/types/tuple/castingTuple.ts === +interface I { } +>I : I + +class A { a = 10; } +>A : A +>a : number +>10 : 10 + +class C implements I { c }; +>C : C +>I : I +>c : any + +class D implements I { d }; +>D : D +>I : I +>d : any + +class E extends A { e }; +>E : E +>A : A +>e : any + +class F extends A { f }; +>F : F +>A : A +>f : any + +enum E1 { one } +>E1 : E1 +>one : E1 + +enum E2 { one } +>E2 : E2 +>one : E2 + +// no error +var numStrTuple: [number, string] = [5, "foo"]; +>numStrTuple : [number, string] +>[5, "foo"] : [number, string] +>5 : 5 +>"foo" : "foo" + +var emptyObjTuple = <[{}, {}]>numStrTuple; +>emptyObjTuple : [{}, {}] +><[{}, {}]>numStrTuple : [{}, {}] +>numStrTuple : [number, string] + +var numStrBoolTuple = <[number, string, boolean]>numStrTuple; +>numStrBoolTuple : [number, string, boolean] +><[number, string, boolean]>numStrTuple : [number, string, boolean] +>numStrTuple : [number, string] + +var classCDTuple: [C, D] = [new C(), new D()]; +>classCDTuple : [C, D] +>C : C +>D : D +>[new C(), new D()] : [C, D] +>new C() : C +>C : typeof C +>new D() : D +>D : typeof D + +var interfaceIITuple = <[I, I]>classCDTuple; +>interfaceIITuple : [I, I] +><[I, I]>classCDTuple : [I, I] +>I : I +>I : I +>classCDTuple : [C, D] + +var classCDATuple = <[C, D, A]>classCDTuple; +>classCDATuple : [C, D, A] +><[C, D, A]>classCDTuple : [C, D, A] +>C : C +>D : D +>A : A +>classCDTuple : [C, D] + +var eleFromCDA1 = classCDATuple[2]; // A +>eleFromCDA1 : A +>classCDATuple[2] : A +>classCDATuple : [C, D, A] +>2 : 2 + +var eleFromCDA2 = classCDATuple[5]; // C | D | A +>eleFromCDA2 : A | C | D +>classCDATuple[5] : A | C | D +>classCDATuple : [C, D, A] +>5 : 5 + +var t10: [E1, E2] = [E1.one, E2.one]; +>t10 : [E1, E2] +>E1 : E1 +>E2 : E2 +>[E1.one, E2.one] : [E1, E2] +>E1.one : E1 +>E1 : typeof E1 +>one : E1 +>E2.one : E2 +>E2 : typeof E2 +>one : E2 + +var t11 = <[number, number]>t10; +>t11 : [number, number] +><[number, number]>t10 : [number, number] +>t10 : [E1, E2] + +var array1 = <{}[]>emptyObjTuple; +>array1 : {}[] +><{}[]>emptyObjTuple : {}[] +>emptyObjTuple : [{}, {}] + +var unionTuple: [C, string | number] = [new C(), "foo"]; +>unionTuple : [C, string | number] +>C : C +>[new C(), "foo"] : [C, string] +>new C() : C +>C : typeof C +>"foo" : "foo" + +var unionTuple2: [C, string | number, D] = [new C(), "foo", new D()]; +>unionTuple2 : [C, string | number, D] +>C : C +>D : D +>[new C(), "foo", new D()] : [C, string, D] +>new C() : C +>C : typeof C +>"foo" : "foo" +>new D() : D +>D : typeof D + +var unionTuple3: [number, string| number] = [10, "foo"]; +>unionTuple3 : [number, string | number] +>[10, "foo"] : [number, string] +>10 : 10 +>"foo" : "foo" + +var unionTuple4 = <[number, number]>unionTuple3; +>unionTuple4 : [number, number] +><[number, number]>unionTuple3 : [number, number] +>unionTuple3 : [number, string | number] + +// error +var t3 = <[number, number]>numStrTuple; +>t3 : [number, number] +><[number, number]>numStrTuple : [number, number] +>numStrTuple : [number, string] + +var t9 = <[A, I]>classCDTuple; +>t9 : [A, I] +><[A, I]>classCDTuple : [A, I] +>A : A +>I : I +>classCDTuple : [C, D] + +var array1 = numStrTuple; +>array1 : {}[] +>numStrTuple : number[] +>numStrTuple : [number, string] + +t4[2] = 10; +>t4[2] = 10 : 10 +>t4[2] : any +>t4 : any +>2 : 2 +>10 : 10 + diff --git a/tests/baselines/reference/catchClauseWithInitializer1.symbols b/tests/baselines/reference/catchClauseWithInitializer1.symbols new file mode 100644 index 00000000000..6f39eb6b244 --- /dev/null +++ b/tests/baselines/reference/catchClauseWithInitializer1.symbols @@ -0,0 +1,6 @@ +=== tests/cases/compiler/catchClauseWithInitializer1.ts === +try { +} +catch (e = 1) { +>e : Symbol(e, Decl(catchClauseWithInitializer1.ts, 2, 7)) +} diff --git a/tests/baselines/reference/catchClauseWithInitializer1.types b/tests/baselines/reference/catchClauseWithInitializer1.types new file mode 100644 index 00000000000..68fe7ce286a --- /dev/null +++ b/tests/baselines/reference/catchClauseWithInitializer1.types @@ -0,0 +1,7 @@ +=== tests/cases/compiler/catchClauseWithInitializer1.ts === +try { +} +catch (e = 1) { +>e : any +>1 : 1 +} diff --git a/tests/baselines/reference/catchClauseWithTypeAnnotation.symbols b/tests/baselines/reference/catchClauseWithTypeAnnotation.symbols new file mode 100644 index 00000000000..8358d40a286 --- /dev/null +++ b/tests/baselines/reference/catchClauseWithTypeAnnotation.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/catchClauseWithTypeAnnotation.ts === +try { +} catch (e: any) { +>e : Symbol(e, Decl(catchClauseWithTypeAnnotation.ts, 1, 9)) +} diff --git a/tests/baselines/reference/catchClauseWithTypeAnnotation.types b/tests/baselines/reference/catchClauseWithTypeAnnotation.types new file mode 100644 index 00000000000..74ee8463b92 --- /dev/null +++ b/tests/baselines/reference/catchClauseWithTypeAnnotation.types @@ -0,0 +1,5 @@ +=== tests/cases/compiler/catchClauseWithTypeAnnotation.ts === +try { +} catch (e: any) { +>e : any +} diff --git a/tests/baselines/reference/cf.symbols b/tests/baselines/reference/cf.symbols new file mode 100644 index 00000000000..9c2d73f5134 --- /dev/null +++ b/tests/baselines/reference/cf.symbols @@ -0,0 +1,111 @@ +=== tests/cases/compiler/cf.ts === +function f() { +>f : Symbol(f, Decl(cf.ts, 0, 0)) + + var z; +>z : Symbol(z, Decl(cf.ts, 1, 7)) + + var x=10; +>x : Symbol(x, Decl(cf.ts, 2, 7)) + + var y=3; +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + L1: for (var i=0;i<19;i++) { +>i : Symbol(i, Decl(cf.ts, 5, 16)) +>i : Symbol(i, Decl(cf.ts, 5, 16)) +>i : Symbol(i, Decl(cf.ts, 5, 16)) + + if (y==7) { +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + continue L1; + x=11; +>x : Symbol(x, Decl(cf.ts, 2, 7)) + } + if (y==3) { +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + y++; +>y : Symbol(y, Decl(cf.ts, 3, 7)) + } + else { + y--; +>y : Symbol(y, Decl(cf.ts, 3, 7)) + } + do { + y+=2; +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + if (y==20) { +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + break; + x=12; +>x : Symbol(x, Decl(cf.ts, 2, 7)) + } + } while (y<41); +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + y++; +>y : Symbol(y, Decl(cf.ts, 3, 7)) + } + while (y>2) { +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + y=y>>1; +>y : Symbol(y, Decl(cf.ts, 3, 7)) +>y : Symbol(y, Decl(cf.ts, 3, 7)) + } + L2: try { + L3: if (xx : Symbol(x, Decl(cf.ts, 2, 7)) +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + break L2; + x=13; +>x : Symbol(x, Decl(cf.ts, 2, 7)) + } + else { + break L3; + x=14; +>x : Symbol(x, Decl(cf.ts, 2, 7)) + } + } + catch (e) { +>e : Symbol(e, Decl(cf.ts, 38, 11)) + + x++; +>x : Symbol(x, Decl(cf.ts, 2, 7)) + } + finally { + x+=3; +>x : Symbol(x, Decl(cf.ts, 2, 7)) + } + y++; +>y : Symbol(y, Decl(cf.ts, 3, 7)) + + for (var k=0;k<10;k++) { +>k : Symbol(k, Decl(cf.ts, 45, 12)) +>k : Symbol(k, Decl(cf.ts, 45, 12)) +>k : Symbol(k, Decl(cf.ts, 45, 12)) + + z; +>z : Symbol(z, Decl(cf.ts, 1, 7)) + + break; + } + for (k=0;k<10;k++) { +>k : Symbol(k, Decl(cf.ts, 45, 12)) +>k : Symbol(k, Decl(cf.ts, 45, 12)) +>k : Symbol(k, Decl(cf.ts, 45, 12)) + + if (k==6) { +>k : Symbol(k, Decl(cf.ts, 45, 12)) + + continue; + } + break; + } +} + diff --git a/tests/baselines/reference/cf.types b/tests/baselines/reference/cf.types new file mode 100644 index 00000000000..b1b5b74c2f6 --- /dev/null +++ b/tests/baselines/reference/cf.types @@ -0,0 +1,169 @@ +=== tests/cases/compiler/cf.ts === +function f() { +>f : () => void + + var z; +>z : any + + var x=10; +>x : number +>10 : 10 + + var y=3; +>y : number +>3 : 3 + + L1: for (var i=0;i<19;i++) { +>L1 : any +>i : number +>0 : 0 +>i<19 : boolean +>i : number +>19 : 19 +>i++ : number +>i : number + + if (y==7) { +>y==7 : boolean +>y : number +>7 : 7 + + continue L1; +>L1 : any + + x=11; +>x=11 : 11 +>x : number +>11 : 11 + } + if (y==3) { +>y==3 : boolean +>y : number +>3 : 3 + + y++; +>y++ : number +>y : number + } + else { + y--; +>y-- : number +>y : number + } + do { + y+=2; +>y+=2 : number +>y : number +>2 : 2 + + if (y==20) { +>y==20 : boolean +>y : number +>20 : 20 + + break; + x=12; +>x=12 : 12 +>x : number +>12 : 12 + } + } while (y<41); +>y<41 : boolean +>y : number +>41 : 41 + + y++; +>y++ : number +>y : number + } + while (y>2) { +>y>2 : boolean +>y : number +>2 : 2 + + y=y>>1; +>y=y>>1 : number +>y : number +>y>>1 : number +>y : number +>1 : 1 + } + L2: try { +>L2 : any + + L3: if (xL3 : any +>xx : number +>y : number + + break L2; +>L2 : any + + x=13; +>x=13 : 13 +>x : number +>13 : 13 + } + else { + break L3; +>L3 : any + + x=14; +>x=14 : 14 +>x : number +>14 : 14 + } + } + catch (e) { +>e : any + + x++; +>x++ : number +>x : number + } + finally { + x+=3; +>x+=3 : number +>x : number +>3 : 3 + } + y++; +>y++ : number +>y : number + + for (var k=0;k<10;k++) { +>k : number +>0 : 0 +>k<10 : boolean +>k : number +>10 : 10 +>k++ : number +>k : number + + z; +>z : any + + break; + } + for (k=0;k<10;k++) { +>k=0 : 0 +>k : number +>0 : 0 +>k<10 : boolean +>k : number +>10 : 10 +>k++ : number +>k : number + + if (k==6) { +>k==6 : boolean +>k : number +>6 : 6 + + continue; + } + break; + } +} + diff --git a/tests/baselines/reference/chainedAssignment1.symbols b/tests/baselines/reference/chainedAssignment1.symbols new file mode 100644 index 00000000000..f3ee7814582 --- /dev/null +++ b/tests/baselines/reference/chainedAssignment1.symbols @@ -0,0 +1,55 @@ +=== tests/cases/compiler/chainedAssignment1.ts === +class X { +>X : Symbol(X, Decl(chainedAssignment1.ts, 0, 0)) + + constructor(public z) { } +>z : Symbol(X.z, Decl(chainedAssignment1.ts, 1, 16)) + + a: number; +>a : Symbol(X.a, Decl(chainedAssignment1.ts, 1, 29)) +} + +class Y { +>Y : Symbol(Y, Decl(chainedAssignment1.ts, 3, 1)) + + constructor(public z) { +>z : Symbol(Y.z, Decl(chainedAssignment1.ts, 6, 16)) + } + a: number; +>a : Symbol(Y.a, Decl(chainedAssignment1.ts, 7, 5)) + + b: string; +>b : Symbol(Y.b, Decl(chainedAssignment1.ts, 8, 14)) +} + +class Z { +>Z : Symbol(Z, Decl(chainedAssignment1.ts, 10, 1)) + + z: any; +>z : Symbol(Z.z, Decl(chainedAssignment1.ts, 12, 9)) + + c: string; +>c : Symbol(Z.c, Decl(chainedAssignment1.ts, 13, 11)) +} + +var c1 = new X(3); +>c1 : Symbol(c1, Decl(chainedAssignment1.ts, 17, 3)) +>X : Symbol(X, Decl(chainedAssignment1.ts, 0, 0)) + +var c2 = new Y(5); +>c2 : Symbol(c2, Decl(chainedAssignment1.ts, 18, 3)) +>Y : Symbol(Y, Decl(chainedAssignment1.ts, 3, 1)) + +var c3 = new Z(); +>c3 : Symbol(c3, Decl(chainedAssignment1.ts, 19, 3)) +>Z : Symbol(Z, Decl(chainedAssignment1.ts, 10, 1)) + +c1 = c2 = c3; // a bug made this not report the same error as below +>c1 : Symbol(c1, Decl(chainedAssignment1.ts, 17, 3)) +>c2 : Symbol(c2, Decl(chainedAssignment1.ts, 18, 3)) +>c3 : Symbol(c3, Decl(chainedAssignment1.ts, 19, 3)) + +c2 = c3; // Error TS111: Cannot convert Z to Y +>c2 : Symbol(c2, Decl(chainedAssignment1.ts, 18, 3)) +>c3 : Symbol(c3, Decl(chainedAssignment1.ts, 19, 3)) + diff --git a/tests/baselines/reference/chainedAssignment1.types b/tests/baselines/reference/chainedAssignment1.types new file mode 100644 index 00000000000..7517f34fb51 --- /dev/null +++ b/tests/baselines/reference/chainedAssignment1.types @@ -0,0 +1,63 @@ +=== tests/cases/compiler/chainedAssignment1.ts === +class X { +>X : X + + constructor(public z) { } +>z : any + + a: number; +>a : number +} + +class Y { +>Y : Y + + constructor(public z) { +>z : any + } + a: number; +>a : number + + b: string; +>b : string +} + +class Z { +>Z : Z + + z: any; +>z : any + + c: string; +>c : string +} + +var c1 = new X(3); +>c1 : X +>new X(3) : X +>X : typeof X +>3 : 3 + +var c2 = new Y(5); +>c2 : Y +>new Y(5) : Y +>Y : typeof Y +>5 : 5 + +var c3 = new Z(); +>c3 : Z +>new Z() : Z +>Z : typeof Z + +c1 = c2 = c3; // a bug made this not report the same error as below +>c1 = c2 = c3 : Z +>c1 : X +>c2 = c3 : Z +>c2 : Y +>c3 : Z + +c2 = c3; // Error TS111: Cannot convert Z to Y +>c2 = c3 : Z +>c2 : Y +>c3 : Z + diff --git a/tests/baselines/reference/chainedAssignment3.symbols b/tests/baselines/reference/chainedAssignment3.symbols new file mode 100644 index 00000000000..5dd02828f83 --- /dev/null +++ b/tests/baselines/reference/chainedAssignment3.symbols @@ -0,0 +1,59 @@ +=== tests/cases/compiler/chainedAssignment3.ts === +class A { +>A : Symbol(A, Decl(chainedAssignment3.ts, 0, 0)) + + id: number; +>id : Symbol(A.id, Decl(chainedAssignment3.ts, 0, 9)) +} + +class B extends A { +>B : Symbol(B, Decl(chainedAssignment3.ts, 2, 1)) +>A : Symbol(A, Decl(chainedAssignment3.ts, 0, 0)) + + value: string; +>value : Symbol(B.value, Decl(chainedAssignment3.ts, 4, 19)) +} + +var a: A; +>a : Symbol(a, Decl(chainedAssignment3.ts, 8, 3)) +>A : Symbol(A, Decl(chainedAssignment3.ts, 0, 0)) + +var b: B; +>b : Symbol(b, Decl(chainedAssignment3.ts, 9, 3)) +>B : Symbol(B, Decl(chainedAssignment3.ts, 2, 1)) + +a = b = null; +>a : Symbol(a, Decl(chainedAssignment3.ts, 8, 3)) +>b : Symbol(b, Decl(chainedAssignment3.ts, 9, 3)) + +a = b = new B(); +>a : Symbol(a, Decl(chainedAssignment3.ts, 8, 3)) +>b : Symbol(b, Decl(chainedAssignment3.ts, 9, 3)) +>B : Symbol(B, Decl(chainedAssignment3.ts, 2, 1)) + +b = a = new B(); +>b : Symbol(b, Decl(chainedAssignment3.ts, 9, 3)) +>a : Symbol(a, Decl(chainedAssignment3.ts, 8, 3)) +>B : Symbol(B, Decl(chainedAssignment3.ts, 2, 1)) + +a.id = b.value = null; +>a.id : Symbol(A.id, Decl(chainedAssignment3.ts, 0, 9)) +>a : Symbol(a, Decl(chainedAssignment3.ts, 8, 3)) +>id : Symbol(A.id, Decl(chainedAssignment3.ts, 0, 9)) +>b.value : Symbol(B.value, Decl(chainedAssignment3.ts, 4, 19)) +>b : Symbol(b, Decl(chainedAssignment3.ts, 9, 3)) +>value : Symbol(B.value, Decl(chainedAssignment3.ts, 4, 19)) + +// error cases +b = a = new A(); +>b : Symbol(b, Decl(chainedAssignment3.ts, 9, 3)) +>a : Symbol(a, Decl(chainedAssignment3.ts, 8, 3)) +>A : Symbol(A, Decl(chainedAssignment3.ts, 0, 0)) + +a = b = new A(); +>a : Symbol(a, Decl(chainedAssignment3.ts, 8, 3)) +>b : Symbol(b, Decl(chainedAssignment3.ts, 9, 3)) +>A : Symbol(A, Decl(chainedAssignment3.ts, 0, 0)) + + + diff --git a/tests/baselines/reference/chainedAssignment3.types b/tests/baselines/reference/chainedAssignment3.types new file mode 100644 index 00000000000..1e6c858ac0c --- /dev/null +++ b/tests/baselines/reference/chainedAssignment3.types @@ -0,0 +1,77 @@ +=== tests/cases/compiler/chainedAssignment3.ts === +class A { +>A : A + + id: number; +>id : number +} + +class B extends A { +>B : B +>A : A + + value: string; +>value : string +} + +var a: A; +>a : A +>A : A + +var b: B; +>b : B +>B : B + +a = b = null; +>a = b = null : null +>a : A +>b = null : null +>b : B +>null : null + +a = b = new B(); +>a = b = new B() : B +>a : A +>b = new B() : B +>b : B +>new B() : B +>B : typeof B + +b = a = new B(); +>b = a = new B() : B +>b : B +>a = new B() : B +>a : A +>new B() : B +>B : typeof B + +a.id = b.value = null; +>a.id = b.value = null : null +>a.id : number +>a : A +>id : number +>b.value = null : null +>b.value : string +>b : B +>value : string +>null : null + +// error cases +b = a = new A(); +>b = a = new A() : A +>b : B +>a = new A() : A +>a : A +>new A() : A +>A : typeof A + +a = b = new A(); +>a = b = new A() : A +>a : A +>b = new A() : A +>b : B +>new A() : A +>A : typeof A + + + diff --git a/tests/baselines/reference/chainedAssignmentChecking.symbols b/tests/baselines/reference/chainedAssignmentChecking.symbols new file mode 100644 index 00000000000..8b23acb7a2b --- /dev/null +++ b/tests/baselines/reference/chainedAssignmentChecking.symbols @@ -0,0 +1,51 @@ +=== tests/cases/compiler/chainedAssignmentChecking.ts === +class X { +>X : Symbol(X, Decl(chainedAssignmentChecking.ts, 0, 0)) + + constructor(public z) { } +>z : Symbol(X.z, Decl(chainedAssignmentChecking.ts, 1, 14)) + + a: number; +>a : Symbol(X.a, Decl(chainedAssignmentChecking.ts, 1, 27)) +} + +class Y { +>Y : Symbol(Y, Decl(chainedAssignmentChecking.ts, 3, 1)) + + constructor(public z) { } +>z : Symbol(Y.z, Decl(chainedAssignmentChecking.ts, 6, 14)) + + a: number; +>a : Symbol(Y.a, Decl(chainedAssignmentChecking.ts, 6, 27)) + + b: string; +>b : Symbol(Y.b, Decl(chainedAssignmentChecking.ts, 7, 12)) +} + +class Z { +>Z : Symbol(Z, Decl(chainedAssignmentChecking.ts, 9, 1)) + + z: any; +>z : Symbol(Z.z, Decl(chainedAssignmentChecking.ts, 11, 9)) + + c: string; +>c : Symbol(Z.c, Decl(chainedAssignmentChecking.ts, 12, 9)) +} + +var c1 = new X(3); +>c1 : Symbol(c1, Decl(chainedAssignmentChecking.ts, 16, 3)) +>X : Symbol(X, Decl(chainedAssignmentChecking.ts, 0, 0)) + +var c2 = new Y(5); +>c2 : Symbol(c2, Decl(chainedAssignmentChecking.ts, 17, 3)) +>Y : Symbol(Y, Decl(chainedAssignmentChecking.ts, 3, 1)) + +var c3 = new Z(); +>c3 : Symbol(c3, Decl(chainedAssignmentChecking.ts, 18, 3)) +>Z : Symbol(Z, Decl(chainedAssignmentChecking.ts, 9, 1)) + +c1 = c2 = c3; // Should be error +>c1 : Symbol(c1, Decl(chainedAssignmentChecking.ts, 16, 3)) +>c2 : Symbol(c2, Decl(chainedAssignmentChecking.ts, 17, 3)) +>c3 : Symbol(c3, Decl(chainedAssignmentChecking.ts, 18, 3)) + diff --git a/tests/baselines/reference/chainedAssignmentChecking.types b/tests/baselines/reference/chainedAssignmentChecking.types new file mode 100644 index 00000000000..b9e8529f617 --- /dev/null +++ b/tests/baselines/reference/chainedAssignmentChecking.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/chainedAssignmentChecking.ts === +class X { +>X : X + + constructor(public z) { } +>z : any + + a: number; +>a : number +} + +class Y { +>Y : Y + + constructor(public z) { } +>z : any + + a: number; +>a : number + + b: string; +>b : string +} + +class Z { +>Z : Z + + z: any; +>z : any + + c: string; +>c : string +} + +var c1 = new X(3); +>c1 : X +>new X(3) : X +>X : typeof X +>3 : 3 + +var c2 = new Y(5); +>c2 : Y +>new Y(5) : Y +>Y : typeof Y +>5 : 5 + +var c3 = new Z(); +>c3 : Z +>new Z() : Z +>Z : typeof Z + +c1 = c2 = c3; // Should be error +>c1 = c2 = c3 : Z +>c1 : X +>c2 = c3 : Z +>c2 : Y +>c3 : Z + diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.symbols b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.symbols new file mode 100644 index 00000000000..c4a3f7b5f4d --- /dev/null +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.symbols @@ -0,0 +1,65 @@ +=== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts === +class Chain { +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 0, 0)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 0, 12)) +>A : Symbol(A, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 5, 1)) + + constructor(public value: T) { } +>value : Symbol(Chain.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 16)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 0, 12)) + + then(cb: (x: T) => S): Chain { +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 2, 9)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 0, 12)) +>cb : Symbol(cb, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 2, 22)) +>x : Symbol(x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 2, 27)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 0, 12)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 2, 9)) +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 0, 0)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 2, 9)) + + return null; + } +} + +class A { +>A : Symbol(A, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 5, 1)) + + x; +>x : Symbol(A.x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 7, 9)) +} +class B extends A { +>B : Symbol(B, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 9, 1)) +>A : Symbol(A, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 5, 1)) + + y; +>y : Symbol(B.y, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 10, 19)) +} +class C extends B { +>C : Symbol(C, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 12, 1)) +>B : Symbol(B, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 9, 1)) + + z; +>z : Symbol(C.z, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 13, 19)) +} + +// Ok to go down the chain, but error to try to climb back up +(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A); +>(new Chain(new A)).then(a => new B).then(b => new C).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36)) +>(new Chain(new A)).then(a => new B).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36)) +>(new Chain(new A)).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36)) +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 0, 0)) +>A : Symbol(A, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 5, 1)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36)) +>a : Symbol(a, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 18, 24)) +>B : Symbol(B, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 9, 1)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36)) +>b : Symbol(b, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 18, 41)) +>C : Symbol(C, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 12, 1)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36)) +>c : Symbol(c, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 18, 58)) +>B : Symbol(B, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 9, 1)) +>b : Symbol(b, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 18, 75)) +>A : Symbol(A, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 5, 1)) + diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.types b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.types new file mode 100644 index 00000000000..53ebb6e2150 --- /dev/null +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.types @@ -0,0 +1,83 @@ +=== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts === +class Chain { +>Chain : Chain +>T : T +>A : A + + constructor(public value: T) { } +>value : T +>T : T + + then(cb: (x: T) => S): Chain { +>then : (cb: (x: T) => S) => Chain +>S : S +>T : T +>cb : (x: T) => S +>x : T +>T : T +>S : S +>Chain : Chain +>S : S + + return null; +>null : null + } +} + +class A { +>A : A + + x; +>x : any +} +class B extends A { +>B : B +>A : A + + y; +>y : any +} +class C extends B { +>C : C +>B : B + + z; +>z : any +} + +// Ok to go down the chain, but error to try to climb back up +(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A); +>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A) : any +>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : any +>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B) : any +>(new Chain(new A)).then(a => new B).then(b => new C).then : (cb: (x: C) => S) => Chain +>(new Chain(new A)).then(a => new B).then(b => new C) : Chain +>(new Chain(new A)).then(a => new B).then : (cb: (x: B) => S) => Chain +>(new Chain(new A)).then(a => new B) : Chain +>(new Chain(new A)).then : (cb: (x: A) => S) => Chain +>(new Chain(new A)) : Chain +>new Chain(new A) : Chain +>Chain : typeof Chain +>new A : A +>A : typeof A +>then : (cb: (x: A) => S) => Chain +>a => new B : (a: A) => B +>a : A +>new B : B +>B : typeof B +>then : (cb: (x: B) => S) => Chain +>b => new C : (b: B) => C +>b : B +>new C : C +>C : typeof C +>then : (cb: (x: C) => S) => Chain +>c => new B : (c: C) => B +>c : C +>new B : B +>B : typeof B +>then : any +>b => new A : (b: any) => A +>b : any +>new A : A +>A : typeof A + diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.symbols b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.symbols new file mode 100644 index 00000000000..e8affe5f84f --- /dev/null +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.symbols @@ -0,0 +1,197 @@ +=== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts === +class Chain { +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 0)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 12)) + + constructor(public value: T) { } +>value : Symbol(Chain.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 16)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 12)) + + then(cb: (x: T) => S): Chain { +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 2, 9)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 12)) +>cb : Symbol(cb, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 2, 22)) +>x : Symbol(x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 2, 27)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 12)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 2, 9)) +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 0)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 2, 9)) + + var t: T; +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 3, 11)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 12)) + + var s: S; +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 4, 11)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 2, 9)) + + // Ok to go down the chain, but error to climb up the chain + (new Chain(t)).then(tt => s).then(ss => t); +>(new Chain(t)).then(tt => s).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>(new Chain(t)).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 0)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 3, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>tt : Symbol(tt, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 6, 28)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 4, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>ss : Symbol(ss, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 6, 42)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 3, 11)) + + // But error to try to climb up the chain + (new Chain(s)).then(ss => t); +>(new Chain(s)).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 0)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 4, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>ss : Symbol(ss, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 9, 28)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 3, 11)) + + // Staying at T or S should be fine + (new Chain(t)).then(tt => t).then(tt => t).then(tt => t); +>(new Chain(t)).then(tt => t).then(tt => t).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>(new Chain(t)).then(tt => t).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>(new Chain(t)).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 0)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 3, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>tt : Symbol(tt, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 12, 28)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 3, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>tt : Symbol(tt, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 12, 42)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 3, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>tt : Symbol(tt, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 12, 56)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 3, 11)) + + (new Chain(s)).then(ss => s).then(ss => s).then(ss => s); +>(new Chain(s)).then(ss => s).then(ss => s).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>(new Chain(s)).then(ss => s).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>(new Chain(s)).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>Chain : Symbol(Chain, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 0, 0)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 4, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>ss : Symbol(ss, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 13, 28)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 4, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>ss : Symbol(ss, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 13, 42)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 4, 11)) +>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 1, 36)) +>ss : Symbol(ss, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 13, 56)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 4, 11)) + + return null; + } +} + +// Similar to above, but T is now constrained. Verify that the constraint is maintained across invocations +interface I { +>I : Symbol(I, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 17, 1)) + + x: number; +>x : Symbol(I.x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 20, 13)) +} +class Chain2 { +>Chain2 : Symbol(Chain2, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 22, 1)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 23, 13)) +>I : Symbol(I, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 17, 1)) + + constructor(public value: T) { } +>value : Symbol(Chain2.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 16)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 23, 13)) + + then(cb: (x: T) => S): Chain2 { +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 25, 9)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 23, 13)) +>cb : Symbol(cb, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 25, 22)) +>x : Symbol(x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 25, 27)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 23, 13)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 25, 9)) +>Chain2 : Symbol(Chain2, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 22, 1)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 25, 9)) + + var i: I; +>i : Symbol(i, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 26, 11)) +>I : Symbol(I, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 17, 1)) + + var t: T; +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 27, 11)) +>T : Symbol(T, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 23, 13)) + + var s: S; +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 28, 11)) +>S : Symbol(S, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 25, 9)) + + // Ok to go down the chain, check the constraint at the end. + // Should get an error that we are assigning a string to a number + (new Chain2(i)).then(ii => t).then(tt => s).value.x = ""; +>(new Chain2(i)).then(ii => t).then(tt => s).value.x : Symbol(I.x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 20, 13)) +>(new Chain2(i)).then(ii => t).then(tt => s).value : Symbol(Chain2.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 16)) +>(new Chain2(i)).then(ii => t).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>(new Chain2(i)).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>Chain2 : Symbol(Chain2, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 22, 1)) +>i : Symbol(i, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 26, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>ii : Symbol(ii, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 31, 29)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 27, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>tt : Symbol(tt, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 31, 43)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 28, 11)) +>value : Symbol(Chain2.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 16)) +>x : Symbol(I.x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 20, 13)) + + // Staying at T or S should keep the constraint. + // Get an error when we assign a string to a number in both cases + (new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x = ""; +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x : Symbol(I.x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 20, 13)) +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value : Symbol(Chain2.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 16)) +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>(new Chain2(i)).then(ii => t).then(tt => t).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>(new Chain2(i)).then(ii => t).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>(new Chain2(i)).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>Chain2 : Symbol(Chain2, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 22, 1)) +>i : Symbol(i, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 26, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>ii : Symbol(ii, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 35, 29)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 27, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>tt : Symbol(tt, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 35, 43)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 27, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>tt : Symbol(tt, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 35, 57)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 27, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>tt : Symbol(tt, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 35, 71)) +>t : Symbol(t, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 27, 11)) +>value : Symbol(Chain2.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 16)) +>x : Symbol(I.x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 20, 13)) + + (new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x = ""; +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x : Symbol(I.x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 20, 13)) +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value : Symbol(Chain2.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 16)) +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>(new Chain2(i)).then(ii => s).then(ss => s).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>(new Chain2(i)).then(ii => s).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>(new Chain2(i)).then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>Chain2 : Symbol(Chain2, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 22, 1)) +>i : Symbol(i, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 26, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>ii : Symbol(ii, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 36, 29)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 28, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>ss : Symbol(ss, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 36, 43)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 28, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>ss : Symbol(ss, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 36, 57)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 28, 11)) +>then : Symbol(Chain2.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 36)) +>ss : Symbol(ss, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 36, 71)) +>s : Symbol(s, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 28, 11)) +>value : Symbol(Chain2.value, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 24, 16)) +>x : Symbol(I.x, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts, 20, 13)) + + return null; + } +} diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.types b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.types new file mode 100644 index 00000000000..5dc0ddb54c0 --- /dev/null +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.types @@ -0,0 +1,257 @@ +=== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts === +class Chain { +>Chain : Chain +>T : T + + constructor(public value: T) { } +>value : T +>T : T + + then(cb: (x: T) => S): Chain { +>then : (cb: (x: T) => S) => Chain +>S : S +>T : T +>cb : (x: T) => S +>x : T +>T : T +>S : S +>Chain : Chain +>S : S + + var t: T; +>t : T +>T : T + + var s: S; +>s : S +>S : S + + // Ok to go down the chain, but error to climb up the chain + (new Chain(t)).then(tt => s).then(ss => t); +>(new Chain(t)).then(tt => s).then(ss => t) : any +>(new Chain(t)).then(tt => s).then : (cb: (x: S) => S) => Chain +>(new Chain(t)).then(tt => s) : Chain +>(new Chain(t)).then : (cb: (x: T) => S) => Chain +>(new Chain(t)) : Chain +>new Chain(t) : Chain +>Chain : typeof Chain +>t : T +>then : (cb: (x: T) => S) => Chain +>tt => s : (tt: T) => S +>tt : T +>s : S +>then : (cb: (x: S) => S) => Chain +>ss => t : (ss: S) => T +>ss : S +>t : T + + // But error to try to climb up the chain + (new Chain(s)).then(ss => t); +>(new Chain(s)).then(ss => t) : any +>(new Chain(s)).then : (cb: (x: S) => S) => Chain +>(new Chain(s)) : Chain +>new Chain(s) : Chain +>Chain : typeof Chain +>s : S +>then : (cb: (x: S) => S) => Chain +>ss => t : (ss: S) => T +>ss : S +>t : T + + // Staying at T or S should be fine + (new Chain(t)).then(tt => t).then(tt => t).then(tt => t); +>(new Chain(t)).then(tt => t).then(tt => t).then(tt => t) : Chain +>(new Chain(t)).then(tt => t).then(tt => t).then : (cb: (x: T) => S) => Chain +>(new Chain(t)).then(tt => t).then(tt => t) : Chain +>(new Chain(t)).then(tt => t).then : (cb: (x: T) => S) => Chain +>(new Chain(t)).then(tt => t) : Chain +>(new Chain(t)).then : (cb: (x: T) => S) => Chain +>(new Chain(t)) : Chain +>new Chain(t) : Chain +>Chain : typeof Chain +>t : T +>then : (cb: (x: T) => S) => Chain +>tt => t : (tt: T) => T +>tt : T +>t : T +>then : (cb: (x: T) => S) => Chain +>tt => t : (tt: T) => T +>tt : T +>t : T +>then : (cb: (x: T) => S) => Chain +>tt => t : (tt: T) => T +>tt : T +>t : T + + (new Chain(s)).then(ss => s).then(ss => s).then(ss => s); +>(new Chain(s)).then(ss => s).then(ss => s).then(ss => s) : Chain +>(new Chain(s)).then(ss => s).then(ss => s).then : (cb: (x: S) => S) => Chain +>(new Chain(s)).then(ss => s).then(ss => s) : Chain +>(new Chain(s)).then(ss => s).then : (cb: (x: S) => S) => Chain +>(new Chain(s)).then(ss => s) : Chain +>(new Chain(s)).then : (cb: (x: S) => S) => Chain +>(new Chain(s)) : Chain +>new Chain(s) : Chain +>Chain : typeof Chain +>s : S +>then : (cb: (x: S) => S) => Chain +>ss => s : (ss: S) => S +>ss : S +>s : S +>then : (cb: (x: S) => S) => Chain +>ss => s : (ss: S) => S +>ss : S +>s : S +>then : (cb: (x: S) => S) => Chain +>ss => s : (ss: S) => S +>ss : S +>s : S + + return null; +>null : null + } +} + +// Similar to above, but T is now constrained. Verify that the constraint is maintained across invocations +interface I { +>I : I + + x: number; +>x : number +} +class Chain2 { +>Chain2 : Chain2 +>T : T +>I : I + + constructor(public value: T) { } +>value : T +>T : T + + then(cb: (x: T) => S): Chain2 { +>then : (cb: (x: T) => S) => Chain2 +>S : S +>T : T +>cb : (x: T) => S +>x : T +>T : T +>S : S +>Chain2 : Chain2 +>S : S + + var i: I; +>i : I +>I : I + + var t: T; +>t : T +>T : T + + var s: S; +>s : S +>S : S + + // Ok to go down the chain, check the constraint at the end. + // Should get an error that we are assigning a string to a number + (new Chain2(i)).then(ii => t).then(tt => s).value.x = ""; +>(new Chain2(i)).then(ii => t).then(tt => s).value.x = "" : "" +>(new Chain2(i)).then(ii => t).then(tt => s).value.x : number +>(new Chain2(i)).then(ii => t).then(tt => s).value : S +>(new Chain2(i)).then(ii => t).then(tt => s) : Chain2 +>(new Chain2(i)).then(ii => t).then : (cb: (x: T) => S) => Chain2 +>(new Chain2(i)).then(ii => t) : Chain2 +>(new Chain2(i)).then : (cb: (x: I) => S) => Chain2 +>(new Chain2(i)) : Chain2 +>new Chain2(i) : Chain2 +>Chain2 : typeof Chain2 +>i : I +>then : (cb: (x: I) => S) => Chain2 +>ii => t : (ii: I) => T +>ii : I +>t : T +>then : (cb: (x: T) => S) => Chain2 +>tt => s : (tt: T) => S +>tt : T +>s : S +>value : S +>x : number +>"" : "" + + // Staying at T or S should keep the constraint. + // Get an error when we assign a string to a number in both cases + (new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x = ""; +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x = "" : "" +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x : number +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value : T +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t) : Chain2 +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then : (cb: (x: T) => S) => Chain2 +>(new Chain2(i)).then(ii => t).then(tt => t).then(tt => t) : Chain2 +>(new Chain2(i)).then(ii => t).then(tt => t).then : (cb: (x: T) => S) => Chain2 +>(new Chain2(i)).then(ii => t).then(tt => t) : Chain2 +>(new Chain2(i)).then(ii => t).then : (cb: (x: T) => S) => Chain2 +>(new Chain2(i)).then(ii => t) : Chain2 +>(new Chain2(i)).then : (cb: (x: I) => S) => Chain2 +>(new Chain2(i)) : Chain2 +>new Chain2(i) : Chain2 +>Chain2 : typeof Chain2 +>i : I +>then : (cb: (x: I) => S) => Chain2 +>ii => t : (ii: I) => T +>ii : I +>t : T +>then : (cb: (x: T) => S) => Chain2 +>tt => t : (tt: T) => T +>tt : T +>t : T +>then : (cb: (x: T) => S) => Chain2 +>tt => t : (tt: T) => T +>tt : T +>t : T +>then : (cb: (x: T) => S) => Chain2 +>tt => t : (tt: T) => T +>tt : T +>t : T +>value : T +>x : number +>"" : "" + + (new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x = ""; +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x = "" : "" +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x : number +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value : S +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s) : Chain2 +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then : (cb: (x: S) => S) => Chain2 +>(new Chain2(i)).then(ii => s).then(ss => s).then(ss => s) : Chain2 +>(new Chain2(i)).then(ii => s).then(ss => s).then : (cb: (x: S) => S) => Chain2 +>(new Chain2(i)).then(ii => s).then(ss => s) : Chain2 +>(new Chain2(i)).then(ii => s).then : (cb: (x: S) => S) => Chain2 +>(new Chain2(i)).then(ii => s) : Chain2 +>(new Chain2(i)).then : (cb: (x: I) => S) => Chain2 +>(new Chain2(i)) : Chain2 +>new Chain2(i) : Chain2 +>Chain2 : typeof Chain2 +>i : I +>then : (cb: (x: I) => S) => Chain2 +>ii => s : (ii: I) => S +>ii : I +>s : S +>then : (cb: (x: S) => S) => Chain2 +>ss => s : (ss: S) => S +>ss : S +>s : S +>then : (cb: (x: S) => S) => Chain2 +>ss => s : (ss: S) => S +>ss : S +>s : S +>then : (cb: (x: S) => S) => Chain2 +>ss => s : (ss: S) => S +>ss : S +>s : S +>value : S +>x : number +>"" : "" + + return null; +>null : null + } +} diff --git a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.symbols b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.symbols index c9ee830a9a5..4146ee56e62 100644 --- a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.symbols +++ b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.symbols @@ -2,16 +2,30 @@ someFunction(function(BaseClass) { >BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) - class Hello extends BaseClass { ->Hello : Symbol(Hello, Decl(weird.js, 0, 34)) + 'use strict'; + const DEFAULT_MESSAGE = "nop!"; +>DEFAULT_MESSAGE : Symbol(DEFAULT_MESSAGE, Decl(weird.js, 2, 9)) + + class Hello extends BaseClass { +>Hello : Symbol(Hello, Decl(weird.js, 2, 35)) >BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) - constructor() { - this.foo = "bar"; ->this.foo : Symbol(Hello.foo, Decl(weird.js, 2, 17)) ->this : Symbol(Hello, Decl(weird.js, 0, 34)) ->foo : Symbol(Hello.foo, Decl(weird.js, 2, 17)) - } - } + constructor() { + super(); + this.foo = "bar"; +>this.foo : Symbol(Hello.foo, Decl(weird.js, 5, 20)) +>this : Symbol(Hello, Decl(weird.js, 2, 35)) +>foo : Symbol(Hello.foo, Decl(weird.js, 5, 20)) + } + _render(error) { +>_render : Symbol(Hello._render, Decl(weird.js, 7, 9)) +>error : Symbol(error, Decl(weird.js, 8, 16)) + + const message = error.message || DEFAULT_MESSAGE; +>message : Symbol(message, Decl(weird.js, 9, 17)) +>error : Symbol(error, Decl(weird.js, 8, 16)) +>DEFAULT_MESSAGE : Symbol(DEFAULT_MESSAGE, Decl(weird.js, 2, 9)) + } + } }); diff --git a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types index 6a0a5ad1479..5d58047f6e4 100644 --- a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types +++ b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types @@ -1,22 +1,45 @@ === tests/cases/compiler/weird.js === someFunction(function(BaseClass) { ->someFunction(function(BaseClass) { class Hello extends BaseClass { constructor() { this.foo = "bar"; } }}) : any +>someFunction(function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; } _render(error) { const message = error.message || DEFAULT_MESSAGE; } }}) : any >someFunction : any ->function(BaseClass) { class Hello extends BaseClass { constructor() { this.foo = "bar"; } }} : (BaseClass: any) => void +>function(BaseClass) { 'use strict'; const DEFAULT_MESSAGE = "nop!"; class Hello extends BaseClass { constructor() { super(); this.foo = "bar"; } _render(error) { const message = error.message || DEFAULT_MESSAGE; } }} : (BaseClass: any) => void >BaseClass : any - class Hello extends BaseClass { + 'use strict'; +>'use strict' : "use strict" + + const DEFAULT_MESSAGE = "nop!"; +>DEFAULT_MESSAGE : "nop!" +>"nop!" : "nop!" + + class Hello extends BaseClass { >Hello : Hello >BaseClass : any - constructor() { - this.foo = "bar"; + constructor() { + super(); +>super() : void +>super : any + + this.foo = "bar"; >this.foo = "bar" : "bar" >this.foo : string >this : this >foo : string >"bar" : "bar" - } - } + } + _render(error) { +>_render : (error: any) => void +>error : any + + const message = error.message || DEFAULT_MESSAGE; +>message : any +>error.message || DEFAULT_MESSAGE : any +>error.message : any +>error : any +>message : any +>DEFAULT_MESSAGE : "nop!" + } + } }); diff --git a/tests/baselines/reference/checkJsFiles.symbols b/tests/baselines/reference/checkJsFiles.symbols new file mode 100644 index 00000000000..c234a5a3e13 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/a.js === +var x = "string"; +>x : Symbol(x, Decl(a.js, 0, 3)) + +x = 0; +>x : Symbol(x, Decl(a.js, 0, 3)) + diff --git a/tests/baselines/reference/checkJsFiles.types b/tests/baselines/reference/checkJsFiles.types new file mode 100644 index 00000000000..10159b5d065 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/a.js === +var x = "string"; +>x : string +>"string" : "string" + +x = 0; +>x = 0 : 0 +>x : string +>0 : 0 + diff --git a/tests/baselines/reference/checkJsFiles2.symbols b/tests/baselines/reference/checkJsFiles2.symbols new file mode 100644 index 00000000000..e70fee49153 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles2.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/a.js === +// @ts-check +var x = "string"; +>x : Symbol(x, Decl(a.js, 1, 3)) + +x = 0; +>x : Symbol(x, Decl(a.js, 1, 3)) + diff --git a/tests/baselines/reference/checkJsFiles2.types b/tests/baselines/reference/checkJsFiles2.types new file mode 100644 index 00000000000..e5aa1997663 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles2.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/a.js === +// @ts-check +var x = "string"; +>x : string +>"string" : "string" + +x = 0; +>x = 0 : 0 +>x : string +>0 : 0 + diff --git a/tests/baselines/reference/checkJsFiles3.symbols b/tests/baselines/reference/checkJsFiles3.symbols new file mode 100644 index 00000000000..e70fee49153 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles3.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/a.js === +// @ts-check +var x = "string"; +>x : Symbol(x, Decl(a.js, 1, 3)) + +x = 0; +>x : Symbol(x, Decl(a.js, 1, 3)) + diff --git a/tests/baselines/reference/checkJsFiles3.types b/tests/baselines/reference/checkJsFiles3.types new file mode 100644 index 00000000000..e5aa1997663 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles3.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/a.js === +// @ts-check +var x = "string"; +>x : string +>"string" : "string" + +x = 0; +>x = 0 : 0 +>x : string +>0 : 0 + diff --git a/tests/baselines/reference/checkJsFiles4.symbols b/tests/baselines/reference/checkJsFiles4.symbols new file mode 100644 index 00000000000..e70fee49153 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles4.symbols @@ -0,0 +1,8 @@ +=== tests/cases/compiler/a.js === +// @ts-check +var x = "string"; +>x : Symbol(x, Decl(a.js, 1, 3)) + +x = 0; +>x : Symbol(x, Decl(a.js, 1, 3)) + diff --git a/tests/baselines/reference/checkJsFiles4.types b/tests/baselines/reference/checkJsFiles4.types new file mode 100644 index 00000000000..e5aa1997663 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles4.types @@ -0,0 +1,11 @@ +=== tests/cases/compiler/a.js === +// @ts-check +var x = "string"; +>x : string +>"string" : "string" + +x = 0; +>x = 0 : 0 +>x : string +>0 : 0 + diff --git a/tests/baselines/reference/checkJsFiles_noErrorLocation.symbols b/tests/baselines/reference/checkJsFiles_noErrorLocation.symbols new file mode 100644 index 00000000000..a2cd8a0b7ac --- /dev/null +++ b/tests/baselines/reference/checkJsFiles_noErrorLocation.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/a.js === +// @ts-check +class A { +>A : Symbol(A, Decl(a.js, 0, 0)) + + constructor() { + + } + foo() { +>foo : Symbol(A.foo, Decl(a.js, 4, 3)) + + return 4; + } +} + +class B extends A { +>B : Symbol(B, Decl(a.js, 8, 1)) +>A : Symbol(A, Decl(a.js, 0, 0)) + + constructor() { + super(); +>super : Symbol(A, Decl(a.js, 0, 0)) + + this.foo = () => 3; +>this.foo : Symbol(B.foo, Decl(a.js, 12, 12)) +>this : Symbol(B, Decl(a.js, 8, 1)) +>foo : Symbol(B.foo, Decl(a.js, 12, 12)) + } +} + +const i = new B(); +>i : Symbol(i, Decl(a.js, 17, 5)) +>B : Symbol(B, Decl(a.js, 8, 1)) + +i.foo(); +>i.foo : Symbol(B.foo, Decl(a.js, 12, 12)) +>i : Symbol(i, Decl(a.js, 17, 5)) +>foo : Symbol(B.foo, Decl(a.js, 12, 12)) + diff --git a/tests/baselines/reference/checkJsFiles_noErrorLocation.types b/tests/baselines/reference/checkJsFiles_noErrorLocation.types new file mode 100644 index 00000000000..d714782fed1 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles_noErrorLocation.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/a.js === +// @ts-check +class A { +>A : A + + constructor() { + + } + foo() { +>foo : () => number + + return 4; +>4 : 4 + } +} + +class B extends A { +>B : B +>A : A + + constructor() { + super(); +>super() : void +>super : typeof A + + this.foo = () => 3; +>this.foo = () => 3 : () => number +>this.foo : () => number +>this : this +>foo : () => number +>() => 3 : () => number +>3 : 3 + } +} + +const i = new B(); +>i : B +>new B() : B +>B : typeof B + +i.foo(); +>i.foo() : number +>i.foo : () => number +>i : B +>foo : () => number + diff --git a/tests/baselines/reference/checkJsdocTypeTag2.symbols b/tests/baselines/reference/checkJsdocTypeTag2.symbols new file mode 100644 index 00000000000..ed35232f445 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag2.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check +/** @type {String} */ +var S = true; +>S : Symbol(S, Decl(0.js, 2, 3)) + +/** @type {number} */ +var n = "hello"; +>n : Symbol(n, Decl(0.js, 5, 3)) + +/** @type {function (number)} */ +const x1 = (a) => a + 1; +>x1 : Symbol(x1, Decl(0.js, 8, 5)) +>a : Symbol(a, Decl(0.js, 8, 12)) +>a : Symbol(a, Decl(0.js, 8, 12)) + +x1("string"); +>x1 : Symbol(x1, Decl(0.js, 8, 5)) + +/** @type {function (number): number} */ +const x2 = (a) => a + 1; +>x2 : Symbol(x2, Decl(0.js, 12, 5)) +>a : Symbol(a, Decl(0.js, 12, 12)) +>a : Symbol(a, Decl(0.js, 12, 12)) + +/** @type {string} */ +var a; +>a : Symbol(a, Decl(0.js, 15, 3)) + +a = x2(0); +>a : Symbol(a, Decl(0.js, 15, 3)) +>x2 : Symbol(x2, Decl(0.js, 12, 5)) + +/** @type {function (number): number} */ +const x3 = (a) => a.concat("hi"); +>x3 : Symbol(x3, Decl(0.js, 19, 5)) +>a : Symbol(a, Decl(0.js, 19, 12)) +>a : Symbol(a, Decl(0.js, 19, 12)) + +x3(0); +>x3 : Symbol(x3, Decl(0.js, 19, 5)) + +/** @type {function (number): string} */ +const x4 = (a) => a + 1; +>x4 : Symbol(x4, Decl(0.js, 23, 5)) +>a : Symbol(a, Decl(0.js, 23, 12)) +>a : Symbol(a, Decl(0.js, 23, 12)) + +x4(0); +>x4 : Symbol(x4, Decl(0.js, 23, 5)) + diff --git a/tests/baselines/reference/checkJsdocTypeTag2.types b/tests/baselines/reference/checkJsdocTypeTag2.types new file mode 100644 index 00000000000..dfee596ca4e --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTag2.types @@ -0,0 +1,76 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check +/** @type {String} */ +var S = true; +>S : string +>true : true + +/** @type {number} */ +var n = "hello"; +>n : number +>"hello" : "hello" + +/** @type {function (number)} */ +const x1 = (a) => a + 1; +>x1 : (arg0: number) => any +>(a) => a + 1 : (a: number) => number +>a : number +>a + 1 : number +>a : number +>1 : 1 + +x1("string"); +>x1("string") : any +>x1 : (arg0: number) => any +>"string" : "string" + +/** @type {function (number): number} */ +const x2 = (a) => a + 1; +>x2 : (arg0: number) => number +>(a) => a + 1 : (a: number) => number +>a : number +>a + 1 : number +>a : number +>1 : 1 + +/** @type {string} */ +var a; +>a : string + +a = x2(0); +>a = x2(0) : number +>a : string +>x2(0) : number +>x2 : (arg0: number) => number +>0 : 0 + +/** @type {function (number): number} */ +const x3 = (a) => a.concat("hi"); +>x3 : (arg0: number) => number +>(a) => a.concat("hi") : (a: number) => any +>a : number +>a.concat("hi") : any +>a.concat : any +>a : number +>concat : any +>"hi" : "hi" + +x3(0); +>x3(0) : number +>x3 : (arg0: number) => number +>0 : 0 + +/** @type {function (number): string} */ +const x4 = (a) => a + 1; +>x4 : (arg0: number) => string +>(a) => a + 1 : (a: number) => number +>a : number +>a + 1 : number +>a : number +>1 : 1 + +x4(0); +>x4(0) : string +>x4 : (arg0: number) => string +>0 : 0 + diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.symbols b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.symbols new file mode 100644 index 00000000000..603b395a755 --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.symbols @@ -0,0 +1,51 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check +var lol; +>lol : Symbol(lol, Decl(0.js, 1, 3)) + +const obj = { +>obj : Symbol(obj, Decl(0.js, 2, 5)) + + /** @type {string|undefined} */ + bar: 42, +>bar : Symbol(bar, Decl(0.js, 2, 13)) + + /** @type {function(number): number} */ + method1(n1) { +>method1 : Symbol(method1, Decl(0.js, 4, 10)) +>n1 : Symbol(n1, Decl(0.js, 6, 10)) + + return "42"; + }, + /** @type {function(number): number} */ + method2: (n1) => "lol", +>method2 : Symbol(method2, Decl(0.js, 8, 4)) +>n1 : Symbol(n1, Decl(0.js, 10, 12)) + + /** @type {function(number): number} */ + arrowFunc: (num="0") => num + 42, +>arrowFunc : Symbol(arrowFunc, Decl(0.js, 10, 25)) +>num : Symbol(num, Decl(0.js, 12, 14)) +>num : Symbol(num, Decl(0.js, 12, 14)) + + /** @type {string} */ + lol +>lol : Symbol(lol, Decl(0.js, 12, 35)) +} +lol = "string" +>lol : Symbol(lol, Decl(0.js, 1, 3)) + +/** @type {string} */ +var s = obj.method1(0); +>s : Symbol(s, Decl(0.js, 18, 3)) +>obj.method1 : Symbol(method1, Decl(0.js, 4, 10)) +>obj : Symbol(obj, Decl(0.js, 2, 5)) +>method1 : Symbol(method1, Decl(0.js, 4, 10)) + +/** @type {string} */ +var s1 = obj.method2("0"); +>s1 : Symbol(s1, Decl(0.js, 21, 3)) +>obj.method2 : Symbol(method2, Decl(0.js, 8, 4)) +>obj : Symbol(obj, Decl(0.js, 2, 5)) +>method2 : Symbol(method2, Decl(0.js, 8, 4)) + diff --git a/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types new file mode 100644 index 00000000000..443826c7aeb --- /dev/null +++ b/tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.types @@ -0,0 +1,67 @@ +=== tests/cases/conformance/jsdoc/0.js === +// @ts-check +var lol; +>lol : any + +const obj = { +>obj : { [x: string]: any; bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } +>{ /** @type {string|undefined} */ bar: 42, /** @type {function(number): number} */ method1(n1) { return "42"; }, /** @type {function(number): number} */ method2: (n1) => "lol", /** @type {function(number): number} */ arrowFunc: (num="0") => num + 42, /** @type {string} */ lol} : { [x: string]: any; bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } + + /** @type {string|undefined} */ + bar: 42, +>bar : string | undefined +>42 : 42 + + /** @type {function(number): number} */ + method1(n1) { +>method1 : (n1: any) => string +>n1 : any + + return "42"; +>"42" : "42" + + }, + /** @type {function(number): number} */ + method2: (n1) => "lol", +>method2 : (arg0: number) => number +>(n1) => "lol" : (n1: any) => string +>n1 : any +>"lol" : "lol" + + /** @type {function(number): number} */ + arrowFunc: (num="0") => num + 42, +>arrowFunc : (arg0: number) => number +>(num="0") => num + 42 : (num?: string) => string +>num : string +>"0" : "0" +>num + 42 : string +>num : string +>42 : 42 + + /** @type {string} */ + lol +>lol : string +} +lol = "string" +>lol = "string" : "string" +>lol : any +>"string" : "string" + +/** @type {string} */ +var s = obj.method1(0); +>s : string +>obj.method1(0) : number +>obj.method1 : (arg0: number) => number +>obj : { [x: string]: any; bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } +>method1 : (arg0: number) => number +>0 : 0 + +/** @type {string} */ +var s1 = obj.method2("0"); +>s1 : string +>obj.method2("0") : number +>obj.method2 : (arg0: number) => number +>obj : { [x: string]: any; bar: string | undefined; method1(arg0: number): number; method2: (arg0: number) => number; arrowFunc: (arg0: number) => number; lol: string; } +>method2 : (arg0: number) => number +>"0" : "0" + diff --git a/tests/baselines/reference/checkJsxChildrenProperty13.symbols b/tests/baselines/reference/checkJsxChildrenProperty13.symbols new file mode 100644 index 00000000000..24bf8a2162a --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty13.symbols @@ -0,0 +1,68 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +interface ButtonProp { +>ButtonProp : Symbol(ButtonProp, Decl(file.tsx, 0, 32)) + + a: number, +>a : Symbol(ButtonProp.a, Decl(file.tsx, 2, 22)) + + b: string, +>b : Symbol(ButtonProp.b, Decl(file.tsx, 3, 14)) + + children: Button; +>children : Symbol(ButtonProp.children, Decl(file.tsx, 4, 14)) +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) +} + +class Button extends React.Component { +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) +>React : Symbol(React, Decl(file.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) +>ButtonProp : Symbol(ButtonProp, Decl(file.tsx, 0, 32)) + + render() { +>render : Symbol(Button.render, Decl(file.tsx, 8, 55)) + + // Error children are specified twice + return ( +>InnerButton : Symbol(InnerButton, Decl(file.tsx, 19, 1)) +>this.props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) +>this : Symbol(Button, Decl(file.tsx, 6, 1)) +>props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) +>children : Symbol(children, Decl(file.tsx, 11, 44)) + +
Hello World
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + +
); +>InnerButton : Symbol(InnerButton, Decl(file.tsx, 19, 1)) + } +} + +interface InnerButtonProp { +>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 15, 1)) + + a: number +>a : Symbol(InnerButtonProp.a, Decl(file.tsx, 17, 27)) +} + +class InnerButton extends React.Component { +>InnerButton : Symbol(InnerButton, Decl(file.tsx, 19, 1)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) +>React : Symbol(React, Decl(file.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) +>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 15, 1)) + + render() { +>render : Symbol(InnerButton.render, Decl(file.tsx, 21, 65)) + + return (); +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2386, 43)) + } +} + diff --git a/tests/baselines/reference/checkJsxChildrenProperty13.types b/tests/baselines/reference/checkJsxChildrenProperty13.types new file mode 100644 index 00000000000..10d3876ae63 --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty13.types @@ -0,0 +1,73 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : typeof React + +interface ButtonProp { +>ButtonProp : ButtonProp + + a: number, +>a : number + + b: string, +>b : string + + children: Button; +>children : Button +>Button : Button +} + +class Button extends React.Component { +>Button : Button +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component +>ButtonProp : ButtonProp + + render() { +>render : () => JSX.Element + + // Error children are specified twice + return ( +>(
Hello World
) : JSX.Element +>
Hello World
: JSX.Element +>InnerButton : typeof InnerButton +>this.props : ButtonProp & { children?: React.ReactNode; } +>this : this +>props : ButtonProp & { children?: React.ReactNode; } +>children : string + +
Hello World
+>
Hello World
: JSX.Element +>div : any +>div : any + +
); +>InnerButton : typeof InnerButton + } +} + +interface InnerButtonProp { +>InnerButtonProp : InnerButtonProp + + a: number +>a : number +} + +class InnerButton extends React.Component { +>InnerButton : InnerButton +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component +>InnerButtonProp : InnerButtonProp + + render() { +>render : () => JSX.Element + + return (); +>() : JSX.Element +> : JSX.Element +>button : any +>button : any + } +} + diff --git a/tests/baselines/reference/checkJsxChildrenProperty2.symbols b/tests/baselines/reference/checkJsxChildrenProperty2.symbols new file mode 100644 index 00000000000..882c83b177a --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty2.symbols @@ -0,0 +1,144 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +interface Prop { +>Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) + + a: number, +>a : Symbol(Prop.a, Decl(file.tsx, 2, 16)) + + b: string, +>b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) + + children: string | JSX.Element +>children : Symbol(Prop.children, Decl(file.tsx, 4, 14)) +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) +} + +function Comp(p: Prop) { +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) +>p : Symbol(p, Decl(file.tsx, 8, 14)) +>Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) + + return
{p.b}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) +>p : Symbol(p, Decl(file.tsx, 8, 14)) +>b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +} + +// Error: missing children +let k = ; +>k : Symbol(k, Decl(file.tsx, 13, 3)) +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) +>a : Symbol(a, Decl(file.tsx, 13, 13)) +>b : Symbol(b, Decl(file.tsx, 13, 20)) + +let k0 = +>k0 : Symbol(k0, Decl(file.tsx, 15, 3)) + + +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) +>a : Symbol(a, Decl(file.tsx, 16, 9)) +>b : Symbol(b, Decl(file.tsx, 16, 16)) +>children : Symbol(children, Decl(file.tsx, 16, 23)) + + hi hi hi! + ; +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) + +let o = { +>o : Symbol(o, Decl(file.tsx, 20, 3)) + + children:"Random" +>children : Symbol(children, Decl(file.tsx, 20, 9)) +} +let k1 = +>k1 : Symbol(k1, Decl(file.tsx, 23, 3)) + + +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) +>a : Symbol(a, Decl(file.tsx, 24, 9)) +>b : Symbol(b, Decl(file.tsx, 24, 16)) +>o : Symbol(o, Decl(file.tsx, 20, 3)) + + hi hi hi! + ; +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) + +// Error: incorrect type +let k2 = +>k2 : Symbol(k2, Decl(file.tsx, 29, 3)) + + +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) +>a : Symbol(a, Decl(file.tsx, 30, 9)) +>b : Symbol(b, Decl(file.tsx, 30, 16)) + +
My Div
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + + {(name: string) =>
My name {name}
} +>name : Symbol(name, Decl(file.tsx, 32, 10)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>name : Symbol(name, Decl(file.tsx, 32, 10)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + +
; +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) + +let k3 = +>k3 : Symbol(k3, Decl(file.tsx, 35, 3)) + + +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) +>a : Symbol(a, Decl(file.tsx, 36, 9)) +>b : Symbol(b, Decl(file.tsx, 36, 16)) + +
My Div
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + + {1000000} +
; +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) + +let k4 = +>k4 : Symbol(k4, Decl(file.tsx, 41, 3)) + + +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) +>a : Symbol(a, Decl(file.tsx, 42, 9)) +>b : Symbol(b, Decl(file.tsx, 42, 16)) + +
My Div
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + + hi hi hi! +
; +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) + +let k5 = +>k5 : Symbol(k5, Decl(file.tsx, 47, 3)) + + +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) +>a : Symbol(a, Decl(file.tsx, 48, 9)) +>b : Symbol(b, Decl(file.tsx, 48, 16)) + +
My Div
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + +
My Div
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + +
; +>Comp : Symbol(Comp, Decl(file.tsx, 6, 1)) + diff --git a/tests/baselines/reference/checkJsxChildrenProperty2.types b/tests/baselines/reference/checkJsxChildrenProperty2.types new file mode 100644 index 00000000000..2817c1709bd --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty2.types @@ -0,0 +1,170 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : typeof React + +interface Prop { +>Prop : Prop + + a: number, +>a : number + + b: string, +>b : string + + children: string | JSX.Element +>children : string | JSX.Element +>JSX : any +>Element : JSX.Element +} + +function Comp(p: Prop) { +>Comp : (p: Prop) => JSX.Element +>p : Prop +>Prop : Prop + + return
{p.b}
; +>
{p.b}
: JSX.Element +>div : any +>p.b : string +>p : Prop +>b : string +>div : any +} + +// Error: missing children +let k = ; +>k : JSX.Element +> : JSX.Element +>Comp : (p: Prop) => JSX.Element +>a : number +>10 : 10 +>b : string + +let k0 = +>k0 : JSX.Element + + +> hi hi hi! : JSX.Element +>Comp : (p: Prop) => JSX.Element +>a : number +>10 : 10 +>b : string +>children : string + + hi hi hi! + ; +>Comp : (p: Prop) => JSX.Element + +let o = { +>o : { children: string; } +>{ children:"Random"} : { children: string; } + + children:"Random" +>children : string +>"Random" : "Random" +} +let k1 = +>k1 : JSX.Element + + +> hi hi hi! : JSX.Element +>Comp : (p: Prop) => JSX.Element +>a : number +>10 : 10 +>b : string +>o : { children: string; } + + hi hi hi! + ; +>Comp : (p: Prop) => JSX.Element + +// Error: incorrect type +let k2 = +>k2 : JSX.Element + + +>
My Div
{(name: string) =>
My name {name}
}
: JSX.Element +>Comp : (p: Prop) => JSX.Element +>a : number +>10 : 10 +>b : string + +
My Div
+>
My Div
: JSX.Element +>div : any +>div : any + + {(name: string) =>
My name {name}
} +>(name: string) =>
My name {name}
: (name: string) => JSX.Element +>name : string +>
My name {name}
: JSX.Element +>div : any +>name : string +>div : any + +
; +>Comp : (p: Prop) => JSX.Element + +let k3 = +>k3 : JSX.Element + + +>
My Div
{1000000}
: JSX.Element +>Comp : (p: Prop) => JSX.Element +>a : number +>10 : 10 +>b : string + +
My Div
+>
My Div
: JSX.Element +>div : any +>div : any + + {1000000} +>1000000 : 1000000 + +
; +>Comp : (p: Prop) => JSX.Element + +let k4 = +>k4 : JSX.Element + + +>
My Div
hi hi hi!
: JSX.Element +>Comp : (p: Prop) => JSX.Element +>a : number +>10 : 10 +>b : string + +
My Div
+>
My Div
: JSX.Element +>div : any +>div : any + + hi hi hi! +
; +>Comp : (p: Prop) => JSX.Element + +let k5 = +>k5 : JSX.Element + + +>
My Div
My Div
: JSX.Element +>Comp : (p: Prop) => JSX.Element +>a : number +>10 : 10 +>b : string + +
My Div
+>
My Div
: JSX.Element +>div : any +>div : any + +
My Div
+>
My Div
: JSX.Element +>div : any +>div : any + +
; +>Comp : (p: Prop) => JSX.Element + diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.symbols b/tests/baselines/reference/checkJsxChildrenProperty4.symbols new file mode 100644 index 00000000000..6372113ea62 --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty4.symbols @@ -0,0 +1,110 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +interface IUser { +>IUser : Symbol(IUser, Decl(file.tsx, 0, 32)) + + Name: string; +>Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) +} + +interface IFetchUserProps { +>IFetchUserProps : Symbol(IFetchUserProps, Decl(file.tsx, 4, 1)) + + children: (user: IUser) => JSX.Element; +>children : Symbol(IFetchUserProps.children, Decl(file.tsx, 6, 27)) +>user : Symbol(user, Decl(file.tsx, 7, 15)) +>IUser : Symbol(IUser, Decl(file.tsx, 0, 32)) +>JSX : Symbol(JSX, Decl(react.d.ts, 2353, 1)) +>Element : Symbol(JSX.Element, Decl(react.d.ts, 2356, 27)) +} + +class FetchUser extends React.Component { +>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) +>React : Symbol(React, Decl(file.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) +>IFetchUserProps : Symbol(IFetchUserProps, Decl(file.tsx, 4, 1)) + + render() { +>render : Symbol(FetchUser.render, Decl(file.tsx, 10, 63)) + + return this.state +>this.state : Symbol(React.Component.state, Decl(react.d.ts, 174, 44)) +>this : Symbol(FetchUser, Decl(file.tsx, 8, 1)) +>state : Symbol(React.Component.state, Decl(react.d.ts, 174, 44)) + + ? this.props.children(this.state.result) +>this.props.children : Symbol(children, Decl(file.tsx, 6, 27), Decl(react.d.ts, 174, 20)) +>this.props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) +>this : Symbol(FetchUser, Decl(file.tsx, 8, 1)) +>props : Symbol(React.Component.props, Decl(react.d.ts, 167, 37)) +>children : Symbol(children, Decl(file.tsx, 6, 27), Decl(react.d.ts, 174, 20)) +>this.state : Symbol(React.Component.state, Decl(react.d.ts, 174, 44)) +>this : Symbol(FetchUser, Decl(file.tsx, 8, 1)) +>state : Symbol(React.Component.state, Decl(react.d.ts, 174, 44)) + + : null; + } +} + +// Error +function UserName() { +>UserName : Symbol(UserName, Decl(file.tsx, 16, 1)) + + return ( + +>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1)) + + { user => ( +>user : Symbol(user, Decl(file.tsx, 22, 13)) + +

{ user.NAme }

+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>user : Symbol(user, Decl(file.tsx, 22, 13)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) + + ) } +
+>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1)) + + ); +} + +function UserName1() { +>UserName1 : Symbol(UserName1, Decl(file.tsx, 27, 1)) + + return ( + +>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1)) + + + + { user => ( +>user : Symbol(user, Decl(file.tsx, 35, 13)) + +

{ user.Name }

+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>user.Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) +>user : Symbol(user, Decl(file.tsx, 35, 13)) +>Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) + + ) } + { user => ( +>user : Symbol(user, Decl(file.tsx, 38, 13)) + +

{ user.Name }

+>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) +>user.Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) +>user : Symbol(user, Decl(file.tsx, 38, 13)) +>Name : Symbol(IUser.Name, Decl(file.tsx, 2, 17)) +>h1 : Symbol(JSX.IntrinsicElements.h1, Decl(react.d.ts, 2410, 47)) + + ) } +
+>FetchUser : Symbol(FetchUser, Decl(file.tsx, 8, 1)) + + ); +} diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.types b/tests/baselines/reference/checkJsxChildrenProperty4.types new file mode 100644 index 00000000000..6e4c04aa231 --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty4.types @@ -0,0 +1,132 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : typeof React + +interface IUser { +>IUser : IUser + + Name: string; +>Name : string +} + +interface IFetchUserProps { +>IFetchUserProps : IFetchUserProps + + children: (user: IUser) => JSX.Element; +>children : (user: IUser) => JSX.Element +>user : IUser +>IUser : IUser +>JSX : any +>Element : JSX.Element +} + +class FetchUser extends React.Component { +>FetchUser : FetchUser +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component +>IFetchUserProps : IFetchUserProps + + render() { +>render : () => JSX.Element + + return this.state +>this.state ? this.props.children(this.state.result) : null : JSX.Element +>this.state : any +>this : this +>state : any + + ? this.props.children(this.state.result) +>this.props.children(this.state.result) : JSX.Element +>this.props.children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | any[] | React.ReactElement)[]) +>this.props : IFetchUserProps & { children?: React.ReactNode; } +>this : this +>props : IFetchUserProps & { children?: React.ReactNode; } +>children : ((user: IUser) => JSX.Element) | (((user: IUser) => JSX.Element) & string) | (((user: IUser) => JSX.Element) & number) | (((user: IUser) => JSX.Element) & true) | (((user: IUser) => JSX.Element) & false) | (((user: IUser) => JSX.Element) & React.ReactElement) | (((user: IUser) => JSX.Element) & (string | number | boolean | any[] | React.ReactElement)[]) +>this.state.result : any +>this.state : any +>this : this +>state : any +>result : any + + : null; +>null : null + } +} + +// Error +function UserName() { +>UserName : () => JSX.Element + + return ( +>( { user => (

{ user.NAme }

) }
) : JSX.Element + + +> { user => (

{ user.NAme }

) }
: JSX.Element +>FetchUser : typeof FetchUser + + { user => ( +>user => (

{ user.NAme }

) : (user: IUser) => JSX.Element +>user : IUser +>(

{ user.NAme }

) : JSX.Element + +

{ user.NAme }

+>

{ user.NAme }

: JSX.Element +>h1 : any +>user.NAme : any +>user : IUser +>NAme : any +>h1 : any + + ) } +
+>FetchUser : typeof FetchUser + + ); +} + +function UserName1() { +>UserName1 : () => JSX.Element + + return ( +>( { user => (

{ user.Name }

) } { user => (

{ user.Name }

) }
) : JSX.Element + + +> { user => (

{ user.Name }

) } { user => (

{ user.Name }

) }
: JSX.Element +>FetchUser : typeof FetchUser + + + + { user => ( +>user => (

{ user.Name }

) : (user: IUser) => JSX.Element +>user : IUser +>(

{ user.Name }

) : JSX.Element + +

{ user.Name }

+>

{ user.Name }

: JSX.Element +>h1 : any +>user.Name : string +>user : IUser +>Name : string +>h1 : any + + ) } + { user => ( +>user => (

{ user.Name }

) : (user: IUser) => JSX.Element +>user : IUser +>(

{ user.Name }

) : JSX.Element + +

{ user.Name }

+>

{ user.Name }

: JSX.Element +>h1 : any +>user.Name : string +>user : IUser +>Name : string +>h1 : any + + ) } +
+>FetchUser : typeof FetchUser + + ); +} diff --git a/tests/baselines/reference/checkJsxChildrenProperty5.symbols b/tests/baselines/reference/checkJsxChildrenProperty5.symbols new file mode 100644 index 00000000000..aa925f3f1b7 --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty5.symbols @@ -0,0 +1,82 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +interface Prop { +>Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) + + a: number, +>a : Symbol(Prop.a, Decl(file.tsx, 2, 16)) + + b: string, +>b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) + + children: Button; +>children : Symbol(Prop.children, Decl(file.tsx, 4, 14)) +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) +} + +class Button extends React.Component { +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) +>React : Symbol(React, Decl(file.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55), Decl(react.d.ts, 161, 66)) + + render() { +>render : Symbol(Button.render, Decl(file.tsx, 8, 48)) + + return (
My Button
) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) + } +} + +function Comp(p: Prop) { +>Comp : Symbol(Comp, Decl(file.tsx, 12, 1)) +>p : Symbol(p, Decl(file.tsx, 14, 14)) +>Prop : Symbol(Prop, Decl(file.tsx, 0, 32)) + + return
{p.b}
; +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +>p.b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) +>p : Symbol(p, Decl(file.tsx, 14, 14)) +>b : Symbol(Prop.b, Decl(file.tsx, 3, 14)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2400, 45)) +} + +// Error: no children specified +let k = ; +>k : Symbol(k, Decl(file.tsx, 19, 3)) +>Comp : Symbol(Comp, Decl(file.tsx, 12, 1)) +>a : Symbol(a, Decl(file.tsx, 19, 13)) +>b : Symbol(b, Decl(file.tsx, 19, 20)) + +// Error: JSX.element is not the same as JSX.ElementClass +let k1 = +>k1 : Symbol(k1, Decl(file.tsx, 22, 3)) + + +>Comp : Symbol(Comp, Decl(file.tsx, 12, 1)) +>a : Symbol(a, Decl(file.tsx, 23, 9)) +>b : Symbol(b, Decl(file.tsx, 23, 16)) + +