You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/compiler/checker.ts
+15-9Lines changed: 15 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -1472,6 +1472,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1472
1472
var argumentsSymbol = createSymbol(SymbolFlags.Property, "arguments" as __String);
1473
1473
var requireSymbol = createSymbol(SymbolFlags.Property, "require" as __String);
1474
1474
var isolatedModulesLikeFlagName = compilerOptions.verbatimModuleSyntax ? "verbatimModuleSyntax" : "isolatedModules";
1475
+
// It is an error to use `importsNotUsedAsValues` alongside `verbatimModuleSyntax`, but we still need to not crash.
1476
+
// Given that, in such a scenario, `verbatimModuleSyntax` is basically disabled, as least as far as alias visibility tracking goes.
1477
+
var canCollectSymbolAliasAccessabilityData = !compilerOptions.verbatimModuleSyntax || !!compilerOptions.importsNotUsedAsValues;
1475
1478
1476
1479
/** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */
1477
1480
var apparentArgumentCount: number | undefined;
@@ -4540,7 +4543,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4540
4543
}
4541
4544
4542
4545
function markExportAsReferenced(node: ImportEqualsDeclaration | ExportSpecifier) {
4543
-
if (compilerOptions.verbatimModuleSyntax) {
4546
+
if (!canCollectSymbolAliasAccessabilityData) {
4544
4547
return;
4545
4548
}
4546
4549
const symbol = getSymbolOfDeclaration(node);
@@ -4559,7 +4562,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4559
4562
// we reach a non-alias or an exported entity (which is always considered referenced). We do this by checking the target of
4560
4563
// the alias as an expression (which recursively takes us back here if the target references another alias).
4561
4564
function markAliasSymbolAsReferenced(symbol: Symbol) {
error TS5104: Option 'importsNotUsedAsValues' is redundant and cannot be specified with option 'verbatimModuleSyntax'.
2
+
tests/cases/compiler/file.ts(1,1): error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.
3
+
tests/cases/compiler/index.ts(1,1): error TS1371: This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'.
4
+
tests/cases/compiler/index.ts(1,9): error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled.
5
+
6
+
7
+
!!! error TS5104: Option 'importsNotUsedAsValues' is redundant and cannot be specified with option 'verbatimModuleSyntax'.
8
+
==== tests/cases/compiler/file.ts (1 errors) ====
9
+
export class A {}
10
+
~~~~~~
11
+
!!! error TS1287: A top-level 'export' modifier cannot be used on value declarations in a CommonJS module when 'verbatimModuleSyntax' is enabled.
0 commit comments