mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Recognize export * as default as a syntactic default export for synthetic default detection (#55985)
This commit is contained in:
parent
e9f68cb296
commit
21109b71aa
@ -4022,7 +4022,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function isSyntacticDefault(node: Node) {
|
||||
return ((isExportAssignment(node) && !node.isExportEquals) || hasSyntacticModifier(node, ModifierFlags.Default) || isExportSpecifier(node));
|
||||
return ((isExportAssignment(node) && !node.isExportEquals)
|
||||
|| hasSyntacticModifier(node, ModifierFlags.Default)
|
||||
|| isExportSpecifier(node)
|
||||
|| isNamespaceExport(node));
|
||||
}
|
||||
|
||||
function getUsageModeForExpression(usage: Expression) {
|
||||
|
||||
18
tests/baselines/reference/exportAsNamespace5.js
Normal file
18
tests/baselines/reference/exportAsNamespace5.js
Normal file
@ -0,0 +1,18 @@
|
||||
//// [tests/cases/conformance/es2020/modules/exportAsNamespace5.ts] ////
|
||||
|
||||
//// [three.d.ts]
|
||||
export type Named = 0;
|
||||
declare const Named: 0;
|
||||
|
||||
//// [two.d.ts]
|
||||
export * as default from "./three";
|
||||
|
||||
//// [one.ts]
|
||||
import ns from "./two";
|
||||
type Alias = ns.Named;
|
||||
ns.Named;
|
||||
|
||||
|
||||
//// [one.js]
|
||||
import ns from "./two";
|
||||
ns.Named;
|
||||
27
tests/baselines/reference/exportAsNamespace5.symbols
Normal file
27
tests/baselines/reference/exportAsNamespace5.symbols
Normal file
@ -0,0 +1,27 @@
|
||||
//// [tests/cases/conformance/es2020/modules/exportAsNamespace5.ts] ////
|
||||
|
||||
=== three.d.ts ===
|
||||
export type Named = 0;
|
||||
>Named : Symbol(Named, Decl(three.d.ts, 0, 0), Decl(three.d.ts, 1, 13))
|
||||
|
||||
declare const Named: 0;
|
||||
>Named : Symbol(Named, Decl(three.d.ts, 0, 0), Decl(three.d.ts, 1, 13))
|
||||
|
||||
=== two.d.ts ===
|
||||
export * as default from "./three";
|
||||
>default : Symbol(default, Decl(two.d.ts, 0, 6))
|
||||
|
||||
=== one.ts ===
|
||||
import ns from "./two";
|
||||
>ns : Symbol(ns, Decl(one.ts, 0, 6))
|
||||
|
||||
type Alias = ns.Named;
|
||||
>Alias : Symbol(Alias, Decl(one.ts, 0, 23))
|
||||
>ns : Symbol(ns, Decl(one.ts, 0, 6))
|
||||
>Named : Symbol(ns.Named, Decl(three.d.ts, 0, 0), Decl(three.d.ts, 1, 13))
|
||||
|
||||
ns.Named;
|
||||
>ns.Named : Symbol(ns.Named, Decl(three.d.ts, 0, 0), Decl(three.d.ts, 1, 13))
|
||||
>ns : Symbol(ns, Decl(one.ts, 0, 6))
|
||||
>Named : Symbol(ns.Named, Decl(three.d.ts, 0, 0), Decl(three.d.ts, 1, 13))
|
||||
|
||||
26
tests/baselines/reference/exportAsNamespace5.types
Normal file
26
tests/baselines/reference/exportAsNamespace5.types
Normal file
@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/es2020/modules/exportAsNamespace5.ts] ////
|
||||
|
||||
=== three.d.ts ===
|
||||
export type Named = 0;
|
||||
>Named : 0
|
||||
|
||||
declare const Named: 0;
|
||||
>Named : 0
|
||||
|
||||
=== two.d.ts ===
|
||||
export * as default from "./three";
|
||||
>default : typeof import("three")
|
||||
|
||||
=== one.ts ===
|
||||
import ns from "./two";
|
||||
>ns : typeof ns
|
||||
|
||||
type Alias = ns.Named;
|
||||
>Alias : 0
|
||||
>ns : any
|
||||
|
||||
ns.Named;
|
||||
>ns.Named : 0
|
||||
>ns : typeof ns
|
||||
>Named : 0
|
||||
|
||||
14
tests/cases/conformance/es2020/modules/exportAsNamespace5.ts
Normal file
14
tests/cases/conformance/es2020/modules/exportAsNamespace5.ts
Normal file
@ -0,0 +1,14 @@
|
||||
// @module: esnext
|
||||
// @moduleResolution: bundler
|
||||
|
||||
// @filename: three.d.ts
|
||||
export type Named = 0;
|
||||
declare const Named: 0;
|
||||
|
||||
// @filename: two.d.ts
|
||||
export * as default from "./three";
|
||||
|
||||
// @filename: one.ts
|
||||
import ns from "./two";
|
||||
type Alias = ns.Named;
|
||||
ns.Named;
|
||||
Loading…
x
Reference in New Issue
Block a user