mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Get export symbol if needed for verbatimModuleSyntax check on default/equals exports (#52448)
This commit is contained in:
@@ -43909,7 +43909,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
|
||||
if (node.expression.kind === SyntaxKind.Identifier) {
|
||||
const id = node.expression as Identifier;
|
||||
const sym = resolveEntityName(id, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node);
|
||||
const sym = getExportSymbolOfValueSymbolIfExported(resolveEntityName(id, SymbolFlags.All, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, node));
|
||||
if (sym) {
|
||||
markAliasReferenced(sym, id);
|
||||
// If not a value, we're interpreting the identifier as a type export, along the lines of (`export { Id as default }`)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//// [tests/cases/compiler/verbatimModuleSyntaxDefaultValue.ts] ////
|
||||
|
||||
//// [package.json]
|
||||
{ "name": "foo", "type": "module" }
|
||||
|
||||
//// [index.ts]
|
||||
class Task {}
|
||||
|
||||
function task(): Task { return new Task(); }
|
||||
|
||||
export const build = task();
|
||||
export default build;
|
||||
|
||||
|
||||
//// [index.js]
|
||||
class Task {
|
||||
}
|
||||
function task() { return new Task(); }
|
||||
export const build = task();
|
||||
export default build;
|
||||
@@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
class Task {}
|
||||
>Task : Symbol(Task, Decl(index.ts, 0, 0))
|
||||
|
||||
function task(): Task { return new Task(); }
|
||||
>task : Symbol(task, Decl(index.ts, 0, 13))
|
||||
>Task : Symbol(Task, Decl(index.ts, 0, 0))
|
||||
>Task : Symbol(Task, Decl(index.ts, 0, 0))
|
||||
|
||||
export const build = task();
|
||||
>build : Symbol(build, Decl(index.ts, 4, 12))
|
||||
>task : Symbol(task, Decl(index.ts, 0, 13))
|
||||
|
||||
export default build;
|
||||
>build : Symbol(build, Decl(index.ts, 4, 12))
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/index.ts ===
|
||||
class Task {}
|
||||
>Task : Task
|
||||
|
||||
function task(): Task { return new Task(); }
|
||||
>task : () => Task
|
||||
>new Task() : Task
|
||||
>Task : typeof Task
|
||||
|
||||
export const build = task();
|
||||
>build : Task
|
||||
>task() : Task
|
||||
>task : () => Task
|
||||
|
||||
export default build;
|
||||
>build : Task
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// @verbatimModuleSyntax: true
|
||||
// @module: node16
|
||||
// @moduleResolution: node16
|
||||
// @target: es2018
|
||||
|
||||
// @filename: package.json
|
||||
{ "name": "foo", "type": "module" }
|
||||
|
||||
// @filename: index.ts
|
||||
class Task {}
|
||||
|
||||
function task(): Task { return new Task(); }
|
||||
|
||||
export const build = task();
|
||||
export default build;
|
||||
Reference in New Issue
Block a user