From 1727912f0437a7f367d90040fc4b0b4f3efd017a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 29 Nov 2022 10:13:26 -0800 Subject: [PATCH 1/5] Cherry-pick fix around `visitEachChild` to release-4.9. (#51544) --- src/compiler/visitorPublic.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 4069b1f86164a..18289157948b8 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -1304,9 +1304,9 @@ namespace ts { }, // Top-level nodes - [SyntaxKind.SourceFile]: function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { + [SyntaxKind.SourceFile]: function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { return context.factory.updateSourceFile(node, - visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes From e7a02f43fce47e1a39259ada5460bcc33c8e98b5 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 30 Nov 2022 11:22:48 -0800 Subject: [PATCH 2/5] Port of #51626 and #51689 to release-4.9 (#51627) * When fsEvent for change is repeated * When trying to check if program is uptodate, read the files from disk to determine the version instead of delaying so that new program is not created if file contents have not changed * Test for empty string change * Fix empty string for file versioning --- src/compiler/tsbuildPublic.ts | 4 +- src/compiler/watch.ts | 10 +- src/compiler/watchPublic.ts | 16 +- src/harness/virtualFileSystemWithWatch.ts | 2 +- .../unittests/tscWatch/watchEnvironment.ts | 32 +++ ...n-no-files-are-emitted-with-incremental.js | 26 +- .../with-noEmitOnError-with-incremental.js | 79 +----- .../with-noEmitOnError.js | 79 +----- .../with-noEmitOnError-with-incremental.js | 79 +----- .../with-noEmitOnError.js | 79 +----- .../with-noEmitOnError-with-incremental.js | 79 +----- .../default/with-noEmitOnError.js | 79 +----- .../with-noEmitOnError-with-incremental.js | 79 +----- .../defaultAndD/with-noEmitOnError.js | 79 +----- .../with-noEmitOnError-with-incremental.js | 79 +----- .../isolatedModules/with-noEmitOnError.js | 79 +----- .../with-noEmitOnError-with-incremental.js | 79 +----- .../isolatedModulesAndD/with-noEmitOnError.js | 79 +----- ...st-implements-hasInvalidatedResolutions.js | 27 +-- .../fsEvent-for-change-is-repeated.js | 226 ++++++++++++++++++ 20 files changed, 359 insertions(+), 932 deletions(-) create mode 100644 tests/baselines/reference/tscWatch/watchEnvironment/fsEvent-for-change-is-repeated.js diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index 1251fca05a9e3..643315046280b 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -292,7 +292,7 @@ namespace ts { // State of the solution const baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); const compilerHost = createCompilerHostFromProgramHost(host, () => state.projectCompilerOptions) as CompilerHost & ReadBuildProgramHost; - setGetSourceFileAsHashVersioned(compilerHost, host); + setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = fileName => parseConfigFile(state, fileName as ResolvedConfigFileName, toResolvedConfigFilePath(state, fileName as ResolvedConfigFileName)); compilerHost.resolveModuleNames = maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = maybeBind(host, host.resolveTypeReferenceDirectives); @@ -1655,7 +1655,7 @@ namespace ts { if (!buildInfoVersionMap) buildInfoVersionMap = getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath!, host); version = buildInfoVersionMap.get(toPath(state, inputFile)); const text = version ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || generateDjb2Hash)(text) : undefined; if (version && version === currentVersion) pseudoInputUpToDate = true; } diff --git a/src/compiler/watch.ts b/src/compiler/watch.ts index d1851cd02cd08..b06ce9626f08b 100644 --- a/src/compiler/watch.ts +++ b/src/compiler/watch.ts @@ -595,12 +595,13 @@ namespace ts { export function createCompilerHostFromProgramHost(host: ProgramHost, getCompilerOptions: () => CompilerOptions, directoryStructureHost: DirectoryStructureHost = host): CompilerHost { const useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); const hostGetNewLine = memoize(() => host.getNewLine()); - return { + const compilerHost: CompilerHost = { getSourceFile: (fileName, languageVersionOrOptions, onError) => { let text: string | undefined; try { performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + const encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); performance.mark("afterIORead"); performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -632,6 +633,7 @@ namespace ts { disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName: string, text: string, writeByteOrderMark: boolean, onError: (message: string) => void) { try { @@ -659,9 +661,9 @@ namespace ts { } } - export function setGetSourceFileAsHashVersioned(compilerHost: CompilerHost, host: { createHash?(data: string): string; }) { + export function setGetSourceFileAsHashVersioned(compilerHost: CompilerHost) { const originalGetSourceFile = compilerHost.getSourceFile; - const computeHash = maybeBind(host, host.createHash) || generateDjb2Hash; + const computeHash = maybeBind(compilerHost, compilerHost.createHash) || generateDjb2Hash; compilerHost.getSourceFile = (...args) => { const result = originalGetSourceFile.call(compilerHost, ...args); if (result) { diff --git a/src/compiler/watchPublic.ts b/src/compiler/watchPublic.ts index 011a24f5b7129..5de1a7ea5a007 100644 --- a/src/compiler/watchPublic.ts +++ b/src/compiler/watchPublic.ts @@ -28,7 +28,7 @@ namespace ts { host.createHash = maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - setGetSourceFileAsHashVersioned(host, system); + setGetSourceFileAsHashVersioned(host); changeCompilerHostLikeToUseCache(host, fileName => toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName)); return host; } @@ -330,7 +330,7 @@ namespace ts { } const compilerHost = createCompilerHostFromProgramHost(host, () => compilerOptions, directoryStructureHost) as CompilerHost & ResolutionCacheHost; - setGetSourceFileAsHashVersioned(compilerHost, host); + setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost const getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = (fileName, ...args) => getVersionedSourceFileByPath(fileName, toPath(fileName), ...args); @@ -452,9 +452,9 @@ namespace ts { const hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); const { originalReadFile, originalFileExists, originalDirectoryExists, - originalCreateDirectory, originalWriteFile, + originalCreateDirectory, originalWriteFile, readFileWithCache, } = changeCompilerHostLikeToUseCache(compilerHost, toPath); - if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileName => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + if (isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, path => getSourceVersion(path, readFileWithCache), fileName => compilerHost.fileExists(fileName), hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -609,9 +609,13 @@ namespace ts { } } - function getSourceVersion(path: Path): string | undefined { + function getSourceVersion(path: Path, readFileWithCache: (fileName: string) => string | undefined): string | undefined { const hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) return undefined; + if (hostSourceFile.version) return hostSourceFile.version; + // Read file and get new version + const text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile: SourceFile, _oldOptions: CompilerOptions, hasSourceFileByPath: boolean) { diff --git a/src/harness/virtualFileSystemWithWatch.ts b/src/harness/virtualFileSystemWithWatch.ts index f5979f9c3876d..caa5681d74f73 100644 --- a/src/harness/virtualFileSystemWithWatch.ts +++ b/src/harness/virtualFileSystemWithWatch.ts @@ -730,7 +730,7 @@ interface Array { length: number; [n: number]: T; }` } } - private invokeFsWatches(fullPath: string, eventName: "rename" | "change", modifiedTime: Date | undefined, useTildeSuffix: boolean | undefined) { + invokeFsWatches(fullPath: string, eventName: "rename" | "change", modifiedTime: Date | undefined, useTildeSuffix: boolean | undefined) { this.invokeFsWatchesCallbacks(fullPath, eventName, modifiedTime, fullPath, useTildeSuffix); this.invokeFsWatchesCallbacks(getDirectoryPath(fullPath), eventName, modifiedTime, fullPath, useTildeSuffix); this.invokeRecursiveFsWatches(fullPath, eventName, modifiedTime, /*entryFullPath*/ undefined, useTildeSuffix); diff --git a/src/testRunner/unittests/tscWatch/watchEnvironment.ts b/src/testRunner/unittests/tscWatch/watchEnvironment.ts index 45dd1ff714391..3472b0ab92312 100644 --- a/src/testRunner/unittests/tscWatch/watchEnvironment.ts +++ b/src/testRunner/unittests/tscWatch/watchEnvironment.ts @@ -687,5 +687,37 @@ namespace ts.tscWatch { ] }); }); + + verifyTscWatch({ + scenario, + subScenario: "fsEvent for change is repeated", + commandLineArgs: ["-w", "main.ts", "--extendedDiagnostics"], + sys: () => createWatchedSystem({ + "/user/username/projects/project/main.ts": `let a: string = "Hello"`, + [libFile.path]: libFile.content, + }, { currentDirectory: "/user/username/projects/project" }), + changes: [ + { + caption: "change main.ts", + change: sys => replaceFileText(sys, "/user/username/projects/project/main.ts", "Hello", "Hello World"), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "receive another change event without modifying the file", + change: sys => sys.invokeFsWatches("/user/username/projects/project/main.ts", "change", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "change main.ts to empty text", + change: sys => sys.writeFile("/user/username/projects/project/main.ts", ""), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + }, + { + caption: "receive another change event without modifying the file", + change: sys => sys.invokeFsWatches("/user/username/projects/project/main.ts", "change", /*modifiedTime*/ undefined, /*useTildeSuffix*/ undefined), + timeouts: sys => sys.runQueuedTimeoutCallbacks(), + } + ] + }); }); } diff --git a/tests/baselines/reference/tsbuildWatch/noEmit/does-not-go-in-loop-when-watching-when-no-files-are-emitted-with-incremental.js b/tests/baselines/reference/tsbuildWatch/noEmit/does-not-go-in-loop-when-watching-when-no-files-are-emitted-with-incremental.js index 2974c0e85109a..38bb7b98bba18 100644 --- a/tests/baselines/reference/tsbuildWatch/noEmit/does-not-go-in-loop-when-watching-when-no-files-are-emitted-with-incremental.js +++ b/tests/baselines/reference/tsbuildWatch/noEmit/does-not-go-in-loop-when-watching-when-no-files-are-emitted-with-incremental.js @@ -132,25 +132,11 @@ Output:: >> Screen clear [12:00:36 AM] File change detected. Starting incremental compilation... -[12:00:37 AM] Project 'tsconfig.json' is out of date because output 'tsconfig.tsbuildinfo' is older than input 'a.js' +[12:00:37 AM] Project 'tsconfig.json' is up to date but needs to update timestamps of output files that are older than input files -[12:00:38 AM] Building project '/user/username/projects/myproject/tsconfig.json'... +[12:00:38 AM] Found 0 errors. Watching for file changes. -[12:00:39 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/myproject/a.js","/user/username/projects/myproject/b.ts"] -Program options: {"allowJs":true,"noEmit":true,"watch":true,"incremental":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} -Program structureReused: Not -Program files:: -/a/lib/lib.d.ts -/user/username/projects/myproject/a.js -/user/username/projects/myproject/b.ts - -Semantic diagnostics in builder refreshed for:: -No shapes updated in the builder:: PolledWatches:: @@ -178,13 +164,13 @@ const x = 10; Output:: >> Screen clear -[12:00:43 AM] File change detected. Starting incremental compilation... +[12:00:42 AM] File change detected. Starting incremental compilation... -[12:00:44 AM] Project 'tsconfig.json' is out of date because output 'tsconfig.tsbuildinfo' is older than input 'a.js' +[12:00:43 AM] Project 'tsconfig.json' is out of date because output 'tsconfig.tsbuildinfo' is older than input 'a.js' -[12:00:45 AM] Building project '/user/username/projects/myproject/tsconfig.json'... +[12:00:44 AM] Building project '/user/username/projects/myproject/tsconfig.json'... -[12:00:53 AM] Found 0 errors. Watching for file changes. +[12:00:52 AM] Found 0 errors. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js index d6d7f1281c501..338d7bdcd3347 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError-with-incremental.js @@ -179,30 +179,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:43 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:44 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -239,9 +215,9 @@ const a = { Output:: >> Screen clear -[12:00:48 AM] File change detected. Starting incremental compilation... +[12:00:46 AM] File change detected. Starting incremental compilation... -[12:01:06 AM] Found 0 errors. Watching for file changes. +[12:01:04 AM] Found 0 errors. Watching for file changes. @@ -370,14 +346,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:13 AM] File change detected. Starting incremental compilation... +[12:01:11 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:17 AM] Found 1 error. Watching for file changes. +[12:01:15 AM] Found 1 error. Watching for file changes. @@ -501,30 +477,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:25 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:26 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -559,9 +511,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:30 AM] File change detected. Starting incremental compilation... +[12:01:26 AM] File change detected. Starting incremental compilation... -[12:01:37 AM] Found 0 errors. Watching for file changes. +[12:01:33 AM] Found 0 errors. Watching for file changes. @@ -673,25 +625,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:44 AM] File change detected. Starting incremental compilation... - -[12:01:45 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js index d66bc1a013f87..95e8ae34b951a 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependencies/with-noEmitOnError.js @@ -103,30 +103,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:36 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:37 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -163,9 +139,9 @@ const a = { Output:: >> Screen clear -[12:00:41 AM] File change detected. Starting incremental compilation... +[12:00:39 AM] File change detected. Starting incremental compilation... -[12:00:58 AM] Found 0 errors. Watching for file changes. +[12:00:56 AM] Found 0 errors. Watching for file changes. @@ -236,14 +212,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:02 AM] File change detected. Starting incremental compilation... +[12:01:00 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:03 AM] Found 1 error. Watching for file changes. +[12:01:01 AM] Found 1 error. Watching for file changes. @@ -291,30 +267,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:08 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:09 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -349,9 +301,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:13 AM] File change detected. Starting incremental compilation... +[12:01:09 AM] File change detected. Starting incremental compilation... -[12:01:17 AM] Found 0 errors. Watching for file changes. +[12:01:13 AM] Found 0 errors. Watching for file changes. @@ -405,25 +357,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:21 AM] File change detected. Starting incremental compilation... - -[12:01:22 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js index 2bdcb7d486e40..6dffbf57945c8 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError-with-incremental.js @@ -180,30 +180,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:43 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:44 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -240,9 +216,9 @@ const a = { Output:: >> Screen clear -[12:00:48 AM] File change detected. Starting incremental compilation... +[12:00:46 AM] File change detected. Starting incremental compilation... -[12:01:12 AM] Found 0 errors. Watching for file changes. +[12:01:10 AM] Found 0 errors. Watching for file changes. @@ -386,14 +362,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:19 AM] File change detected. Starting incremental compilation... +[12:01:17 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:23 AM] Found 1 error. Watching for file changes. +[12:01:21 AM] Found 1 error. Watching for file changes. @@ -518,30 +494,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:31 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:32 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -576,9 +528,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:36 AM] File change detected. Starting incremental compilation... +[12:01:32 AM] File change detected. Starting incremental compilation... -[12:01:46 AM] Found 0 errors. Watching for file changes. +[12:01:42 AM] Found 0 errors. Watching for file changes. @@ -692,25 +644,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:53 AM] File change detected. Starting incremental compilation... - -[12:01:54 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js index 2bda15b03c628..082ae16309b37 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/assumeChangesOnlyAffectDirectDependenciesAndD/with-noEmitOnError.js @@ -103,30 +103,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:36 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:37 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -163,9 +139,9 @@ const a = { Output:: >> Screen clear -[12:00:41 AM] File change detected. Starting incremental compilation... +[12:00:39 AM] File change detected. Starting incremental compilation... -[12:01:04 AM] Found 0 errors. Watching for file changes. +[12:01:02 AM] Found 0 errors. Watching for file changes. @@ -250,14 +226,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:08 AM] File change detected. Starting incremental compilation... +[12:01:06 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:09 AM] Found 1 error. Watching for file changes. +[12:01:07 AM] Found 1 error. Watching for file changes. @@ -305,30 +281,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:14 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:15 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -363,9 +315,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:19 AM] File change detected. Starting incremental compilation... +[12:01:15 AM] File change detected. Starting incremental compilation... -[12:01:26 AM] Found 0 errors. Watching for file changes. +[12:01:22 AM] Found 0 errors. Watching for file changes. @@ -420,25 +372,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:30 AM] File change detected. Starting incremental compilation... - -[12:01:31 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"assumeChangesOnlyAffectDirectDependencies":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js index b26fe57c145e6..f94f56fdda486 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError-with-incremental.js @@ -178,30 +178,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:43 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:44 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -238,9 +214,9 @@ const a = { Output:: >> Screen clear -[12:00:48 AM] File change detected. Starting incremental compilation... +[12:00:46 AM] File change detected. Starting incremental compilation... -[12:01:06 AM] Found 0 errors. Watching for file changes. +[12:01:04 AM] Found 0 errors. Watching for file changes. @@ -368,14 +344,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:13 AM] File change detected. Starting incremental compilation... +[12:01:11 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:17 AM] Found 1 error. Watching for file changes. +[12:01:15 AM] Found 1 error. Watching for file changes. @@ -498,30 +474,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:25 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:26 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -556,9 +508,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:30 AM] File change detected. Starting incremental compilation... +[12:01:26 AM] File change detected. Starting incremental compilation... -[12:01:37 AM] Found 0 errors. Watching for file changes. +[12:01:33 AM] Found 0 errors. Watching for file changes. @@ -669,25 +621,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:44 AM] File change detected. Starting incremental compilation... - -[12:01:45 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js index 483578915d3a3..fc110fc3d1045 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/default/with-noEmitOnError.js @@ -103,30 +103,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:36 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:37 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -163,9 +139,9 @@ const a = { Output:: >> Screen clear -[12:00:41 AM] File change detected. Starting incremental compilation... +[12:00:39 AM] File change detected. Starting incremental compilation... -[12:00:58 AM] Found 0 errors. Watching for file changes. +[12:00:56 AM] Found 0 errors. Watching for file changes. @@ -236,14 +212,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:02 AM] File change detected. Starting incremental compilation... +[12:01:00 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:03 AM] Found 1 error. Watching for file changes. +[12:01:01 AM] Found 1 error. Watching for file changes. @@ -291,30 +267,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:08 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:09 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -349,9 +301,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:13 AM] File change detected. Starting incremental compilation... +[12:01:09 AM] File change detected. Starting incremental compilation... -[12:01:17 AM] Found 0 errors. Watching for file changes. +[12:01:13 AM] Found 0 errors. Watching for file changes. @@ -405,25 +357,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:21 AM] File change detected. Starting incremental compilation... - -[12:01:22 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js index f3f271e408e65..21626d15930f6 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError-with-incremental.js @@ -179,30 +179,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:43 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:44 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -239,9 +215,9 @@ const a = { Output:: >> Screen clear -[12:00:48 AM] File change detected. Starting incremental compilation... +[12:00:46 AM] File change detected. Starting incremental compilation... -[12:01:12 AM] Found 0 errors. Watching for file changes. +[12:01:10 AM] Found 0 errors. Watching for file changes. @@ -384,14 +360,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:19 AM] File change detected. Starting incremental compilation... +[12:01:17 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:23 AM] Found 1 error. Watching for file changes. +[12:01:21 AM] Found 1 error. Watching for file changes. @@ -515,30 +491,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:31 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:32 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -573,9 +525,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:36 AM] File change detected. Starting incremental compilation... +[12:01:32 AM] File change detected. Starting incremental compilation... -[12:01:46 AM] Found 0 errors. Watching for file changes. +[12:01:42 AM] Found 0 errors. Watching for file changes. @@ -688,25 +640,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:53 AM] File change detected. Starting incremental compilation... - -[12:01:54 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js index b33198034eaf9..ca4884cd960dd 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/defaultAndD/with-noEmitOnError.js @@ -103,30 +103,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:36 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:37 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -163,9 +139,9 @@ const a = { Output:: >> Screen clear -[12:00:41 AM] File change detected. Starting incremental compilation... +[12:00:39 AM] File change detected. Starting incremental compilation... -[12:01:04 AM] Found 0 errors. Watching for file changes. +[12:01:02 AM] Found 0 errors. Watching for file changes. @@ -250,14 +226,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:08 AM] File change detected. Starting incremental compilation... +[12:01:06 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:09 AM] Found 1 error. Watching for file changes. +[12:01:07 AM] Found 1 error. Watching for file changes. @@ -305,30 +281,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:14 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:15 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -363,9 +315,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:19 AM] File change detected. Starting incremental compilation... +[12:01:15 AM] File change detected. Starting incremental compilation... -[12:01:26 AM] Found 0 errors. Watching for file changes. +[12:01:22 AM] Found 0 errors. Watching for file changes. @@ -420,25 +372,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:30 AM] File change detected. Starting incremental compilation... - -[12:01:31 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js index 173cad06584a6..270276068d948 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError-with-incremental.js @@ -178,30 +178,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:43 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:44 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -238,9 +214,9 @@ const a = { Output:: >> Screen clear -[12:00:48 AM] File change detected. Starting incremental compilation... +[12:00:46 AM] File change detected. Starting incremental compilation... -[12:01:06 AM] Found 0 errors. Watching for file changes. +[12:01:04 AM] Found 0 errors. Watching for file changes. @@ -368,14 +344,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:13 AM] File change detected. Starting incremental compilation... +[12:01:11 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:17 AM] Found 1 error. Watching for file changes. +[12:01:15 AM] Found 1 error. Watching for file changes. @@ -498,30 +474,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:25 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:26 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -556,9 +508,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:30 AM] File change detected. Starting incremental compilation... +[12:01:26 AM] File change detected. Starting incremental compilation... -[12:01:37 AM] Found 0 errors. Watching for file changes. +[12:01:33 AM] Found 0 errors. Watching for file changes. @@ -669,25 +621,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:44 AM] File change detected. Starting incremental compilation... - -[12:01:45 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js index 0b5a5d297e865..cad0db6e3253c 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModules/with-noEmitOnError.js @@ -103,30 +103,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:36 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:37 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -163,9 +139,9 @@ const a = { Output:: >> Screen clear -[12:00:41 AM] File change detected. Starting incremental compilation... +[12:00:39 AM] File change detected. Starting incremental compilation... -[12:00:58 AM] Found 0 errors. Watching for file changes. +[12:00:56 AM] Found 0 errors. Watching for file changes. @@ -236,14 +212,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:02 AM] File change detected. Starting incremental compilation... +[12:01:00 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:03 AM] Found 1 error. Watching for file changes. +[12:01:01 AM] Found 1 error. Watching for file changes. @@ -291,30 +267,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:08 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:09 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -349,9 +301,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:13 AM] File change detected. Starting incremental compilation... +[12:01:09 AM] File change detected. Starting incremental compilation... -[12:01:17 AM] Found 0 errors. Watching for file changes. +[12:01:13 AM] Found 0 errors. Watching for file changes. @@ -405,25 +357,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:21 AM] File change detected. Starting incremental compilation... - -[12:01:22 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js index fb739948fa60d..e124204a8f575 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError-with-incremental.js @@ -179,30 +179,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:43 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:44 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -239,9 +215,9 @@ const a = { Output:: >> Screen clear -[12:00:48 AM] File change detected. Starting incremental compilation... +[12:00:46 AM] File change detected. Starting incremental compilation... -[12:01:12 AM] Found 0 errors. Watching for file changes. +[12:01:10 AM] Found 0 errors. Watching for file changes. @@ -384,14 +360,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:19 AM] File change detected. Starting incremental compilation... +[12:01:17 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:23 AM] Found 1 error. Watching for file changes. +[12:01:21 AM] Found 1 error. Watching for file changes. @@ -515,30 +491,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:31 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:32 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -573,9 +525,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:36 AM] File change detected. Starting incremental compilation... +[12:01:32 AM] File change detected. Starting incremental compilation... -[12:01:46 AM] Found 0 errors. Watching for file changes. +[12:01:42 AM] Found 0 errors. Watching for file changes. @@ -688,25 +640,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:53 AM] File change detected. Starting incremental compilation... - -[12:01:54 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"declaration":true,"incremental":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js index d030833345579..705d8b2e000f3 100644 --- a/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js +++ b/tests/baselines/reference/tscWatch/emitAndErrorUpdates/isolatedModulesAndD/with-noEmitOnError.js @@ -103,30 +103,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:00:36 AM] File change detected. Starting incremental compilation... - -src/main.ts:4:1 - error TS1005: ',' expected. - -4 ; -  ~ - -[12:00:37 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -163,9 +139,9 @@ const a = { Output:: >> Screen clear -[12:00:41 AM] File change detected. Starting incremental compilation... +[12:00:39 AM] File change detected. Starting incremental compilation... -[12:01:04 AM] Found 0 errors. Watching for file changes. +[12:01:02 AM] Found 0 errors. Watching for file changes. @@ -250,14 +226,14 @@ const a: string = 10; Output:: >> Screen clear -[12:01:08 AM] File change detected. Starting incremental compilation... +[12:01:06 AM] File change detected. Starting incremental compilation... src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. 2 const a: string = 10;    ~ -[12:01:09 AM] Found 1 error. Watching for file changes. +[12:01:07 AM] Found 1 error. Watching for file changes. @@ -305,30 +281,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:14 AM] File change detected. Starting incremental compilation... - -src/main.ts:2:7 - error TS2322: Type 'number' is not assignable to type 'string'. - -2 const a: string = 10; -   ~ - -[12:01:15 AM] Found 1 error. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: @@ -363,9 +315,9 @@ const a: string = "hello"; Output:: >> Screen clear -[12:01:19 AM] File change detected. Starting incremental compilation... +[12:01:15 AM] File change detected. Starting incremental compilation... -[12:01:26 AM] Found 0 errors. Watching for file changes. +[12:01:22 AM] Found 0 errors. Watching for file changes. @@ -420,25 +372,6 @@ Input:: //// [/user/username/projects/noEmitOnError/src/main.ts] file written with same contents Output:: ->> Screen clear -[12:01:30 AM] File change detected. Starting incremental compilation... - -[12:01:31 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/noEmitOnError/shared/types/db.ts","/user/username/projects/noEmitOnError/src/main.ts","/user/username/projects/noEmitOnError/src/other.ts"] -Program options: {"outDir":"/user/username/projects/noEmitOnError/dev-build","noEmitOnError":true,"watch":true,"isolatedModules":true,"declaration":true,"configFilePath":"/user/username/projects/noEmitOnError/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/noEmitOnError/shared/types/db.ts -/user/username/projects/noEmitOnError/src/main.ts -/user/username/projects/noEmitOnError/src/other.ts - -Semantic diagnostics in builder refreshed for:: - -No shapes updated in the builder:: PolledWatches:: /user/username/projects/noemitonerror/node_modules/@types: diff --git a/tests/baselines/reference/tscWatch/watchApi/host-implements-hasInvalidatedResolutions.js b/tests/baselines/reference/tscWatch/watchApi/host-implements-hasInvalidatedResolutions.js index 71dac5e657e1b..01ce85a26b5b7 100644 --- a/tests/baselines/reference/tscWatch/watchApi/host-implements-hasInvalidatedResolutions.js +++ b/tests/baselines/reference/tscWatch/watchApi/host-implements-hasInvalidatedResolutions.js @@ -101,26 +101,7 @@ FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: Wa Scheduling update Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file Synchronizing program -[12:00:29 AM] File change detected. Starting incremental compilation... - -CreatingProgramWith:: - roots: ["/user/username/projects/myproject/main.ts"] - options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} -[12:00:30 AM] Found 0 errors. Watching for file changes. - - - -Program root files: ["/user/username/projects/myproject/main.ts"] -Program options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} -Program structureReused: Completely -Program files:: -/a/lib/lib.d.ts -/user/username/projects/myproject/other.d.ts -/user/username/projects/myproject/main.ts - -Semantic diagnostics in builder refreshed for:: -No shapes updated in the builder:: PolledWatches:: /user/username/projects/myproject/node_modules/@types: @@ -153,12 +134,12 @@ FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: Wa Scheduling update Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file Synchronizing program -[12:00:33 AM] File change detected. Starting incremental compilation... +[12:00:31 AM] File change detected. Starting incremental compilation... CreatingProgramWith:: roots: ["/user/username/projects/myproject/main.ts"] options: {"traceResolution":true,"extendedDiagnostics":true,"configFilePath":"/user/username/projects/myproject/tsconfig.json"} -[12:00:37 AM] Found 0 errors. Watching for file changes. +[12:00:35 AM] Found 0 errors. Watching for file changes. @@ -211,7 +192,7 @@ FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: Wa Scheduling update Elapsed:: *ms FileWatcher:: Triggered with /user/username/projects/myproject/other.d.ts 1:: WatchInfo: /user/username/projects/myproject/other.d.ts 250 undefined Source file Synchronizing program -[12:00:42 AM] File change detected. Starting incremental compilation... +[12:00:40 AM] File change detected. Starting incremental compilation... CreatingProgramWith:: roots: ["/user/username/projects/myproject/main.ts"] @@ -222,7 +203,7 @@ Loading module as file / folder, candidate module location '/user/username/proje File '/user/username/projects/myproject/other.ts' exist - use it as a name resolution result. ======== Module name './other' was successfully resolved to '/user/username/projects/myproject/other.ts'. ======== FileWatcher:: Added:: WatchInfo: /user/username/projects/myproject/other.ts 250 undefined Source file -[12:00:48 AM] Found 0 errors. Watching for file changes. +[12:00:46 AM] Found 0 errors. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/watchEnvironment/fsEvent-for-change-is-repeated.js b/tests/baselines/reference/tscWatch/watchEnvironment/fsEvent-for-change-is-repeated.js new file mode 100644 index 0000000000000..777e659658064 --- /dev/null +++ b/tests/baselines/reference/tscWatch/watchEnvironment/fsEvent-for-change-is-repeated.js @@ -0,0 +1,226 @@ +Input:: +//// [/user/username/projects/project/main.ts] +let a: string = "Hello" + +//// [/a/lib/lib.d.ts] +/// +interface Boolean {} +interface Function {} +interface CallableFunction {} +interface NewableFunction {} +interface IArguments {} +interface Number { toExponential: any; } +interface Object {} +interface RegExp {} +interface String { charAt: any; } +interface Array { length: number; [n: number]: T; } + + +/a/lib/tsc.js -w main.ts --extendedDiagnostics +Output:: +[12:00:19 AM] Starting compilation in watch mode... + +Current directory: /user/username/projects/project CaseSensitiveFileNames: false +Synchronizing program +CreatingProgramWith:: + roots: ["main.ts"] + options: {"watch":true,"extendedDiagnostics":true} +FileWatcher:: Added:: WatchInfo: main.ts 250 undefined Source file +FileWatcher:: Added:: WatchInfo: /a/lib/lib.d.ts 250 undefined Source file +DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Type roots +Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /user/username/projects/project/node_modules/@types 1 undefined Type roots +[12:00:22 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["main.ts"] +Program options: {"watch":true,"extendedDiagnostics":true} +Program structureReused: Not +Program files:: +/a/lib/lib.d.ts +main.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +main.ts + +Shape signatures in builder refreshed for:: +/a/lib/lib.d.ts (used version) +/user/username/projects/project/main.ts (used version) + +PolledWatches:: +/user/username/projects/project/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/project/main.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/project/main.js] +var a = "Hello"; + + + +Change:: change main.ts + +Input:: +//// [/user/username/projects/project/main.ts] +let a: string = "Hello World" + + +Output:: +FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file +Synchronizing program +[12:00:26 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["main.ts"] + options: {"watch":true,"extendedDiagnostics":true} +[12:00:30 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["main.ts"] +Program options: {"watch":true,"extendedDiagnostics":true} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +main.ts + +Semantic diagnostics in builder refreshed for:: +/a/lib/lib.d.ts +main.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/project/main.ts (computed .d.ts) + +PolledWatches:: +/user/username/projects/project/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/project/main.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/project/main.js] +var a = "Hello World"; + + + +Change:: receive another change event without modifying the file + +Input:: + +Output:: +FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file +Synchronizing program + + +PolledWatches:: +/user/username/projects/project/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/project/main.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + + +Change:: change main.ts to empty text + +Input:: +//// [/user/username/projects/project/main.ts] + + + +Output:: +FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file +Synchronizing program +[12:00:34 AM] File change detected. Starting incremental compilation... + +CreatingProgramWith:: + roots: ["main.ts"] + options: {"watch":true,"extendedDiagnostics":true} +[12:00:38 AM] Found 0 errors. Watching for file changes. + + + +Program root files: ["main.ts"] +Program options: {"watch":true,"extendedDiagnostics":true} +Program structureReused: Completely +Program files:: +/a/lib/lib.d.ts +main.ts + +Semantic diagnostics in builder refreshed for:: +main.ts + +Shape signatures in builder refreshed for:: +/user/username/projects/project/main.ts (used version) + +PolledWatches:: +/user/username/projects/project/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/project/main.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + +//// [/user/username/projects/project/main.js] + + + +Change:: receive another change event without modifying the file + +Input:: + +Output:: +FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file +Scheduling update +Elapsed:: *ms FileWatcher:: Triggered with main.ts 1:: WatchInfo: main.ts 250 undefined Source file +Synchronizing program + + +PolledWatches:: +/user/username/projects/project/node_modules/@types: + {"pollingInterval":500} + +FsWatches:: +/user/username/projects/project/main.ts: + {} +/a/lib/lib.d.ts: + {} + +FsWatchesRecursive:: + +exitCode:: ExitStatus.undefined + From b4d382b9b12460adf2da4cc0d1429cf19f8dc8be Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 2 Dec 2022 10:55:03 -0800 Subject: [PATCH 3/5] Cherry-pick changes for narrowing to tagged literal types. --- src/compiler/checker.ts | 5 +- .../reference/unknownControlFlow.errors.txt | 22 ++++++++ .../baselines/reference/unknownControlFlow.js | 43 +++++++++++++++ .../reference/unknownControlFlow.symbols | 48 +++++++++++++++++ .../reference/unknownControlFlow.types | 52 +++++++++++++++++++ .../types/unknown/unknownControlFlow.ts | 22 ++++++++ 6 files changed, 191 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c4a19cb8e8c2d..73797735e2ffe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21630,7 +21630,10 @@ namespace ts { } function isUnitLikeType(type: Type): boolean { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + const t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & TypeFlags.Intersection ? some((t as IntersectionType).types, isUnitType) : isUnitType(t); } function extractUnitType(type: Type) { diff --git a/tests/baselines/reference/unknownControlFlow.errors.txt b/tests/baselines/reference/unknownControlFlow.errors.txt index 410237e3133a7..6056f775acf0a 100644 --- a/tests/baselines/reference/unknownControlFlow.errors.txt +++ b/tests/baselines/reference/unknownControlFlow.errors.txt @@ -444,4 +444,26 @@ tests/cases/conformance/types/unknown/unknownControlFlow.ts(293,5): error TS2345 function x(x: T_AB & undefined, y: any) { let r2: never = y as T_AB & undefined; } + + // Repro from #51538 + + type Left = 'left'; + type Right = 'right' & { right: 'right' }; + type Either = Left | Right; + + function assertNever(v: never): never { + throw new Error('never'); + } + + function fx20(value: Either) { + if (value === 'left') { + const foo: 'left' = value; + } + else if (value === 'right') { + const bar: 'right' = value; + } + else { + assertNever(value); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/unknownControlFlow.js b/tests/baselines/reference/unknownControlFlow.js index a4979179cfb7a..68233905e13b9 100644 --- a/tests/baselines/reference/unknownControlFlow.js +++ b/tests/baselines/reference/unknownControlFlow.js @@ -427,6 +427,28 @@ type AB = "A" | "B"; function x(x: T_AB & undefined, y: any) { let r2: never = y as T_AB & undefined; } + +// Repro from #51538 + +type Left = 'left'; +type Right = 'right' & { right: 'right' }; +type Either = Left | Right; + +function assertNever(v: never): never { + throw new Error('never'); +} + +function fx20(value: Either) { + if (value === 'left') { + const foo: 'left' = value; + } + else if (value === 'right') { + const bar: 'right' = value; + } + else { + assertNever(value); + } +} //// [unknownControlFlow.js] @@ -772,6 +794,20 @@ function doSomething2(value) { function x(x, y) { var r2 = y; } +function assertNever(v) { + throw new Error('never'); +} +function fx20(value) { + if (value === 'left') { + var foo_1 = value; + } + else if (value === 'right') { + var bar = value; + } + else { + assertNever(value); + } +} //// [unknownControlFlow.d.ts] @@ -844,3 +880,10 @@ type R = T extends keyof TypeB ? [TypeA[T], TypeB[T]] : n type R2 = T extends keyof TypeA ? T extends keyof TypeB ? [TypeA[T], TypeB[T]] : never : never; type AB = "A" | "B"; declare function x(x: T_AB & undefined, y: any): void; +type Left = 'left'; +type Right = 'right' & { + right: 'right'; +}; +type Either = Left | Right; +declare function assertNever(v: never): never; +declare function fx20(value: Either): void; diff --git a/tests/baselines/reference/unknownControlFlow.symbols b/tests/baselines/reference/unknownControlFlow.symbols index d69e69fe08ee6..762505aba1907 100644 --- a/tests/baselines/reference/unknownControlFlow.symbols +++ b/tests/baselines/reference/unknownControlFlow.symbols @@ -995,3 +995,51 @@ function x(x: T_AB & undefined, y: any) { >T_AB : Symbol(T_AB, Decl(unknownControlFlow.ts, 425, 11)) } +// Repro from #51538 + +type Left = 'left'; +>Left : Symbol(Left, Decl(unknownControlFlow.ts, 427, 1)) + +type Right = 'right' & { right: 'right' }; +>Right : Symbol(Right, Decl(unknownControlFlow.ts, 431, 19)) +>right : Symbol(right, Decl(unknownControlFlow.ts, 432, 24)) + +type Either = Left | Right; +>Either : Symbol(Either, Decl(unknownControlFlow.ts, 432, 42)) +>Left : Symbol(Left, Decl(unknownControlFlow.ts, 427, 1)) +>Right : Symbol(Right, Decl(unknownControlFlow.ts, 431, 19)) + +function assertNever(v: never): never { +>assertNever : Symbol(assertNever, Decl(unknownControlFlow.ts, 433, 27)) +>v : Symbol(v, Decl(unknownControlFlow.ts, 435, 21)) + + throw new Error('never'); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) +} + +function fx20(value: Either) { +>fx20 : Symbol(fx20, Decl(unknownControlFlow.ts, 437, 1)) +>value : Symbol(value, Decl(unknownControlFlow.ts, 439, 14)) +>Either : Symbol(Either, Decl(unknownControlFlow.ts, 432, 42)) + + if (value === 'left') { +>value : Symbol(value, Decl(unknownControlFlow.ts, 439, 14)) + + const foo: 'left' = value; +>foo : Symbol(foo, Decl(unknownControlFlow.ts, 441, 13)) +>value : Symbol(value, Decl(unknownControlFlow.ts, 439, 14)) + } + else if (value === 'right') { +>value : Symbol(value, Decl(unknownControlFlow.ts, 439, 14)) + + const bar: 'right' = value; +>bar : Symbol(bar, Decl(unknownControlFlow.ts, 444, 13)) +>value : Symbol(value, Decl(unknownControlFlow.ts, 439, 14)) + } + else { + assertNever(value); +>assertNever : Symbol(assertNever, Decl(unknownControlFlow.ts, 433, 27)) +>value : Symbol(value, Decl(unknownControlFlow.ts, 439, 14)) + } +} + diff --git a/tests/baselines/reference/unknownControlFlow.types b/tests/baselines/reference/unknownControlFlow.types index 2cf2c101c9dad..24cbd3b162850 100644 --- a/tests/baselines/reference/unknownControlFlow.types +++ b/tests/baselines/reference/unknownControlFlow.types @@ -1076,3 +1076,55 @@ function x(x: T_AB & undefined, y: any) { >y : any } +// Repro from #51538 + +type Left = 'left'; +>Left : "left" + +type Right = 'right' & { right: 'right' }; +>Right : "right" & { right: 'right'; } +>right : "right" + +type Either = Left | Right; +>Either : Right | "left" + +function assertNever(v: never): never { +>assertNever : (v: never) => never +>v : never + + throw new Error('never'); +>new Error('never') : Error +>Error : ErrorConstructor +>'never' : "never" +} + +function fx20(value: Either) { +>fx20 : (value: Either) => void +>value : Either + + if (value === 'left') { +>value === 'left' : boolean +>value : Either +>'left' : "left" + + const foo: 'left' = value; +>foo : "left" +>value : "left" + } + else if (value === 'right') { +>value === 'right' : boolean +>value : Right +>'right' : "right" + + const bar: 'right' = value; +>bar : "right" +>value : Right + } + else { + assertNever(value); +>assertNever(value) : never +>assertNever : (v: never) => never +>value : never + } +} + diff --git a/tests/cases/conformance/types/unknown/unknownControlFlow.ts b/tests/cases/conformance/types/unknown/unknownControlFlow.ts index 082ebad7bc1f5..1f82ab4944da5 100644 --- a/tests/cases/conformance/types/unknown/unknownControlFlow.ts +++ b/tests/cases/conformance/types/unknown/unknownControlFlow.ts @@ -429,3 +429,25 @@ type AB = "A" | "B"; function x(x: T_AB & undefined, y: any) { let r2: never = y as T_AB & undefined; } + +// Repro from #51538 + +type Left = 'left'; +type Right = 'right' & { right: 'right' }; +type Either = Left | Right; + +function assertNever(v: never): never { + throw new Error('never'); +} + +function fx20(value: Either) { + if (value === 'left') { + const foo: 'left' = value; + } + else if (value === 'right') { + const bar: 'right' = value; + } + else { + assertNever(value); + } +} From eb5419fc8d980859b98553586dfb5f40d811a745 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 5 Dec 2022 11:13:46 -0800 Subject: [PATCH 4/5] Cherry-pick #51704 to release 4.9 (#51712) * Manual port of #51704 * Add a testcase --- src/compiler/checker.ts | 2 +- tests/baselines/reference/satisfiesEmit.errors.txt | 13 +++++++++++++ tests/baselines/reference/satisfiesEmit.js | 12 ++++++++++++ tests/baselines/reference/satisfiesEmit.symbols | 10 ++++++++++ tests/baselines/reference/satisfiesEmit.types | 10 ++++++++++ tests/cases/compiler/satisfiesEmit.ts | 3 +++ 6 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/satisfiesEmit.errors.txt create mode 100644 tests/baselines/reference/satisfiesEmit.js create mode 100644 tests/baselines/reference/satisfiesEmit.symbols create mode 100644 tests/baselines/reference/satisfiesEmit.types create mode 100644 tests/cases/compiler/satisfiesEmit.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 73797735e2ffe..1e58b72b7e1d2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -32707,13 +32707,13 @@ namespace ts { function checkSatisfiesExpression(node: SatisfiesExpression) { checkSourceElement(node.type); + const exprType = checkExpression(node.expression); const targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - const exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; diff --git a/tests/baselines/reference/satisfiesEmit.errors.txt b/tests/baselines/reference/satisfiesEmit.errors.txt new file mode 100644 index 0000000000000..45f8097024cf3 --- /dev/null +++ b/tests/baselines/reference/satisfiesEmit.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/satisfiesEmit.ts(2,20): error TS2307: Cannot find module 'foo' or its corresponding type declarations. +tests/cases/compiler/satisfiesEmit.ts(3,23): error TS2304: Cannot find name 'bleh'. + + +==== tests/cases/compiler/satisfiesEmit.ts (2 errors) ==== + // This import should not be elided in the emitted JS + import a = require("foo"); + ~~~~~ +!!! error TS2307: Cannot find module 'foo' or its corresponding type declarations. + const p = a satisfies bleh; + ~~~~ +!!! error TS2304: Cannot find name 'bleh'. + \ No newline at end of file diff --git a/tests/baselines/reference/satisfiesEmit.js b/tests/baselines/reference/satisfiesEmit.js new file mode 100644 index 0000000000000..6851dbe9f8dd5 --- /dev/null +++ b/tests/baselines/reference/satisfiesEmit.js @@ -0,0 +1,12 @@ +//// [satisfiesEmit.ts] +// This import should not be elided in the emitted JS +import a = require("foo"); +const p = a satisfies bleh; + + +//// [satisfiesEmit.js] +"use strict"; +exports.__esModule = true; +// This import should not be elided in the emitted JS +var a = require("foo"); +var p = a; diff --git a/tests/baselines/reference/satisfiesEmit.symbols b/tests/baselines/reference/satisfiesEmit.symbols new file mode 100644 index 0000000000000..051902990e69b --- /dev/null +++ b/tests/baselines/reference/satisfiesEmit.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/satisfiesEmit.ts === +// This import should not be elided in the emitted JS +import a = require("foo"); +>a : Symbol(a, Decl(satisfiesEmit.ts, 0, 0)) + +const p = a satisfies bleh; +>p : Symbol(p, Decl(satisfiesEmit.ts, 2, 5)) +>a : Symbol(a, Decl(satisfiesEmit.ts, 0, 0)) +>bleh : Symbol(bleh) + diff --git a/tests/baselines/reference/satisfiesEmit.types b/tests/baselines/reference/satisfiesEmit.types new file mode 100644 index 0000000000000..9546af9e238c6 --- /dev/null +++ b/tests/baselines/reference/satisfiesEmit.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/satisfiesEmit.ts === +// This import should not be elided in the emitted JS +import a = require("foo"); +>a : any + +const p = a satisfies bleh; +>p : bleh +>a satisfies bleh : bleh +>a : any + diff --git a/tests/cases/compiler/satisfiesEmit.ts b/tests/cases/compiler/satisfiesEmit.ts new file mode 100644 index 0000000000000..bf2c6156e95ee --- /dev/null +++ b/tests/cases/compiler/satisfiesEmit.ts @@ -0,0 +1,3 @@ +// This import should not be elided in the emitted JS +import a = require("foo"); +const p = a satisfies bleh; From e2868216f637e875a74c675845625eb15dcfe9a2 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 6 Dec 2022 17:42:25 +0000 Subject: [PATCH 5/5] Bump version to 4.9.4 and LKG. --- lib/tsc.js | 42 +++++++++++++++++++++-------------- lib/tsserver.js | 45 ++++++++++++++++++++++++-------------- lib/tsserverlibrary.js | 45 ++++++++++++++++++++++++-------------- lib/typescript.js | 45 ++++++++++++++++++++++++-------------- lib/typescriptServices.js | 45 ++++++++++++++++++++++++-------------- lib/typingsInstaller.js | 45 ++++++++++++++++++++++++-------------- package.json | 2 +- src/compiler/corePublic.ts | 2 +- 8 files changed, 167 insertions(+), 104 deletions(-) diff --git a/lib/tsc.js b/lib/tsc.js index 0ac0683ff06f2..80afaea533e28 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) { var ts; (function (ts) { ts.versionMajorMinor = "4.9"; - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); var NativeCollections; (function (NativeCollections) { var globals = typeof globalThis !== "undefined" ? globalThis : @@ -57536,7 +57536,8 @@ var ts; return !!(type.flags & 109440); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + var t = getBaseConstraintOrType(type); + return t.flags & 2097152 ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 ? ts.find(type.types, isUnitType) || type : type; @@ -66236,11 +66237,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -77596,8 +77597,8 @@ var ts; _a[302] = function visitEachChildOfEnumMember(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, - _a[308] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, undefined, undefined, nodesVisitor)); + _a[308] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, _a[353] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { return context.factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression)); @@ -104718,12 +104719,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -104754,6 +104756,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -104769,9 +104772,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -104887,7 +104890,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -104972,7 +104975,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { var args = []; @@ -105092,8 +105095,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -105218,9 +105221,14 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -105652,7 +105660,7 @@ var ts; var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames()); var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -106634,7 +106642,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/tsserver.js b/lib/tsserver.js index 4d7f350bb9174..a2960e9f6795b 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -109,7 +109,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68904,7 +68904,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79084,11 +79087,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91973,8 +91976,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126211,12 +126214,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126247,6 +126251,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126265,9 +126270,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126399,7 +126404,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126485,7 +126490,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126613,8 +126618,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126753,9 +126758,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127249,7 +127260,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128282,7 +128293,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 4c9c38508f58d..1b41c9347d2f7 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -108,7 +108,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68903,7 +68903,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79083,11 +79086,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91972,8 +91975,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126210,12 +126213,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126246,6 +126250,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126264,9 +126269,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126398,7 +126403,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126484,7 +126489,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126612,8 +126617,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126752,9 +126757,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127248,7 +127259,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128281,7 +128292,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/typescript.js b/lib/typescript.js index 7e5216130ba64..c2688dd27c335 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -99,7 +99,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68894,7 +68894,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79074,11 +79077,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91963,8 +91966,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126201,12 +126204,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126237,6 +126241,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126255,9 +126260,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126389,7 +126394,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126475,7 +126480,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126603,8 +126608,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126743,9 +126748,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127239,7 +127250,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128272,7 +128283,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 27225845567c3..98086d72a80af 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -99,7 +99,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68894,7 +68894,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79074,11 +79077,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91963,8 +91966,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126201,12 +126204,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126237,6 +126241,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126255,9 +126260,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126389,7 +126394,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126475,7 +126480,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126603,8 +126608,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126743,9 +126748,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127239,7 +127250,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128272,7 +128283,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index df6dbf82ce8c7..a4a6c6314ce7e 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -89,7 +89,7 @@ var ts; // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - ts.version = "".concat(ts.versionMajorMinor, ".3"); + ts.version = "".concat(ts.versionMajorMinor, ".4"); /* @internal */ var Comparison; (function (Comparison) { @@ -68884,7 +68884,10 @@ var ts; return !!(type.flags & 109440 /* TypeFlags.Unit */); } function isUnitLikeType(type) { - return isUnitType(getBaseConstraintOrType(type)); + // Intersections that reduce to 'never' (e.g. 'T & null' where 'T extends {}') are not unit types. + var t = getBaseConstraintOrType(type); + // Scan intersections such that tagged literal types are considered unit types. + return t.flags & 2097152 /* TypeFlags.Intersection */ ? ts.some(t.types, isUnitType) : isUnitType(t); } function extractUnitType(type) { return type.flags & 2097152 /* TypeFlags.Intersection */ ? ts.find(type.types, isUnitType) || type : type; @@ -79064,11 +79067,11 @@ var ts; } function checkSatisfiesExpression(node) { checkSourceElement(node.type); + var exprType = checkExpression(node.expression); var targetType = getTypeFromTypeNode(node.type); if (isErrorType(targetType)) { return targetType; } - var exprType = checkExpression(node.expression); checkTypeAssignableToAndOptionallyElaborate(exprType, targetType, node.type, node.expression, ts.Diagnostics.Type_0_does_not_satisfy_the_expected_type_1); return exprType; } @@ -91953,8 +91956,8 @@ var ts; return context.factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression)); }, // Top-level nodes - _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) { - return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context, /*start*/ undefined, /*ensureUseStrict*/ undefined, nodesVisitor)); + _a[308 /* SyntaxKind.SourceFile */] = function visitEachChildOfSourceFile(node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) { + return context.factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context)); }, // Transformation nodes _a[353 /* SyntaxKind.PartiallyEmittedExpression */] = function visitEachChildOfPartiallyEmittedExpression(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) { @@ -126191,12 +126194,13 @@ var ts; if (directoryStructureHost === void 0) { directoryStructureHost = host; } var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames(); var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); }); - return { + var compilerHost = { getSourceFile: function (fileName, languageVersionOrOptions, onError) { var text; try { ts.performance.mark("beforeIORead"); - text = host.readFile(fileName, getCompilerOptions().charset); + var encoding = getCompilerOptions().charset; + text = !encoding ? compilerHost.readFile(fileName) : host.readFile(fileName, encoding); ts.performance.mark("afterIORead"); ts.performance.measure("I/O Read", "beforeIORead", "afterIORead"); } @@ -126227,6 +126231,7 @@ var ts; disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature, storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit, }; + return compilerHost; function writeFile(fileName, text, writeByteOrderMark, onError) { try { ts.performance.mark("beforeIOWrite"); @@ -126245,9 +126250,9 @@ var ts; } } ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost; - function setGetSourceFileAsHashVersioned(compilerHost, host) { + function setGetSourceFileAsHashVersioned(compilerHost) { var originalGetSourceFile = compilerHost.getSourceFile; - var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash; + var computeHash = ts.maybeBind(compilerHost, compilerHost.createHash) || ts.generateDjb2Hash; compilerHost.getSourceFile = function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -126379,7 +126384,7 @@ var ts; host.createHash = ts.maybeBind(system, system.createHash); host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature; host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit; - ts.setGetSourceFileAsHashVersioned(host, system); + ts.setGetSourceFileAsHashVersioned(host); ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); }); return host; } @@ -126465,7 +126470,7 @@ var ts; configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile); } var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); // Members for CompilerHost var getNewSourceFile = compilerHost.getSourceFile; compilerHost.getSourceFile = function (fileName) { @@ -126593,8 +126598,8 @@ var ts; } } var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions); - var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile; - if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { + var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, readFileWithCache = _a.readFileWithCache; + if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, function (path) { return getSourceVersion(path, readFileWithCache); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) { if (hasChangedConfigFileParsingErrors) { if (reportFileChangeDetectedOnCreateProgram) { reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation); @@ -126733,9 +126738,15 @@ var ts; } } } - function getSourceVersion(path) { + function getSourceVersion(path, readFileWithCache) { var hostSourceFile = sourceFilesCache.get(path); - return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version; + if (!hostSourceFile) + return undefined; + if (hostSourceFile.version) + return hostSourceFile.version; + // Read file and get new version + var text = readFileWithCache(path); + return text !== undefined ? (compilerHost.createHash || ts.generateDjb2Hash)(text) : undefined; } function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) { var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath); @@ -127229,7 +127240,7 @@ var ts; // State of the solution var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options); var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; }); - ts.setGetSourceFileAsHashVersioned(compilerHost, host); + ts.setGetSourceFileAsHashVersioned(compilerHost); compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); }; compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames); compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives); @@ -128262,7 +128273,7 @@ var ts; buildInfoVersionMap = ts.getBuildInfoFileVersionMap(buildInfoProgram, buildInfoPath, host); version_3 = buildInfoVersionMap.get(toPath(state, inputFile)); var text = version_3 ? state.readFileWithCache(inputFile) : undefined; - currentVersion = text && (host.createHash || ts.generateDjb2Hash)(text); + currentVersion = text !== undefined ? (host.createHash || ts.generateDjb2Hash)(text) : undefined; if (version_3 && version_3 === currentVersion) pseudoInputUpToDate = true; } diff --git a/package.json b/package.json index 18f05a1d55942..f5de7c1fc823a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "4.9.3", + "version": "4.9.4", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index 778475b396366..449bd11b603ff 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -5,7 +5,7 @@ namespace ts { // The following is baselined as a literal template type without intervention /** The version of the TypeScript compiler release */ // eslint-disable-next-line @typescript-eslint/no-inferrable-types - export const version: string = `${versionMajorMinor}.3`; + export const version: string = `${versionMajorMinor}.4`; /** * Type of objects whose values are all of the same type.