From e75f470be05018aaad6d6f599b4ddd4da76f7ae3 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Fri, 19 Apr 2024 12:33:00 -0700 Subject: [PATCH] Report positionless tsconfig option errors on `compilerOptions` key (#58254) --- src/compiler/program.ts | 43 +++++++-- ...ield2(moduleresolution=bundler).errors.txt | 7 +- .../tsc/moduleResolution/alternateResult.js | 91 +++++++++++++------ .../with-nodeNext-resolution.js | 5 +- .../moduleResolution/alternateResult.js | 65 ++++++++++--- .../diagnostics-from-cache.js | 10 +- ...esolutions-from-file-are-partially-used.js | 10 +- ...s-with-partially-used-import-attributes.js | 10 +- .../type-reference-resolutions-reuse.js | 10 +- .../moduleResolution/alternateResult.js | 11 ++- .../verbatimModuleSyntaxCompat3.errors.txt | 14 +-- 11 files changed, 210 insertions(+), 66 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 886133027b5cb..86cde5bd72a58 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -313,6 +313,7 @@ import { toPath as ts_toPath, trace, tracing, + tryCast, TsConfigSourceFile, TypeChecker, typeDirectiveIsEqualTo, @@ -1618,6 +1619,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg // Map storing if there is emit blocking diagnostics for given input const hasEmitBlockingDiagnostics = new Map(); let _compilerOptionsObjectLiteralSyntax: ObjectLiteralExpression | false | undefined; + let _compilerOptionsPropertySyntax: PropertyAssignment | false | undefined; let moduleResolutionCache: ModuleResolutionCache | undefined; let actualResolveModuleNamesWorker: ( @@ -4400,7 +4402,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } if (options.checkJs && !getAllowJSCompilerOption(options)) { - programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + createDiagnosticForOptionName(Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"); } if (options.emitDeclarationOnly) { @@ -4823,7 +4825,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } }); if (needCompilerDiagnostic) { - programDiagnostics.add(createCompilerDiagnostic(message, ...args)); + createCompilerOptionsDiagnostic(message, ...args); } } @@ -4845,7 +4847,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg } }); if (needCompilerDiagnostic) { - programDiagnostics.add(createCompilerDiagnostic(message, ...args)); + createCompilerOptionsDiagnostic(message, ...args); } } @@ -4893,25 +4895,50 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg !createOptionDiagnosticInObjectLiteralSyntax(compilerOptionsObjectLiteralSyntax, onKey, option1, option2, message, ...args); if (needCompilerDiagnostic) { + createCompilerOptionsDiagnostic(message, ...args); + } + } + + function createCompilerOptionsDiagnostic(message: DiagnosticMessageChain): void; + function createCompilerOptionsDiagnostic(message: DiagnosticMessage, ...args: DiagnosticArguments): void; + function createCompilerOptionsDiagnostic(message: DiagnosticMessage | DiagnosticMessageChain, ...args: DiagnosticArguments): void; + function createCompilerOptionsDiagnostic(message: DiagnosticMessage | DiagnosticMessageChain, ...args: DiagnosticArguments): void { + const compilerOptionsProperty = getCompilerOptionsPropertySyntax(); + if (compilerOptionsProperty) { // eslint-disable-next-line local/no-in-operator if ("messageText" in message) { - programDiagnostics.add(createCompilerDiagnosticFromMessageChain(message)); + programDiagnostics.add(createDiagnosticForNodeFromMessageChain(options.configFile!, compilerOptionsProperty.name, message)); } else { - programDiagnostics.add(createCompilerDiagnostic(message, ...args)); + programDiagnostics.add(createDiagnosticForNodeInSourceFile(options.configFile!, compilerOptionsProperty.name, message, ...args)); } } + // eslint-disable-next-line local/no-in-operator + else if ("messageText" in message) { + programDiagnostics.add(createCompilerDiagnosticFromMessageChain(message)); + } + else { + programDiagnostics.add(createCompilerDiagnostic(message, ...args)); + } } function getCompilerOptionsObjectLiteralSyntax() { if (_compilerOptionsObjectLiteralSyntax === undefined) { - _compilerOptionsObjectLiteralSyntax = forEachPropertyAssignment( + const compilerOptionsProperty = getCompilerOptionsPropertySyntax(); + _compilerOptionsObjectLiteralSyntax = compilerOptionsProperty ? tryCast(compilerOptionsProperty.initializer, isObjectLiteralExpression) || false : false; + } + return _compilerOptionsObjectLiteralSyntax || undefined; + } + + function getCompilerOptionsPropertySyntax() { + if (_compilerOptionsPropertySyntax === undefined) { + _compilerOptionsPropertySyntax = forEachPropertyAssignment( getTsConfigObjectLiteralExpression(options.configFile), "compilerOptions", - prop => isObjectLiteralExpression(prop.initializer) ? prop.initializer : undefined, + identity, ) || false; } - return _compilerOptionsObjectLiteralSyntax || undefined; + return _compilerOptionsPropertySyntax || undefined; } function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral: ObjectLiteralExpression, onKey: boolean, key1: string, key2: string | undefined, messageChain: DiagnosticMessageChain): boolean; diff --git a/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt b/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt index bc87e9cadb7ff..93275a57fad27 100644 --- a/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt +++ b/tests/baselines/reference/resolutionCandidateFromPackageJsonField2(moduleresolution=bundler).errors.txt @@ -1,11 +1,12 @@ -error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. +tsconfig.json(2,5): error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. test.ts(1,19): error TS5097: An import path can only end with a '.ts' extension when 'allowImportingTsExtensions' is enabled. -!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. -==== tsconfig.json (0 errors) ==== +==== tsconfig.json (1 errors) ==== { "compilerOptions": { + ~~~~~~~~~~~~~~~~~ +!!! error TS5095: Option 'bundler' can only be used when 'module' is set to 'preserve' or to 'es2015' or later. "paths": { "foo/*": ["./dist/*"], "baz/*.ts": ["./types/*.d.ts"] diff --git a/tests/baselines/reference/tsc/moduleResolution/alternateResult.js b/tests/baselines/reference/tsc/moduleResolution/alternateResult.js index 5a900934d8c5c..a395679675802 100644 --- a/tests/baselines/reference/tsc/moduleResolution/alternateResult.js +++ b/tests/baselines/reference/tsc/moduleResolution/alternateResult.js @@ -344,10 +344,13 @@ File '/home/src/projects/project/node_modules/foo2/package.json' exists accordin File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. + +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -657,10 +660,13 @@ File '/home/src/projects/project/node_modules/foo2/package.json' exists accordin File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -896,10 +902,13 @@ File '/home/src/projects/project/node_modules/foo2/package.json' exists accordin File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. + +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -1125,10 +1134,13 @@ File '/home/src/projects/project/node_modules/foo2/package.json' exists accordin File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -1341,10 +1353,13 @@ File '/home/src/projects/project/node_modules/foo2/package.json' exists accordin File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. + +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -1526,10 +1541,13 @@ File '/home/src/projects/project/node_modules/foo2/package.json' exists accordin File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -1780,10 +1798,13 @@ File '/home/src/projects/project/node_modules/foo2/package.json' exists accordin File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -2085,10 +2106,13 @@ File '/home/src/projects/project/node_modules/@types/bar/package.json' exists ac File '/home/src/projects/project/node_modules/foo2/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. + +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -2406,10 +2430,13 @@ File '/home/src/projects/project/node_modules/foo/package.json' exists according File '/home/src/projects/project/node_modules/@types/bar/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -2713,10 +2740,13 @@ File '/home/src/projects/project/node_modules/foo/package.json' exists according File '/home/src/projects/project/node_modules/@types/bar/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -2952,10 +2982,13 @@ File '/home/src/projects/project/node_modules/foo/package.json' exists according File '/home/src/projects/project/node_modules/@types/bar/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. + +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -3181,10 +3214,13 @@ File '/home/src/projects/project/node_modules/foo/package.json' exists according File '/home/src/projects/project/node_modules/@types/bar/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ @@ -3397,10 +3433,13 @@ File '/home/src/projects/project/node_modules/foo/package.json' exists according File '/home/src/projects/project/node_modules/@types/bar/package.json' exists according to earlier cached lookups. File '/lib/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +home/src/projects/project/tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ -Found 1 error. +Found 1 error in home/src/projects/project/tsconfig.json:2 exitCode:: ExitStatus.DiagnosticsPresent_OutputsGenerated Program root files: [ diff --git a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js index 6b45de2e38a17..d59303ac57b12 100644 --- a/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js +++ b/tests/baselines/reference/tscWatch/forceConsistentCasingInFileNames/with-nodeNext-resolution.js @@ -101,7 +101,10 @@ Resolving real path for '/Users/name/projects/web/node_modules/@types/yargs/inde File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ ../../../../a/lib/lib.d.ts Default library for target 'es5' diff --git a/tests/baselines/reference/tscWatch/moduleResolution/alternateResult.js b/tests/baselines/reference/tscWatch/moduleResolution/alternateResult.js index 89bed50555193..bc15ee8d8d4a4 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/alternateResult.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/alternateResult.js @@ -361,7 +361,10 @@ Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/project/index DirectoryWatcher:: Triggered with /home/src/projects/project/tsconfig.tsbuildinfo :: WatchInfo: /home/src/projects/project 0 undefined Failed Lookup Locations Scheduling invalidateFailedLookup, Cancelled earlier one Elapsed:: *ms DirectoryWatcher:: Triggered with /home/src/projects/project/tsconfig.tsbuildinfo :: WatchInfo: /home/src/projects/project 0 undefined Failed Lookup Locations -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -656,7 +659,10 @@ File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists a File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -802,7 +808,10 @@ File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists a File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -958,7 +967,10 @@ File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists a File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -1093,7 +1105,10 @@ File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists a File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -1221,7 +1236,10 @@ File '/home/src/projects/project/node_modules/@types/bar2/package.json' exists a File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -1478,7 +1496,10 @@ File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. DirectoryWatcher:: Close:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Close:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -1799,7 +1820,10 @@ File '/package.json' does not exist according to earlier cached lookups. FileWatcher:: Close:: WatchInfo: /home/src/projects/project/node_modules/@types/bar2/index.d.ts 250 undefined Source file DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations Elapsed:: *ms DirectoryWatcher:: Added:: WatchInfo: /home/src/projects/node_modules 1 undefined Failed Lookup Locations -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -2083,7 +2107,10 @@ File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. FileWatcher:: Close:: WatchInfo: /home/src/projects/project/node_modules/foo2/index.d.ts 250 undefined Source file -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -2370,7 +2397,10 @@ File '/home/src/projects/project/node_modules/@types/bar/package.json' exists ac File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -2516,7 +2546,10 @@ File '/home/src/projects/project/node_modules/@types/bar/package.json' exists ac File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -2672,7 +2705,10 @@ File '/home/src/projects/project/node_modules/@types/bar/package.json' exists ac File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -2807,7 +2843,10 @@ File '/home/src/projects/project/node_modules/@types/bar/package.json' exists ac File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js b/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js index 435f7467b47d3..1f46995e2e9b2 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/diagnostics-from-cache.js @@ -70,7 +70,10 @@ File '/a/package.json' does not exist. File '/package.json' does not exist. error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file '/user/username/projects/myproject/package.json'. Supply the `rootDir` compiler option to disambiguate. -error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 2 errors. Watching for file changes. @@ -184,7 +187,10 @@ File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. error TS2209: The project root is ambiguous, but is required to resolve export map entry '.' in file '/user/username/projects/myproject/package.json'. Supply the `rootDir` compiler option to disambiguate. -error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 2 errors. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-file-are-partially-used.js b/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-file-are-partially-used.js index 1797f0e719304..60dc7b726f851 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-file-are-partially-used.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-file-are-partially-used.js @@ -150,7 +150,10 @@ File '/user/username/projects/myproject/node_modules/pkg/package.json' exists ac File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -306,7 +309,10 @@ Reusing resolution of module 'pkg1' from '/user/username/projects/myproject/inde File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-files-with-partially-used-import-attributes.js b/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-files-with-partially-used-import-attributes.js index bc9955ee993c5..3bf5e03b78492 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-files-with-partially-used-import-attributes.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/module-resolutions-from-files-with-partially-used-import-attributes.js @@ -150,7 +150,10 @@ File '/user/username/projects/myproject/node_modules/pkg/package.json' exists ac File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -306,7 +309,10 @@ Reusing resolution of module 'pkg1' from '/user/username/projects/myproject/inde File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js b/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js index 211276f05e8f9..8486e21b7207c 100644 --- a/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js +++ b/tests/baselines/reference/tscWatch/moduleResolution/type-reference-resolutions-reuse.js @@ -150,7 +150,10 @@ File '/package.json' does not exist according to earlier cached lookups. File '/a/lib/package.json' does not exist. File '/a/package.json' does not exist. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. @@ -327,7 +330,10 @@ File '/package.json' does not exist according to earlier cached lookups. File '/a/lib/package.json' does not exist according to earlier cached lookups. File '/a/package.json' does not exist according to earlier cached lookups. File '/package.json' does not exist according to earlier cached lookups. -error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. +tsconfig.json:2:3 - error TS5110: Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'. + +2 "compilerOptions": { +   ~~~~~~~~~~~~~~~~~ [HH:MM:SS AM] Found 1 error. Watching for file changes. diff --git a/tests/baselines/reference/tsserver/moduleResolution/alternateResult.js b/tests/baselines/reference/tsserver/moduleResolution/alternateResult.js index 9d4baf81507da..61fd420bfb5dd 100644 --- a/tests/baselines/reference/tsserver/moduleResolution/alternateResult.js +++ b/tests/baselines/reference/tsserver/moduleResolution/alternateResult.js @@ -466,9 +466,18 @@ Info seq [hh:mm:ss:mss] event: "configFile": "/home/src/projects/project/tsconfig.json", "diagnostics": [ { + "start": { + "line": 2, + "offset": 3 + }, + "end": { + "line": 2, + "offset": 20 + }, "text": "Option 'module' must be set to 'Node16' when option 'moduleResolution' is set to 'Node16'.", "code": 5110, - "category": "error" + "category": "error", + "fileName": "/home/src/projects/project/tsconfig.json" } ] } diff --git a/tests/baselines/reference/verbatimModuleSyntaxCompat3.errors.txt b/tests/baselines/reference/verbatimModuleSyntaxCompat3.errors.txt index 8cb0dac888c99..7aaeb294be7d5 100644 --- a/tests/baselines/reference/verbatimModuleSyntaxCompat3.errors.txt +++ b/tests/baselines/reference/verbatimModuleSyntaxCompat3.errors.txt @@ -1,17 +1,19 @@ -error TS5102: Option 'importsNotUsedAsValues' has been removed. Please remove it from your configuration. +/tsconfig.json(3,5): error TS5102: Option 'importsNotUsedAsValues' has been removed. Please remove it from your configuration. Use 'verbatimModuleSyntax' instead. -error TS5102: Option 'preserveValueImports' has been removed. Please remove it from your configuration. +/tsconfig.json(3,5): error TS5102: Option 'preserveValueImports' has been removed. Please remove it from your configuration. Use 'verbatimModuleSyntax' instead. +==== /tsconfig.json (2 errors) ==== + { + "extends": "./tsconfig.base.json", + "compilerOptions": { + ~~~~~~~~~~~~~~~~~ !!! error TS5102: Option 'importsNotUsedAsValues' has been removed. Please remove it from your configuration. !!! error TS5102: Use 'verbatimModuleSyntax' instead. + ~~~~~~~~~~~~~~~~~ !!! error TS5102: Option 'preserveValueImports' has been removed. Please remove it from your configuration. !!! error TS5102: Use 'verbatimModuleSyntax' instead. -==== /tsconfig.json (0 errors) ==== - { - "extends": "./tsconfig.base.json", - "compilerOptions": { "verbatimModuleSyntax": true } }