mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-23 10:04:47 -05:00
Visit default export expressions (#18977)
This commit is contained in:
@@ -861,10 +861,10 @@ namespace ts {
|
||||
if (original && hasAssociatedEndOfDeclarationMarker(original)) {
|
||||
// Defer exports until we encounter an EndOfDeclarationMarker node
|
||||
const id = getOriginalNodeId(node);
|
||||
deferredExports[id] = appendExportStatement(deferredExports[id], createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true);
|
||||
deferredExports[id] = appendExportStatement(deferredExports[id], createIdentifier("default"), visitNode(node.expression, importCallExpressionVisitor), /*location*/ node, /*allowComments*/ true);
|
||||
}
|
||||
else {
|
||||
statements = appendExportStatement(statements, createIdentifier("default"), node.expression, /*location*/ node, /*allowComments*/ true);
|
||||
statements = appendExportStatement(statements, createIdentifier("default"), visitNode(node.expression, importCallExpressionVisitor), /*location*/ node, /*allowComments*/ true);
|
||||
}
|
||||
|
||||
return singleOrMany(statements);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
tests/cases/compiler/dynamicImportInDefaultExportExpression.ts(3,23): error TS2307: Cannot find module './foo2'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/dynamicImportInDefaultExportExpression.ts (1 errors) ====
|
||||
export default {
|
||||
getInstance: function () {
|
||||
return import('./foo2');
|
||||
~~~~~~~~
|
||||
!!! error TS2307: Cannot find module './foo2'.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [dynamicImportInDefaultExportExpression.ts]
|
||||
export default {
|
||||
getInstance: function () {
|
||||
return import('./foo2');
|
||||
}
|
||||
}
|
||||
|
||||
//// [dynamicImportInDefaultExportExpression.js]
|
||||
"use strict";
|
||||
exports.__esModule = true;
|
||||
exports["default"] = {
|
||||
getInstance: function () {
|
||||
return Promise.resolve().then(function () { return require('./foo2'); });
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/dynamicImportInDefaultExportExpression.ts ===
|
||||
export default {
|
||||
getInstance: function () {
|
||||
>getInstance : Symbol(getInstance, Decl(dynamicImportInDefaultExportExpression.ts, 0, 16))
|
||||
|
||||
return import('./foo2');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
=== tests/cases/compiler/dynamicImportInDefaultExportExpression.ts ===
|
||||
export default {
|
||||
>{ getInstance: function () { return import('./foo2'); }} : { getInstance: () => Promise<any>; }
|
||||
|
||||
getInstance: function () {
|
||||
>getInstance : () => Promise<any>
|
||||
>function () { return import('./foo2'); } : () => Promise<any>
|
||||
|
||||
return import('./foo2');
|
||||
>import('./foo2') : Promise<any>
|
||||
>'./foo2' : "./foo2"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
export default {
|
||||
getInstance: function () {
|
||||
return import('./foo2');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user