diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index f72f30b226c..ef22ec250b3 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -236,10 +236,7 @@ namespace ts { } }); - if (oldCompilerOptions && - (oldCompilerOptions.outDir !== compilerOptions.outDir || - oldCompilerOptions.declarationDir !== compilerOptions.declarationDir || - (oldCompilerOptions.outFile || oldCompilerOptions.out) !== (compilerOptions.outFile || compilerOptions.out))) { + if (oldCompilerOptions && compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) { // Add all files to affectedFilesPendingEmit since emit changed state.affectedFilesPendingEmit = concatenate(state.affectedFilesPendingEmit, newProgram.getSourceFiles().map(f => f.path)); if (state.affectedFilesPendingEmitIndex === undefined) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0a025f29c20..22b268d3905 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -114,6 +114,11 @@ namespace ts { getIdentifierCount: () => sum(host.getSourceFiles(), "identifierCount"), getSymbolCount: () => sum(host.getSourceFiles(), "symbolCount") + symbolCount, getTypeCount: () => typeCount, + getRelationCacheSizes: () => ({ + assignable: assignableRelation.size, + identity: identityRelation.size, + subtype: subtypeRelation.size, + }), isUndefinedSymbol: symbol => symbol === undefinedSymbol, isArgumentsSymbol: symbol => symbol === argumentsSymbol, isUnknownSymbol: symbol => symbol === unknownSymbol, @@ -6709,11 +6714,12 @@ namespace ts { const links = getSymbolLinks(symbol); if (!links.lateSymbol && some(symbol.declarations, hasLateBindableName)) { // force late binding of members/exports. This will set the late-bound symbol + const parent = getMergedSymbol(symbol.parent)!; if (some(symbol.declarations, hasStaticModifier)) { - getExportsOfSymbol(symbol.parent!); + getExportsOfSymbol(parent); } else { - getMembersOfSymbol(symbol.parent!); + getMembersOfSymbol(parent); } } return links.lateSymbol || (links.lateSymbol = symbol); @@ -12043,7 +12049,7 @@ namespace ts { } function isStringIndexSignatureOnlyType(type: Type): boolean { - return type.flags & TypeFlags.Object && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, IndexKind.String) && !getIndexInfoOfType(type, IndexKind.Number) || + return type.flags & TypeFlags.Object && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, IndexKind.String) && !getIndexInfoOfType(type, IndexKind.Number) || type.flags & TypeFlags.UnionOrIntersection && every((type).types, isStringIndexSignatureOnlyType) || false; } @@ -15016,12 +15022,11 @@ namespace ts { } // If no inferences can be made to K's constraint, infer from a union of the property types // in the source to the template type X. - const valueTypes = compact([ - getIndexTypeOfType(source, IndexKind.String), - getIndexTypeOfType(source, IndexKind.Number), - ...map(getPropertiesOfType(source), getTypeOfSymbol) - ]); - inferFromTypes(getUnionType(valueTypes), getTemplateTypeFromMappedType(target)); + const propTypes = map(getPropertiesOfType(source), getTypeOfSymbol); + const stringIndexType = getIndexTypeOfType(source, IndexKind.String); + const numberIndexInfo = getNonEnumNumberIndexInfo(source); + const numberIndexType = numberIndexInfo && numberIndexInfo.type; + inferFromTypes(getUnionType(append(append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target)); return true; } return false; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 12a20e0df42..edb25e9cb71 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -281,6 +281,7 @@ namespace ts { name: "declaration", shortName: "d", type: "boolean", + affectsEmit: true, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, description: Diagnostics.Generates_corresponding_d_ts_file, @@ -288,6 +289,7 @@ namespace ts { { name: "declarationMap", type: "boolean", + affectsEmit: true, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, description: Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file, @@ -295,12 +297,14 @@ namespace ts { { name: "emitDeclarationOnly", type: "boolean", + affectsEmit: true, category: Diagnostics.Advanced_Options, description: Diagnostics.Only_emit_d_ts_declaration_files, }, { name: "sourceMap", type: "boolean", + affectsEmit: true, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, description: Diagnostics.Generates_corresponding_map_file, @@ -308,6 +312,7 @@ namespace ts { { name: "outFile", type: "string", + affectsEmit: true, isFilePath: true, paramType: Diagnostics.FILE, showInSimplifiedHelpView: true, @@ -317,6 +322,7 @@ namespace ts { { name: "outDir", type: "string", + affectsEmit: true, isFilePath: true, paramType: Diagnostics.DIRECTORY, showInSimplifiedHelpView: true, @@ -326,6 +332,7 @@ namespace ts { { name: "rootDir", type: "string", + affectsEmit: true, isFilePath: true, paramType: Diagnostics.LOCATION, category: Diagnostics.Basic_Options, @@ -334,6 +341,7 @@ namespace ts { { name: "composite", type: "boolean", + affectsEmit: true, isTSConfigOnly: true, category: Diagnostics.Basic_Options, description: Diagnostics.Enable_project_compilation, @@ -341,6 +349,7 @@ namespace ts { { name: "tsBuildInfoFile", type: "string", + affectsEmit: true, isFilePath: true, paramType: Diagnostics.FILE, category: Diagnostics.Basic_Options, @@ -349,6 +358,7 @@ namespace ts { { name: "removeComments", type: "boolean", + affectsEmit: true, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, description: Diagnostics.Do_not_emit_comments_to_output, @@ -356,6 +366,7 @@ namespace ts { { name: "noEmit", type: "boolean", + affectsEmit: true, showInSimplifiedHelpView: true, category: Diagnostics.Basic_Options, description: Diagnostics.Do_not_emit_outputs, @@ -363,12 +374,14 @@ namespace ts { { name: "importHelpers", type: "boolean", + affectsEmit: true, category: Diagnostics.Basic_Options, description: Diagnostics.Import_emit_helpers_from_tslib }, { name: "downlevelIteration", type: "boolean", + affectsEmit: true, category: Diagnostics.Basic_Options, description: Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 }, @@ -580,6 +593,7 @@ namespace ts { { name: "sourceRoot", type: "string", + affectsEmit: true, paramType: Diagnostics.LOCATION, category: Diagnostics.Source_Map_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, @@ -587,6 +601,7 @@ namespace ts { { name: "mapRoot", type: "string", + affectsEmit: true, paramType: Diagnostics.LOCATION, category: Diagnostics.Source_Map_Options, description: Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, @@ -594,12 +609,14 @@ namespace ts { { name: "inlineSourceMap", type: "boolean", + affectsEmit: true, category: Diagnostics.Source_Map_Options, description: Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file }, { name: "inlineSources", type: "boolean", + affectsEmit: true, category: Diagnostics.Source_Map_Options, description: Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set }, @@ -635,6 +652,7 @@ namespace ts { { name: "out", type: "string", + affectsEmit: true, isFilePath: false, // This is intentionally broken to support compatability with existing tsconfig files // for correct behaviour, please use outFile category: Diagnostics.Advanced_Options, @@ -644,6 +662,7 @@ namespace ts { { name: "reactNamespace", type: "string", + affectsEmit: true, category: Diagnostics.Advanced_Options, description: Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit }, @@ -662,6 +681,7 @@ namespace ts { { name: "emitBOM", type: "boolean", + affectsEmit: true, category: Diagnostics.Advanced_Options, description: Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, @@ -677,6 +697,7 @@ namespace ts { crlf: NewLineKind.CarriageReturnLineFeed, lf: NewLineKind.LineFeed }), + affectsEmit: true, paramType: Diagnostics.NEWLINE, category: Diagnostics.Advanced_Options, description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, @@ -704,6 +725,7 @@ namespace ts { { name: "stripInternal", type: "boolean", + affectsEmit: true, category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, }, @@ -724,24 +746,28 @@ namespace ts { { name: "noEmitHelpers", type: "boolean", + affectsEmit: true, category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output }, { name: "noEmitOnError", type: "boolean", + affectsEmit: true, category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, { name: "preserveConstEnums", type: "boolean", + affectsEmit: true, category: Diagnostics.Advanced_Options, description: Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code }, { name: "declarationDir", type: "string", + affectsEmit: true, isFilePath: true, paramType: Diagnostics.DIRECTORY, category: Diagnostics.Advanced_Options, @@ -826,6 +852,10 @@ namespace ts { export const semanticDiagnosticsOptionDeclarations: ReadonlyArray = optionDeclarations.filter(option => !!option.affectsSemanticDiagnostics); + /* @internal */ + export const affectsEmitOptionDeclarations: ReadonlyArray = + optionDeclarations.filter(option => !!option.affectsEmit); + /* @internal */ export const moduleResolutionOptionDeclarations: ReadonlyArray = optionDeclarations.filter(option => !!option.affectsModuleResolution); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 74bb8e1b1c8..4f50aa3ab1f 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -927,6 +927,7 @@ namespace ts { getIdentifierCount: () => getDiagnosticsProducingTypeChecker().getIdentifierCount(), getSymbolCount: () => getDiagnosticsProducingTypeChecker().getSymbolCount(), getTypeCount: () => getDiagnosticsProducingTypeChecker().getTypeCount(), + getRelationCacheSizes: () => getDiagnosticsProducingTypeChecker().getRelationCacheSizes(), getFileProcessingDiagnostics: () => fileProcessingDiagnostics, getResolvedTypeReferenceDirectives: () => resolvedTypeReferenceDirectives, isSourceFileFromExternalLibrary, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 6fba5f149cf..f9ad5ba1570 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2961,6 +2961,7 @@ namespace ts { /* @internal */ getIdentifierCount(): number; /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + /* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number }; /* @internal */ getFileProcessingDiagnostics(): DiagnosticCollection; /* @internal */ getResolvedTypeReferenceDirectives(): Map; @@ -3246,6 +3247,7 @@ namespace ts { /* @internal */ getIdentifierCount(): number; /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + /* @internal */ getRelationCacheSizes(): { assignable: number, identity: number, subtype: number }; /* @internal */ isArrayType(type: Type): boolean; /* @internal */ isTupleType(type: Type): boolean; @@ -4827,6 +4829,7 @@ namespace ts { affectsModuleResolution?: true; // currently same effect as `affectsSourceFile` affectsBindDiagnostics?: true; // true if this affects binding (currently same effect as `affectsSourceFile`) affectsSemanticDiagnostics?: true; // true if option affects semantic diagnostics + affectsEmit?: true; // true if the options affects emit } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index eca7dc7aee9..2e6c3ae4f86 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -7320,6 +7320,11 @@ namespace ts { semanticDiagnosticsOptionDeclarations.some(option => !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option))); } + export function compilerOptionsAffectEmit(newOptions: CompilerOptions, oldOptions: CompilerOptions): boolean { + return oldOptions !== newOptions && + affectsEmitOptionDeclarations.some(option => !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option))); + } + export function getCompilerOptionValue(options: CompilerOptions, option: CommandLineOption): unknown { return option.strictFlag ? getStrictOptionValue(options, option.name as StrictOptionName) : options[option.name]; } diff --git a/src/harness/fakes.ts b/src/harness/fakes.ts index dcc125698c8..489a41dd677 100644 --- a/src/harness/fakes.ts +++ b/src/harness/fakes.ts @@ -397,19 +397,6 @@ namespace fakes { const value = super.readFile(path); if (!value || !ts.isBuildInfoFile(path)) return value; const buildInfo = ts.getBuildInfo(value); - if (buildInfo.program) { - // Fix lib signatures - for (const path of ts.getOwnKeys(buildInfo.program.fileInfos)) { - if (ts.startsWith(path, "/lib/")) { - const currentValue = buildInfo.program.fileInfos[path]; - ts.Debug.assert(currentValue.signature === path); - ts.Debug.assert(currentValue.signature === currentValue.version); - const text = super.readFile(path)!; - const signature = ts.generateDjb2Hash(text); - buildInfo.program.fileInfos[path] = { version: signature, signature }; - } - } - } ts.Debug.assert(buildInfo.version === version); buildInfo.version = ts.version; return ts.getBuildInfoText(buildInfo); @@ -419,15 +406,6 @@ namespace fakes { if (!ts.isBuildInfoFile(fileName)) return super.writeFile(fileName, content, writeByteOrderMark); const buildInfo = ts.getBuildInfo(content); if (buildInfo.program) { - // Fix lib signatures - for (const path of ts.getOwnKeys(buildInfo.program.fileInfos)) { - if (ts.startsWith(path, "/lib/")) { - const currentValue = buildInfo.program.fileInfos[path]; - ts.Debug.assert(currentValue.signature === currentValue.version); - buildInfo.program.fileInfos[path] = { version: path, signature: path }; - } - } - // reference Map if (buildInfo.program.referencedMap) { const referencedMap: ts.MapLike = {}; diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index d3ea4744e8a..6b73324e2f7 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -92,6 +92,7 @@ "unittests/tsbuild/amdModulesWithOut.ts", "unittests/tsbuild/emptyFiles.ts", "unittests/tsbuild/graphOrdering.ts", + "unittests/tsbuild/lateBoundSymbol.ts", "unittests/tsbuild/missingExtendedFile.ts", "unittests/tsbuild/outFile.ts", "unittests/tsbuild/referencesWithRootDirInParent.ts", diff --git a/src/testRunner/unittests/tsbuild/helpers.ts b/src/testRunner/unittests/tsbuild/helpers.ts index 6915dd5d3b7..88eb61cd422 100644 --- a/src/testRunner/unittests/tsbuild/helpers.ts +++ b/src/testRunner/unittests/tsbuild/helpers.ts @@ -62,31 +62,26 @@ namespace ts { } } + const libContent = `${TestFSWithWatch.libFile.content} +interface ReadonlyArray {} +declare const console: { log(msg: any): void; };`; + export function loadProjectFromDisk(root: string, time?: vfs.FileSystemOptions["time"]): vfs.FileSystem { const resolver = vfs.createResolver(Harness.IO); const fs = new vfs.FileSystem(/*ignoreCase*/ true, { files: { - ["/lib"]: new vfs.Mount(vpath.resolve(Harness.IO.getWorkspaceRoot(), "built/local"), resolver), ["/src"]: new vfs.Mount(vpath.resolve(Harness.IO.getWorkspaceRoot(), root), resolver) }, cwd: "/", meta: { defaultLibLocation: "/lib" }, time }); + fs.mkdirSync("/lib"); + fs.writeFileSync("/lib/lib.d.ts", libContent); fs.makeReadonly(); return fs; } - export function getLibs() { - return [ - "/lib/lib.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.webworker.importscripts.d.ts", - "/lib/lib.scripthost.d.ts" - ]; - } - function generateSourceMapBaselineFiles(fs: vfs.FileSystem, mapFileNames: ReadonlyArray) { for (const mapFile of mapFileNames) { if (!fs.existsSync(mapFile)) continue; @@ -285,8 +280,10 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt let newFs: vfs.FileSystem; let actualReadFileMap: Map; let host: fakes.SolutionBuilderHost; + let beforeBuildTime: number; + let afterBuildTime: number; before(() => { - assert.equal(fs.statSync(lastProjectOutputJs).mtimeMs, firstBuildTime, "First build timestamp is correct"); + beforeBuildTime = fs.statSync(lastProjectOutputJs).mtimeMs; tick(); newFs = fs.shadow(); tick(); @@ -298,14 +295,18 @@ Mismatch Actual(path, actual, expected): ${JSON.stringify(arrayFrom(mapDefinedIt expectedBuildInfoFilesForSectionBaselines, modifyFs: incrementalModifyFs, })); - assert.equal(newFs.statSync(lastProjectOutputJs).mtimeMs, time(), "Second build timestamp is correct"); + afterBuildTime = newFs.statSync(lastProjectOutputJs).mtimeMs; }); after(() => { newFs = undefined!; actualReadFileMap = undefined!; host = undefined!; }); - if (!baselineOnly) { + it("verify build output times", () => { + assert.equal(beforeBuildTime, firstBuildTime, "First build timestamp is correct"); + assert.equal(afterBuildTime, time(), "Second build timestamp is correct"); + }); + if (!baselineOnly || verifyDiagnostics) { it(`verify diagnostics`, () => { host.assertDiagnosticMessages(...(incrementalExpectedDiagnostics || emptyArray)); }); diff --git a/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts b/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts new file mode 100644 index 00000000000..ff9f1fc7c7a --- /dev/null +++ b/src/testRunner/unittests/tsbuild/lateBoundSymbol.ts @@ -0,0 +1,47 @@ +namespace ts { + describe("unittests:: tsbuild:: lateBoundSymbol:: interface is merged and contains late bound member", () => { + let projFs: vfs.FileSystem; + const { time, tick } = getTime(); + before(() => { + projFs = loadProjectFromDisk("tests/projects/lateBoundSymbol", time); + }); + after(() => { + projFs = undefined!; // Release the contents + }); + + verifyTsbuildOutput({ + scenario: "interface is merged and contains late bound member", + projFs: () => projFs, + time, + tick, + proj: "lateBoundSymbol", + rootNames: ["/src/tsconfig.json"], + expectedMapFileNames: emptyArray, + lastProjectOutputJs: "/src/src/main.js", + outputFiles: [ + "/src/src/hkt.js", + "/src/src/main.js", + "/src/tsconfig.tsbuildinfo", + ], + initialBuild: { + modifyFs: noop, + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tsconfig.json", "src/src/hkt.js"], + [Diagnostics.Building_project_0, "/src/tsconfig.json"] + ] + }, + incrementalDtsUnchangedBuild: { + modifyFs: fs => replaceText(fs, "/src/src/main.ts", "const x = 10;", ""), + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, "src/tsconfig.json", "src/src/hkt.js", "src/src/main.ts"], + [Diagnostics.Building_project_0, "/src/tsconfig.json"], + [Diagnostics.Updating_unchanged_output_timestamps_of_project_0, "/src/tsconfig.json"] + ] + }, + baselineOnly: true, + verifyDiagnostics: true + }); + }); +} diff --git a/src/testRunner/unittests/tsbuild/sample.ts b/src/testRunner/unittests/tsbuild/sample.ts index 588eb256eda..6e31ada9ee5 100644 --- a/src/testRunner/unittests/tsbuild/sample.ts +++ b/src/testRunner/unittests/tsbuild/sample.ts @@ -399,14 +399,14 @@ export class cNew {}`); const builder = createSolutionBuilder(host, ["/src/tests"], { listFiles: true }); builder.buildAllProjects(); assert.deepEqual(host.traces, [ - ...getLibs(), + "/lib/lib.d.ts", "/src/core/anotherModule.ts", "/src/core/index.ts", "/src/core/some_decl.d.ts", - ...getLibs(), + "/lib/lib.d.ts", ...getCoreOutputs(), "/src/logic/index.ts", - ...getLibs(), + "/lib/lib.d.ts", ...getCoreOutputs(), "/src/logic/index.d.ts", "/src/tests/index.ts" @@ -720,6 +720,47 @@ class someClass { }`), "/src/tests/tsconfig.tsbuildinfo", ] }); + + verifyTsbuildOutput({ + scenario: "when declaration option changes", + projFs: () => projFs, + time, + tick, + proj: "sample1", + rootNames: ["/src/core"], + expectedMapFileNames: emptyArray, + lastProjectOutputJs: "/src/core/index.js", + initialBuild: { + modifyFs: fs => fs.writeFileSync("/src/core/tsconfig.json", `{ + "compilerOptions": { + "incremental": true, + "skipDefaultLibCheck": true + } +}`), + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.js"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"], + ] + }, + incrementalDtsChangedBuild: { + modifyFs: fs => replaceText(fs, "/src/core/tsconfig.json", `"incremental": true,`, `"incremental": true, "declaration": true,`), + expectedDiagnostics: [ + getExpectedDiagnosticForProjectsInBuild("src/core/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/core/tsconfig.json", "src/core/anotherModule.d.ts"], + [Diagnostics.Building_project_0, "/src/core/tsconfig.json"] + ] + }, + outputFiles: [ + "/src/core/anotherModule.js", + "/src/core/anotherModule.d.ts", + "/src/core/index.js", + "/src/core/index.d.ts", + "/src/core/tsconfig.tsbuildinfo", + ], + baselineOnly: true, + verifyDiagnostics: true + }); }); }); } diff --git a/src/testRunner/unittests/tsbuild/transitiveReferences.ts b/src/testRunner/unittests/tsbuild/transitiveReferences.ts index 7944d1fda09..30e28de8cde 100644 --- a/src/testRunner/unittests/tsbuild/transitiveReferences.ts +++ b/src/testRunner/unittests/tsbuild/transitiveReferences.ts @@ -7,12 +7,12 @@ namespace ts { "/src/c.js" ]; const expectedFileTraces = [ - ...getLibs(), + "/lib/lib.d.ts", "/src/a.ts", - ...getLibs(), + "/lib/lib.d.ts", "/src/a.d.ts", "/src/b.ts", - ...getLibs(), + "/lib/lib.d.ts", "/src/a.d.ts", "/src/b.d.ts", "/src/refs/a.d.ts", @@ -63,9 +63,9 @@ export const b = new A();`); // Error in b build only a const allExpectedOutputs = ["/src/a.js", "/src/a.d.ts"]; const expectedFileTraces = [ - ...getLibs(), + "/lib/lib.d.ts", "/src/a.ts", - ...getLibs(), + "/lib/lib.d.ts", "/src/b.ts" ]; verifyBuild(fs => modifyFsBTsToNonRelativeImport(fs, "node"), diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index 984ebe21cf6..500480463bd 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -340,6 +340,10 @@ namespace ts { const checkTime = performance.getDuration("Check"); const emitTime = performance.getDuration("Emit"); if (compilerOptions.extendedDiagnostics) { + const caches = program.getRelationCacheSizes(); + reportCountStatistic("Assignability cache size", caches.assignable); + reportCountStatistic("Identity cache size", caches.identity); + reportCountStatistic("Subtype cache size", caches.subtype); performance.forEachMeasure((name, duration) => reportTimeStatistic(`${name} time`, duration)); } else { diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt b/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt index ba2fe38c145..8b018263a4b 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt +++ b/tests/baselines/reference/keyofAndIndexedAccess2.errors.txt @@ -188,6 +188,7 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23 !!! error TS2322: Type '123' is not assignable to type '"some string"'. } +<<<<<<< HEAD // Repros from #30938 function fn} | {elements: Array}>(param: T, cb: (element: T['elements'][number]) => void) { @@ -197,4 +198,12 @@ tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts(108,5): error TS23 function fn2>(param: T, cb: (element: T[number]) => void) { cb(param[0]); } +======= + // Repro from #30920 + + type StrictExtract = T extends U ? U extends T ? T : never : never; + type StrictExclude = T extends StrictExtract ? never : T; + type A = { [Q in { [P in keyof T]: P; }[keyof T]]: T[Q]; }; + type B = A<{ [Q in keyof T]: StrictExclude, {}>; }>; +>>>>>>> master \ No newline at end of file diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.js b/tests/baselines/reference/keyofAndIndexedAccess2.js index 2ef82b3d68e..9956a17bf47 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.js +++ b/tests/baselines/reference/keyofAndIndexedAccess2.js @@ -109,6 +109,7 @@ function get123(): Type[K] { return 123; // Error } +<<<<<<< HEAD // Repros from #30938 function fn} | {elements: Array}>(param: T, cb: (element: T['elements'][number]) => void) { @@ -118,6 +119,14 @@ function fn} | {elements: Array}>(par function fn2>(param: T, cb: (element: T[number]) => void) { cb(param[0]); } +======= +// Repro from #30920 + +type StrictExtract = T extends U ? U extends T ? T : never : never; +type StrictExclude = T extends StrictExtract ? never : T; +type A = { [Q in { [P in keyof T]: P; }[keyof T]]: T[Q]; }; +type B = A<{ [Q in keyof T]: StrictExclude, {}>; }>; +>>>>>>> master //// [keyofAndIndexedAccess2.js] diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.symbols b/tests/baselines/reference/keyofAndIndexedAccess2.symbols index 5113eb736db..e0eb723649a 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.symbols +++ b/tests/baselines/reference/keyofAndIndexedAccess2.symbols @@ -388,6 +388,7 @@ function get123(): Type[K] { return 123; // Error } +<<<<<<< HEAD // Repros from #30938 function fn} | {elements: Array}>(param: T, cb: (element: T['elements'][number]) => void) { @@ -424,4 +425,51 @@ function fn2>(param: T, cb: (element: T[number]) => void >cb : Symbol(cb, Decl(keyofAndIndexedAccess2.ts, 116, 47)) >param : Symbol(param, Decl(keyofAndIndexedAccess2.ts, 116, 38)) } +======= +// Repro from #30920 + +type StrictExtract = T extends U ? U extends T ? T : never : never; +>StrictExtract : Symbol(StrictExtract, Decl(keyofAndIndexedAccess2.ts, 108, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 112, 19)) +>U : Symbol(U, Decl(keyofAndIndexedAccess2.ts, 112, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 112, 19)) +>U : Symbol(U, Decl(keyofAndIndexedAccess2.ts, 112, 21)) +>U : Symbol(U, Decl(keyofAndIndexedAccess2.ts, 112, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 112, 19)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 112, 19)) + +type StrictExclude = T extends StrictExtract ? never : T; +>StrictExclude : Symbol(StrictExclude, Decl(keyofAndIndexedAccess2.ts, 112, 73)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 113, 19)) +>U : Symbol(U, Decl(keyofAndIndexedAccess2.ts, 113, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 113, 19)) +>StrictExtract : Symbol(StrictExtract, Decl(keyofAndIndexedAccess2.ts, 108, 1)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 113, 19)) +>U : Symbol(U, Decl(keyofAndIndexedAccess2.ts, 113, 21)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 113, 19)) + +type A = { [Q in { [P in keyof T]: P; }[keyof T]]: T[Q]; }; +>A : Symbol(A, Decl(keyofAndIndexedAccess2.ts, 113, 69)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 114, 7)) +>Q : Symbol(Q, Decl(keyofAndIndexedAccess2.ts, 114, 15)) +>P : Symbol(P, Decl(keyofAndIndexedAccess2.ts, 114, 23)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 114, 7)) +>P : Symbol(P, Decl(keyofAndIndexedAccess2.ts, 114, 23)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 114, 7)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 114, 7)) +>Q : Symbol(Q, Decl(keyofAndIndexedAccess2.ts, 114, 15)) + +type B = A<{ [Q in keyof T]: StrictExclude, {}>; }>; +>B : Symbol(B, Decl(keyofAndIndexedAccess2.ts, 114, 62)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 115, 7)) +>V : Symbol(V, Decl(keyofAndIndexedAccess2.ts, 115, 9)) +>A : Symbol(A, Decl(keyofAndIndexedAccess2.ts, 113, 69)) +>Q : Symbol(Q, Decl(keyofAndIndexedAccess2.ts, 115, 20)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 115, 7)) +>StrictExclude : Symbol(StrictExclude, Decl(keyofAndIndexedAccess2.ts, 112, 73)) +>B : Symbol(B, Decl(keyofAndIndexedAccess2.ts, 114, 62)) +>T : Symbol(T, Decl(keyofAndIndexedAccess2.ts, 115, 7)) +>Q : Symbol(Q, Decl(keyofAndIndexedAccess2.ts, 115, 20)) +>V : Symbol(V, Decl(keyofAndIndexedAccess2.ts, 115, 9)) +>>>>>>> master diff --git a/tests/baselines/reference/keyofAndIndexedAccess2.types b/tests/baselines/reference/keyofAndIndexedAccess2.types index 286db62e4b5..16bd970d341 100644 --- a/tests/baselines/reference/keyofAndIndexedAccess2.types +++ b/tests/baselines/reference/keyofAndIndexedAccess2.types @@ -423,6 +423,7 @@ function get123(): Type[K] { >123 : 123 } +<<<<<<< HEAD // Repros from #30938 function fn} | {elements: Array}>(param: T, cb: (element: T['elements'][number]) => void) { @@ -456,4 +457,19 @@ function fn2>(param: T, cb: (element: T[number]) => void >param : T >0 : 0 } +======= +// Repro from #30920 + +type StrictExtract = T extends U ? U extends T ? T : never : never; +>StrictExtract : StrictExtract + +type StrictExclude = T extends StrictExtract ? never : T; +>StrictExclude : StrictExclude + +type A = { [Q in { [P in keyof T]: P; }[keyof T]]: T[Q]; }; +>A : A + +type B = A<{ [Q in keyof T]: StrictExclude, {}>; }>; +>B : A<{ [Q in keyof T]: StrictExclude, {}>; }>, {}>; }>, {}>; }>, {}>; }>, {}>; }>, {}>; }>, {}>; }>, {}>; }>, {}>; }>, {}>; }>, {}>; }> +>>>>>>> master diff --git a/tests/baselines/reference/mappedToToIndexSignatureInference.js b/tests/baselines/reference/mappedToToIndexSignatureInference.js index 2ea09b663a9..03a24ab0ad9 100644 --- a/tests/baselines/reference/mappedToToIndexSignatureInference.js +++ b/tests/baselines/reference/mappedToToIndexSignatureInference.js @@ -2,7 +2,21 @@ declare const fn: (object: { [Key in K]: V }) => object; declare const a: { [index: string]: number }; fn(a); + +// Repro from #30218 + +declare function enumValues(e: Record): V[]; + +enum E { A = 'foo', B = 'bar' } + +let x: E[] = enumValues(E); //// [mappedToToIndexSignatureInference.js] fn(a); +var E; +(function (E) { + E["A"] = "foo"; + E["B"] = "bar"; +})(E || (E = {})); +var x = enumValues(E); diff --git a/tests/baselines/reference/mappedToToIndexSignatureInference.symbols b/tests/baselines/reference/mappedToToIndexSignatureInference.symbols index d071f3f4c1c..d2d6f923f87 100644 --- a/tests/baselines/reference/mappedToToIndexSignatureInference.symbols +++ b/tests/baselines/reference/mappedToToIndexSignatureInference.symbols @@ -16,3 +16,26 @@ fn(a); >fn : Symbol(fn, Decl(mappedToToIndexSignatureInference.ts, 0, 13)) >a : Symbol(a, Decl(mappedToToIndexSignatureInference.ts, 1, 13)) +// Repro from #30218 + +declare function enumValues(e: Record): V[]; +>enumValues : Symbol(enumValues, Decl(mappedToToIndexSignatureInference.ts, 2, 6)) +>K : Symbol(K, Decl(mappedToToIndexSignatureInference.ts, 6, 28)) +>V : Symbol(V, Decl(mappedToToIndexSignatureInference.ts, 6, 45)) +>e : Symbol(e, Decl(mappedToToIndexSignatureInference.ts, 6, 64)) +>Record : Symbol(Record, Decl(lib.es5.d.ts, --, --)) +>K : Symbol(K, Decl(mappedToToIndexSignatureInference.ts, 6, 28)) +>V : Symbol(V, Decl(mappedToToIndexSignatureInference.ts, 6, 45)) +>V : Symbol(V, Decl(mappedToToIndexSignatureInference.ts, 6, 45)) + +enum E { A = 'foo', B = 'bar' } +>E : Symbol(E, Decl(mappedToToIndexSignatureInference.ts, 6, 86)) +>A : Symbol(E.A, Decl(mappedToToIndexSignatureInference.ts, 8, 8)) +>B : Symbol(E.B, Decl(mappedToToIndexSignatureInference.ts, 8, 19)) + +let x: E[] = enumValues(E); +>x : Symbol(x, Decl(mappedToToIndexSignatureInference.ts, 10, 3)) +>E : Symbol(E, Decl(mappedToToIndexSignatureInference.ts, 6, 86)) +>enumValues : Symbol(enumValues, Decl(mappedToToIndexSignatureInference.ts, 2, 6)) +>E : Symbol(E, Decl(mappedToToIndexSignatureInference.ts, 6, 86)) + diff --git a/tests/baselines/reference/mappedToToIndexSignatureInference.types b/tests/baselines/reference/mappedToToIndexSignatureInference.types index 35b9b3565e0..21ab79e8e48 100644 --- a/tests/baselines/reference/mappedToToIndexSignatureInference.types +++ b/tests/baselines/reference/mappedToToIndexSignatureInference.types @@ -12,3 +12,22 @@ fn(a); >fn : (object: { [Key in K]: V; }) => object >a : { [index: string]: number; } +// Repro from #30218 + +declare function enumValues(e: Record): V[]; +>enumValues : (e: Record) => V[] +>e : Record + +enum E { A = 'foo', B = 'bar' } +>E : E +>A : E.A +>'foo' : "foo" +>B : E.B +>'bar' : "bar" + +let x: E[] = enumValues(E); +>x : E[] +>enumValues(E) : E[] +>enumValues : (e: Record) => V[] +>E : typeof E + diff --git a/tests/baselines/reference/tsbuild/lateBoundSymbol/incremental-declaration-doesnt-change/interface-is-merged-and-contains-late-bound-member.js b/tests/baselines/reference/tsbuild/lateBoundSymbol/incremental-declaration-doesnt-change/interface-is-merged-and-contains-late-bound-member.js new file mode 100644 index 00000000000..b0549b1a8fb --- /dev/null +++ b/tests/baselines/reference/tsbuild/lateBoundSymbol/incremental-declaration-doesnt-change/interface-is-merged-and-contains-late-bound-member.js @@ -0,0 +1,65 @@ +//// [/src/src/main.js] +"use strict"; +exports.__esModule = true; +var sym = Symbol(); + + +//// [/src/src/main.ts] +import { HKT } from "./hkt"; + +const sym = Symbol(); + +declare module "./hkt" { + interface HKT { + [sym]: { a: T } + } +} + +type A = HKT[typeof sym]; + +//// [/src/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "/lib/lib.d.ts": { + "version": "-15964756381", + "signature": "-15964756381" + }, + "/src/src/globals.d.ts": { + "version": "-1994196675", + "signature": "-1994196675" + }, + "/src/src/hkt.ts": { + "version": "675797797", + "signature": "2373810515" + }, + "/src/src/main.ts": { + "version": "-27494779858", + "signature": "-7779857705" + } + }, + "options": { + "rootDir": "/src/src", + "incremental": true, + "configFilePath": "/src/tsconfig.json" + }, + "referencedMap": { + "/src/src/main.ts": [ + "/src/src/hkt.ts" + ] + }, + "exportedModulesMap": { + "/src/src/main.ts": [ + "/src/src/hkt.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "/lib/lib.d.ts", + "/src/src/globals.d.ts", + "/src/src/hkt.ts", + "/src/src/main.ts" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsbuild/lateBoundSymbol/initial-Build/interface-is-merged-and-contains-late-bound-member.js b/tests/baselines/reference/tsbuild/lateBoundSymbol/initial-Build/interface-is-merged-and-contains-late-bound-member.js new file mode 100644 index 00000000000..a48d6df88e4 --- /dev/null +++ b/tests/baselines/reference/tsbuild/lateBoundSymbol/initial-Build/interface-is-merged-and-contains-late-bound-member.js @@ -0,0 +1,58 @@ +//// [/src/src/hkt.js] +"use strict"; +exports.__esModule = true; + + +//// [/src/src/main.js] +"use strict"; +exports.__esModule = true; +var sym = Symbol(); +var x = 10; + + +//// [/src/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "/lib/lib.d.ts": { + "version": "-15964756381", + "signature": "-15964756381" + }, + "/src/src/globals.d.ts": { + "version": "-1994196675", + "signature": "-1994196675" + }, + "/src/src/hkt.ts": { + "version": "675797797", + "signature": "2373810515" + }, + "/src/src/main.ts": { + "version": "-28387946490", + "signature": "-7779857705" + } + }, + "options": { + "rootDir": "/src/src", + "incremental": true, + "configFilePath": "/src/tsconfig.json" + }, + "referencedMap": { + "/src/src/main.ts": [ + "/src/src/hkt.ts" + ] + }, + "exportedModulesMap": { + "/src/src/main.ts": [ + "/src/src/hkt.ts" + ] + }, + "semanticDiagnosticsPerFile": [ + "/lib/lib.d.ts", + "/src/src/globals.d.ts", + "/src/src/hkt.ts", + "/src/src/main.ts" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/sample.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/sample.js index c1274f3f49f..a698d6c34cf 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/sample.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/sample.js @@ -172,24 +172,8 @@ export class someClass { } "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/anothermodule.ts": { "version": "-2676574883", @@ -215,10 +199,6 @@ export class someClass { } "exportedModulesMap": {}, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/core/some_decl.d.ts" @@ -232,24 +212,8 @@ export class someClass { } "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-2069755619", @@ -285,10 +249,6 @@ export class someClass { } }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts" @@ -302,24 +262,8 @@ export class someClass { } "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-2069755619", @@ -365,10 +309,6 @@ export class someClass { } }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts", diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-declaration-option-changes.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-declaration-option-changes.js new file mode 100644 index 00000000000..69c7b20d506 --- /dev/null +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-declaration-option-changes.js @@ -0,0 +1,57 @@ +//// [/src/core/anotherModule.d.ts] +export declare const World = "hello"; + + +//// [/src/core/index.d.ts] +export declare const someString: string; +export declare function leftPad(s: string, n: number): string; +export declare function multiply(a: number, b: number): number; + + +//// [/src/core/tsconfig.json] +{ + "compilerOptions": { + "incremental": true, "declaration": true, + "skipDefaultLibCheck": true + } +} + +//// [/src/core/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "/lib/lib.d.ts": { + "version": "-15964756381", + "signature": "-15964756381" + }, + "/src/core/anothermodule.ts": { + "version": "-2676574883", + "signature": "-8396256275" + }, + "/src/core/index.ts": { + "version": "-18749805970", + "signature": "1874987148" + }, + "/src/core/some_decl.d.ts": { + "version": "-9253692965", + "signature": "-9253692965" + } + }, + "options": { + "incremental": true, + "declaration": true, + "skipDefaultLibCheck": true, + "configFilePath": "/src/core/tsconfig.json" + }, + "referencedMap": {}, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "/lib/lib.d.ts", + "/src/core/anothermodule.ts", + "/src/core/index.ts", + "/src/core/some_decl.d.ts" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-logic-config-changes-declaration-dir.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-logic-config-changes-declaration-dir.js index 3412d1c89a2..53f222a4bf5 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-logic-config-changes-declaration-dir.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-changes/when-logic-config-changes-declaration-dir.js @@ -25,24 +25,8 @@ export declare const m: typeof mod; "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-13851440507", @@ -79,10 +63,6 @@ export declare const m: typeof mod; }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts" @@ -96,24 +76,8 @@ export declare const m: typeof mod; "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-13851440507", @@ -159,10 +123,6 @@ export declare const m: typeof mod; }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts", diff --git a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-doesnt-change/sample.js b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-doesnt-change/sample.js index 85fcc62cfc9..aae81ea9fdc 100644 --- a/tests/baselines/reference/tsbuild/sample1/incremental-declaration-doesnt-change/sample.js +++ b/tests/baselines/reference/tsbuild/sample1/incremental-declaration-doesnt-change/sample.js @@ -25,24 +25,8 @@ class someClass { } "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/anothermodule.ts": { "version": "-2676574883", @@ -68,10 +52,6 @@ class someClass { } "exportedModulesMap": {}, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/core/some_decl.d.ts" diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/sample.js b/tests/baselines/reference/tsbuild/sample1/initial-Build/sample.js index 21e8c9b820f..ef63741766a 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/sample.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-Build/sample.js @@ -185,24 +185,8 @@ exports.multiply = multiply; "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/anothermodule.ts": { "version": "-2676574883", @@ -228,10 +212,6 @@ exports.multiply = multiply; "exportedModulesMap": {}, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/core/some_decl.d.ts" @@ -390,24 +370,8 @@ sourceFile:index.ts "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-13851440507", @@ -443,10 +407,6 @@ sourceFile:index.ts }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts" @@ -476,24 +436,8 @@ exports.m = mod; "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-13851440507", @@ -539,10 +483,6 @@ exports.m = mod; }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts", diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-declaration-option-changes.js b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-declaration-option-changes.js new file mode 100644 index 00000000000..90f10c0a25c --- /dev/null +++ b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-declaration-option-changes.js @@ -0,0 +1,62 @@ +//// [/src/core/anotherModule.js] +"use strict"; +exports.__esModule = true; +exports.World = "hello"; + + +//// [/src/core/index.js] +"use strict"; +exports.__esModule = true; +exports.someString = "HELLO WORLD"; +function leftPad(s, n) { return s + n; } +exports.leftPad = leftPad; +function multiply(a, b) { return a * b; } +exports.multiply = multiply; + + +//// [/src/core/tsconfig.json] +{ + "compilerOptions": { + "incremental": true, + "skipDefaultLibCheck": true + } +} + +//// [/src/core/tsconfig.tsbuildinfo] +{ + "program": { + "fileInfos": { + "/lib/lib.d.ts": { + "version": "-15964756381", + "signature": "-15964756381" + }, + "/src/core/anothermodule.ts": { + "version": "-2676574883", + "signature": "-8396256275" + }, + "/src/core/index.ts": { + "version": "-18749805970", + "signature": "1874987148" + }, + "/src/core/some_decl.d.ts": { + "version": "-9253692965", + "signature": "-9253692965" + } + }, + "options": { + "incremental": true, + "skipDefaultLibCheck": true, + "configFilePath": "/src/core/tsconfig.json" + }, + "referencedMap": {}, + "exportedModulesMap": {}, + "semanticDiagnosticsPerFile": [ + "/lib/lib.d.ts", + "/src/core/anothermodule.ts", + "/src/core/index.ts", + "/src/core/some_decl.d.ts" + ] + }, + "version": "FakeTSVersion" +} + diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-config-changes-declaration-dir.js b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-config-changes-declaration-dir.js index 21e8c9b820f..ef63741766a 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-config-changes-declaration-dir.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-config-changes-declaration-dir.js @@ -185,24 +185,8 @@ exports.multiply = multiply; "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/anothermodule.ts": { "version": "-2676574883", @@ -228,10 +212,6 @@ exports.multiply = multiply; "exportedModulesMap": {}, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/core/some_decl.d.ts" @@ -390,24 +370,8 @@ sourceFile:index.ts "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-13851440507", @@ -443,10 +407,6 @@ sourceFile:index.ts }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts" @@ -476,24 +436,8 @@ exports.m = mod; "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-13851440507", @@ -539,10 +483,6 @@ exports.m = mod; }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts", diff --git a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-specifies-tsBuildInfoFile.js b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-specifies-tsBuildInfoFile.js index 990a019c479..b3b74cb388c 100644 --- a/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-specifies-tsBuildInfoFile.js +++ b/tests/baselines/reference/tsbuild/sample1/initial-Build/when-logic-specifies-tsBuildInfoFile.js @@ -185,24 +185,8 @@ exports.multiply = multiply; "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/anothermodule.ts": { "version": "-2676574883", @@ -228,10 +212,6 @@ exports.multiply = multiply; "exportedModulesMap": {}, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/core/some_decl.d.ts" @@ -390,24 +370,8 @@ sourceFile:index.ts "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-13851440507", @@ -444,10 +408,6 @@ sourceFile:index.ts }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts" @@ -493,24 +453,8 @@ exports.m = mod; "program": { "fileInfos": { "/lib/lib.d.ts": { - "version": "/lib/lib.d.ts", - "signature": "/lib/lib.d.ts" - }, - "/lib/lib.es5.d.ts": { - "version": "/lib/lib.es5.d.ts", - "signature": "/lib/lib.es5.d.ts" - }, - "/lib/lib.dom.d.ts": { - "version": "/lib/lib.dom.d.ts", - "signature": "/lib/lib.dom.d.ts" - }, - "/lib/lib.webworker.importscripts.d.ts": { - "version": "/lib/lib.webworker.importscripts.d.ts", - "signature": "/lib/lib.webworker.importscripts.d.ts" - }, - "/lib/lib.scripthost.d.ts": { - "version": "/lib/lib.scripthost.d.ts", - "signature": "/lib/lib.scripthost.d.ts" + "version": "-15964756381", + "signature": "-15964756381" }, "/src/core/index.ts": { "version": "-13851440507", @@ -556,10 +500,6 @@ exports.m = mod; }, "semanticDiagnosticsPerFile": [ "/lib/lib.d.ts", - "/lib/lib.dom.d.ts", - "/lib/lib.es5.d.ts", - "/lib/lib.scripthost.d.ts", - "/lib/lib.webworker.importscripts.d.ts", "/src/core/anothermodule.ts", "/src/core/index.ts", "/src/logic/index.ts", diff --git a/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js new file mode 100644 index 00000000000..bfb6f0a29c7 --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js @@ -0,0 +1,18 @@ +//// [uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts] +const FOO_SYMBOL = Symbol('Foo'); + +declare global { + interface Promise { + [FOO_SYMBOL]?: number; + } +} + +export function foo(p: Promise) { + p[FOO_SYMBOL] = 3; +} + +//// [uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.js] +const FOO_SYMBOL = Symbol('Foo'); +export function foo(p) { + p[FOO_SYMBOL] = 3; +} diff --git a/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.symbols b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.symbols new file mode 100644 index 00000000000..17af30e8fac --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts === +const FOO_SYMBOL = Symbol('Foo'); +>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5)) +>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + +declare global { +>global : Symbol(global, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 33)) + + interface Promise { +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 2, 16)) +>T : Symbol(T, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 3, 22)) + + [FOO_SYMBOL]?: number; +>[FOO_SYMBOL] : Symbol(Promise[FOO_SYMBOL], Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 3, 26)) +>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5)) + } +} + +export function foo(p: Promise) { +>foo : Symbol(foo, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 6, 1)) +>T : Symbol(T, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 20)) +>p : Symbol(p, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 23)) +>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 2, 16)) +>T : Symbol(T, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 20)) + + p[FOO_SYMBOL] = 3; +>p : Symbol(p, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 8, 23)) +>FOO_SYMBOL : Symbol(FOO_SYMBOL, Decl(uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts, 0, 5)) +} diff --git a/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types new file mode 100644 index 00000000000..62dcc0607ae --- /dev/null +++ b/tests/baselines/reference/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts === +const FOO_SYMBOL = Symbol('Foo'); +>FOO_SYMBOL : unique symbol +>Symbol('Foo') : unique symbol +>Symbol : SymbolConstructor +>'Foo' : "Foo" + +declare global { +>global : any + + interface Promise { + [FOO_SYMBOL]?: number; +>[FOO_SYMBOL] : number | undefined +>FOO_SYMBOL : unique symbol + } +} + +export function foo(p: Promise) { +>foo : (p: Promise) => void +>p : Promise + + p[FOO_SYMBOL] = 3; +>p[FOO_SYMBOL] = 3 : 3 +>p[FOO_SYMBOL] : number | undefined +>p : Promise +>FOO_SYMBOL : unique symbol +>3 : 3 +} diff --git a/tests/cases/compiler/mappedToToIndexSignatureInference.ts b/tests/cases/compiler/mappedToToIndexSignatureInference.ts index 6ce63ead59c..ee6f71a0616 100644 --- a/tests/cases/compiler/mappedToToIndexSignatureInference.ts +++ b/tests/cases/compiler/mappedToToIndexSignatureInference.ts @@ -1,3 +1,11 @@ declare const fn: (object: { [Key in K]: V }) => object; declare const a: { [index: string]: number }; fn(a); + +// Repro from #30218 + +declare function enumValues(e: Record): V[]; + +enum E { A = 'foo', B = 'bar' } + +let x: E[] = enumValues(E); diff --git a/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts b/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts new file mode 100644 index 00000000000..f79c2a36e86 --- /dev/null +++ b/tests/cases/compiler/uniqueSymbolAssignmentOnGlobalAugmentationSuceeds.ts @@ -0,0 +1,13 @@ +// @strict: true +// @target: es6 +const FOO_SYMBOL = Symbol('Foo'); + +declare global { + interface Promise { + [FOO_SYMBOL]?: number; + } +} + +export function foo(p: Promise) { + p[FOO_SYMBOL] = 3; +} \ No newline at end of file diff --git a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts index 2d63e5681ba..356e0a42ae9 100644 --- a/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts +++ b/tests/cases/conformance/types/keyof/keyofAndIndexedAccess2.ts @@ -111,6 +111,13 @@ function get123(): Type[K] { return 123; // Error } +// Repro from #30920 + +type StrictExtract = T extends U ? U extends T ? T : never : never; +type StrictExclude = T extends StrictExtract ? never : T; +type A = { [Q in { [P in keyof T]: P; }[keyof T]]: T[Q]; }; +type B = A<{ [Q in keyof T]: StrictExclude, {}>; }>; + // Repros from #30938 function fn} | {elements: Array}>(param: T, cb: (element: T['elements'][number]) => void) { diff --git a/tests/projects/lateBoundSymbol/src/globals.d.ts b/tests/projects/lateBoundSymbol/src/globals.d.ts new file mode 100644 index 00000000000..8100e5859af --- /dev/null +++ b/tests/projects/lateBoundSymbol/src/globals.d.ts @@ -0,0 +1,4 @@ +interface SymbolConstructor { + (description?: string | number): symbol; +} +declare var Symbol: SymbolConstructor; \ No newline at end of file diff --git a/tests/projects/lateBoundSymbol/src/hkt.ts b/tests/projects/lateBoundSymbol/src/hkt.ts new file mode 100644 index 00000000000..2b844a9ab79 --- /dev/null +++ b/tests/projects/lateBoundSymbol/src/hkt.ts @@ -0,0 +1 @@ +export interface HKT { } \ No newline at end of file diff --git a/tests/projects/lateBoundSymbol/src/main.ts b/tests/projects/lateBoundSymbol/src/main.ts new file mode 100644 index 00000000000..e5b5fcc6daa --- /dev/null +++ b/tests/projects/lateBoundSymbol/src/main.ts @@ -0,0 +1,11 @@ +import { HKT } from "./hkt"; + +const sym = Symbol(); + +declare module "./hkt" { + interface HKT { + [sym]: { a: T } + } +} +const x = 10; +type A = HKT[typeof sym]; \ No newline at end of file diff --git a/tests/projects/lateBoundSymbol/tsconfig.json b/tests/projects/lateBoundSymbol/tsconfig.json new file mode 100644 index 00000000000..6146e91d1f3 --- /dev/null +++ b/tests/projects/lateBoundSymbol/tsconfig.json @@ -0,0 +1,6 @@ +{ + "compilerOptions": { + "rootDir": "src", + "incremental": true + } +} \ No newline at end of file diff --git a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withFiles.json b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withFiles.json index 71097850dbf..e463caf4879 100644 --- a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withFiles.json +++ b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withFiles.json @@ -1,7 +1,6 @@ { "compilerOptions": { "composite": true, - "target": "esnext", "moduleResolution": "node", "module": "commonjs", "resolveJsonModule": true, diff --git a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withInclude.json b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withInclude.json index 5efdbe28ac4..dde5eec33c4 100644 --- a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withInclude.json +++ b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withInclude.json @@ -1,7 +1,6 @@ { "compilerOptions": { "composite": true, - "target": "esnext", "moduleResolution": "node", "module": "commonjs", "resolveJsonModule": true, diff --git a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeAndFiles.json b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeAndFiles.json index f50c629bac5..82da9b398a7 100644 --- a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeAndFiles.json +++ b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeAndFiles.json @@ -1,7 +1,6 @@ { "compilerOptions": { "composite": true, - "target": "esnext", "moduleResolution": "node", "module": "commonjs", "resolveJsonModule": true, diff --git a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeOfJson.json b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeOfJson.json index 72d960b6fba..47279604fa6 100644 --- a/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeOfJson.json +++ b/tests/projects/resolveJsonModuleAndComposite/tsconfig_withIncludeOfJson.json @@ -1,7 +1,6 @@ { "compilerOptions": { "composite": true, - "target": "esnext", "moduleResolution": "node", "module": "commonjs", "resolveJsonModule": true,