mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 05:17:43 -05:00
Fix isolatedModules check for export assignments (#57148)
This commit is contained in:
@@ -46384,11 +46384,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
);
|
||||
}
|
||||
|
||||
if (!isIllegalExportDefaultInCJS && getIsolatedModules(compilerOptions) && !(sym.flags & SymbolFlags.Value)) {
|
||||
if (!isIllegalExportDefaultInCJS && !(node.flags & NodeFlags.Ambient) && getIsolatedModules(compilerOptions) && !(sym.flags & SymbolFlags.Value)) {
|
||||
const nonLocalMeanings = getSymbolFlags(sym, /*excludeTypeOnlyMeanings*/ false, /*excludeLocalMeanings*/ true);
|
||||
if (
|
||||
sym.flags & SymbolFlags.Alias
|
||||
&& resolveAlias(sym) !== unknownSymbol
|
||||
&& getSymbolFlags(sym, /*excludeTypeOnlyMeanings*/ false, /*excludeLocalMeanings*/ true) & SymbolFlags.Type
|
||||
&& nonLocalMeanings & SymbolFlags.Type
|
||||
&& !(nonLocalMeanings & SymbolFlags.Value)
|
||||
&& (!typeOnlyDeclaration || getSourceFileOfNode(typeOnlyDeclaration) !== getSourceFileOfNode(node))
|
||||
) {
|
||||
// import { SomeType } from "./someModule";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/b.ts(3,5): error TS1362: 'A' cannot be used as a value because it was exported using 'export type'.
|
||||
/d.ts(2,10): error TS1291: 'A' resolves to a type and must be marked type-only in this file before re-exporting when 'isolatedModules' is enabled. Consider using 'import type' where 'A' is imported.
|
||||
/d.ts(2,10): error TS1289: 'A' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when 'isolatedModules' is enabled. Consider using 'import type' where 'A' is imported.
|
||||
|
||||
|
||||
==== /a.ts (0 errors) ====
|
||||
@@ -22,4 +22,5 @@
|
||||
import { A } from './a';
|
||||
export = A;
|
||||
~
|
||||
!!! error TS1291: 'A' resolves to a type and must be marked type-only in this file before re-exporting when 'isolatedModules' is enabled. Consider using 'import type' where 'A' is imported.
|
||||
!!! error TS1289: 'A' resolves to a type-only declaration and must be marked type-only in this file before re-exporting when 'isolatedModules' is enabled. Consider using 'import type' where 'A' is imported.
|
||||
!!! related TS1377 /a.ts:2:15: 'A' was exported here.
|
||||
25
tests/cases/compiler/isolatedModulesReExportAlias.ts
Normal file
25
tests/cases/compiler/isolatedModulesReExportAlias.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// @isolatedModules: true
|
||||
// @noEmit: true
|
||||
// @noTypesAndSymbols: true
|
||||
|
||||
// @Filename: /events.d.ts
|
||||
declare module "events" {
|
||||
interface EventEmitterOptions {
|
||||
captureRejections?: boolean;
|
||||
}
|
||||
class EventEmitter {
|
||||
constructor(options?: EventEmitterOptions);
|
||||
}
|
||||
export = EventEmitter;
|
||||
}
|
||||
declare module "node:events" {
|
||||
import events = require("events");
|
||||
export = events;
|
||||
}
|
||||
|
||||
// @Filename: /moreEvents.ts
|
||||
import events = require("events");
|
||||
export = events;
|
||||
|
||||
// @Filename: /boo.ts
|
||||
// Bad test runner (ignores stuff when last file contains the string r-e-q-u-i-r-e)
|
||||
Reference in New Issue
Block a user