mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
Add support for import defer proposal (#60757)
Co-authored-by: Ujjwal Sharma <ryzokuken@disroot.org> Co-authored-by: Nicolò Ribaudo <hell@nicr.dev>
This commit is contained in:
138 files changed
+2710
-292
No files matched your search
+58
-13
@@ -10247,7 +10247,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(
|
||||
/*isTypeOnly*/ false,
|
||||
/*phaseModifier*/ undefined,
|
||||
/*name*/ undefined,
|
||||
factory.createNamedImports([factory.createImportSpecifier(
|
||||
/*isTypeOnly*/ false,
|
||||
@@ -10344,7 +10344,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
addResult(
|
||||
factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(isTypeOnly, factory.createIdentifier(localName), /*namedBindings*/ undefined),
|
||||
factory.createImportClause(
|
||||
/* phaseModifier */ isTypeOnly ? SyntaxKind.TypeKeyword : undefined,
|
||||
factory.createIdentifier(localName),
|
||||
/*namedBindings*/ undefined,
|
||||
),
|
||||
specifier,
|
||||
attributes,
|
||||
),
|
||||
@@ -10360,7 +10364,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
addResult(
|
||||
factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(isTypeOnly, /*name*/ undefined, factory.createNamespaceImport(factory.createIdentifier(localName))),
|
||||
factory.createImportClause(
|
||||
/* phaseModifier */ isTypeOnly ? SyntaxKind.TypeKeyword : undefined,
|
||||
/*name*/ undefined,
|
||||
factory.createNamespaceImport(factory.createIdentifier(localName)),
|
||||
),
|
||||
specifier,
|
||||
(node as ImportClause).parent.attributes,
|
||||
),
|
||||
@@ -10389,7 +10397,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(
|
||||
isTypeOnly,
|
||||
/* phaseModifier */ isTypeOnly ? SyntaxKind.TypeKeyword : undefined,
|
||||
/*name*/ undefined,
|
||||
factory.createNamedImports([
|
||||
factory.createImportSpecifier(
|
||||
@@ -38014,6 +38022,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
if (node.keywordToken === SyntaxKind.ImportKeyword) {
|
||||
if (node.name.escapedText === "defer") {
|
||||
Debug.assert(!isCallExpression(node.parent) || node.parent.expression !== node, "Trying to get the type of `import.defer` in `import.defer(...)`");
|
||||
return errorType;
|
||||
}
|
||||
return checkImportMetaProperty(node);
|
||||
}
|
||||
|
||||
@@ -41452,7 +41464,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
// Optimize for the common case of a call to a function with a single non-generic call
|
||||
// signature where we can just fetch the return type without checking the arguments.
|
||||
if (isCallExpression(expr) && expr.expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !isSymbolOrSymbolForCall(expr)) {
|
||||
if (isCallExpression(expr) && expr.expression.kind !== SyntaxKind.SuperKeyword && !isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !isSymbolOrSymbolForCall(expr) && !isImportCall(expr)) {
|
||||
return isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
|
||||
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
|
||||
}
|
||||
@@ -41606,8 +41618,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
case SyntaxKind.ElementAccessExpression:
|
||||
return checkIndexedAccess(node as ElementAccessExpression, checkMode);
|
||||
case SyntaxKind.CallExpression:
|
||||
if ((node as CallExpression).expression.kind === SyntaxKind.ImportKeyword) {
|
||||
return checkImportCallExpression(node as ImportCall);
|
||||
if (isImportCall(node)) {
|
||||
return checkImportCallExpression(node);
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.NewExpression:
|
||||
@@ -49877,6 +49889,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return isExportAssignment(node.parent) ? Debug.checkDefined(node.parent.symbol) : undefined;
|
||||
|
||||
case SyntaxKind.ImportKeyword:
|
||||
if (isMetaProperty(node.parent) && node.parent.name.escapedText === "defer") {
|
||||
return undefined;
|
||||
}
|
||||
// falls through
|
||||
case SyntaxKind.NewKeyword:
|
||||
return isMetaProperty(node.parent) ? checkMetaPropertyKeyword(node.parent).symbol : undefined;
|
||||
case SyntaxKind.InstanceOfKeyword:
|
||||
@@ -52851,7 +52867,18 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
break;
|
||||
case SyntaxKind.ImportKeyword:
|
||||
if (escapedText !== "meta") {
|
||||
return grammarErrorOnNode(node.name, Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, unescapeLeadingUnderscores(node.name.escapedText), tokenToString(node.keywordToken), "meta");
|
||||
const isCallee = isCallExpression(node.parent) && node.parent.expression === node;
|
||||
if (escapedText === "defer") {
|
||||
if (!isCallee) {
|
||||
return grammarErrorAtPos(node, node.end, 0, Diagnostics._0_expected, "(");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isCallee) {
|
||||
return grammarErrorOnNode(node.name, Diagnostics._0_is_not_a_valid_meta_property_for_keyword_import_Did_you_mean_meta_or_defer, unescapeLeadingUnderscores(node.name.escapedText));
|
||||
}
|
||||
return grammarErrorOnNode(node.name, Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, unescapeLeadingUnderscores(node.name.escapedText), tokenToString(node.keywordToken), "meta");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -53110,11 +53137,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function checkGrammarImportClause(node: ImportClause): boolean {
|
||||
if (node.isTypeOnly && node.name && node.namedBindings) {
|
||||
return grammarErrorOnNode(node, Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
|
||||
if (node.phaseModifier === SyntaxKind.TypeKeyword) {
|
||||
if (node.name && node.namedBindings) {
|
||||
return grammarErrorOnNode(node, Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
|
||||
}
|
||||
if (node.namedBindings?.kind === SyntaxKind.NamedImports) {
|
||||
return checkGrammarNamedImportsOrExports(node.namedBindings);
|
||||
}
|
||||
}
|
||||
if (node.isTypeOnly && node.namedBindings?.kind === SyntaxKind.NamedImports) {
|
||||
return checkGrammarNamedImportsOrExports(node.namedBindings);
|
||||
else if (node.phaseModifier === SyntaxKind.DeferKeyword) {
|
||||
if (node.name) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Default_imports_are_not_allowed_in_a_deferred_import);
|
||||
}
|
||||
if (node.namedBindings?.kind === SyntaxKind.NamedImports) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Named_imports_are_not_allowed_in_a_deferred_import);
|
||||
}
|
||||
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.Preserve) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Deferred_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_or_preserve);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -53137,7 +53177,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
return grammarErrorOnNode(node, Diagnostics.ESM_syntax_is_not_allowed_in_a_CommonJS_module_when_verbatimModuleSyntax_is_enabled);
|
||||
}
|
||||
|
||||
if (moduleKind === ModuleKind.ES2015) {
|
||||
if (node.expression.kind === SyntaxKind.MetaProperty) {
|
||||
if (moduleKind !== ModuleKind.ESNext && moduleKind !== ModuleKind.Preserve) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Deferred_imports_are_only_supported_when_the_module_flag_is_set_to_esnext_or_preserve);
|
||||
}
|
||||
}
|
||||
else if (moduleKind === ModuleKind.ES2015) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_es2022_esnext_commonjs_amd_system_umd_node16_node18_or_nodenext);
|
||||
}
|
||||
|
||||
|
||||
@@ -8487,5 +8487,21 @@
|
||||
"String literal import and export names are not supported when the '--module' flag is set to 'es2015' or 'es2020'.": {
|
||||
"category": "Error",
|
||||
"code": 18057
|
||||
},
|
||||
"Default imports are not allowed in a deferred import.": {
|
||||
"category": "Error",
|
||||
"code": 18058
|
||||
},
|
||||
"Named imports are not allowed in a deferred import.": {
|
||||
"category": "Error",
|
||||
"code": 18059
|
||||
},
|
||||
"Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.": {
|
||||
"category": "Error",
|
||||
"code": 18060
|
||||
},
|
||||
"'{0}' is not a valid meta-property for keyword 'import'. Did you mean 'meta' or 'defer'?": {
|
||||
"category": "Error",
|
||||
"code": 18061
|
||||
}
|
||||
}
|
||||
@@ -3686,8 +3686,8 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri
|
||||
}
|
||||
|
||||
function emitImportClause(node: ImportClause) {
|
||||
if (node.isTypeOnly) {
|
||||
emitTokenWithComment(SyntaxKind.TypeKeyword, node.pos, writeKeyword, node);
|
||||
if (node.phaseModifier !== undefined) {
|
||||
emitTokenWithComment(node.phaseModifier, node.pos, writeKeyword, node);
|
||||
writeSpace();
|
||||
}
|
||||
emit(node.name);
|
||||
|
||||
@@ -135,6 +135,7 @@ import {
|
||||
ImportClause,
|
||||
ImportDeclaration,
|
||||
ImportEqualsDeclaration,
|
||||
ImportPhaseModifierSyntaxKind,
|
||||
ImportSpecifier,
|
||||
ImportTypeAssertionContainer,
|
||||
ImportTypeNode,
|
||||
@@ -4723,14 +4724,18 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
}
|
||||
|
||||
// @api
|
||||
function createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause {
|
||||
function createImportClause(phaseModifier: ImportPhaseModifierSyntaxKind | boolean | undefined, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause {
|
||||
const node = createBaseDeclaration<ImportClause>(SyntaxKind.ImportClause);
|
||||
node.isTypeOnly = isTypeOnly;
|
||||
if (typeof phaseModifier === "boolean") {
|
||||
phaseModifier = phaseModifier ? SyntaxKind.TypeKeyword : undefined;
|
||||
}
|
||||
node.isTypeOnly = phaseModifier === SyntaxKind.TypeKeyword;
|
||||
node.phaseModifier = phaseModifier;
|
||||
node.name = name;
|
||||
node.namedBindings = namedBindings;
|
||||
node.transformFlags |= propagateChildFlags(node.name) |
|
||||
propagateChildFlags(node.namedBindings);
|
||||
if (isTypeOnly) {
|
||||
if (phaseModifier === SyntaxKind.TypeKeyword) {
|
||||
node.transformFlags |= TransformFlags.ContainsTypeScript;
|
||||
}
|
||||
node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context
|
||||
@@ -4738,11 +4743,14 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode
|
||||
}
|
||||
|
||||
// @api
|
||||
function updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined) {
|
||||
return node.isTypeOnly !== isTypeOnly
|
||||
function updateImportClause(node: ImportClause, phaseModifier: ImportPhaseModifierSyntaxKind | boolean | undefined, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined) {
|
||||
if (typeof phaseModifier === "boolean") {
|
||||
phaseModifier = phaseModifier ? SyntaxKind.TypeKeyword : undefined;
|
||||
}
|
||||
return node.phaseModifier !== phaseModifier
|
||||
|| node.name !== name
|
||||
|| node.namedBindings !== namedBindings
|
||||
? update(createImportClause(isTypeOnly, name, namedBindings), node)
|
||||
? update(createImportClause(phaseModifier, name, namedBindings), node)
|
||||
: node;
|
||||
}
|
||||
|
||||
|
||||
@@ -730,7 +730,7 @@ export function createExternalHelpersImportDeclarationIfNeeded(nodeFactory: Node
|
||||
|
||||
const externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings),
|
||||
nodeFactory.createImportClause(/*phaseModifier*/ undefined, /*name*/ undefined, namedBindings),
|
||||
nodeFactory.createStringLiteral(externalHelpersModuleNameText),
|
||||
/*attributes*/ undefined,
|
||||
);
|
||||
|
||||
+33
-13
@@ -123,6 +123,7 @@ import {
|
||||
ImportDeclaration,
|
||||
ImportEqualsDeclaration,
|
||||
ImportOrExportSpecifier,
|
||||
ImportPhaseModifierSyntaxKind,
|
||||
ImportSpecifier,
|
||||
ImportTypeAssertionContainer,
|
||||
ImportTypeNode,
|
||||
@@ -5938,7 +5939,15 @@ namespace Parser {
|
||||
nextToken(); // advance past the 'import'
|
||||
nextToken(); // advance past the dot
|
||||
expression = finishNode(factory.createMetaProperty(SyntaxKind.ImportKeyword, parseIdentifierName()), pos);
|
||||
sourceFlags |= NodeFlags.PossiblyContainsImportMeta;
|
||||
|
||||
if ((expression as MetaProperty).name.escapedText === "defer") {
|
||||
if (token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) {
|
||||
sourceFlags |= NodeFlags.PossiblyContainsDynamicImport;
|
||||
}
|
||||
}
|
||||
else {
|
||||
sourceFlags |= NodeFlags.PossiblyContainsImportMeta;
|
||||
}
|
||||
}
|
||||
else {
|
||||
expression = parseMemberExpressionOrHigher();
|
||||
@@ -7190,6 +7199,7 @@ namespace Parser {
|
||||
// could be legal, it would add complexity for very little gain.
|
||||
case SyntaxKind.InterfaceKeyword:
|
||||
case SyntaxKind.TypeKeyword:
|
||||
case SyntaxKind.DeferKeyword:
|
||||
return nextTokenIsIdentifierOnSameLine();
|
||||
case SyntaxKind.ModuleKeyword:
|
||||
case SyntaxKind.NamespaceKeyword:
|
||||
@@ -7221,7 +7231,7 @@ namespace Parser {
|
||||
|
||||
case SyntaxKind.ImportKeyword:
|
||||
nextToken();
|
||||
return token() === SyntaxKind.StringLiteral || token() === SyntaxKind.AsteriskToken ||
|
||||
return token() === SyntaxKind.DeferKeyword || token() === SyntaxKind.StringLiteral || token() === SyntaxKind.AsteriskToken ||
|
||||
token() === SyntaxKind.OpenBraceToken || tokenIsIdentifierOrKeyword(token());
|
||||
case SyntaxKind.ExportKeyword:
|
||||
let currentToken = nextToken();
|
||||
@@ -7295,6 +7305,7 @@ namespace Parser {
|
||||
case SyntaxKind.NamespaceKeyword:
|
||||
case SyntaxKind.TypeKeyword:
|
||||
case SyntaxKind.GlobalKeyword:
|
||||
case SyntaxKind.DeferKeyword:
|
||||
// When these don't start a declaration, they're an identifier in an expression statement
|
||||
return true;
|
||||
|
||||
@@ -8372,21 +8383,25 @@ namespace Parser {
|
||||
identifier = parseIdentifier();
|
||||
}
|
||||
|
||||
let isTypeOnly = false;
|
||||
let phaseModifier: ImportPhaseModifierSyntaxKind | undefined;
|
||||
if (
|
||||
identifier?.escapedText === "type" &&
|
||||
(token() !== SyntaxKind.FromKeyword || isIdentifier() && lookAhead(nextTokenIsFromKeywordOrEqualsToken)) &&
|
||||
(isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())
|
||||
) {
|
||||
isTypeOnly = true;
|
||||
phaseModifier = SyntaxKind.TypeKeyword;
|
||||
identifier = isIdentifier() ? parseIdentifier() : undefined;
|
||||
}
|
||||
else if (identifier?.escapedText === "defer" && token() !== SyntaxKind.FromKeyword) {
|
||||
phaseModifier = SyntaxKind.DeferKeyword;
|
||||
identifier = isIdentifier() ? parseIdentifier() : undefined;
|
||||
}
|
||||
|
||||
if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration()) {
|
||||
return parseImportEqualsDeclaration(pos, hasJSDoc, modifiers, identifier, isTypeOnly);
|
||||
if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() && phaseModifier !== SyntaxKind.DeferKeyword) {
|
||||
return parseImportEqualsDeclaration(pos, hasJSDoc, modifiers, identifier, phaseModifier === SyntaxKind.TypeKeyword);
|
||||
}
|
||||
|
||||
const importClause = tryParseImportClause(identifier, afterImportPos, isTypeOnly);
|
||||
const importClause = tryParseImportClause(identifier, afterImportPos, phaseModifier, /*skipJsDocLeadingAsterisks*/ undefined);
|
||||
const moduleSpecifier = parseModuleSpecifier();
|
||||
const attributes = tryParseImportAttributes();
|
||||
|
||||
@@ -8395,7 +8410,7 @@ namespace Parser {
|
||||
return withJSDoc(finishNode(node, pos), hasJSDoc);
|
||||
}
|
||||
|
||||
function tryParseImportClause(identifier: Identifier | undefined, pos: number, isTypeOnly: boolean, skipJsDocLeadingAsterisks = false) {
|
||||
function tryParseImportClause(identifier: Identifier | undefined, pos: number, phaseModifier: undefined | ImportPhaseModifierSyntaxKind, skipJsDocLeadingAsterisks = false) {
|
||||
// ImportDeclaration:
|
||||
// import ImportClause from ModuleSpecifier ;
|
||||
// import ModuleSpecifier;
|
||||
@@ -8405,7 +8420,7 @@ namespace Parser {
|
||||
token() === SyntaxKind.AsteriskToken || // import *
|
||||
token() === SyntaxKind.OpenBraceToken // import {
|
||||
) {
|
||||
importClause = parseImportClause(identifier, pos, isTypeOnly, skipJsDocLeadingAsterisks);
|
||||
importClause = parseImportClause(identifier, pos, phaseModifier, skipJsDocLeadingAsterisks);
|
||||
parseExpected(SyntaxKind.FromKeyword);
|
||||
}
|
||||
return importClause;
|
||||
@@ -8471,7 +8486,7 @@ namespace Parser {
|
||||
return finished;
|
||||
}
|
||||
|
||||
function parseImportClause(identifier: Identifier | undefined, pos: number, isTypeOnly: boolean, skipJsDocLeadingAsterisks: boolean) {
|
||||
function parseImportClause(identifier: Identifier | undefined, pos: number, phaseModifier: undefined | ImportPhaseModifierSyntaxKind, skipJsDocLeadingAsterisks: boolean) {
|
||||
// ImportClause:
|
||||
// ImportedDefaultBinding
|
||||
// NameSpaceImport
|
||||
@@ -8487,11 +8502,16 @@ namespace Parser {
|
||||
parseOptional(SyntaxKind.CommaToken)
|
||||
) {
|
||||
if (skipJsDocLeadingAsterisks) scanner.setSkipJsDocLeadingAsterisks(true);
|
||||
namedBindings = token() === SyntaxKind.AsteriskToken ? parseNamespaceImport() : parseNamedImportsOrExports(SyntaxKind.NamedImports);
|
||||
if (token() === SyntaxKind.AsteriskToken) {
|
||||
namedBindings = parseNamespaceImport();
|
||||
}
|
||||
else {
|
||||
namedBindings = parseNamedImportsOrExports(SyntaxKind.NamedImports);
|
||||
}
|
||||
if (skipJsDocLeadingAsterisks) scanner.setSkipJsDocLeadingAsterisks(false);
|
||||
}
|
||||
|
||||
return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos);
|
||||
return finishNode(factory.createImportClause(phaseModifier, identifier, namedBindings), pos);
|
||||
}
|
||||
|
||||
function parseModuleReference() {
|
||||
@@ -9525,7 +9545,7 @@ namespace Parser {
|
||||
identifier = parseIdentifier();
|
||||
}
|
||||
|
||||
const importClause = tryParseImportClause(identifier, afterImportTagPos, /*isTypeOnly*/ true, /*skipJsDocLeadingAsterisks*/ true);
|
||||
const importClause = tryParseImportClause(identifier, afterImportTagPos, SyntaxKind.TypeKeyword, /*skipJsDocLeadingAsterisks*/ true);
|
||||
const moduleSpecifier = parseModuleSpecifier();
|
||||
const attributes = tryParseImportAttributes();
|
||||
|
||||
|
||||
@@ -151,6 +151,7 @@ export const textToKeywordObj: MapLike<KeywordSyntaxKind> = {
|
||||
debugger: SyntaxKind.DebuggerKeyword,
|
||||
declare: SyntaxKind.DeclareKeyword,
|
||||
default: SyntaxKind.DefaultKeyword,
|
||||
defer: SyntaxKind.DeferKeyword,
|
||||
delete: SyntaxKind.DeleteKeyword,
|
||||
do: SyntaxKind.DoKeyword,
|
||||
else: SyntaxKind.ElseKeyword,
|
||||
|
||||
@@ -877,6 +877,7 @@ export function transformDeclarations(context: TransformationContext): Transform
|
||||
tryGetResolutionModeOverride(decl.attributes),
|
||||
);
|
||||
}
|
||||
const phaseModifier = decl.importClause.phaseModifier === SyntaxKind.DeferKeyword ? undefined : decl.importClause.phaseModifier;
|
||||
// The `importClause` visibility corresponds to the default's visibility.
|
||||
const visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
|
||||
if (!decl.importClause.namedBindings) {
|
||||
@@ -886,7 +887,7 @@ export function transformDeclarations(context: TransformationContext): Transform
|
||||
decl.modifiers,
|
||||
factory.updateImportClause(
|
||||
decl.importClause,
|
||||
decl.importClause.isTypeOnly,
|
||||
phaseModifier,
|
||||
visibleDefaultBinding,
|
||||
/*namedBindings*/ undefined,
|
||||
),
|
||||
@@ -902,7 +903,7 @@ export function transformDeclarations(context: TransformationContext): Transform
|
||||
decl.modifiers,
|
||||
factory.updateImportClause(
|
||||
decl.importClause,
|
||||
decl.importClause.isTypeOnly,
|
||||
phaseModifier,
|
||||
visibleDefaultBinding,
|
||||
namedBindings,
|
||||
),
|
||||
@@ -918,7 +919,7 @@ export function transformDeclarations(context: TransformationContext): Transform
|
||||
decl.modifiers,
|
||||
factory.updateImportClause(
|
||||
decl.importClause,
|
||||
decl.importClause.isTypeOnly,
|
||||
phaseModifier,
|
||||
visibleDefaultBinding,
|
||||
bindingList && bindingList.length ? factory.updateNamedImports(decl.importClause.namedBindings, bindingList) : undefined,
|
||||
),
|
||||
|
||||
@@ -172,7 +172,7 @@ export function transformJsx(context: TransformationContext): (x: SourceFile | B
|
||||
for (const [importSource, importSpecifiersMap] of arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries())) {
|
||||
if (isExternalModule(node)) {
|
||||
// Add `import` statement
|
||||
const importStatement = factory.createImportDeclaration(/*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, factory.createNamedImports(arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), /*attributes*/ undefined);
|
||||
const importStatement = factory.createImportDeclaration(/*modifiers*/ undefined, factory.createImportClause(/*phaseModifier*/ undefined, /*name*/ undefined, factory.createNamedImports(arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), /*attributes*/ undefined);
|
||||
setParentRecursive(importStatement, /*incremental*/ false);
|
||||
statements = insertStatementAfterCustomPrologue(statements.slice(), importStatement);
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S
|
||||
const importStatement = factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(
|
||||
/*isTypeOnly*/ false,
|
||||
/*phaseModifier*/ undefined,
|
||||
/*name*/ undefined,
|
||||
factory.createNamedImports([
|
||||
factory.createImportSpecifier(/*isTypeOnly*/ false, factory.createIdentifier("createRequire"), createRequireName),
|
||||
@@ -351,7 +351,7 @@ export function transformECMAScriptModule(context: TransformationContext): (x: S
|
||||
const importDecl = factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(
|
||||
/*isTypeOnly*/ false,
|
||||
/*phaseModifier*/ undefined,
|
||||
/*name*/ undefined,
|
||||
factory.createNamespaceImport(
|
||||
synthName,
|
||||
|
||||
@@ -2282,11 +2282,11 @@ export function transformTypeScript(context: TransformationContext): Transformer
|
||||
* @param node The import clause node.
|
||||
*/
|
||||
function visitImportClause(node: ImportClause): VisitResult<ImportClause> | undefined {
|
||||
Debug.assert(!node.isTypeOnly);
|
||||
Debug.assert(node.phaseModifier !== SyntaxKind.TypeKeyword);
|
||||
// Elide the import clause if we elide both its name and its named bindings.
|
||||
const name = shouldEmitAliasDeclaration(node) ? node.name : undefined;
|
||||
const namedBindings = visitNode(node.namedBindings, visitNamedImportBindings, isNamedImportBindings);
|
||||
return (name || namedBindings) ? factory.updateImportClause(node, /*isTypeOnly*/ false, name, namedBindings) : undefined;
|
||||
return (name || namedBindings) ? factory.updateImportClause(node, node.phaseModifier, name, namedBindings) : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+21
-6
@@ -222,7 +222,8 @@ export const enum SyntaxKind {
|
||||
GlobalKeyword,
|
||||
BigIntKeyword,
|
||||
OverrideKeyword,
|
||||
OfKeyword, // LastKeyword and LastToken and LastContextualKeyword
|
||||
OfKeyword,
|
||||
DeferKeyword, // LastKeyword and LastToken and LastContextualKeyword
|
||||
|
||||
// Parse tree nodes
|
||||
|
||||
@@ -462,7 +463,7 @@ export const enum SyntaxKind {
|
||||
FirstReservedWord = BreakKeyword,
|
||||
LastReservedWord = WithKeyword,
|
||||
FirstKeyword = BreakKeyword,
|
||||
LastKeyword = OfKeyword,
|
||||
LastKeyword = DeferKeyword,
|
||||
FirstFutureReservedWord = ImplementsKeyword,
|
||||
LastFutureReservedWord = YieldKeyword,
|
||||
FirstTypeNode = TypePredicate,
|
||||
@@ -487,7 +488,7 @@ export const enum SyntaxKind {
|
||||
FirstJSDocTagNode = JSDocTag,
|
||||
LastJSDocTagNode = JSDocImportTag,
|
||||
/** @internal */ FirstContextualKeyword = AbstractKeyword,
|
||||
/** @internal */ LastContextualKeyword = OfKeyword,
|
||||
/** @internal */ LastContextualKeyword = LastKeyword,
|
||||
}
|
||||
|
||||
export type TriviaSyntaxKind =
|
||||
@@ -599,6 +600,7 @@ export type KeywordSyntaxKind =
|
||||
| SyntaxKind.DebuggerKeyword
|
||||
| SyntaxKind.DeclareKeyword
|
||||
| SyntaxKind.DefaultKeyword
|
||||
| SyntaxKind.DeferKeyword
|
||||
| SyntaxKind.DeleteKeyword
|
||||
| SyntaxKind.DoKeyword
|
||||
| SyntaxKind.ElseKeyword
|
||||
@@ -3099,7 +3101,7 @@ export interface SuperCall extends CallExpression {
|
||||
}
|
||||
|
||||
export interface ImportCall extends CallExpression {
|
||||
readonly expression: ImportExpression;
|
||||
readonly expression: ImportExpression | ImportDeferProperty;
|
||||
}
|
||||
|
||||
export interface ExpressionWithTypeArguments extends MemberExpression, NodeWithTypeArguments {
|
||||
@@ -3179,6 +3181,11 @@ export interface ImportMetaProperty extends MetaProperty {
|
||||
readonly name: Identifier & { readonly escapedText: __String & "meta"; };
|
||||
}
|
||||
|
||||
export interface ImportDeferProperty extends MetaProperty {
|
||||
readonly keywordToken: SyntaxKind.ImportKeyword;
|
||||
readonly name: Identifier & { readonly escapedText: __String & "defer"; };
|
||||
}
|
||||
|
||||
/// A JSX expression of the form <TagName attrs>...</TagName>
|
||||
export interface JsxElement extends PrimaryExpression {
|
||||
readonly kind: SyntaxKind.JsxElement;
|
||||
@@ -3711,11 +3718,15 @@ export type NamedExportBindings =
|
||||
export interface ImportClause extends NamedDeclaration {
|
||||
readonly kind: SyntaxKind.ImportClause;
|
||||
readonly parent: ImportDeclaration | JSDocImportTag;
|
||||
/** @deprecated Use `phaseModifier` instead */
|
||||
readonly isTypeOnly: boolean;
|
||||
readonly phaseModifier: undefined | ImportPhaseModifierSyntaxKind;
|
||||
readonly name?: Identifier; // Default binding
|
||||
readonly namedBindings?: NamedImportBindings;
|
||||
}
|
||||
|
||||
export type ImportPhaseModifierSyntaxKind = SyntaxKind.TypeKeyword | SyntaxKind.DeferKeyword;
|
||||
|
||||
/** @deprecated */
|
||||
export type AssertionKey = ImportAttributeName;
|
||||
|
||||
@@ -9068,8 +9079,12 @@ export interface NodeFactory {
|
||||
updateImportEqualsDeclaration(node: ImportEqualsDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
||||
createImportDeclaration(modifiers: readonly ModifierLike[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, attributes?: ImportAttributes): ImportDeclaration;
|
||||
updateImportDeclaration(node: ImportDeclaration, modifiers: readonly ModifierLike[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, attributes: ImportAttributes | undefined): ImportDeclaration;
|
||||
createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
createImportClause(phaseModifier: ImportPhaseModifierSyntaxKind | undefined, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
// eslint-disable-next-line @typescript-eslint/unified-signatures -- Cannot unify due to the @deprecated tag
|
||||
/** @deprecated */ createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
updateImportClause(node: ImportClause, phaseModifier: ImportPhaseModifierSyntaxKind | undefined, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
// eslint-disable-next-line @typescript-eslint/unified-signatures -- Cannot unify due to the @deprecated tag
|
||||
/** @deprecated */ updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
/** @deprecated */ createAssertClause(elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
|
||||
/** @deprecated */ updateAssertClause(node: AssertClause, elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
|
||||
/** @deprecated */ createAssertEntry(name: AssertionKey, value: Expression): AssertEntry;
|
||||
|
||||
@@ -2648,7 +2648,13 @@ export function isSuperCall(n: Node): n is SuperCall {
|
||||
|
||||
/** @internal */
|
||||
export function isImportCall(n: Node): n is ImportCall {
|
||||
return n.kind === SyntaxKind.CallExpression && (n as CallExpression).expression.kind === SyntaxKind.ImportKeyword;
|
||||
if (n.kind !== SyntaxKind.CallExpression) return false;
|
||||
const e = (n as CallExpression).expression;
|
||||
return e.kind === SyntaxKind.ImportKeyword || (
|
||||
isMetaProperty(e)
|
||||
&& e.keywordToken === SyntaxKind.ImportKeyword
|
||||
&& e.name.escapedText === "defer"
|
||||
);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@@ -3599,8 +3605,10 @@ export function isExpressionNode(node: Node): boolean {
|
||||
case SyntaxKind.JsxFragment:
|
||||
case SyntaxKind.YieldExpression:
|
||||
case SyntaxKind.AwaitExpression:
|
||||
case SyntaxKind.MetaProperty:
|
||||
return true;
|
||||
case SyntaxKind.MetaProperty:
|
||||
// `import.defer` in `import.defer(...)` is not an expression
|
||||
return !isImportCall(node.parent) || node.parent.expression !== node;
|
||||
case SyntaxKind.ExpressionWithTypeArguments:
|
||||
return !isHeritageClause(node.parent) && !isJSDocAugmentsTag(node.parent);
|
||||
case SyntaxKind.QualifiedName:
|
||||
@@ -10939,10 +10947,11 @@ export function isTypeDeclaration(node: Node): node is TypeParameterDeclaration
|
||||
case SyntaxKind.JSDocEnumTag:
|
||||
return true;
|
||||
case SyntaxKind.ImportClause:
|
||||
return (node as ImportClause).isTypeOnly;
|
||||
return (node as ImportClause).phaseModifier === SyntaxKind.TypeKeyword;
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return (node as ImportSpecifier).parent.parent.phaseModifier === SyntaxKind.TypeKeyword;
|
||||
case SyntaxKind.ExportSpecifier:
|
||||
return (node as ImportSpecifier | ExportSpecifier).parent.parent.isTypeOnly;
|
||||
return (node as ExportSpecifier).parent.parent.isTypeOnly;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -12114,7 +12123,7 @@ function getNodeAtPosition(sourceFile: SourceFile, position: number, includeJSDo
|
||||
};
|
||||
while (true) {
|
||||
const child = isJavaScriptFile && includeJSDoc && hasJSDocNodes(current) && forEach(current.jsDoc, getContainingChild) || forEachChild(current, getContainingChild);
|
||||
if (!child) {
|
||||
if (!child || isMetaProperty(child)) {
|
||||
return current;
|
||||
}
|
||||
current = child;
|
||||
|
||||
@@ -1534,12 +1534,13 @@ export function isImportOrExportSpecifier(node: Node): node is ImportSpecifier |
|
||||
export function isTypeOnlyImportDeclaration(node: Node): node is TypeOnlyImportDeclaration {
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.ImportSpecifier:
|
||||
return (node as ImportSpecifier).isTypeOnly || (node as ImportSpecifier).parent.parent.isTypeOnly;
|
||||
return (node as ImportSpecifier).isTypeOnly || (node as ImportSpecifier).parent.parent.phaseModifier === SyntaxKind.TypeKeyword;
|
||||
case SyntaxKind.NamespaceImport:
|
||||
return (node as NamespaceImport).parent.isTypeOnly;
|
||||
return (node as NamespaceImport).parent.phaseModifier === SyntaxKind.TypeKeyword;
|
||||
case SyntaxKind.ImportClause:
|
||||
return (node as ImportClause).phaseModifier === SyntaxKind.TypeKeyword;
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
return (node as ImportClause | ImportEqualsDeclaration).isTypeOnly;
|
||||
return (node as ImportEqualsDeclaration).isTypeOnly;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1549,7 +1549,7 @@ const visitEachChildTable: VisitEachChildTable = {
|
||||
[SyntaxKind.ImportClause]: function visitEachChildOfImportClause(node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) {
|
||||
return context.factory.updateImportClause(
|
||||
node,
|
||||
node.isTypeOnly,
|
||||
node.phaseModifier,
|
||||
nodeVisitor(node.name, visitor, isIdentifier),
|
||||
nodeVisitor(node.namedBindings, visitor, isNamedImportBindings),
|
||||
);
|
||||
|
||||
@@ -125,13 +125,13 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, de
|
||||
changes.replaceNodeWithNodes(sourceFile, declaration, [
|
||||
factory.createImportDeclaration(
|
||||
getSynthesizedDeepClones(declaration.modifiers, /*includeTrivia*/ true),
|
||||
factory.createImportClause(/*isTypeOnly*/ true, getSynthesizedDeepClone(importClause.name, /*includeTrivia*/ true), /*namedBindings*/ undefined),
|
||||
factory.createImportClause(SyntaxKind.TypeKeyword, getSynthesizedDeepClone(importClause.name, /*includeTrivia*/ true), /*namedBindings*/ undefined),
|
||||
getSynthesizedDeepClone(declaration.moduleSpecifier, /*includeTrivia*/ true),
|
||||
getSynthesizedDeepClone(declaration.attributes, /*includeTrivia*/ true),
|
||||
),
|
||||
factory.createImportDeclaration(
|
||||
getSynthesizedDeepClones(declaration.modifiers, /*includeTrivia*/ true),
|
||||
factory.createImportClause(/*isTypeOnly*/ true, /*name*/ undefined, getSynthesizedDeepClone(importClause.namedBindings, /*includeTrivia*/ true)),
|
||||
factory.createImportClause(SyntaxKind.TypeKeyword, /*name*/ undefined, getSynthesizedDeepClone(importClause.namedBindings, /*includeTrivia*/ true)),
|
||||
getSynthesizedDeepClone(declaration.moduleSpecifier, /*includeTrivia*/ true),
|
||||
getSynthesizedDeepClone(declaration.attributes, /*includeTrivia*/ true),
|
||||
),
|
||||
@@ -144,7 +144,7 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, de
|
||||
sameMap(importClause.namedBindings.elements, e => factory.updateImportSpecifier(e, /*isTypeOnly*/ false, e.propertyName, e.name)),
|
||||
)
|
||||
: importClause.namedBindings;
|
||||
const importDeclaration = factory.updateImportDeclaration(declaration, declaration.modifiers, factory.updateImportClause(importClause, /*isTypeOnly*/ true, importClause.name, newNamedBindings), declaration.moduleSpecifier, declaration.attributes);
|
||||
const importDeclaration = factory.updateImportDeclaration(declaration, declaration.modifiers, factory.updateImportClause(importClause, SyntaxKind.TypeKeyword, importClause.name, newNamedBindings), declaration.moduleSpecifier, declaration.attributes);
|
||||
changes.replaceNode(sourceFile, declaration, importDeclaration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -622,7 +622,7 @@ function createImportAdderWorker(sourceFile: SourceFile | FutureSourceFile, prog
|
||||
declaration.importClause!,
|
||||
factory.updateImportClause(
|
||||
declaration.importClause!,
|
||||
declaration.importClause!.isTypeOnly,
|
||||
declaration.importClause!.phaseModifier,
|
||||
declaration.importClause!.name,
|
||||
/*namedBindings*/ undefined,
|
||||
),
|
||||
@@ -715,7 +715,7 @@ function createImportAdderWorker(sourceFile: SourceFile | FutureSourceFile, prog
|
||||
d.modifiers,
|
||||
d.importClause && factory.updateImportClause(
|
||||
d.importClause,
|
||||
d.importClause.isTypeOnly,
|
||||
d.importClause.phaseModifier,
|
||||
verbatimImports.has(d.importClause) ? d.importClause.name : undefined,
|
||||
verbatimImports.has(d.importClause.namedBindings as NamespaceImport)
|
||||
? d.importClause.namedBindings as NamespaceImport :
|
||||
@@ -2080,7 +2080,7 @@ function getNewImports(
|
||||
: factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(
|
||||
shouldUseTypeOnly(namespaceLikeImport, preferences),
|
||||
shouldUseTypeOnly(namespaceLikeImport, preferences) ? SyntaxKind.TypeKeyword : undefined,
|
||||
/*name*/ undefined,
|
||||
factory.createNamespaceImport(factory.createIdentifier(namespaceLikeImport.name)),
|
||||
),
|
||||
|
||||
@@ -61,7 +61,7 @@ function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, in
|
||||
statement,
|
||||
defaultImportName && !allowSyntheticDefaults
|
||||
? factory.createImportEqualsDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, defaultImportName, factory.createExternalModuleReference(moduleSpecifier))
|
||||
: factory.createImportDeclaration(/*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, namedImports), moduleSpecifier, /*attributes*/ undefined),
|
||||
: factory.createImportDeclaration(/*modifiers*/ undefined, factory.createImportClause(/*phaseModifier*/ undefined, defaultImportName, namedImports), moduleSpecifier, /*attributes*/ undefined),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ function splitTypeOnlyImport(changes: textChanges.ChangeTracker, importDeclarati
|
||||
factory.updateImportDeclaration(
|
||||
importDeclaration,
|
||||
importDeclaration.modifiers,
|
||||
factory.updateImportClause(importClause, importClause.isTypeOnly, importClause.name, /*namedBindings*/ undefined),
|
||||
factory.updateImportClause(importClause, importClause.phaseModifier, importClause.name, /*namedBindings*/ undefined),
|
||||
importDeclaration.moduleSpecifier,
|
||||
importDeclaration.attributes,
|
||||
),
|
||||
@@ -62,7 +62,7 @@ function splitTypeOnlyImport(changes: textChanges.ChangeTracker, importDeclarati
|
||||
importDeclaration,
|
||||
factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.updateImportClause(importClause, importClause.isTypeOnly, /*name*/ undefined, importClause.namedBindings),
|
||||
factory.updateImportClause(importClause, importClause.phaseModifier, /*name*/ undefined, importClause.namedBindings),
|
||||
importDeclaration.moduleSpecifier,
|
||||
importDeclaration.attributes,
|
||||
),
|
||||
|
||||
@@ -639,7 +639,7 @@ function updateImportDeclarationAndClause(
|
||||
return factory.updateImportDeclaration(
|
||||
importDeclaration,
|
||||
importDeclaration.modifiers,
|
||||
factory.updateImportClause(importDeclaration.importClause!, importDeclaration.importClause!.isTypeOnly, name, namedBindings), // TODO: GH#18217
|
||||
factory.updateImportClause(importDeclaration.importClause!, importDeclaration.importClause!.phaseModifier, name, namedBindings), // TODO: GH#18217
|
||||
importDeclaration.moduleSpecifier,
|
||||
importDeclaration.attributes,
|
||||
);
|
||||
|
||||
@@ -290,5 +290,5 @@ function createImport(node: ImportDeclaration, defaultImportName: Identifier | u
|
||||
}
|
||||
|
||||
function createImportClause(defaultImportName: Identifier | undefined, elements: readonly ImportSpecifier[] | undefined) {
|
||||
return factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? factory.createNamedImports(elements) : undefined);
|
||||
return factory.createImportClause(/*phaseModifier*/ undefined, defaultImportName, elements && elements.length ? factory.createNamedImports(elements) : undefined);
|
||||
}
|
||||
@@ -423,7 +423,7 @@ function updateNamespaceLikeImportNode(node: SupportedImport, newNamespaceName:
|
||||
case SyntaxKind.ImportDeclaration:
|
||||
return factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, factory.createNamespaceImport(newNamespaceId)),
|
||||
factory.createImportClause(/*phaseModifier*/ undefined, /*name*/ undefined, factory.createNamespaceImport(newNamespaceId)),
|
||||
newModuleString,
|
||||
/*attributes*/ undefined,
|
||||
);
|
||||
@@ -645,7 +645,7 @@ function filterImport(i: SupportedImport, moduleSpecifier: StringLiteralLike, ke
|
||||
const defaultImport = clause.name && keep(clause.name) ? clause.name : undefined;
|
||||
const namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep);
|
||||
return defaultImport || namedBindings
|
||||
? factory.createImportDeclaration(/*modifiers*/ undefined, factory.createImportClause(clause.isTypeOnly, defaultImport, namedBindings), getSynthesizedDeepClone(moduleSpecifier), /*attributes*/ undefined)
|
||||
? factory.createImportDeclaration(/*modifiers*/ undefined, factory.createImportClause(clause.phaseModifier, defaultImport, namedBindings), getSynthesizedDeepClone(moduleSpecifier), /*attributes*/ undefined)
|
||||
: undefined;
|
||||
}
|
||||
case SyntaxKind.ImportEqualsDeclaration:
|
||||
|
||||
@@ -2488,7 +2488,7 @@ export function makeImport(defaultImport: Identifier | undefined, namedImports:
|
||||
return factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
defaultImport || namedImports
|
||||
? factory.createImportClause(!!isTypeOnly, defaultImport, namedImports && namedImports.length ? factory.createNamedImports(namedImports) : undefined)
|
||||
? factory.createImportClause(isTypeOnly ? SyntaxKind.TypeKeyword : undefined, defaultImport, namedImports && namedImports.length ? factory.createNamedImports(namedImports) : undefined)
|
||||
: undefined,
|
||||
typeof moduleSpecifier === "string" ? makeStringLiteral(moduleSpecifier, quotePreference) : moduleSpecifier,
|
||||
/*attributes*/ undefined,
|
||||
|
||||
@@ -342,7 +342,7 @@ describe("unittests:: TransformAPI", () => {
|
||||
const importStar = ts.factory.createImportDeclaration(
|
||||
/*modifiers*/ undefined,
|
||||
/*importClause*/ ts.factory.createImportClause(
|
||||
/*isTypeOnly*/ false,
|
||||
/*phaseModifier*/ undefined,
|
||||
/*name*/ undefined,
|
||||
ts.factory.createNamespaceImport(ts.factory.createIdentifier("i0")),
|
||||
),
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"modifierFlagsCache": 0,
|
||||
"transformFlags": 1,
|
||||
"isTypeOnly": true,
|
||||
"phaseModifier": 156,
|
||||
"name": {
|
||||
"kind": "Identifier",
|
||||
"pos": 16,
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"modifierFlagsCache": 0,
|
||||
"transformFlags": 1,
|
||||
"isTypeOnly": true,
|
||||
"phaseModifier": 156,
|
||||
"namedBindings": {
|
||||
"kind": "NamedImports",
|
||||
"pos": 16,
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
"modifierFlagsCache": 0,
|
||||
"transformFlags": 1,
|
||||
"isTypeOnly": true,
|
||||
"phaseModifier": 156,
|
||||
"namedBindings": {
|
||||
"kind": "NamespaceImport",
|
||||
"pos": 16,
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
"modifierFlagsCache": 0,
|
||||
"transformFlags": 1,
|
||||
"isTypeOnly": true,
|
||||
"phaseModifier": 156,
|
||||
"namedBindings": {
|
||||
"kind": "NamespaceImport",
|
||||
"pos": 16,
|
||||
|
||||
+223
-210
@@ -3841,203 +3841,204 @@ declare namespace ts {
|
||||
BigIntKeyword = 163,
|
||||
OverrideKeyword = 164,
|
||||
OfKeyword = 165,
|
||||
QualifiedName = 166,
|
||||
ComputedPropertyName = 167,
|
||||
TypeParameter = 168,
|
||||
Parameter = 169,
|
||||
Decorator = 170,
|
||||
PropertySignature = 171,
|
||||
PropertyDeclaration = 172,
|
||||
MethodSignature = 173,
|
||||
MethodDeclaration = 174,
|
||||
ClassStaticBlockDeclaration = 175,
|
||||
Constructor = 176,
|
||||
GetAccessor = 177,
|
||||
SetAccessor = 178,
|
||||
CallSignature = 179,
|
||||
ConstructSignature = 180,
|
||||
IndexSignature = 181,
|
||||
TypePredicate = 182,
|
||||
TypeReference = 183,
|
||||
FunctionType = 184,
|
||||
ConstructorType = 185,
|
||||
TypeQuery = 186,
|
||||
TypeLiteral = 187,
|
||||
ArrayType = 188,
|
||||
TupleType = 189,
|
||||
OptionalType = 190,
|
||||
RestType = 191,
|
||||
UnionType = 192,
|
||||
IntersectionType = 193,
|
||||
ConditionalType = 194,
|
||||
InferType = 195,
|
||||
ParenthesizedType = 196,
|
||||
ThisType = 197,
|
||||
TypeOperator = 198,
|
||||
IndexedAccessType = 199,
|
||||
MappedType = 200,
|
||||
LiteralType = 201,
|
||||
NamedTupleMember = 202,
|
||||
TemplateLiteralType = 203,
|
||||
TemplateLiteralTypeSpan = 204,
|
||||
ImportType = 205,
|
||||
ObjectBindingPattern = 206,
|
||||
ArrayBindingPattern = 207,
|
||||
BindingElement = 208,
|
||||
ArrayLiteralExpression = 209,
|
||||
ObjectLiteralExpression = 210,
|
||||
PropertyAccessExpression = 211,
|
||||
ElementAccessExpression = 212,
|
||||
CallExpression = 213,
|
||||
NewExpression = 214,
|
||||
TaggedTemplateExpression = 215,
|
||||
TypeAssertionExpression = 216,
|
||||
ParenthesizedExpression = 217,
|
||||
FunctionExpression = 218,
|
||||
ArrowFunction = 219,
|
||||
DeleteExpression = 220,
|
||||
TypeOfExpression = 221,
|
||||
VoidExpression = 222,
|
||||
AwaitExpression = 223,
|
||||
PrefixUnaryExpression = 224,
|
||||
PostfixUnaryExpression = 225,
|
||||
BinaryExpression = 226,
|
||||
ConditionalExpression = 227,
|
||||
TemplateExpression = 228,
|
||||
YieldExpression = 229,
|
||||
SpreadElement = 230,
|
||||
ClassExpression = 231,
|
||||
OmittedExpression = 232,
|
||||
ExpressionWithTypeArguments = 233,
|
||||
AsExpression = 234,
|
||||
NonNullExpression = 235,
|
||||
MetaProperty = 236,
|
||||
SyntheticExpression = 237,
|
||||
SatisfiesExpression = 238,
|
||||
TemplateSpan = 239,
|
||||
SemicolonClassElement = 240,
|
||||
Block = 241,
|
||||
EmptyStatement = 242,
|
||||
VariableStatement = 243,
|
||||
ExpressionStatement = 244,
|
||||
IfStatement = 245,
|
||||
DoStatement = 246,
|
||||
WhileStatement = 247,
|
||||
ForStatement = 248,
|
||||
ForInStatement = 249,
|
||||
ForOfStatement = 250,
|
||||
ContinueStatement = 251,
|
||||
BreakStatement = 252,
|
||||
ReturnStatement = 253,
|
||||
WithStatement = 254,
|
||||
SwitchStatement = 255,
|
||||
LabeledStatement = 256,
|
||||
ThrowStatement = 257,
|
||||
TryStatement = 258,
|
||||
DebuggerStatement = 259,
|
||||
VariableDeclaration = 260,
|
||||
VariableDeclarationList = 261,
|
||||
FunctionDeclaration = 262,
|
||||
ClassDeclaration = 263,
|
||||
InterfaceDeclaration = 264,
|
||||
TypeAliasDeclaration = 265,
|
||||
EnumDeclaration = 266,
|
||||
ModuleDeclaration = 267,
|
||||
ModuleBlock = 268,
|
||||
CaseBlock = 269,
|
||||
NamespaceExportDeclaration = 270,
|
||||
ImportEqualsDeclaration = 271,
|
||||
ImportDeclaration = 272,
|
||||
ImportClause = 273,
|
||||
NamespaceImport = 274,
|
||||
NamedImports = 275,
|
||||
ImportSpecifier = 276,
|
||||
ExportAssignment = 277,
|
||||
ExportDeclaration = 278,
|
||||
NamedExports = 279,
|
||||
NamespaceExport = 280,
|
||||
ExportSpecifier = 281,
|
||||
MissingDeclaration = 282,
|
||||
ExternalModuleReference = 283,
|
||||
JsxElement = 284,
|
||||
JsxSelfClosingElement = 285,
|
||||
JsxOpeningElement = 286,
|
||||
JsxClosingElement = 287,
|
||||
JsxFragment = 288,
|
||||
JsxOpeningFragment = 289,
|
||||
JsxClosingFragment = 290,
|
||||
JsxAttribute = 291,
|
||||
JsxAttributes = 292,
|
||||
JsxSpreadAttribute = 293,
|
||||
JsxExpression = 294,
|
||||
JsxNamespacedName = 295,
|
||||
CaseClause = 296,
|
||||
DefaultClause = 297,
|
||||
HeritageClause = 298,
|
||||
CatchClause = 299,
|
||||
ImportAttributes = 300,
|
||||
ImportAttribute = 301,
|
||||
/** @deprecated */ AssertClause = 300,
|
||||
/** @deprecated */ AssertEntry = 301,
|
||||
/** @deprecated */ ImportTypeAssertionContainer = 302,
|
||||
PropertyAssignment = 303,
|
||||
ShorthandPropertyAssignment = 304,
|
||||
SpreadAssignment = 305,
|
||||
EnumMember = 306,
|
||||
SourceFile = 307,
|
||||
Bundle = 308,
|
||||
JSDocTypeExpression = 309,
|
||||
JSDocNameReference = 310,
|
||||
JSDocMemberName = 311,
|
||||
JSDocAllType = 312,
|
||||
JSDocUnknownType = 313,
|
||||
JSDocNullableType = 314,
|
||||
JSDocNonNullableType = 315,
|
||||
JSDocOptionalType = 316,
|
||||
JSDocFunctionType = 317,
|
||||
JSDocVariadicType = 318,
|
||||
JSDocNamepathType = 319,
|
||||
JSDoc = 320,
|
||||
DeferKeyword = 166,
|
||||
QualifiedName = 167,
|
||||
ComputedPropertyName = 168,
|
||||
TypeParameter = 169,
|
||||
Parameter = 170,
|
||||
Decorator = 171,
|
||||
PropertySignature = 172,
|
||||
PropertyDeclaration = 173,
|
||||
MethodSignature = 174,
|
||||
MethodDeclaration = 175,
|
||||
ClassStaticBlockDeclaration = 176,
|
||||
Constructor = 177,
|
||||
GetAccessor = 178,
|
||||
SetAccessor = 179,
|
||||
CallSignature = 180,
|
||||
ConstructSignature = 181,
|
||||
IndexSignature = 182,
|
||||
TypePredicate = 183,
|
||||
TypeReference = 184,
|
||||
FunctionType = 185,
|
||||
ConstructorType = 186,
|
||||
TypeQuery = 187,
|
||||
TypeLiteral = 188,
|
||||
ArrayType = 189,
|
||||
TupleType = 190,
|
||||
OptionalType = 191,
|
||||
RestType = 192,
|
||||
UnionType = 193,
|
||||
IntersectionType = 194,
|
||||
ConditionalType = 195,
|
||||
InferType = 196,
|
||||
ParenthesizedType = 197,
|
||||
ThisType = 198,
|
||||
TypeOperator = 199,
|
||||
IndexedAccessType = 200,
|
||||
MappedType = 201,
|
||||
LiteralType = 202,
|
||||
NamedTupleMember = 203,
|
||||
TemplateLiteralType = 204,
|
||||
TemplateLiteralTypeSpan = 205,
|
||||
ImportType = 206,
|
||||
ObjectBindingPattern = 207,
|
||||
ArrayBindingPattern = 208,
|
||||
BindingElement = 209,
|
||||
ArrayLiteralExpression = 210,
|
||||
ObjectLiteralExpression = 211,
|
||||
PropertyAccessExpression = 212,
|
||||
ElementAccessExpression = 213,
|
||||
CallExpression = 214,
|
||||
NewExpression = 215,
|
||||
TaggedTemplateExpression = 216,
|
||||
TypeAssertionExpression = 217,
|
||||
ParenthesizedExpression = 218,
|
||||
FunctionExpression = 219,
|
||||
ArrowFunction = 220,
|
||||
DeleteExpression = 221,
|
||||
TypeOfExpression = 222,
|
||||
VoidExpression = 223,
|
||||
AwaitExpression = 224,
|
||||
PrefixUnaryExpression = 225,
|
||||
PostfixUnaryExpression = 226,
|
||||
BinaryExpression = 227,
|
||||
ConditionalExpression = 228,
|
||||
TemplateExpression = 229,
|
||||
YieldExpression = 230,
|
||||
SpreadElement = 231,
|
||||
ClassExpression = 232,
|
||||
OmittedExpression = 233,
|
||||
ExpressionWithTypeArguments = 234,
|
||||
AsExpression = 235,
|
||||
NonNullExpression = 236,
|
||||
MetaProperty = 237,
|
||||
SyntheticExpression = 238,
|
||||
SatisfiesExpression = 239,
|
||||
TemplateSpan = 240,
|
||||
SemicolonClassElement = 241,
|
||||
Block = 242,
|
||||
EmptyStatement = 243,
|
||||
VariableStatement = 244,
|
||||
ExpressionStatement = 245,
|
||||
IfStatement = 246,
|
||||
DoStatement = 247,
|
||||
WhileStatement = 248,
|
||||
ForStatement = 249,
|
||||
ForInStatement = 250,
|
||||
ForOfStatement = 251,
|
||||
ContinueStatement = 252,
|
||||
BreakStatement = 253,
|
||||
ReturnStatement = 254,
|
||||
WithStatement = 255,
|
||||
SwitchStatement = 256,
|
||||
LabeledStatement = 257,
|
||||
ThrowStatement = 258,
|
||||
TryStatement = 259,
|
||||
DebuggerStatement = 260,
|
||||
VariableDeclaration = 261,
|
||||
VariableDeclarationList = 262,
|
||||
FunctionDeclaration = 263,
|
||||
ClassDeclaration = 264,
|
||||
InterfaceDeclaration = 265,
|
||||
TypeAliasDeclaration = 266,
|
||||
EnumDeclaration = 267,
|
||||
ModuleDeclaration = 268,
|
||||
ModuleBlock = 269,
|
||||
CaseBlock = 270,
|
||||
NamespaceExportDeclaration = 271,
|
||||
ImportEqualsDeclaration = 272,
|
||||
ImportDeclaration = 273,
|
||||
ImportClause = 274,
|
||||
NamespaceImport = 275,
|
||||
NamedImports = 276,
|
||||
ImportSpecifier = 277,
|
||||
ExportAssignment = 278,
|
||||
ExportDeclaration = 279,
|
||||
NamedExports = 280,
|
||||
NamespaceExport = 281,
|
||||
ExportSpecifier = 282,
|
||||
MissingDeclaration = 283,
|
||||
ExternalModuleReference = 284,
|
||||
JsxElement = 285,
|
||||
JsxSelfClosingElement = 286,
|
||||
JsxOpeningElement = 287,
|
||||
JsxClosingElement = 288,
|
||||
JsxFragment = 289,
|
||||
JsxOpeningFragment = 290,
|
||||
JsxClosingFragment = 291,
|
||||
JsxAttribute = 292,
|
||||
JsxAttributes = 293,
|
||||
JsxSpreadAttribute = 294,
|
||||
JsxExpression = 295,
|
||||
JsxNamespacedName = 296,
|
||||
CaseClause = 297,
|
||||
DefaultClause = 298,
|
||||
HeritageClause = 299,
|
||||
CatchClause = 300,
|
||||
ImportAttributes = 301,
|
||||
ImportAttribute = 302,
|
||||
/** @deprecated */ AssertClause = 301,
|
||||
/** @deprecated */ AssertEntry = 302,
|
||||
/** @deprecated */ ImportTypeAssertionContainer = 303,
|
||||
PropertyAssignment = 304,
|
||||
ShorthandPropertyAssignment = 305,
|
||||
SpreadAssignment = 306,
|
||||
EnumMember = 307,
|
||||
SourceFile = 308,
|
||||
Bundle = 309,
|
||||
JSDocTypeExpression = 310,
|
||||
JSDocNameReference = 311,
|
||||
JSDocMemberName = 312,
|
||||
JSDocAllType = 313,
|
||||
JSDocUnknownType = 314,
|
||||
JSDocNullableType = 315,
|
||||
JSDocNonNullableType = 316,
|
||||
JSDocOptionalType = 317,
|
||||
JSDocFunctionType = 318,
|
||||
JSDocVariadicType = 319,
|
||||
JSDocNamepathType = 320,
|
||||
JSDoc = 321,
|
||||
/** @deprecated Use SyntaxKind.JSDoc */
|
||||
JSDocComment = 320,
|
||||
JSDocText = 321,
|
||||
JSDocTypeLiteral = 322,
|
||||
JSDocSignature = 323,
|
||||
JSDocLink = 324,
|
||||
JSDocLinkCode = 325,
|
||||
JSDocLinkPlain = 326,
|
||||
JSDocTag = 327,
|
||||
JSDocAugmentsTag = 328,
|
||||
JSDocImplementsTag = 329,
|
||||
JSDocAuthorTag = 330,
|
||||
JSDocDeprecatedTag = 331,
|
||||
JSDocClassTag = 332,
|
||||
JSDocPublicTag = 333,
|
||||
JSDocPrivateTag = 334,
|
||||
JSDocProtectedTag = 335,
|
||||
JSDocReadonlyTag = 336,
|
||||
JSDocOverrideTag = 337,
|
||||
JSDocCallbackTag = 338,
|
||||
JSDocOverloadTag = 339,
|
||||
JSDocEnumTag = 340,
|
||||
JSDocParameterTag = 341,
|
||||
JSDocReturnTag = 342,
|
||||
JSDocThisTag = 343,
|
||||
JSDocTypeTag = 344,
|
||||
JSDocTemplateTag = 345,
|
||||
JSDocTypedefTag = 346,
|
||||
JSDocSeeTag = 347,
|
||||
JSDocPropertyTag = 348,
|
||||
JSDocThrowsTag = 349,
|
||||
JSDocSatisfiesTag = 350,
|
||||
JSDocImportTag = 351,
|
||||
SyntaxList = 352,
|
||||
NotEmittedStatement = 353,
|
||||
NotEmittedTypeElement = 354,
|
||||
PartiallyEmittedExpression = 355,
|
||||
CommaListExpression = 356,
|
||||
SyntheticReferenceExpression = 357,
|
||||
Count = 358,
|
||||
JSDocComment = 321,
|
||||
JSDocText = 322,
|
||||
JSDocTypeLiteral = 323,
|
||||
JSDocSignature = 324,
|
||||
JSDocLink = 325,
|
||||
JSDocLinkCode = 326,
|
||||
JSDocLinkPlain = 327,
|
||||
JSDocTag = 328,
|
||||
JSDocAugmentsTag = 329,
|
||||
JSDocImplementsTag = 330,
|
||||
JSDocAuthorTag = 331,
|
||||
JSDocDeprecatedTag = 332,
|
||||
JSDocClassTag = 333,
|
||||
JSDocPublicTag = 334,
|
||||
JSDocPrivateTag = 335,
|
||||
JSDocProtectedTag = 336,
|
||||
JSDocReadonlyTag = 337,
|
||||
JSDocOverrideTag = 338,
|
||||
JSDocCallbackTag = 339,
|
||||
JSDocOverloadTag = 340,
|
||||
JSDocEnumTag = 341,
|
||||
JSDocParameterTag = 342,
|
||||
JSDocReturnTag = 343,
|
||||
JSDocThisTag = 344,
|
||||
JSDocTypeTag = 345,
|
||||
JSDocTemplateTag = 346,
|
||||
JSDocTypedefTag = 347,
|
||||
JSDocSeeTag = 348,
|
||||
JSDocPropertyTag = 349,
|
||||
JSDocThrowsTag = 350,
|
||||
JSDocSatisfiesTag = 351,
|
||||
JSDocImportTag = 352,
|
||||
SyntaxList = 353,
|
||||
NotEmittedStatement = 354,
|
||||
NotEmittedTypeElement = 355,
|
||||
PartiallyEmittedExpression = 356,
|
||||
CommaListExpression = 357,
|
||||
SyntheticReferenceExpression = 358,
|
||||
Count = 359,
|
||||
FirstAssignment = 64,
|
||||
LastAssignment = 79,
|
||||
FirstCompoundAssignment = 65,
|
||||
@@ -4045,15 +4046,15 @@ declare namespace ts {
|
||||
FirstReservedWord = 83,
|
||||
LastReservedWord = 118,
|
||||
FirstKeyword = 83,
|
||||
LastKeyword = 165,
|
||||
LastKeyword = 166,
|
||||
FirstFutureReservedWord = 119,
|
||||
LastFutureReservedWord = 127,
|
||||
FirstTypeNode = 182,
|
||||
LastTypeNode = 205,
|
||||
FirstTypeNode = 183,
|
||||
LastTypeNode = 206,
|
||||
FirstPunctuation = 19,
|
||||
LastPunctuation = 79,
|
||||
FirstToken = 0,
|
||||
LastToken = 165,
|
||||
LastToken = 166,
|
||||
FirstTriviaToken = 2,
|
||||
LastTriviaToken = 7,
|
||||
FirstLiteralToken = 9,
|
||||
@@ -4062,13 +4063,13 @@ declare namespace ts {
|
||||
LastTemplateToken = 18,
|
||||
FirstBinaryOperator = 30,
|
||||
LastBinaryOperator = 79,
|
||||
FirstStatement = 243,
|
||||
LastStatement = 259,
|
||||
FirstNode = 166,
|
||||
FirstJSDocNode = 309,
|
||||
LastJSDocNode = 351,
|
||||
FirstJSDocTagNode = 327,
|
||||
LastJSDocTagNode = 351,
|
||||
FirstStatement = 244,
|
||||
LastStatement = 260,
|
||||
FirstNode = 167,
|
||||
FirstJSDocNode = 310,
|
||||
LastJSDocNode = 352,
|
||||
FirstJSDocTagNode = 328,
|
||||
LastJSDocTagNode = 352,
|
||||
}
|
||||
type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia;
|
||||
type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral;
|
||||
@@ -4156,6 +4157,7 @@ declare namespace ts {
|
||||
| SyntaxKind.DebuggerKeyword
|
||||
| SyntaxKind.DeclareKeyword
|
||||
| SyntaxKind.DefaultKeyword
|
||||
| SyntaxKind.DeferKeyword
|
||||
| SyntaxKind.DeleteKeyword
|
||||
| SyntaxKind.DoKeyword
|
||||
| SyntaxKind.ElseKeyword
|
||||
@@ -5128,7 +5130,7 @@ declare namespace ts {
|
||||
readonly expression: SuperExpression;
|
||||
}
|
||||
interface ImportCall extends CallExpression {
|
||||
readonly expression: ImportExpression;
|
||||
readonly expression: ImportExpression | ImportDeferProperty;
|
||||
}
|
||||
interface ExpressionWithTypeArguments extends MemberExpression, NodeWithTypeArguments {
|
||||
readonly kind: SyntaxKind.ExpressionWithTypeArguments;
|
||||
@@ -5178,6 +5180,12 @@ declare namespace ts {
|
||||
readonly keywordToken: SyntaxKind.NewKeyword | SyntaxKind.ImportKeyword;
|
||||
readonly name: Identifier;
|
||||
}
|
||||
interface ImportDeferProperty extends MetaProperty {
|
||||
readonly keywordToken: SyntaxKind.ImportKeyword;
|
||||
readonly name: Identifier & {
|
||||
readonly escapedText: __String & "defer";
|
||||
};
|
||||
}
|
||||
interface JsxElement extends PrimaryExpression {
|
||||
readonly kind: SyntaxKind.JsxElement;
|
||||
readonly openingElement: JsxOpeningElement;
|
||||
@@ -5517,10 +5525,13 @@ declare namespace ts {
|
||||
interface ImportClause extends NamedDeclaration {
|
||||
readonly kind: SyntaxKind.ImportClause;
|
||||
readonly parent: ImportDeclaration | JSDocImportTag;
|
||||
/** @deprecated Use `phaseModifier` instead */
|
||||
readonly isTypeOnly: boolean;
|
||||
readonly phaseModifier: undefined | ImportPhaseModifierSyntaxKind;
|
||||
readonly name?: Identifier;
|
||||
readonly namedBindings?: NamedImportBindings;
|
||||
}
|
||||
type ImportPhaseModifierSyntaxKind = SyntaxKind.TypeKeyword | SyntaxKind.DeferKeyword;
|
||||
/** @deprecated */
|
||||
type AssertionKey = ImportAttributeName;
|
||||
/** @deprecated */
|
||||
@@ -7728,8 +7739,10 @@ declare namespace ts {
|
||||
updateImportEqualsDeclaration(node: ImportEqualsDeclaration, modifiers: readonly ModifierLike[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration;
|
||||
createImportDeclaration(modifiers: readonly ModifierLike[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, attributes?: ImportAttributes): ImportDeclaration;
|
||||
updateImportDeclaration(node: ImportDeclaration, modifiers: readonly ModifierLike[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, attributes: ImportAttributes | undefined): ImportDeclaration;
|
||||
createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
createImportClause(phaseModifier: ImportPhaseModifierSyntaxKind | undefined, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
/** @deprecated */ createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
updateImportClause(node: ImportClause, phaseModifier: ImportPhaseModifierSyntaxKind | undefined, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
/** @deprecated */ updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause;
|
||||
/** @deprecated */ createAssertClause(elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
|
||||
/** @deprecated */ updateAssertClause(node: AssertClause, elements: NodeArray<AssertEntry>, multiLine?: boolean): AssertClause;
|
||||
/** @deprecated */ createAssertEntry(name: AssertionKey, value: Expression): AssertEntry;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
b.ts(1,1): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import.defer("./a.js").then(ns => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.foo = foo;
|
||||
function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>"./a.js" : Symbol("a", Decl(a.ts, 0, 0))
|
||||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
|
||||
ns.foo();
|
||||
>ns.foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then(ns => { ns.foo();}) : Promise<void>
|
||||
> : ^^^^^^^^^^^^^
|
||||
>import.defer("./a.js").then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>import.defer("./a.js") : Promise<typeof import("a")>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
>"./a.js" : "./a.js"
|
||||
> : ^^^^^^^^
|
||||
>then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns => { ns.foo();} : (ns: typeof import("a")) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ns.foo();
|
||||
>ns.foo() : void
|
||||
> : ^^^^
|
||||
>ns.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
b.ts(1,1): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import.defer("./a.js").then(ns => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>"./a.js" : Symbol("a", Decl(a.ts, 0, 0))
|
||||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
|
||||
ns.foo();
|
||||
>ns.foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then(ns => { ns.foo();}) : Promise<void>
|
||||
> : ^^^^^^^^^^^^^
|
||||
>import.defer("./a.js").then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>import.defer("./a.js") : Promise<typeof import("a")>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
>"./a.js" : "./a.js"
|
||||
> : ^^^^^^^^
|
||||
>then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns => { ns.foo();} : (ns: typeof import("a")) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ns.foo();
|
||||
>ns.foo() : void
|
||||
> : ^^^^
|
||||
>ns.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
b.ts(1,1): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import.defer("./a.js").then(ns => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>"./a.js" : Symbol("a", Decl(a.ts, 0, 0))
|
||||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
|
||||
ns.foo();
|
||||
>ns.foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then(ns => { ns.foo();}) : Promise<void>
|
||||
> : ^^^^^^^^^^^^^
|
||||
>import.defer("./a.js").then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>import.defer("./a.js") : Promise<typeof import("a")>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
>"./a.js" : "./a.js"
|
||||
> : ^^^^^^^^
|
||||
>then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns => { ns.foo();} : (ns: typeof import("a")) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ns.foo();
|
||||
>ns.foo() : void
|
||||
> : ^^^^
|
||||
>ns.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>"./a.js" : Symbol("a", Decl(a.ts, 0, 0))
|
||||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
|
||||
ns.foo();
|
||||
>ns.foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then(ns => { ns.foo();}) : Promise<void>
|
||||
> : ^^^^^^^^^^^^^
|
||||
>import.defer("./a.js").then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>import.defer("./a.js") : Promise<typeof import("a")>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
>"./a.js" : "./a.js"
|
||||
> : ^^^^^^^^
|
||||
>then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns => { ns.foo();} : (ns: typeof import("a")) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ns.foo();
|
||||
>ns.foo() : void
|
||||
> : ^^^^
|
||||
>ns.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
b.ts(1,1): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import.defer("./a.js").then(ns => {
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.foo = foo;
|
||||
function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>"./a.js" : Symbol("a", Decl(a.ts, 0, 0))
|
||||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
|
||||
ns.foo();
|
||||
>ns.foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then(ns => { ns.foo();}) : Promise<void>
|
||||
> : ^^^^^^^^^^^^^
|
||||
>import.defer("./a.js").then : <TResult1 = { default: typeof import("a"); foo(): void; }, TResult2 = never>(onfulfilled?: (value: { default: typeof import("a"); foo(): void; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>import.defer("./a.js") : Promise<{ default: typeof import("a"); foo(): void; }>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
>"./a.js" : "./a.js"
|
||||
> : ^^^^^^^^
|
||||
>then : <TResult1 = { default: typeof import("a"); foo(): void; }, TResult2 = never>(onfulfilled?: (value: { default: typeof import("a"); foo(): void; }) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns => { ns.foo();} : (ns: { default: typeof import("a"); foo(): void; }) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns : { default: typeof import("a"); foo(): void; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ns.foo();
|
||||
>ns.foo() : void
|
||||
> : ^^^^
|
||||
>ns.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>ns : { default: typeof import("a"); foo(): void; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import.defer("./a.js").then(ns => {
|
||||
ns.foo();
|
||||
});
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>"./a.js" : Symbol("a", Decl(a.ts, 0, 0))
|
||||
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
|
||||
ns.foo();
|
||||
>ns.foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 28))
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import.defer("./a.js").then(ns => {
|
||||
>import.defer("./a.js").then(ns => { ns.foo();}) : Promise<void>
|
||||
> : ^^^^^^^^^^^^^
|
||||
>import.defer("./a.js").then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>import.defer("./a.js") : Promise<typeof import("a")>
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
>"./a.js" : "./a.js"
|
||||
> : ^^^^^^^^
|
||||
>then : <TResult1 = typeof import("a"), TResult2 = never>(onfulfilled?: (value: typeof import("a")) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns => { ns.foo();} : (ns: typeof import("a")) => void
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
ns.foo();
|
||||
>ns.foo() : void
|
||||
> : ^^^^
|
||||
>ns.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>ns : typeof import("a")
|
||||
> : ^^^^^^^^^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
b.ts(1,13): error TS1005: '(' expected.
|
||||
b.ts(3,14): error TS1005: '(' expected.
|
||||
b.ts(5,22): error TS1005: '(' expected.
|
||||
b.ts(7,13): error TS1005: '(' expected.
|
||||
|
||||
|
||||
==== b.ts (4 errors) ====
|
||||
import.defer;
|
||||
|
||||
!!! error TS1005: '(' expected.
|
||||
|
||||
(import.defer)("a");
|
||||
|
||||
!!! error TS1005: '(' expected.
|
||||
|
||||
Function(import.defer);
|
||||
|
||||
!!! error TS1005: '(' expected.
|
||||
|
||||
import.defer
|
||||
|
||||
!!! error TS1005: '(' expected.
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDeferInvalidStandalone.ts] ////
|
||||
|
||||
//// [b.ts]
|
||||
import.defer;
|
||||
|
||||
(import.defer)("a");
|
||||
|
||||
Function(import.defer);
|
||||
|
||||
import.defer
|
||||
|
||||
//// [b.js]
|
||||
import.defer;
|
||||
(import.defer)("a");
|
||||
Function(import.defer);
|
||||
import.defer;
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDeferInvalidStandalone.ts] ////
|
||||
|
||||
=== b.ts ===
|
||||
import.defer;
|
||||
|
||||
(import.defer)("a");
|
||||
|
||||
Function(import.defer);
|
||||
>Function : Symbol(Function, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --))
|
||||
|
||||
import.defer
|
||||
@@ -0,0 +1,37 @@
|
||||
//// [tests/cases/conformance/importDefer/dynamicImportDeferInvalidStandalone.ts] ////
|
||||
|
||||
=== b.ts ===
|
||||
import.defer;
|
||||
>import.defer : any
|
||||
> : ^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
|
||||
(import.defer)("a");
|
||||
>(import.defer)("a") : any
|
||||
> : ^^^
|
||||
>(import.defer) : any
|
||||
> : ^^^
|
||||
>import.defer : any
|
||||
> : ^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
>"a" : "a"
|
||||
> : ^^^
|
||||
|
||||
Function(import.defer);
|
||||
>Function(import.defer) : Function
|
||||
> : ^^^^^^^^
|
||||
>Function : FunctionConstructor
|
||||
> : ^^^^^^^^^^^^^^^^^^^
|
||||
>import.defer : any
|
||||
> : ^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
|
||||
import.defer
|
||||
>import.defer : any
|
||||
> : ^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
b.ts(1,1): error TS1128: Declaration or statement expected.
|
||||
b.ts(1,8): error TS2304: Cannot find name 'defer'.
|
||||
b.ts(1,16): error TS2304: Cannot find name 'as'.
|
||||
b.ts(1,19): error TS1005: ';' expected.
|
||||
b.ts(1,19): error TS2304: Cannot find name 'ns'.
|
||||
b.ts(1,22): error TS1434: Unexpected keyword or identifier.
|
||||
b.ts(1,22): error TS2304: Cannot find name 'from'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (7 errors) ====
|
||||
export defer * as ns from "a";
|
||||
~~~~~~
|
||||
!!! error TS1128: Declaration or statement expected.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'defer'.
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'as'.
|
||||
~~
|
||||
!!! error TS1005: ';' expected.
|
||||
~~
|
||||
!!! error TS2304: Cannot find name 'ns'.
|
||||
~~~~
|
||||
!!! error TS1434: Unexpected keyword or identifier.
|
||||
~~~~
|
||||
!!! error TS2304: Cannot find name 'from'.
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
//// [tests/cases/conformance/importDefer/exportDeferInvalid.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
export defer * as ns from "a";
|
||||
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
defer * as;
|
||||
ns;
|
||||
from;
|
||||
"a";
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [tests/cases/conformance/importDefer/exportDeferInvalid.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
|
||||
export defer * as ns from "a";
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [tests/cases/conformance/importDefer/exportDeferInvalid.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
export defer * as ns from "a";
|
||||
>defer * as : number
|
||||
> : ^^^^^^
|
||||
>defer : any
|
||||
> : ^^^
|
||||
>as : any
|
||||
> : ^^^
|
||||
>ns : any
|
||||
> : ^^^
|
||||
>from : any
|
||||
> : ^^^
|
||||
>"a" : "a"
|
||||
> : ^^^
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDefaultBindingDefer.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default function defer() {
|
||||
console.log("defer from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer from "a";
|
||||
|
||||
defer();
|
||||
|
||||
//// [a.js]
|
||||
export default function defer() {
|
||||
console.log("defer from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import defer from "a";
|
||||
defer();
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDefaultBindingDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export default function defer() {
|
||||
>defer : Symbol(defer, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("defer from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer from "a";
|
||||
>defer : Symbol(defer, Decl(b.ts, 0, 6))
|
||||
|
||||
defer();
|
||||
>defer : Symbol(defer, Decl(b.ts, 0, 6))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//// [tests/cases/conformance/importDefer/importDefaultBindingDefer.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export default function defer() {
|
||||
>defer : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("defer from a");
|
||||
>console.log("defer from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"defer from a" : "defer from a"
|
||||
> : ^^^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer from "a";
|
||||
>defer : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
defer();
|
||||
>defer() : void
|
||||
> : ^^^^
|
||||
>defer : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferComments.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export {};
|
||||
|
||||
//// [b.ts]
|
||||
/*1*/ import /*2*/ defer /*3*/ * /*4*/ as /*5*/ aNs /*6*/ from /*7*/ "a" /*8*/;
|
||||
|
||||
|
||||
//// [a.js]
|
||||
export {};
|
||||
//// [b.js]
|
||||
export {};
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferComments.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== b.ts ===
|
||||
/*1*/ import /*2*/ defer /*3*/ * /*4*/ as /*5*/ aNs /*6*/ from /*7*/ "a" /*8*/;
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 24))
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferComments.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
|
||||
export {};
|
||||
|
||||
=== b.ts ===
|
||||
/*1*/ import /*2*/ defer /*3*/ * /*4*/ as /*5*/ aNs /*6*/ from /*7*/ "a" /*8*/;
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferDeclaration.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export interface Foo {
|
||||
x: number;
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer * as ns from "./a.js";
|
||||
|
||||
export type X = { foo: ns.Foo };
|
||||
|
||||
|
||||
//// [a.js]
|
||||
export {};
|
||||
//// [b.js]
|
||||
export {};
|
||||
|
||||
|
||||
//// [a.d.ts]
|
||||
export interface Foo {
|
||||
x: number;
|
||||
}
|
||||
//// [b.d.ts]
|
||||
import * as ns from "./a.js";
|
||||
export type X = {
|
||||
foo: ns.Foo;
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferDeclaration.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export interface Foo {
|
||||
>Foo : Symbol(Foo, Decl(a.ts, 0, 0))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(Foo.x, Decl(a.ts, 0, 22))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as ns from "./a.js";
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 12))
|
||||
|
||||
export type X = { foo: ns.Foo };
|
||||
>X : Symbol(X, Decl(b.ts, 0, 35))
|
||||
>foo : Symbol(foo, Decl(b.ts, 2, 17))
|
||||
>ns : Symbol(ns, Decl(b.ts, 0, 12))
|
||||
>Foo : Symbol(ns.Foo, Decl(a.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferDeclaration.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export interface Foo {
|
||||
x: number;
|
||||
>x : number
|
||||
> : ^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as ns from "./a.js";
|
||||
>ns : typeof ns
|
||||
> : ^^^^^^^^^
|
||||
|
||||
export type X = { foo: ns.Foo };
|
||||
>X : X
|
||||
> : ^
|
||||
>foo : ns.Foo
|
||||
> : ^^^^^^
|
||||
>ns : any
|
||||
> : ^^^
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
b.ts(1,8): error TS18058: Default imports are not allowed in a deferred import.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export default function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import defer foo from "a";
|
||||
~~~~~~~~~
|
||||
!!! error TS18058: Default imports are not allowed in a deferred import.
|
||||
|
||||
foo();
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferInvalidDefault.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export default function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer foo from "a";
|
||||
|
||||
foo();
|
||||
|
||||
//// [a.js]
|
||||
export default function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import defer foo from "a";
|
||||
foo();
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferInvalidDefault.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export default function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer foo from "a";
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 6))
|
||||
|
||||
foo();
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 6))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferInvalidDefault.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export default function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer foo from "a";
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
foo();
|
||||
>foo() : void
|
||||
> : ^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
b.ts(1,8): error TS18059: Named imports are not allowed in a deferred import.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import defer { foo } from "a";
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS18059: Named imports are not allowed in a deferred import.
|
||||
|
||||
foo();
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferInvalidNamed.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer { foo } from "a";
|
||||
|
||||
foo();
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import defer { foo } from "a";
|
||||
foo();
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferInvalidNamed.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer { foo } from "a";
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 14))
|
||||
|
||||
foo();
|
||||
>foo : Symbol(foo, Decl(b.ts, 0, 14))
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferInvalidNamed.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer { foo } from "a";
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
foo();
|
||||
>foo() : void
|
||||
> : ^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/foo.js(2,18): error TS1005: 'from' expected.
|
||||
/foo.js(6,12): error TS2503: Cannot find namespace 'ns'.
|
||||
|
||||
|
||||
==== /types.ts (0 errors) ====
|
||||
export type X = 1;
|
||||
|
||||
==== /foo.js (2 errors) ====
|
||||
/**
|
||||
* @import defer * as ns from "./types"
|
||||
~
|
||||
!!! error TS1005: 'from' expected.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type { ns.X }
|
||||
~~
|
||||
!!! error TS2503: Cannot find namespace 'ns'.
|
||||
*/
|
||||
let a = 2;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [tests/cases/conformance/jsdoc/importDeferJsdoc.ts] ////
|
||||
|
||||
//// [types.ts]
|
||||
export type X = 1;
|
||||
|
||||
//// [foo.js]
|
||||
/**
|
||||
* @import defer * as ns from "./types"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type { ns.X }
|
||||
*/
|
||||
let a = 2;
|
||||
|
||||
|
||||
|
||||
|
||||
//// [types.d.ts]
|
||||
export type X = 1;
|
||||
//// [foo.d.ts]
|
||||
/**
|
||||
* @import defer * as ns from "./types"
|
||||
*/
|
||||
/**
|
||||
* @type { ns.X }
|
||||
*/
|
||||
declare let a: ns.X;
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [tests/cases/conformance/jsdoc/importDeferJsdoc.ts] ////
|
||||
|
||||
=== /types.ts ===
|
||||
export type X = 1;
|
||||
>X : Symbol(X, Decl(types.ts, 0, 0))
|
||||
|
||||
=== /foo.js ===
|
||||
/**
|
||||
* @import defer * as ns from "./types"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type { ns.X }
|
||||
*/
|
||||
let a = 2;
|
||||
>a : Symbol(a, Decl(foo.js, 7, 3))
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/jsdoc/importDeferJsdoc.ts] ////
|
||||
|
||||
=== /types.ts ===
|
||||
export type X = 1;
|
||||
>X : 1
|
||||
> : ^
|
||||
|
||||
=== /foo.js ===
|
||||
/**
|
||||
* @import defer * as ns from "./types"
|
||||
*/
|
||||
|
||||
/**
|
||||
* @type { ns.X }
|
||||
*/
|
||||
let a = 2;
|
||||
>a : ns.X
|
||||
> : ^^^^
|
||||
>2 : 2
|
||||
> : ^
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
b.ts(1,8): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import defer * as aNs from "./a.js";
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,24 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer * as aNs from "./a.js";
|
||||
|
||||
aNs.foo();
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.foo = foo;
|
||||
function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const aNs = require("./a.js");
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
>foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo() : void
|
||||
> : ^^^^
|
||||
>aNs.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
b.ts(1,8): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import defer * as aNs from "./a.js";
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer * as aNs from "./a.js";
|
||||
|
||||
aNs.foo();
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import defer * as aNs from "./a.js";
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
>foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo() : void
|
||||
> : ^^^^
|
||||
>aNs.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
b.ts(1,8): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import defer * as aNs from "./a.js";
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer * as aNs from "./a.js";
|
||||
|
||||
aNs.foo();
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import defer * as aNs from "./a.js";
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
>foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo() : void
|
||||
> : ^^^^
|
||||
>aNs.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer * as aNs from "./a.js";
|
||||
|
||||
aNs.foo();
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import defer * as aNs from "./a.js";
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
>foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo() : void
|
||||
> : ^^^^
|
||||
>aNs.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
b.ts(1,8): error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
|
||||
==== a.ts (0 errors) ====
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
==== b.ts (1 errors) ====
|
||||
import defer * as aNs from "./a.js";
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS18060: Deferred imports are only supported when the '--module' flag is set to 'esnext' or 'preserve'.
|
||||
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,57 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer * as aNs from "./a.js";
|
||||
|
||||
aNs.foo();
|
||||
|
||||
//// [a.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.foo = foo;
|
||||
function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || (function () {
|
||||
var ownKeys = function(o) {
|
||||
ownKeys = Object.getOwnPropertyNames || function (o) {
|
||||
var ar = [];
|
||||
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
||||
return ar;
|
||||
};
|
||||
return ownKeys(o);
|
||||
};
|
||||
return function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const aNs = __importStar(require("./a.js"));
|
||||
aNs.foo();
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : Symbol(foo, Decl(a.ts, 0, 0))
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --))
|
||||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --))
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
>aNs : Symbol(aNs, Decl(b.ts, 0, 12))
|
||||
>foo : Symbol(aNs.foo, Decl(a.ts, 0, 0))
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
=== a.ts ===
|
||||
export function foo() {
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
console.log("foo from a");
|
||||
>console.log("foo from a") : void
|
||||
> : ^^^^
|
||||
>console.log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>console : Console
|
||||
> : ^^^^^^^
|
||||
>log : (...data: any[]) => void
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>"foo from a" : "foo from a"
|
||||
> : ^^^^^^^^^^^^
|
||||
}
|
||||
|
||||
=== b.ts ===
|
||||
import defer * as aNs from "./a.js";
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
aNs.foo();
|
||||
>aNs.foo() : void
|
||||
> : ^^^^
|
||||
>aNs.foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
>aNs : typeof aNs
|
||||
> : ^^^^^^^^^^
|
||||
>foo : () => void
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/importDefer/importDeferNamespace.ts] ////
|
||||
|
||||
//// [a.ts]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
|
||||
//// [b.ts]
|
||||
import defer * as aNs from "./a.js";
|
||||
|
||||
aNs.foo();
|
||||
|
||||
//// [a.js]
|
||||
export function foo() {
|
||||
console.log("foo from a");
|
||||
}
|
||||
//// [b.js]
|
||||
import defer * as aNs from "./a.js";
|
||||
aNs.foo();
|
||||
Loaded 100 of 138 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user