Skip to content

Commit d6c32ba

Browse files
committed
Add missing ambient check to vMS export= error
1 parent 86f8114 commit d6c32ba

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

src/compiler/checker.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -44313,15 +44313,15 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4431344313
if (getAllSymbolFlags(sym) & SymbolFlags.Value) {
4431444314
// However if it is a value, we need to check it's being used correctly
4431544315
checkExpressionCached(id);
44316-
if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, SymbolFlags.Value)) {
44316+
if (!isIllegalExportDefaultInCJS && !(node.flags & NodeFlags.Ambient) && compilerOptions.verbatimModuleSyntax && getTypeOnlyAliasDeclaration(sym, SymbolFlags.Value)) {
4431744317
error(id,
4431844318
node.isExportEquals
4431944319
? Diagnostics.An_export_declaration_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration
4432044320
: Diagnostics.An_export_default_must_reference_a_real_value_when_verbatimModuleSyntax_is_enabled_but_0_resolves_to_a_type_only_declaration,
4432144321
idText(id));
4432244322
}
4432344323
}
44324-
else if (!isIllegalExportDefaultInCJS && compilerOptions.verbatimModuleSyntax) {
44324+
else if (!isIllegalExportDefaultInCJS && !(node.flags & NodeFlags.Ambient) && compilerOptions.verbatimModuleSyntax) {
4432544325
error(id,
4432644326
node.isExportEquals
4432744327
? Diagnostics.An_export_declaration_must_reference_a_value_when_verbatimModuleSyntax_is_enabled_but_0_only_refers_to_a_type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
=== tests/cases/conformance/externalModules/type1.d.ts ===
2+
declare namespace NS {
3+
>NS : Symbol(NS, Decl(type1.d.ts, 0, 0))
4+
5+
type A = object;
6+
>A : Symbol(A, Decl(type1.d.ts, 0, 22))
7+
}
8+
9+
export = NS;
10+
>NS : Symbol(NS, Decl(type1.d.ts, 0, 0))
11+
12+
export as namespace MyTypes;
13+
>MyTypes : Symbol(MyTypes, Decl(type1.d.ts, 4, 12))
14+
15+
=== tests/cases/conformance/externalModules/type2.d.ts ===
16+
import type * as NS from './type1';
17+
>NS : Symbol(NS, Decl(type2.d.ts, 0, 11))
18+
19+
export = NS;
20+
>NS : Symbol(NS, Decl(type2.d.ts, 0, 11))
21+
22+
export as namespace ModuleATypes;
23+
>ModuleATypes : Symbol(ModuleATypes, Decl(type2.d.ts, 2, 12))
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/conformance/externalModules/type1.d.ts ===
2+
declare namespace NS {
3+
type A = object;
4+
>A : object
5+
}
6+
7+
export = NS;
8+
>NS : any
9+
10+
export as namespace MyTypes;
11+
>MyTypes : error
12+
13+
=== tests/cases/conformance/externalModules/type2.d.ts ===
14+
import type * as NS from './type1';
15+
>NS : error
16+
17+
export = NS;
18+
>NS : any
19+
20+
export as namespace ModuleATypes;
21+
>ModuleATypes : error
22+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// @verbatimModuleSyntax: true
2+
3+
// @Filename: type1.d.ts
4+
declare namespace NS {
5+
type A = object;
6+
}
7+
8+
export = NS;
9+
export as namespace MyTypes;
10+
11+
// @Filename: type2.d.ts
12+
import type * as NS from './type1';
13+
14+
export = NS;
15+
export as namespace ModuleATypes;

0 commit comments

Comments
 (0)