diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index faf51568241f5..f72f30b226cab 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -792,7 +792,7 @@ namespace ts { state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - affected.emitBuildInfo(writeFile || host.writeFile, cancellationToken), + affected.emitBuildInfo(writeFile || maybeBind(host, host.writeFile), cancellationToken), affected, /*isPendingEmitFile*/ false, /*isBuildInfoEmit*/ true @@ -820,7 +820,7 @@ namespace ts { state, // When whole program is affected, do emit only once (eg when --out or --outFile is specified) // Otherwise just affected file - Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected as SourceFile, writeFile || host.writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), + Debug.assertDefined(state.program).emit(affected === state.program ? undefined : affected as SourceFile, writeFile || maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers), affected, isPendingEmitFile ); @@ -862,7 +862,7 @@ namespace ts { }; } } - return Debug.assertDefined(state.program).emit(targetSourceFile, writeFile || host.writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); + return Debug.assertDefined(state.program).emit(targetSourceFile, writeFile || maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers); } /** diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 3c4b0577fb664..12a20e0df42e1 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -136,6 +136,13 @@ namespace ts { category: Diagnostics.Advanced_Options, description: Diagnostics.Show_verbose_diagnostic_information }, + { + name: "incremental", + shortName: "i", + type: "boolean", + category: Diagnostics.Basic_Options, + description: Diagnostics.Enable_incremental_compilation, + }, ]; /* @internal */ @@ -331,19 +338,11 @@ namespace ts { category: Diagnostics.Basic_Options, description: Diagnostics.Enable_project_compilation, }, - { - name: "incremental", - type: "boolean", - isTSConfigOnly: true, - category: Diagnostics.Basic_Options, - description: Diagnostics.Enable_incremental_compilation, - }, { name: "tsBuildInfoFile", type: "string", isFilePath: true, paramType: Diagnostics.FILE, - isTSConfigOnly: true, category: Diagnostics.Basic_Options, description: Diagnostics.Specify_file_to_store_incremental_compilation_information, }, diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 9ae3e1ca77eae..6cb498df8279e 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3072,6 +3072,10 @@ "category": "Error", "code": 5073 }, + "Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified.": { + "category": "Error", + "code": 5074 + }, "Generates a sourcemap for each corresponding '.d.ts' file.": { "category": "Message", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index be867db68fb77..8f91e3d25c163 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -54,7 +54,7 @@ namespace ts { /*@internal*/ export function getOutputPathForBuildInfo(options: CompilerOptions) { const configFile = options.configFilePath; - if (!configFile || !isIncrementalCompilation(options)) return undefined; + if (!isIncrementalCompilation(options)) return undefined; if (options.tsBuildInfoFile) return options.tsBuildInfoFile; const outPath = options.outFile || options.out; let buildInfoExtensionLess: string; @@ -62,6 +62,7 @@ namespace ts { buildInfoExtensionLess = removeFileExtension(outPath); } else { + if (!configFile) return undefined; const configFileExtensionLess = removeFileExtension(configFile); buildInfoExtensionLess = options.outDir ? options.rootDir ? diff --git a/src/compiler/program.ts b/src/compiler/program.ts index b188e708a623f..6418f55968ba3 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -193,7 +193,8 @@ namespace ts { getDirectories: (path: string) => system.getDirectories(path), realpath, readDirectory: (path, extensions, include, exclude, depth) => system.readDirectory(path, extensions, include, exclude, depth), - createDirectory: d => system.createDirectory(d) + createDirectory: d => system.createDirectory(d), + createHash: maybeBind(system, system.createHash) }; return compilerHost; } @@ -315,7 +316,10 @@ namespace ts { }; } - export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray { + // tslint:disable unified-signatures + export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + /*@internal*/ export function getPreEmitDiagnostics(program: BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; + export function getPreEmitDiagnostics(program: Program | BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray { const diagnostics = [ ...program.getConfigFileParsingDiagnostics(), ...program.getOptionsDiagnostics(cancellationToken), @@ -330,6 +334,7 @@ namespace ts { return sortAndDeduplicateDiagnostics(diagnostics); } + // tslint:enable unified-signatures export interface FormatDiagnosticsHost { getCurrentDirectory(): string; @@ -2730,6 +2735,9 @@ namespace ts { createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite"); } } + else if (options.incremental && !options.outFile && !options.out && !options.configFilePath) { + programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified)); + } verifyProjectReferences(); diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index cc79c02f1d69e..16e6e42272ea9 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -30,6 +30,7 @@ namespace ts { listEmittedFiles?: boolean; listFiles?: boolean; pretty?: boolean; + incremental?: boolean; traceResolution?: boolean; /* @internal */ diagnostics?: boolean; @@ -363,7 +364,7 @@ namespace ts { function getCompilerOptionsOfBuildOptions(buildOptions: BuildOptions): CompilerOptions { const result = {} as CompilerOptions; commonOptionsWithBuild.forEach(option => { - result[option.name] = buildOptions[option.name]; + if (hasProperty(buildOptions, option.name)) result[option.name] = buildOptions[option.name]; }); return result; } diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 98ddee61f8e8d..843d22554ed87 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -12,7 +12,7 @@ namespace ts.codefix { registerCodeFix({ errorCodes, getCodeActions(context) { - const info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker()); + const info = getInfo(context.sourceFile, context.span.start, context.program.getTypeChecker(), context.program); if (!info) return undefined; if (info.kind === InfoKind.Enum) { @@ -37,7 +37,7 @@ namespace ts.codefix { return createCombinedCodeActions(textChanges.ChangeTracker.with(context, changes => { eachDiagnostic(context, errorCodes, diag => { - const info = getInfo(diag.file, diag.start, checker); + const info = getInfo(diag.file, diag.start, checker, context.program); if (!info || !addToSeen(seen, getNodeId(info.parentDeclaration) + "#" + info.token.text)) { return; } @@ -113,7 +113,7 @@ namespace ts.codefix { } type Info = EnumInfo | ClassOrInterfaceInfo; - function getInfo(tokenSourceFile: SourceFile, tokenPos: number, checker: TypeChecker): Info | undefined { + function getInfo(tokenSourceFile: SourceFile, tokenPos: number, checker: TypeChecker, program: Program): Info | undefined { // The identifier of the missing property. eg: // this.missing = 1; // ^^^^^^^ @@ -131,7 +131,7 @@ namespace ts.codefix { // Prefer to change the class instead of the interface if they are merged const classOrInterface = find(symbol.declarations, isClassLike) || find(symbol.declarations, isInterfaceDeclaration); - if (classOrInterface) { + if (classOrInterface && !program.isSourceFileFromExternalLibrary(classOrInterface.getSourceFile())) { const makeStatic = ((leftExpressionType as TypeReference).target || leftExpressionType) !== checker.getDeclaredTypeOfSymbol(symbol); const declSourceFile = classOrInterface.getSourceFile(); const inJs = isSourceFileJS(declSourceFile); @@ -139,7 +139,7 @@ namespace ts.codefix { return { kind: InfoKind.ClassOrInterface, token, parentDeclaration: classOrInterface, makeStatic, declSourceFile, inJs, call }; } const enumDeclaration = find(symbol.declarations, isEnumDeclaration); - if (enumDeclaration) { + if (enumDeclaration && !program.isSourceFileFromExternalLibrary(enumDeclaration.getSourceFile())) { return { kind: InfoKind.Enum, token, parentDeclaration: enumDeclaration }; } return undefined; diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 26a49df3dbb15..ccb2378c644a8 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -365,6 +365,26 @@ namespace ts { } }); }); + + it("parse --incremental", () => { + // --lib es6 0.ts + assertParseResult(["--incremental", "0.ts"], + { + errors: [], + fileNames: ["0.ts"], + options: { incremental: true } + }); + }); + + it("parse --tsBuildInfoFile", () => { + // --lib es6 0.ts + assertParseResult(["--tsBuildInfoFile", "build.tsbuildinfo", "0.ts"], + { + errors: [], + fileNames: ["0.ts"], + options: { tsBuildInfoFile: "build.tsbuildinfo" } + }); + }); }); describe("unittests:: config:: commandLineParsing:: parseBuildOptions", () => { @@ -456,6 +476,33 @@ namespace ts { }); }); + it("parse build with --incremental", () => { + // --lib es6 0.ts + assertParseResult(["--incremental", "tests"], + { + errors: [], + projects: ["tests"], + buildOptions: { incremental: true } + }); + }); + + it("parse build with --tsBuildInfoFile", () => { + // --lib es6 0.ts + assertParseResult(["--tsBuildInfoFile", "build.tsbuildinfo", "tests"], + { + errors: [{ + messageText: "Unknown build option '--tsBuildInfoFile'.", + category: Diagnostics.Unknown_build_option_0.category, + code: Diagnostics.Unknown_build_option_0.code, + file: undefined, + start: undefined, + length: undefined + }], + projects: ["build.tsbuildinfo", "tests"], + buildOptions: { } + }); + }); + describe("Combining options that make no sense together", () => { function verifyInvalidCombination(flag1: keyof BuildOptions, flag2: keyof BuildOptions) { it(`--${flag1} and --${flag2} together is invalid`, () => { diff --git a/src/testRunner/unittests/tsbuild/outFile.ts b/src/testRunner/unittests/tsbuild/outFile.ts index 5328806565835..48beeef4f61da 100644 --- a/src/testRunner/unittests/tsbuild/outFile.ts +++ b/src/testRunner/unittests/tsbuild/outFile.ts @@ -197,8 +197,8 @@ namespace ts { dtsUnchangedExpectedReadFilesDependOrdered = undefined!; }); - function createSolutionBuilder(host: fakes.SolutionBuilderHost) { - return ts.createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: true }); + function createSolutionBuilder(host: fakes.SolutionBuilderHost, baseOptions?: BuildOptions) { + return ts.createSolutionBuilder(host, ["/src/third"], { dry: false, force: false, verbose: true, ...(baseOptions || {}) }); } function getInitialExpectedReadFiles(additionalSourceFiles?: ReadonlyArray) { @@ -446,6 +446,49 @@ namespace ts { ); }); + it("rebuilds completely when command line incremental flag changes between non dts changes", () => { + const fs = outFileFs.shadow(); + // Make non composite third project + replaceText(fs, sources[project.third][source.config], `"composite": true,`, ""); + + // Build with command line incremental + const host = new fakes.SolutionBuilderHost(fs); + const builder = createSolutionBuilder(host, { incremental: true }); + builder.buildAllProjects(); + host.assertDiagnosticMessages(...initialExpectedDiagnostics); + host.clearDiagnostics(); + tick(); + + // Make non incremental build with change in file that doesnt affect dts + appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);"); + builder.resetBuildContext({ verbose: true }); + builder.buildAllProjects(); + host.assertDiagnosticMessages(getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), + [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]], + [Diagnostics.Building_project_0, sources[project.first][source.config]], + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.second][source.config], relSources[project.second][source.ts][part.one], relOutputFiles[project.second][ext.js]], + [Diagnostics.Project_0_is_out_of_date_because_output_of_its_dependency_1_has_changed, relSources[project.third][source.config], "src/first"], + [Diagnostics.Building_project_0, sources[project.third][source.config]] + ); + host.clearDiagnostics(); + tick(); + + // Make incremental build with change in file that doesnt affect dts + appendText(fs, relSources[project.first][source.ts][part.one], "console.log(s);"); + builder.resetBuildContext({ verbose: true, incremental: true }); + builder.buildAllProjects(); + // Builds completely because tsbuildinfo is old. + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild(relSources[project.first][source.config], relSources[project.second][source.config], relSources[project.third][source.config]), + [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.first][source.config], relOutputFiles[project.first][ext.js], relSources[project.first][source.ts][part.one]], + [Diagnostics.Building_project_0, sources[project.first][source.config]], + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, relSources[project.second][source.config], relSources[project.second][source.ts][part.one], relOutputFiles[project.second][ext.js]], + [Diagnostics.Project_0_is_out_of_date_because_oldest_output_1_is_older_than_newest_input_2, relSources[project.third][source.config], relOutputFiles[project.third][ext.buildinfo], "src/first"], + [Diagnostics.Building_project_0, sources[project.third][source.config]] + ); + host.clearDiagnostics(); + }); + describe("Prepend output with .tsbuildinfo", () => { // Prologues describe("Prologues", () => { diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index ccc04d38088d5..984ebe21cf6e6 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -165,6 +165,9 @@ namespace ts { reportWatchModeWithoutSysSupport(); createWatchOfFilesAndCompilerOptions(commandLine.fileNames, commandLineOptions); } + else if (isIncrementalCompilation(commandLineOptions)) { + performIncrementalCompilation(commandLine); + } else { performCompilation(commandLine.fileNames, /*references*/ undefined, commandLineOptions); } diff --git a/tests/baselines/reference/incrementalConfig.js b/tests/baselines/reference/incrementalConfig.js new file mode 100644 index 0000000000000..b90c65b9f0901 --- /dev/null +++ b/tests/baselines/reference/incrementalConfig.js @@ -0,0 +1,6 @@ +//// [a.ts] +const x = 10; + + +//// [a.js] +var x = 10; diff --git a/tests/baselines/reference/incrementalConfig.symbols b/tests/baselines/reference/incrementalConfig.symbols new file mode 100644 index 0000000000000..05c35bcf58a68 --- /dev/null +++ b/tests/baselines/reference/incrementalConfig.symbols @@ -0,0 +1,4 @@ +=== /a.ts === +const x = 10; +>x : Symbol(x, Decl(a.ts, 0, 5)) + diff --git a/tests/baselines/reference/incrementalConfig.types b/tests/baselines/reference/incrementalConfig.types new file mode 100644 index 0000000000000..ed892fed2ba10 --- /dev/null +++ b/tests/baselines/reference/incrementalConfig.types @@ -0,0 +1,5 @@ +=== /a.ts === +const x = 10; +>x : 10 +>10 : 10 + diff --git a/tests/baselines/reference/incrementalInvalid.errors.txt b/tests/baselines/reference/incrementalInvalid.errors.txt new file mode 100644 index 0000000000000..6c88c5fc9d35f --- /dev/null +++ b/tests/baselines/reference/incrementalInvalid.errors.txt @@ -0,0 +1,8 @@ +error TS5074: Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified. + + +!!! error TS5074: Option '--incremental' can only be specified using tsconfig, emitting to single file or when option `--tsBuildInfoFile` is specified. +==== tests/cases/compiler/incrementalInvalid.ts (0 errors) ==== + const x = 10; + + \ No newline at end of file diff --git a/tests/baselines/reference/incrementalInvalid.js b/tests/baselines/reference/incrementalInvalid.js new file mode 100644 index 0000000000000..6ca4b1b2dada7 --- /dev/null +++ b/tests/baselines/reference/incrementalInvalid.js @@ -0,0 +1,7 @@ +//// [incrementalInvalid.ts] +const x = 10; + + + +//// [incrementalInvalid.js] +var x = 10; diff --git a/tests/baselines/reference/incrementalInvalid.symbols b/tests/baselines/reference/incrementalInvalid.symbols new file mode 100644 index 0000000000000..7a75ad5da9d2d --- /dev/null +++ b/tests/baselines/reference/incrementalInvalid.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/incrementalInvalid.ts === +const x = 10; +>x : Symbol(x, Decl(incrementalInvalid.ts, 0, 5)) + + diff --git a/tests/baselines/reference/incrementalInvalid.types b/tests/baselines/reference/incrementalInvalid.types new file mode 100644 index 0000000000000..90e391222dd4b --- /dev/null +++ b/tests/baselines/reference/incrementalInvalid.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/incrementalInvalid.ts === +const x = 10; +>x : 10 +>10 : 10 + + diff --git a/tests/baselines/reference/incrementalOut.js b/tests/baselines/reference/incrementalOut.js new file mode 100644 index 0000000000000..af73fb45a2209 --- /dev/null +++ b/tests/baselines/reference/incrementalOut.js @@ -0,0 +1,7 @@ +//// [incrementalOut.ts] +const x = 10; + + + +//// [output.js] +var x = 10; diff --git a/tests/baselines/reference/incrementalOut.symbols b/tests/baselines/reference/incrementalOut.symbols new file mode 100644 index 0000000000000..6ad1a4d76ee79 --- /dev/null +++ b/tests/baselines/reference/incrementalOut.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/incrementalOut.ts === +const x = 10; +>x : Symbol(x, Decl(incrementalOut.ts, 0, 5)) + + diff --git a/tests/baselines/reference/incrementalOut.types b/tests/baselines/reference/incrementalOut.types new file mode 100644 index 0000000000000..55b02107adf34 --- /dev/null +++ b/tests/baselines/reference/incrementalOut.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/incrementalOut.ts === +const x = 10; +>x : 10 +>10 : 10 + + diff --git a/tests/baselines/reference/incrementalTsBuildInfoFile.js b/tests/baselines/reference/incrementalTsBuildInfoFile.js new file mode 100644 index 0000000000000..cdb778d8dd551 --- /dev/null +++ b/tests/baselines/reference/incrementalTsBuildInfoFile.js @@ -0,0 +1,8 @@ +//// [a.ts] +const x = 10; + + + + +//// [a.js] +var x = 10; diff --git a/tests/baselines/reference/incrementalTsBuildInfoFile.symbols b/tests/baselines/reference/incrementalTsBuildInfoFile.symbols new file mode 100644 index 0000000000000..d596c6006d7ee --- /dev/null +++ b/tests/baselines/reference/incrementalTsBuildInfoFile.symbols @@ -0,0 +1,6 @@ +=== /a.ts === +const x = 10; +>x : Symbol(x, Decl(a.ts, 0, 5)) + + + diff --git a/tests/baselines/reference/incrementalTsBuildInfoFile.types b/tests/baselines/reference/incrementalTsBuildInfoFile.types new file mode 100644 index 0000000000000..ab563af0e56a8 --- /dev/null +++ b/tests/baselines/reference/incrementalTsBuildInfoFile.types @@ -0,0 +1,7 @@ +=== /a.ts === +const x = 10; +>x : 10 +>10 : 10 + + + diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json index ec795e83e23d3..8e4ff5171868d 100644 --- a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json index b931fe1745a65..7332496971fba 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with advanced options/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json index 6a437fd4c14b5..ebf7070cfa4d4 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json index d1d8d42c433ad..25f9b39967a8d 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json index c2bcb1307c1fb..fc1fb8ec631d8 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json index 37c1960d80d36..dcff85de986d4 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "lib": ["es5","es2015.promise"], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json index ec795e83e23d3..8e4ff5171868d 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json index bc24243c11f5c..112be7a95f953 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ "lib": ["es5","es2015.core"], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json index 1c16ed114165f..4c4b740a12284 100644 --- a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { /* Basic Options */ + // "incremental": true, /* Enable incremental compilation */ "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ // "lib": [], /* Specify library files to be included in the compilation. */ @@ -14,7 +15,6 @@ // "outDir": "./", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ // "composite": true, /* Enable project compilation */ - // "incremental": true, /* Enable incremental compilation */ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ // "removeComments": true, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ diff --git a/tests/cases/compiler/incrementalConfig.ts b/tests/cases/compiler/incrementalConfig.ts new file mode 100644 index 0000000000000..6ed172c837a68 --- /dev/null +++ b/tests/cases/compiler/incrementalConfig.ts @@ -0,0 +1,8 @@ +// @incremental: true + +// @Filename: /a.ts +const x = 10; + +// @Filename: /tsconfig.json +{ } + diff --git a/tests/cases/compiler/incrementalInvalid.ts b/tests/cases/compiler/incrementalInvalid.ts new file mode 100644 index 0000000000000..4a7c3e72de96e --- /dev/null +++ b/tests/cases/compiler/incrementalInvalid.ts @@ -0,0 +1,4 @@ +// @incremental: true + +const x = 10; + diff --git a/tests/cases/compiler/incrementalOut.ts b/tests/cases/compiler/incrementalOut.ts new file mode 100644 index 0000000000000..4cd49dbba112d --- /dev/null +++ b/tests/cases/compiler/incrementalOut.ts @@ -0,0 +1,5 @@ +// @incremental: true +// @out: output.js + +const x = 10; + diff --git a/tests/cases/compiler/incrementalTsBuildInfoFile.ts b/tests/cases/compiler/incrementalTsBuildInfoFile.ts new file mode 100644 index 0000000000000..51a9661187cb6 --- /dev/null +++ b/tests/cases/compiler/incrementalTsBuildInfoFile.ts @@ -0,0 +1,8 @@ +// @incremental: true +// @tsBuildInfoFile: /a.tsbuildinfo + + +// @Filename: /a.ts +const x = 10; + + diff --git a/tests/cases/fourslash/addMemberInDeclarationFile.ts b/tests/cases/fourslash/addMemberInDeclarationFile.ts new file mode 100644 index 0000000000000..1d2e900512db8 --- /dev/null +++ b/tests/cases/fourslash/addMemberInDeclarationFile.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: ./declarations.d.ts +//// interface Response {} + +// @Filename: foo.ts +//// import './declarations.d.ts' +//// declare const resp: Response +//// resp.test() + +goTo.file('foo.ts') + +verify.codeFixAvailable([ + { description: "Declare method 'test'" }, + { description: "Declare property 'test'" }, + { description: "Add index signature for property 'test'" } +]) diff --git a/tests/cases/fourslash/addMemberNotInNodeModulesDeclarationFile.ts b/tests/cases/fourslash/addMemberNotInNodeModulesDeclarationFile.ts new file mode 100644 index 0000000000000..3a97aeac6dd84 --- /dev/null +++ b/tests/cases/fourslash/addMemberNotInNodeModulesDeclarationFile.ts @@ -0,0 +1,19 @@ +/// + +// @noImplicitReferences: true +// @traceResolution: true + +// @Filename: /node_modules/foo/types.d.ts +//// interface Response {} + +// @Filename: /node_modules/foo/package.json +//// { "types": "types.d.ts" } + +// @Filename: /foo.ts +//// import { Response } from 'foo' +//// declare const resp: Response +//// resp.test() + +goTo.file('/foo.ts') + +verify.not.codeFixAvailable()