Skip to content

Commit 81f6282

Browse files
committed
Revert recognizing invalid forms as type-only
1 parent 7615d29 commit 81f6282

File tree

7 files changed

+19
-33
lines changed

7 files changed

+19
-33
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,12 +2457,7 @@ namespace ts {
24572457
const name = (specifier.propertyName ?? specifier.name).escapedText;
24582458
const exportSymbol = getExportsOfSymbol(symbol).get(name);
24592459
const resolved = resolveSymbol(exportSymbol, dontResolveAlias);
2460-
if (!markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false)) {
2461-
if (resolved && symbol.exports && !symbol.exports.has(name)) {
2462-
// `resolved` must have come from a namespace export, which could be `export type *`
2463-
markSymbolOfAliasDeclarationIfTypeOnly(specifier, symbol.exports.get(InternalSymbolName.ExportStar), /*finalTarget*/ undefined, /*overwriteEmpty*/ true);
2464-
}
2465-
}
2460+
markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, /*overwriteEmpty*/ false);
24662461
return resolved;
24672462
}
24682463
}
@@ -3272,7 +3267,6 @@ namespace ts {
32723267
const lookupTable = createMap<ExportCollisionTracker>() as ExportCollisionTrackerTable;
32733268
for (const node of exportStars.declarations) {
32743269
const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier!);
3275-
markSymbolOfAliasDeclarationIfTypeOnly(node, resolvedModule, /*finalTarget*/ undefined, /*overwriteEmpty*/ false);
32763270
const exportedSymbols = visit(resolvedModule);
32773271
extendExportSymbols(
32783272
nestedSymbols,

src/compiler/utilitiesPublic.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,11 +1727,9 @@ namespace ts {
17271727
case SyntaxKind.ExportSpecifier:
17281728
return (node as ImportOrExportSpecifier).parent.parent.isTypeOnly;
17291729
case SyntaxKind.NamespaceImport:
1730-
case SyntaxKind.NamespaceExport:
1731-
return (node as NamespaceImport | NamespaceExport).parent.isTypeOnly;
1730+
return (node as NamespaceImport).parent.isTypeOnly;
17321731
case SyntaxKind.ImportClause:
1733-
case SyntaxKind.ExportDeclaration:
1734-
return (node as ImportClause | ExportDeclaration).isTypeOnly;
1732+
return (node as ImportClause).isTypeOnly;
17351733
default:
17361734
return false;
17371735
}
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
tests/cases/conformance/externalModules/typeOnly/b.ts(1,1): error TS1383: Only named exports may use 'export type'.
22
tests/cases/conformance/externalModules/typeOnly/c.ts(1,1): error TS1383: Only named exports may use 'export type'.
3-
tests/cases/conformance/externalModules/typeOnly/d.ts(2,1): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
4-
tests/cases/conformance/externalModules/typeOnly/e.ts(2,1): error TS1362: 'ns' cannot be used as a value because it was exported using 'export type'.
53

64

75
==== tests/cases/conformance/externalModules/typeOnly/a.ts (0 errors) ====
@@ -17,17 +15,11 @@ tests/cases/conformance/externalModules/typeOnly/e.ts(2,1): error TS1362: 'ns' c
1715
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1816
!!! error TS1383: Only named exports may use 'export type'.
1917

20-
==== tests/cases/conformance/externalModules/typeOnly/d.ts (1 errors) ====
18+
==== tests/cases/conformance/externalModules/typeOnly/d.ts (0 errors) ====
2119
import { A } from './b';
22-
A; // Error
23-
~
24-
!!! error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
25-
!!! related TS1377 tests/cases/conformance/externalModules/typeOnly/b.ts:1:1: 'A' was exported here.
20+
A;
2621

27-
==== tests/cases/conformance/externalModules/typeOnly/e.ts (1 errors) ====
22+
==== tests/cases/conformance/externalModules/typeOnly/e.ts (0 errors) ====
2823
import { ns } from './c';
29-
ns.A; // Error
30-
~~
31-
!!! error TS1362: 'ns' cannot be used as a value because it was exported using 'export type'.
32-
!!! related TS1377 tests/cases/conformance/externalModules/typeOnly/c.ts:1:13: 'ns' was exported here.
24+
ns.A;
3325

tests/baselines/reference/exportNamespace4.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export type * as ns from './a'; // Grammar error
1111

1212
//// [d.ts]
1313
import { A } from './b';
14-
A; // Error
14+
A;
1515

1616
//// [e.ts]
1717
import { ns } from './c';
18-
ns.A; // Error
18+
ns.A;
1919

2020

2121
//// [a.js]
@@ -36,8 +36,10 @@ exports.__esModule = true;
3636
//// [d.js]
3737
"use strict";
3838
exports.__esModule = true;
39-
A; // Error
39+
var b_1 = require("./b");
40+
b_1.A;
4041
//// [e.js]
4142
"use strict";
4243
exports.__esModule = true;
43-
ns.A; // Error
44+
var c_1 = require("./c");
45+
c_1.ns.A;

tests/baselines/reference/exportNamespace4.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ export type * as ns from './a'; // Grammar error
1313
import { A } from './b';
1414
>A : Symbol(A, Decl(d.ts, 0, 8))
1515

16-
A; // Error
16+
A;
1717
>A : Symbol(A, Decl(d.ts, 0, 8))
1818

1919
=== tests/cases/conformance/externalModules/typeOnly/e.ts ===
2020
import { ns } from './c';
2121
>ns : Symbol(ns, Decl(e.ts, 0, 8))
2222

23-
ns.A; // Error
23+
ns.A;
2424
>ns.A : Symbol(ns.A, Decl(a.ts, 0, 0))
2525
>ns : Symbol(ns, Decl(e.ts, 0, 8))
2626
>A : Symbol(ns.A, Decl(a.ts, 0, 0))

tests/baselines/reference/exportNamespace4.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ export type * as ns from './a'; // Grammar error
1313
import { A } from './b';
1414
>A : typeof A
1515

16-
A; // Error
16+
A;
1717
>A : typeof A
1818

1919
=== tests/cases/conformance/externalModules/typeOnly/e.ts ===
2020
import { ns } from './c';
2121
>ns : typeof ns
2222

23-
ns.A; // Error
23+
ns.A;
2424
>ns.A : typeof ns.A
2525
>ns : typeof ns
2626
>A : typeof ns.A

tests/cases/conformance/externalModules/typeOnly/exportNamespace4.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export type * as ns from './a'; // Grammar error
99

1010
// @Filename: d.ts
1111
import { A } from './b';
12-
A; // Error
12+
A;
1313

1414
// @Filename: e.ts
1515
import { ns } from './c';
16-
ns.A; // Error
16+
ns.A;

0 commit comments

Comments
 (0)