Skip to content

Commit 1623c04

Browse files
committed
validate paths without baseUrl requires configFilePath
1 parent 8ae2c21 commit 1623c04

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/CompilerOptions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ export function validateOptions(options: CompilerOptions): ts.Diagnostic[] {
9999
diagnostics.push(diagnosticFactories.unsupportedJsxEmit());
100100
}
101101

102-
// paths without baseUrl is now supported (TS 6.0+ resolves paths relative to tsconfig location)
102+
if (options.paths && Object.keys(options.paths).length > 0 && !options.baseUrl && !options.configFilePath) {
103+
diagnostics.push(diagnosticFactories.pathsWithoutBaseDirectory());
104+
}
103105

104106
return diagnostics;
105107
}

src/transpilation/diagnostics.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ export const cannotBundleLibrary = createDiagnosticFactory(
5555
);
5656

5757
export const unsupportedJsxEmit = createDiagnosticFactory(() => 'JSX is only supported with "react" jsx option.');
58+
59+
export const pathsWithoutBaseDirectory = createDiagnosticFactory(
60+
() =>
61+
"When using 'paths' without 'baseUrl', a tsconfig.json must be present so paths can be resolved relative to it."
62+
);

0 commit comments

Comments
 (0)