Merge branch 'master' into ownJsonParsing

This commit is contained in:
Sheetal Nandi
2017-06-05 17:01:09 -07:00
207 changed files with 885 additions and 5497 deletions
+2 -2
View File
@@ -18,7 +18,7 @@ export class Rule extends Lint.Rules.AbstractRule {
function walk(ctx: Lint.WalkContext<void>, checkCatch: boolean, checkElse: boolean): void {
const { sourceFile } = ctx;
function recur(node: ts.Node): void {
ts.forEachChild(sourceFile, function recur(node) {
switch (node.kind) {
case ts.SyntaxKind.IfStatement:
checkIf(node as ts.IfStatement);
@@ -28,7 +28,7 @@ function walk(ctx: Lint.WalkContext<void>, checkCatch: boolean, checkElse: boole
break;
}
ts.forEachChild(node, recur);
}
});
function checkIf(node: ts.IfStatement): void {
const { thenStatement, elseStatement } = node;
+1 -5
View File
@@ -2333,7 +2333,7 @@ namespace ts {
// A common practice in node modules is to set 'export = module.exports = {}', this ensures that 'exports'
// is still pointing to 'module.exports'.
// We do not want to consider this as 'export=' since a module can have only one of these.
// Similarly we do not want to treat 'module.exports = exports' as an 'export='.
// Similarlly we do not want to treat 'module.exports = exports' as an 'export='.
const assignedExpression = getRightMostAssignedExpression(node.right);
if (isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) {
// Mark it as a module in case there are no other exports in the file
@@ -2741,10 +2741,6 @@ namespace ts {
transformFlags |= TransformFlags.AssertES2015;
}
if (expression.kind === SyntaxKind.ImportKeyword) {
transformFlags |= TransformFlags.ContainsDynamicImport;
}
node.transformFlags = transformFlags | TransformFlags.HasComputedFlags;
return transformFlags & ~TransformFlags.ArrayLiteralOrCallOrNewExcludes;
}
+23 -72
View File
@@ -216,6 +216,11 @@ namespace ts {
getSuggestionForNonexistentProperty,
getSuggestionForNonexistentSymbol,
getBaseConstraintOfType,
getJsxNamespace,
resolveNameAtLocation(location: Node, name: string, meaning: SymbolFlags): Symbol | undefined {
location = getParseTreeNode(location);
return resolveName(location, name, meaning, /*nameNotFoundMessage*/ undefined, name);
},
};
const tupleTypes: GenericType[] = [];
@@ -741,6 +746,7 @@ namespace ts {
if (declarationFile !== useFile) {
if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
(!compilerOptions.outFile && !compilerOptions.out) ||
isInTypeQuery(usage) ||
isInAmbientContext(declaration)) {
// nodes are in different files and order cannot be determined
return true;
@@ -853,7 +859,7 @@ namespace ts {
location: Node | undefined,
name: string,
meaning: SymbolFlags,
nameNotFoundMessage: DiagnosticMessage,
nameNotFoundMessage: DiagnosticMessage | undefined,
nameArg: string | Identifier,
suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol {
return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage);
@@ -1370,6 +1376,9 @@ namespace ts {
// An 'import { Point } from "graphics"' needs to create a symbol that combines the value side 'Point'
// property with the type/namespace side interface 'Point'.
function combineValueAndTypeSymbols(valueSymbol: Symbol, typeSymbol: Symbol): Symbol {
if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) {
return unknownSymbol;
}
if (valueSymbol.flags & (SymbolFlags.Type | SymbolFlags.Namespace)) {
return valueSymbol;
}
@@ -2288,7 +2297,7 @@ namespace ts {
function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string {
const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.WriteTypeParametersInQualifiedName);
Debug.assert(typeNode !== undefined, "should always get typenode?");
Debug.assert(typeNode !== undefined, "should always get typenode");
const options = { removeComments: true };
const writer = createTextWriter("");
const printer = createPrinter(options);
@@ -5847,7 +5856,8 @@ namespace ts {
}
}
return arrayFrom(props.values());
} else {
}
else {
return getPropertiesOfType(type);
}
}
@@ -8362,12 +8372,6 @@ namespace ts {
/**
* This is *not* a bi-directional relationship.
* If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'.
*
* A type S is comparable to a type T if some (but not necessarily all) of the possible values of S are also possible values of T.
* It is used to check following cases:
* - the types of the left and right sides of equality/inequality operators (`===`, `!==`, `==`, `!=`).
* - the types of `case` clause expressions and their respective `switch` expressions.
* - the type of an expression in a type assertion with the type being asserted.
*/
function isTypeComparableTo(source: Type, target: Type): boolean {
return isTypeRelatedTo(source, target, comparableRelation);
@@ -14163,7 +14167,7 @@ namespace ts {
checkJsxPreconditions(node);
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
const reactRefErr = compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
const reactRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
const reactNamespace = getJsxNamespace();
const reactSym = resolveName(node.tagName, reactNamespace, SymbolFlags.Value, reactRefErr, reactNamespace);
if (reactSym) {
@@ -14534,6 +14538,7 @@ namespace ts {
const maximumLengthDifference = Math.min(3, name.length * 0.34);
let bestDistance = Number.MAX_VALUE;
let bestCandidate = undefined;
let justCheckExactMatches = false;
if (name.length > 30) {
return undefined;
}
@@ -14546,6 +14551,9 @@ namespace ts {
if (candidateName === name) {
return candidate;
}
if (justCheckExactMatches) {
continue;
}
if (candidateName.length < 3 ||
name.length < 3 ||
candidateName === "eval" ||
@@ -14561,7 +14569,8 @@ namespace ts {
continue;
}
if (distance < 3) {
return candidate;
justCheckExactMatches = true;
bestCandidate = candidate;
}
else if (distance < bestDistance) {
bestDistance = distance;
@@ -16170,35 +16179,6 @@ namespace ts {
return getReturnTypeOfSignature(signature);
}
function checkImportCallExpression(node: ImportCall): Type {
// Check grammar of dynamic import
checkGrammarArguments(node, node.arguments) || checkGrammarImportCallExpression(node);
if (node.arguments.length === 0) {
return createPromiseReturnType(node, anyType);
}
const specifier = node.arguments[0];
const specifierType = checkExpressionCached(specifier);
// Even though multiple arugments is grammatically incorrect, type-check extra arguments for completion
for (let i = 1; i < node.arguments.length; ++i) {
checkExpressionCached(node.arguments[i]);
}
if (specifierType.flags & TypeFlags.Undefined || specifierType.flags & TypeFlags.Null || !isTypeAssignableTo(specifierType, stringType)) {
error(specifier, Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
}
// resolveExternalModuleName will return undefined if the moduleReferenceExpression is not a string literal
const moduleSymbol = resolveExternalModuleName(node, specifier);
if (moduleSymbol) {
const esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true);
if (esModuleSymbol) {
return createPromiseReturnType(node, getTypeOfSymbol(esModuleSymbol));
}
}
return createPromiseReturnType(node, anyType);
}
function isCommonJsRequire(node: Node) {
if (!isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) {
return false;
@@ -16405,18 +16385,14 @@ namespace ts {
return emptyObjectType;
}
function createPromiseReturnType(func: FunctionLikeDeclaration | ImportCall, promisedType: Type) {
function createPromiseReturnType(func: FunctionLikeDeclaration, promisedType: Type) {
const promiseType = createPromiseType(promisedType);
if (promiseType === emptyObjectType) {
error(func, isImportCall(func) ?
Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option);
error(func, Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option);
return unknownType;
}
else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) {
error(func, isImportCall(func) ?
Diagnostics.A_dynamic_import_call_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option :
Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
error(func, Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option);
}
return promiseType;
@@ -17775,10 +17751,6 @@ namespace ts {
case SyntaxKind.ElementAccessExpression:
return checkIndexedAccess(<ElementAccessExpression>node);
case SyntaxKind.CallExpression:
if ((<CallExpression>node).expression.kind === SyntaxKind.ImportKeyword) {
return checkImportCallExpression(<ImportCall>node);
}
/* falls through */
case SyntaxKind.NewExpression:
return checkCallExpression(<CallExpression>node);
case SyntaxKind.TaggedTemplateExpression:
@@ -24704,27 +24676,6 @@ namespace ts {
});
return result;
}
function checkGrammarImportCallExpression(node: ImportCall): boolean {
if (modulekind === ModuleKind.ES2015) {
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_be_used_when_targeting_ECMAScript_2015_modules);
}
if (node.typeArguments) {
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_cannot_have_type_arguments);
}
const arguments = node.arguments;
if (arguments.length !== 1) {
return grammarErrorOnNode(node, Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
}
// see: parseArgumentOrArrayLiteralElement...we use this function which parse arguments of callExpression to parse specifier for dynamic import.
// parseArgumentOrArrayLiteralElement allows spread element to be in an argument list which is not allowed as specifier in dynamic import.
if (isSpreadElement(arguments[0])) {
return grammarErrorOnNode(arguments[0], Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
}
}
}
/** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */
+1 -2
View File
@@ -100,12 +100,11 @@ namespace ts {
"umd": ModuleKind.UMD,
"es6": ModuleKind.ES2015,
"es2015": ModuleKind.ES2015,
"esnext": ModuleKind.ESNext
}),
paramType: Diagnostics.KIND,
showInSimplifiedHelpView: true,
category: Diagnostics.Basic_Options,
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_es2015_or_ESNext,
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
},
{
name: "lib",
+1 -1
View File
@@ -473,7 +473,7 @@ namespace ts {
* @param array The array to map.
* @param mapfn The callback used to map the result into one or more values.
*/
export function flatMap<T, U>(array: T[], mapfn: (x: T, i: number) => U | U[]): U[] {
export function flatMap<T, U>(array: T[] | undefined, mapfn: (x: T, i: number) => U | U[] | undefined): U[] | undefined {
let result: U[];
if (array) {
result = [];
+18 -36
View File
@@ -883,31 +883,14 @@
"category": "Error",
"code": 1322
},
"Dynamic import cannot be used when targeting ECMAScript 2015 modules.": {
"String literal with double quotes expected.": {
"category": "Error",
"code": 1323
},
"Dynamic import must have one specifier as an argument.": {
"Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.": {
"category": "Error",
"code": 1324
},
"Specifier of dynamic import cannot be spread element.": {
"category": "Error",
"code": 1325
},
"Dynamic import cannot have type arguments": {
"category": "Error",
"code": 1326
},
"String literal with double quotes expected.": {
"category": "Error",
"code": 1327
},
"Property value can only be string literal, numeric literal, 'true', 'false', 'null', object literal or array literal.": {
"category": "Error",
"code": 1328
},
"Duplicate identifier '{0}'.": {
"category": "Error",
"code": 2300
@@ -1952,6 +1935,10 @@
"category": "Error",
"code": 2649
},
"Cannot emit namespaced JSX elements in React.": {
"category": "Error",
"code": 2650
},
"A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums.": {
"category": "Error",
"code": 2651
@@ -2184,14 +2171,6 @@
"category": "Error",
"code": 2710
},
"A dynamic import call returns a 'Promise'. Make sure you have a declaration for 'Promise' or include 'ES2015' in your `--lib` option.": {
"category": "Error",
"code": 2711
},
"A dynamic import call in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option.": {
"category": "Error",
"code": 2712
},
"Import declaration '{0}' is using private name '{1}'.": {
"category": "Error",
@@ -2658,7 +2637,7 @@
"category": "Message",
"code": 6015
},
"Specify module code generation: 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'.": {
"Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'.": {
"category": "Message",
"code": 6016
},
@@ -3394,11 +3373,6 @@
"category": "Error",
"code": 7035
},
"Dynamic import's specifier must be of type 'string', but here has type '{0}'.": {
"category": "Error",
"code": 7036
},
"You cannot rename this element.": {
"category": "Error",
"code": 8000
@@ -3593,11 +3567,11 @@
"category": "Message",
"code": 90015
},
"Add declaration for missing property '{0}'.": {
"Declare property '{0}'.": {
"category": "Message",
"code": 90016
},
"Add index signature for missing property '{0}'.": {
"Add index signature for property '{0}'.": {
"category": "Message",
"code": 90017
},
@@ -3621,7 +3595,15 @@
"category": "Message",
"code": 90022
},
"Declare method '{0}'.": {
"category": "Message",
"code": 90023
},
"Declare static method '{0}'.": {
"category": "Message",
"code": 90024
},
"Convert function to an ES2015 class": {
"category": "Message",
"code": 95001
-1
View File
@@ -740,7 +740,6 @@ namespace ts {
case SyntaxKind.SuperKeyword:
case SyntaxKind.TrueKeyword:
case SyntaxKind.ThisKeyword:
case SyntaxKind.ImportKeyword:
writeTokenNode(node);
return;
+2 -2
View File
@@ -2495,8 +2495,8 @@ namespace ts {
helpers
} = sourceEmitNode;
if (!destEmitNode) destEmitNode = {};
if (leadingComments) destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments);
if (trailingComments) destEmitNode.trailingComments = addRange(trailingComments.slice(), destEmitNode.trailingComments);
if (leadingComments) destEmitNode.leadingComments = concatenate(leadingComments, destEmitNode.leadingComments);
if (trailingComments) destEmitNode.trailingComments = concatenate(trailingComments, destEmitNode.trailingComments);
if (flags) destEmitNode.flags = flags;
if (commentRange) destEmitNode.commentRange = commentRange;
if (sourceMapRange) destEmitNode.sourceMapRange = sourceMapRange;
+25 -42
View File
@@ -45,16 +45,10 @@ namespace ts {
}
}
/**
* Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
* stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
* embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
* a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
*
* @param node a given node to visit its children
* @param cbNode a callback to be invoked for all child nodes
* @param cbNodeArray a callback to be invoked for embedded array
*/
// Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
// stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
// embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns
// a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned.
export function forEachChild<T>(node: Node, cbNode: (node: Node) => T | undefined, cbNodeArray?: (nodes: NodeArray<Node>) => T | undefined): T | undefined {
if (!node) {
return;
@@ -2448,7 +2442,7 @@ namespace ts {
if (token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken) {
return parseSignatureMember(SyntaxKind.CallSignature);
}
if (token() === SyntaxKind.NewKeyword && lookAhead(nextTokenIsOpenParenOrLessThan)) {
if (token() === SyntaxKind.NewKeyword && lookAhead(isStartOfConstructSignature)) {
return parseSignatureMember(SyntaxKind.ConstructSignature);
}
const fullStart = getNodePos();
@@ -2459,7 +2453,7 @@ namespace ts {
return parsePropertyOrMethodSignature(fullStart, modifiers);
}
function nextTokenIsOpenParenOrLessThan() {
function isStartOfConstructSignature() {
nextToken();
return token() === SyntaxKind.OpenParenToken || token() === SyntaxKind.LessThanToken;
}
@@ -2815,7 +2809,6 @@ namespace ts {
case SyntaxKind.SlashToken:
case SyntaxKind.SlashEqualsToken:
case SyntaxKind.Identifier:
case SyntaxKind.ImportKeyword:
return true;
default:
return isIdentifier();
@@ -3549,10 +3542,10 @@ namespace ts {
* 5) --UnaryExpression[?Yield]
*/
if (isUpdateExpression()) {
const updateExpression = parseUpdateExpression();
const incrementExpression = parseIncrementExpression();
return token() === SyntaxKind.AsteriskAsteriskToken ?
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), updateExpression) :
updateExpression;
<BinaryExpression>parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) :
incrementExpression;
}
/**
@@ -3618,7 +3611,7 @@ namespace ts {
}
// falls through
default:
return parseUpdateExpression();
return parseIncrementExpression();
}
}
@@ -3634,7 +3627,7 @@ namespace ts {
*/
function isUpdateExpression(): boolean {
// This function is called inside parseUnaryExpression to decide
// whether to call parseSimpleUnaryExpression or call parseUpdateExpression directly
// whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly
switch (token()) {
case SyntaxKind.PlusToken:
case SyntaxKind.MinusToken:
@@ -3658,9 +3651,9 @@ namespace ts {
}
/**
* Parse ES7 UpdateExpression. UpdateExpression is used instead of ES6's PostFixExpression.
* Parse ES7 IncrementExpression. IncrementExpression is used instead of ES6's PostFixExpression.
*
* ES7 UpdateExpression[yield]:
* ES7 IncrementExpression[yield]:
* 1) LeftHandSideExpression[?yield]
* 2) LeftHandSideExpression[?yield] [[no LineTerminator here]]++
* 3) LeftHandSideExpression[?yield] [[no LineTerminator here]]--
@@ -3668,7 +3661,7 @@ namespace ts {
* 5) --LeftHandSideExpression[?yield]
* In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression
*/
function parseUpdateExpression(): UpdateExpression {
function parseIncrementExpression(): IncrementExpression {
if (token() === SyntaxKind.PlusPlusToken || token() === SyntaxKind.MinusMinusToken) {
const node = <PrefixUnaryExpression>createNode(SyntaxKind.PrefixUnaryExpression);
node.operator = <PrefixUnaryOperator>token();
@@ -3718,27 +3711,17 @@ namespace ts {
// CallExpression Arguments
// CallExpression[Expression]
// CallExpression.IdentifierName
// import (AssignmentExpression)
// super Arguments
// super ( ArgumentListopt )
// super.IdentifierName
//
// Because of the recursion in these calls, we need to bottom out first. There are three
// bottom out states we can run into: 1) We see 'super' which must start either of
// the last two CallExpression productions. 2) We see 'import' which must start import call.
// 3)we have a MemberExpression which either completes the LeftHandSideExpression,
// or starts the beginning of the first four CallExpression productions.
let expression: MemberExpression;
if (token() === SyntaxKind.ImportKeyword && lookAhead(nextTokenIsOpenParenOrLessThan)) {
// We don't want to eagerly consume all import keyword as import call expression so we look a head to find "("
// For example:
// var foo3 = require("subfolder
// import * as foo1 from "module-from-node -> we want this import to be a statement rather than import call expression
sourceFile.flags |= NodeFlags.PossiblyContainDynamicImport;
expression = parseTokenNode<PrimaryExpression>();
}
else {
expression = token() === SyntaxKind.SuperKeyword ? parseSuperExpression() : parseMemberExpressionOrHigher();
}
// Because of the recursion in these calls, we need to bottom out first. There are two
// bottom out states we can run into. Either we see 'super' which must start either of
// the last two CallExpression productions. Or we have a MemberExpression which either
// completes the LeftHandSideExpression, or starts the beginning of the first four
// CallExpression productions.
const expression = token() === SyntaxKind.SuperKeyword
? parseSuperExpression()
: parseMemberExpressionOrHigher();
// Now, we *may* be complete. However, we might have consumed the start of a
// CallExpression. As such, we need to consume the rest of it here to be complete.
@@ -3746,7 +3729,7 @@ namespace ts {
}
function parseMemberExpressionOrHigher(): MemberExpression {
// Note: to make our lives simpler, we decompose the NewExpression productions and
// Note: to make our lives simpler, we decompose the the NewExpression productions and
// place ObjectCreationExpression and FunctionExpression into PrimaryExpression.
// like so:
//
@@ -4840,11 +4823,11 @@ namespace ts {
// however, we say they are here so that we may gracefully parse them and error later.
case SyntaxKind.CatchKeyword:
case SyntaxKind.FinallyKeyword:
case SyntaxKind.ImportKeyword:
return true;
case SyntaxKind.ConstKeyword:
case SyntaxKind.ExportKeyword:
case SyntaxKind.ImportKeyword:
return isStartOfDeclaration();
case SyntaxKind.AsyncKeyword:
+17 -27
View File
@@ -985,16 +985,12 @@ namespace ts {
if (sourceFile) {
return getDiagnostics(sourceFile, cancellationToken);
}
const allDiagnostics: Diagnostic[] = [];
forEach(program.getSourceFiles(), sourceFile => {
return sortAndDeduplicateDiagnostics(flatMap(program.getSourceFiles(), sourceFile => {
if (cancellationToken) {
cancellationToken.throwIfCancellationRequested();
}
addRange(allDiagnostics, getDiagnostics(sourceFile, cancellationToken));
});
return sortAndDeduplicateDiagnostics(allDiagnostics);
return getDiagnostics(sourceFile, cancellationToken);
}));
}
function getSyntacticDiagnostics(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] {
@@ -1331,19 +1327,17 @@ namespace ts {
}
function getOptionsDiagnostics(): Diagnostic[] {
const allDiagnostics: Diagnostic[] = [];
addRange(allDiagnostics, fileProcessingDiagnostics.getGlobalDiagnostics());
addRange(allDiagnostics, programDiagnostics.getGlobalDiagnostics());
if (options.configFile) {
addRange(allDiagnostics, programDiagnostics.getDiagnostics(options.configFile.fileName));
}
return sortAndDeduplicateDiagnostics(allDiagnostics);
return sortAndDeduplicateDiagnostics(concatenate(
fileProcessingDiagnostics.getGlobalDiagnostics(),
concatenate(
programDiagnostics.getGlobalDiagnostics(),
options.configFile ? programDiagnostics.getDiagnostics(options.configFile.fileName) : []
)
));
}
function getGlobalDiagnostics(): Diagnostic[] {
const allDiagnostics: Diagnostic[] = [];
addRange(allDiagnostics, getDiagnosticsProducingTypeChecker().getGlobalDiagnostics());
return sortAndDeduplicateDiagnostics(allDiagnostics);
return sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice());
}
function processRootFile(fileName: string, isDefaultLib: boolean) {
@@ -1370,7 +1364,6 @@ namespace ts {
const isJavaScriptFile = isSourceFileJavaScript(file);
const isExternalModuleFile = isExternalModule(file);
// file.imports may not be undefined if there exists dynamic import
let imports: LiteralExpression[];
let moduleAugmentations: LiteralExpression[];
let ambientModules: string[];
@@ -1390,8 +1383,8 @@ namespace ts {
for (const node of file.statements) {
collectModuleReferences(node, /*inAmbientModule*/ false);
if ((file.flags & NodeFlags.PossiblyContainDynamicImport) || isJavaScriptFile) {
collectDynamicImportOrRequireCalls(node);
if (isJavaScriptFile) {
collectRequireCalls(node);
}
}
@@ -1454,16 +1447,12 @@ namespace ts {
}
}
function collectDynamicImportOrRequireCalls(node: Node): void {
function collectRequireCalls(node: Node): void {
if (isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) {
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
}
// we have to check the argument list has length of 1. We will still have to process these even though we have parsing error.
else if (isImportCall(node) && node.arguments.length === 1 && node.arguments[0].kind === SyntaxKind.StringLiteral) {
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
}
else {
forEachChild(node, collectDynamicImportOrRequireCalls);
forEachChild(node, collectRequireCalls);
}
}
}
@@ -1495,7 +1484,8 @@ namespace ts {
}
}
return sourceFile;
} else {
}
else {
const sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
if (sourceFileNoExtension) return sourceFileNoExtension;
-1
View File
@@ -16,7 +16,6 @@
namespace ts {
function getModuleTransformer(moduleKind: ModuleKind): TransformerFactory<SourceFile> {
switch (moduleKind) {
case ModuleKind.ESNext:
case ModuleKind.ES2015:
return transformES2015Module;
case ModuleKind.System:
+2 -2
View File
@@ -2095,9 +2095,9 @@ namespace ts {
enableSubstitutionsForBlockScopedBindings();
}
const declarations = flatten(map(node.declarations, node.flags & NodeFlags.Let
const declarations = flatMap(node.declarations, node.flags & NodeFlags.Let
? visitVariableDeclarationInLetDeclarationList
: visitVariableDeclaration));
: visitVariableDeclaration);
const declarationList = createVariableDeclarationList(declarations);
setOriginalNode(declarationList, node);
+13 -124
View File
@@ -46,7 +46,6 @@ namespace ts {
let currentSourceFile: SourceFile; // The current file.
let currentModuleInfo: ExternalModuleInfo; // The ExternalModuleInfo for the current file.
let noSubstitution: boolean[]; // Set of nodes for which substitution rules should be ignored.
let needUMDDynamicImportHelper: boolean;
return transformSourceFile;
@@ -56,7 +55,7 @@ namespace ts {
* @param node The SourceFile node.
*/
function transformSourceFile(node: SourceFile) {
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules || node.transformFlags & TransformFlags.ContainsDynamicImport)) {
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
return node;
}
@@ -67,9 +66,9 @@ namespace ts {
// Perform the transformation.
const transformModule = getTransformModuleDelegate(moduleKind);
const updated = transformModule(node);
currentSourceFile = undefined;
currentModuleInfo = undefined;
needUMDDynamicImportHelper = false;
return aggregateTransformFlags(updated);
}
@@ -108,7 +107,6 @@ namespace ts {
// we need to inform the emitter to add the __export helper.
addEmitHelper(updated, exportStarHelper);
}
addEmitHelpers(updated, context.readEmitHelpers());
return updated;
}
@@ -413,9 +411,6 @@ namespace ts {
// we need to inform the emitter to add the __export helper.
addEmitHelper(body, exportStarHelper);
}
if (needUMDDynamicImportHelper) {
addEmitHelper(body, dynamicImportUMDHelper);
}
return body;
}
@@ -493,110 +488,12 @@ namespace ts {
return visitEndOfDeclarationMarker(<EndOfDeclarationMarker>node);
default:
return visitEachChild(node, importCallExpressionVisitor, context);
// This visitor does not descend into the tree, as export/import statements
// are only transformed at the top level of a file.
return node;
}
}
function importCallExpressionVisitor(node: Node): VisitResult<Node> {
// This visitor does not need to descend into the tree if there is no dynamic import,
// as export/import statements are only transformed at the top level of a file.
if (!(node.transformFlags & TransformFlags.ContainsDynamicImport)) {
return node;
}
if (isImportCall(node)) {
return visitImportCallExpression(<ImportCall>node);
}
else {
return visitEachChild(node, importCallExpressionVisitor, context);
}
}
function visitImportCallExpression(node: ImportCall): Expression {
switch (compilerOptions.module) {
case ModuleKind.CommonJS:
return transformImportCallExpressionCommonJS(node);
case ModuleKind.AMD:
return transformImportCallExpressionAMD(node);
case ModuleKind.UMD:
return transformImportCallExpressionUMD(node);
}
Debug.fail("All supported module kind in this transformation step should have been handled");
}
function transformImportCallExpressionUMD(node: ImportCall): Expression {
// (function (factory) {
// ... (regular UMD)
// }
// })(function (require, exports, useSyncRequire) {
// "use strict";
// Object.defineProperty(exports, "__esModule", { value: true });
// var __syncRequire = typeof module === "object" && typeof module.exports === "object";
// var __resolved = new Promise(function (resolve) { resolve(); });
// .....
// __syncRequire
// ? __resolved.then(function () { return require(x); }) /*CommonJs Require*/
// : new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/
// });
needUMDDynamicImportHelper = true;
return createConditional(
/*condition*/ createIdentifier("__syncRequire"),
/*whenTrue*/ transformImportCallExpressionCommonJS(node),
/*whenFalse*/ transformImportCallExpressionAMD(node)
);
}
function transformImportCallExpressionAMD(node: ImportCall): Expression {
// improt("./blah")
// emit as
// define(["require", "exports", "blah"], function (require, exports) {
// ...
// new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/
// });
const resolve = createUniqueName("resolve");
const reject = createUniqueName("reject");
return createNew(
createIdentifier("Promise"),
/*typeArguments*/ undefined,
[createFunctionExpression(
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
/*name*/ undefined,
/*typeParameters*/ undefined,
[createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ resolve),
createParameter(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject)],
/*type*/ undefined,
createBlock([createStatement(
createCall(
createIdentifier("require"),
/*typeArguments*/ undefined,
[createArrayLiteral([firstOrUndefined(node.arguments) || createOmittedExpression()]), resolve, reject]
))])
)]);
}
function transformImportCallExpressionCommonJS(node: ImportCall): Expression {
// import("./blah")
// emit as
// Promise.resolve().then(function () { return require(x); }) /*CommonJs Require*/
// We have to wrap require in then callback so that require is done in asynchronously
// if we simply do require in resolve callback in Promise constructor. We will execute the loading immediately
return createCall(
createPropertyAccess(
createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []),
"then"),
/*typeArguments*/ undefined,
[createFunctionExpression(
/*modifiers*/ undefined,
/*asteriskToken*/ undefined,
/*name*/ undefined,
/*typeParameters*/ undefined,
/*parameters*/ undefined,
/*type*/ undefined,
createBlock([createReturn(createCall(createIdentifier("require"), /*typeArguments*/ undefined, node.arguments))])
)]);
}
/**
* Visits an ImportDeclaration node.
*
@@ -889,9 +786,9 @@ namespace ts {
node.asteriskToken,
getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true),
/*typeParameters*/ undefined,
visitNodes(node.parameters, importCallExpressionVisitor),
node.parameters,
/*type*/ undefined,
visitEachChild(node.body, importCallExpressionVisitor, context)
node.body
),
/*location*/ node
),
@@ -900,7 +797,7 @@ namespace ts {
);
}
else {
statements = append(statements, visitEachChild(node, importCallExpressionVisitor, context));
statements = append(statements, node);
}
if (hasAssociatedEndOfDeclarationMarker(node)) {
@@ -931,7 +828,7 @@ namespace ts {
visitNodes(node.modifiers, modifierVisitor, isModifier),
getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true),
/*typeParameters*/ undefined,
visitNodes(node.heritageClauses, importCallExpressionVisitor),
node.heritageClauses,
node.members
),
node
@@ -941,7 +838,7 @@ namespace ts {
);
}
else {
statements = append(statements, visitEachChild(node, importCallExpressionVisitor, context));
statements = append(statements, node);
}
if (hasAssociatedEndOfDeclarationMarker(node)) {
@@ -993,7 +890,7 @@ namespace ts {
}
}
else {
statements = append(statements, visitEachChild(node, importCallExpressionVisitor, context));
statements = append(statements, node);
}
if (hasAssociatedEndOfDeclarationMarker(node)) {
@@ -1016,7 +913,7 @@ namespace ts {
function transformInitializedVariable(node: VariableDeclaration): Expression {
if (isBindingPattern(node.name)) {
return flattenDestructuringAssignment(
visitNode(node, importCallExpressionVisitor),
node,
/*visitor*/ undefined,
context,
FlattenLevel.All,
@@ -1033,7 +930,7 @@ namespace ts {
),
/*location*/ node.name
),
visitNode(node.initializer, importCallExpressionVisitor)
node.initializer
);
}
}
@@ -1600,12 +1497,4 @@ namespace ts {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}`
};
// emit helper for dynamic import
const dynamicImportUMDHelper: EmitHelper = {
name: "typescript:dynamicimport-sync-require",
scoped: true,
text: `
var __syncRequire = typeof module === "object" && typeof module.exports === "object";`
};
}
+25 -49
View File
@@ -50,7 +50,7 @@ namespace ts {
* @param node The SourceFile node.
*/
function transformSourceFile(node: SourceFile) {
if (node.isDeclarationFile || !(isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & TransformFlags.ContainsDynamicImport)) {
if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) {
return node;
}
@@ -646,7 +646,7 @@ namespace ts {
return undefined;
}
const expression = visitNode(node.expression, destructuringAndImportCallVisitor, isExpression);
const expression = visitNode(node.expression, destructuringVisitor, isExpression);
const original = node.original;
if (original && hasAssociatedEndOfDeclarationMarker(original)) {
// Defer exports until we encounter an EndOfDeclarationMarker node
@@ -673,12 +673,12 @@ namespace ts {
node.asteriskToken,
getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true),
/*typeParameters*/ undefined,
visitNodes(node.parameters, destructuringAndImportCallVisitor, isParameterDeclaration),
visitNodes(node.parameters, destructuringVisitor, isParameterDeclaration),
/*type*/ undefined,
visitNode(node.body, destructuringAndImportCallVisitor, isBlock)));
visitNode(node.body, destructuringVisitor, isBlock)));
}
else {
hoistedStatements = append(hoistedStatements, visitEachChild(node, destructuringAndImportCallVisitor, context));
hoistedStatements = append(hoistedStatements, node);
}
if (hasAssociatedEndOfDeclarationMarker(node)) {
@@ -716,8 +716,8 @@ namespace ts {
/*modifiers*/ undefined,
node.name,
/*typeParameters*/ undefined,
visitNodes(node.heritageClauses, destructuringAndImportCallVisitor, isHeritageClause),
visitNodes(node.members, destructuringAndImportCallVisitor, isClassElement)
visitNodes(node.heritageClauses, destructuringVisitor, isHeritageClause),
visitNodes(node.members, destructuringVisitor, isClassElement)
),
node
)
@@ -747,7 +747,7 @@ namespace ts {
*/
function visitVariableStatement(node: VariableStatement): VisitResult<Statement> {
if (!shouldHoistVariableDeclarationList(node.declarationList)) {
return visitNode(node, destructuringAndImportCallVisitor, isStatement);
return visitNode(node, destructuringVisitor, isStatement);
}
let expressions: Expression[];
@@ -820,13 +820,13 @@ namespace ts {
return isBindingPattern(node.name)
? flattenDestructuringAssignment(
node,
destructuringAndImportCallVisitor,
destructuringVisitor,
context,
FlattenLevel.All,
/*needsValue*/ false,
createAssignment
)
: createAssignment(node.name, visitNode(node.initializer, destructuringAndImportCallVisitor, isExpression));
: createAssignment(node.name, visitNode(node.initializer, destructuringVisitor, isExpression));
}
/**
@@ -1204,7 +1204,7 @@ namespace ts {
return visitEndOfDeclarationMarker(<EndOfDeclarationMarker>node);
default:
return destructuringAndImportCallVisitor(node);
return destructuringVisitor(node);
}
}
@@ -1220,8 +1220,8 @@ namespace ts {
node = updateFor(
node,
visitForInitializer(node.initializer),
visitNode(node.condition, destructuringAndImportCallVisitor, isExpression),
visitNode(node.incrementor, destructuringAndImportCallVisitor, isExpression),
visitNode(node.condition, destructuringVisitor, isExpression),
visitNode(node.incrementor, destructuringVisitor, isExpression),
visitNode(node.statement, nestedElementVisitor, isStatement)
);
@@ -1241,7 +1241,7 @@ namespace ts {
node = updateForIn(
node,
visitForInitializer(node.initializer),
visitNode(node.expression, destructuringAndImportCallVisitor, isExpression),
visitNode(node.expression, destructuringVisitor, isExpression),
visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock)
);
@@ -1262,7 +1262,7 @@ namespace ts {
node,
node.awaitModifier,
visitForInitializer(node.initializer),
visitNode(node.expression, destructuringAndImportCallVisitor, isExpression),
visitNode(node.expression, destructuringVisitor, isExpression),
visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock)
);
@@ -1313,7 +1313,7 @@ namespace ts {
return updateDo(
node,
visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock),
visitNode(node.expression, destructuringAndImportCallVisitor, isExpression)
visitNode(node.expression, destructuringVisitor, isExpression)
);
}
@@ -1325,7 +1325,7 @@ namespace ts {
function visitWhileStatement(node: WhileStatement): VisitResult<Statement> {
return updateWhile(
node,
visitNode(node.expression, destructuringAndImportCallVisitor, isExpression),
visitNode(node.expression, destructuringVisitor, isExpression),
visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock)
);
}
@@ -1351,7 +1351,7 @@ namespace ts {
function visitWithStatement(node: WithStatement): VisitResult<Statement> {
return updateWith(
node,
visitNode(node.expression, destructuringAndImportCallVisitor, isExpression),
visitNode(node.expression, destructuringVisitor, isExpression),
visitNode(node.statement, nestedElementVisitor, isStatement, liftToBlock)
);
}
@@ -1364,7 +1364,7 @@ namespace ts {
function visitSwitchStatement(node: SwitchStatement): VisitResult<Statement> {
return updateSwitch(
node,
visitNode(node.expression, destructuringAndImportCallVisitor, isExpression),
visitNode(node.expression, destructuringVisitor, isExpression),
visitNode(node.caseBlock, nestedElementVisitor, isCaseBlock)
);
}
@@ -1395,7 +1395,7 @@ namespace ts {
function visitCaseClause(node: CaseClause): VisitResult<CaseOrDefaultClause> {
return updateCaseClause(
node,
visitNode(node.expression, destructuringAndImportCallVisitor, isExpression),
visitNode(node.expression, destructuringVisitor, isExpression),
visitNodes(node.statements, nestedElementVisitor, isStatement)
);
}
@@ -1461,43 +1461,19 @@ namespace ts {
*
* @param node The node to visit.
*/
function destructuringAndImportCallVisitor(node: Node): VisitResult<Node> {
function destructuringVisitor(node: Node): VisitResult<Node> {
if (node.transformFlags & TransformFlags.DestructuringAssignment
&& node.kind === SyntaxKind.BinaryExpression) {
return visitDestructuringAssignment(<DestructuringAssignment>node);
}
else if (isImportCall(node)) {
return visitImportCallExpression(node);
}
else if ((node.transformFlags & TransformFlags.ContainsDestructuringAssignment) || (node.transformFlags & TransformFlags.ContainsDynamicImport)) {
return visitEachChild(node, destructuringAndImportCallVisitor, context);
else if (node.transformFlags & TransformFlags.ContainsDestructuringAssignment) {
return visitEachChild(node, destructuringVisitor, context);
}
else {
return node;
}
}
function visitImportCallExpression(node: ImportCall): Expression {
// import("./blah")
// emit as
// System.register([], function (_export, _context) {
// return {
// setters: [],
// execute: () => {
// _context.import('./blah');
// }
// };
// });
return createCall(
createPropertyAccess(
contextObject,
createIdentifier("import")
),
/*typeArguments*/ undefined,
node.arguments
);
}
/**
* Visits a DestructuringAssignment to flatten destructuring to exported symbols.
*
@@ -1507,14 +1483,14 @@ namespace ts {
if (hasExportedReferenceInDestructuringTarget(node.left)) {
return flattenDestructuringAssignment(
node,
destructuringAndImportCallVisitor,
destructuringVisitor,
context,
FlattenLevel.All,
/*needsValue*/ true
);
}
return visitEachChild(node, destructuringAndImportCallVisitor, context);
return visitEachChild(node, destructuringVisitor, context);
}
/**
+14 -33
View File
@@ -395,7 +395,6 @@ namespace ts {
// Enum value count
Count,
// Markers
FirstAssignment = EqualsToken,
LastAssignment = CaretEqualsToken,
@@ -450,14 +449,6 @@ namespace ts {
ThisNodeOrAnySubNodesHasError = 1 << 17, // If this node or any of its children had an error
HasAggregatedChildData = 1 << 18, // If we've computed data from children and cached it in this node
// This flag will be set to true when the parse encounter dynamic import so that post-parsing process of module resolution
// will not walk the tree if the flag is not set. However, this flag is just a approximation because once it is set, the flag never get reset.
// (hence it is named "possiblyContainDynamicImport").
// During editing, if dynamic import is remove, incremental parsing will *NOT* update this flag. This will then causes walking of the tree during module resolution.
// However, the removal operation should not occur often and in the case of the removal, it is likely that users will add back the import anyway.
// The advantage of this approach is its simplicity. For the case of batch compilation, we garuntee that users won't have to pay the price of walking the tree if dynamic import isn't used.
PossiblyContainDynamicImport = 1 << 19,
BlockScoped = Let | Const,
ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn,
@@ -1010,10 +1001,8 @@ namespace ts {
_unaryExpressionBrand: any;
}
/** Deprecated, please use UpdateExpression */
export type IncrementExpression = UpdateExpression;
export interface UpdateExpression extends UnaryExpression {
_updateExpressionBrand: any;
export interface IncrementExpression extends UnaryExpression {
_incrementExpressionBrand: any;
}
// see: https://tc39.github.io/ecma262/#prod-UpdateExpression
@@ -1024,9 +1013,10 @@ namespace ts {
| SyntaxKind.PlusToken
| SyntaxKind.MinusToken
| SyntaxKind.TildeToken
| SyntaxKind.ExclamationToken;
| SyntaxKind.ExclamationToken
;
export interface PrefixUnaryExpression extends UpdateExpression {
export interface PrefixUnaryExpression extends IncrementExpression {
kind: SyntaxKind.PrefixUnaryExpression;
operator: PrefixUnaryOperator;
operand: UnaryExpression;
@@ -1038,13 +1028,13 @@ namespace ts {
| SyntaxKind.MinusMinusToken
;
export interface PostfixUnaryExpression extends UpdateExpression {
export interface PostfixUnaryExpression extends IncrementExpression {
kind: SyntaxKind.PostfixUnaryExpression;
operand: LeftHandSideExpression;
operator: PostfixUnaryOperator;
}
export interface LeftHandSideExpression extends UpdateExpression {
export interface LeftHandSideExpression extends IncrementExpression {
_leftHandSideExpressionBrand: any;
}
@@ -1072,10 +1062,6 @@ namespace ts {
kind: SyntaxKind.SuperKeyword;
}
export interface ImportExpression extends PrimaryExpression {
kind: SyntaxKind.ImportKeyword;
}
export interface DeleteExpression extends UnaryExpression {
kind: SyntaxKind.DeleteExpression;
expression: UnaryExpression;
@@ -1468,7 +1454,10 @@ namespace ts {
}
// see: https://tc39.github.io/ecma262/#prod-SuperProperty
export type SuperProperty = SuperPropertyAccessExpression | SuperElementAccessExpression;
export type SuperProperty
= SuperPropertyAccessExpression
| SuperElementAccessExpression
;
export interface CallExpression extends LeftHandSideExpression, Declaration {
kind: SyntaxKind.CallExpression;
@@ -1482,10 +1471,6 @@ namespace ts {
expression: SuperExpression;
}
export interface ImportCall extends CallExpression {
expression: ImportExpression;
}
export interface ExpressionWithTypeArguments extends TypeNode {
kind: SyntaxKind.ExpressionWithTypeArguments;
parent?: HeritageClause;
@@ -2555,7 +2540,6 @@ namespace ts {
getNonNullableType(type: Type): Type;
/** Note that the resulting nodes cannot be checked. */
typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode;
/** Note that the resulting nodes cannot be checked. */
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration;
@@ -2625,6 +2609,9 @@ namespace ts {
* Does not include properties of primitive types.
*/
/* @internal */ getAllPossiblePropertiesOfType(type: Type): Symbol[];
/* @internal */ getJsxNamespace(): string;
/* @internal */ resolveNameAtLocation(location: Node, name: string, meaning: SymbolFlags): Symbol | undefined;
}
export enum NodeBuilderFlags {
@@ -3585,7 +3572,6 @@ namespace ts {
UMD = 3,
System = 4,
ES2015 = 5,
ESNext = 6
}
export const enum JsxEmit {
@@ -3973,11 +3959,6 @@ namespace ts {
ContainsYield = 1 << 24,
ContainsHoistedDeclarationOrCompletion = 1 << 25,
ContainsDynamicImport = 1 << 26,
// Please leave this as 1 << 29.
// It is the maximum bit we can set before we outgrow the size of a v8 small integer (SMI) on an x86 system.
// It is a good reminder of how much room we have left
HasComputedFlags = 1 << 29, // Transform flags have been computed.
// Assertions
+4 -22
View File
@@ -604,10 +604,6 @@ namespace ts {
return n.kind === SyntaxKind.CallExpression && (<CallExpression>n).expression.kind === SyntaxKind.SuperKeyword;
}
export function isImportCall(n: Node): n is ImportCall {
return n.kind === SyntaxKind.CallExpression && (<CallExpression>n).expression.kind === SyntaxKind.ImportKeyword;
}
export function isPrologueDirective(node: Node): node is PrologueDirective {
return node.kind === SyntaxKind.ExpressionStatement
&& (<ExpressionStatement>node).expression.kind === SyntaxKind.StringLiteral;
@@ -1449,24 +1445,10 @@ namespace ts {
}
function getJSDocTags(node: Node, kind: SyntaxKind): JSDocTag[] {
const docs = getJSDocs(node);
if (docs) {
const result: JSDocTag[] = [];
for (const doc of docs) {
if (doc.kind === SyntaxKind.JSDocParameterTag) {
if (doc.kind === kind) {
result.push(doc as JSDocTag);
}
}
else {
const tags = (doc as JSDoc).tags;
if (tags) {
result.push(...filter(tags, tag => tag.kind === kind));
}
}
}
return result;
}
return flatMap(getJSDocs(node), doc =>
doc.kind === SyntaxKind.JSDocComment
? filter((doc as JSDoc).tags, tag => tag.kind === kind)
: doc.kind === kind && doc);
}
function getFirstJSDocTag(node: Node, kind: SyntaxKind): JSDocTag {
+42 -37
View File
@@ -479,24 +479,11 @@ namespace FourSlash {
}
private getDiagnostics(fileName: string): ts.Diagnostic[] {
const syntacticErrors = this.languageService.getSyntacticDiagnostics(fileName);
const semanticErrors = this.languageService.getSemanticDiagnostics(fileName);
const diagnostics: ts.Diagnostic[] = [];
diagnostics.push.apply(diagnostics, syntacticErrors);
diagnostics.push.apply(diagnostics, semanticErrors);
return diagnostics;
return this.languageService.getSyntacticDiagnostics(fileName).concat(this.languageService.getSemanticDiagnostics(fileName));
}
private getAllDiagnostics(): ts.Diagnostic[] {
const diagnostics: ts.Diagnostic[] = [];
for (const fileName of this.languageServiceAdapterHost.getFilenames()) {
diagnostics.push.apply(this.getDiagnostics(fileName));
}
return diagnostics;
return ts.flatMap(this.languageServiceAdapterHost.getFilenames(), fileName => this.getDiagnostics(fileName));
}
public verifyErrorExistsAfterMarker(markerName: string, negative: boolean, after: boolean) {
@@ -2276,23 +2263,22 @@ namespace FourSlash {
}
/**
* Compares expected text to the text that would be in the sole range
* (ie: [|...|]) in the file after applying the codefix sole codefix
* in the source file.
*
* Because codefixes are only applied on the working file, it is unsafe
* to apply this more than once (consider a refactoring across files).
* Finds and applies a code action corresponding to the supplied parameters.
* If index is undefined, applies the unique code action available.
* @param errorCode The error code that generated the code action.
* @param index The nth (0-index-based) codeaction available generated by errorCode.
*/
public verifyRangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number) {
public getAndApplyCodeActions(errorCode?: number, index?: number) {
const fileName = this.activeFile.fileName;
this.applyCodeActions(this.getCodeFixActions(fileName, errorCode), index);
}
public verifyRangeIs(expectedText: string, includeWhiteSpace?: boolean) {
const ranges = this.getRanges();
if (ranges.length !== 1) {
this.raiseError("Exactly one range should be specified in the testfile.");
}
const fileName = this.activeFile.fileName;
this.applyCodeAction(fileName, this.getCodeFixActions(fileName, errorCode), index);
const actualText = this.rangeText(ranges[0]);
const result = includeWhiteSpace
@@ -2304,6 +2290,16 @@ namespace FourSlash {
}
}
/**
* Compares expected text to the text that would be in the sole range
* (ie: [|...|]) in the file after applying the codefix sole codefix
* in the source file.
*/
public verifyRangeAfterCodeFix(expectedText: string, includeWhiteSpace?: boolean, errorCode?: number, index?: number) {
this.getAndApplyCodeActions(errorCode, index);
this.verifyRangeIs(expectedText, includeWhiteSpace);
}
/**
* Applies fixes for the errors in fileName and compares the results to
* expectedContents after all fixes have been applied.
@@ -2316,7 +2312,7 @@ namespace FourSlash {
public verifyFileAfterCodeFix(expectedContents: string, fileName?: string) {
fileName = fileName ? fileName : this.activeFile.fileName;
this.applyCodeAction(fileName, this.getCodeFixActions(fileName));
this.applyCodeActions(this.getCodeFixActions(fileName));
const actualContents: string = this.getFileContent(fileName);
if (this.removeWhitespace(actualContents) !== this.removeWhitespace(expectedContents)) {
@@ -2354,11 +2350,10 @@ namespace FourSlash {
return actions;
}
private applyCodeAction(fileName: string, actions: ts.CodeAction[], index?: number): void {
private applyCodeActions(actions: ts.CodeAction[], index?: number): void {
if (index === undefined) {
if (!(actions && actions.length === 1)) {
const actionText = (actions && actions.length) ? JSON.stringify(actions) : "none";
this.raiseError(`Should find exactly one codefix, but found ${actionText}`);
this.raiseError(`Should find exactly one codefix, but ${actions ? actions.length : "none"} found.`);
}
index = 0;
}
@@ -2368,12 +2363,11 @@ namespace FourSlash {
}
}
const fileChanges = ts.find(actions[index].changes, change => change.fileName === fileName);
if (!fileChanges) {
this.raiseError("The CodeFix found doesn't provide any changes in this file.");
}
const changes = actions[index].changes;
this.applyEdits(fileChanges.fileName, fileChanges.textChanges, /*isFormattingEdit*/ false);
for (const change of changes) {
this.applyEdits(change.fileName, change.textChanges, /*isFormattingEdit*/ false);
}
}
public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) {
@@ -2385,7 +2379,10 @@ namespace FourSlash {
const codeFixes = this.getCodeFixActions(this.activeFile.fileName, errorCode);
if (!codeFixes || codeFixes.length === 0) {
this.raiseError("No codefixes returned.");
if (expectedTextArray.length !== 0) {
this.raiseError("No codefixes returned.");
}
return;
}
const actualTextArray: string[] = [];
@@ -2758,7 +2755,7 @@ namespace FourSlash {
const codeActions = this.languageService.getRefactorCodeActions(this.activeFile.fileName, formattingOptions, markerPos, refactorNameToApply);
this.applyCodeAction(this.activeFile.fileName, codeActions);
this.applyCodeActions(codeActions);
const actualContent = this.getFileContent(this.activeFile.fileName);
if (this.normalizeNewlines(actualContent) !== this.normalizeNewlines(expectedContent)) {
@@ -3805,6 +3802,14 @@ namespace FourSlashInterface {
this.state.verifyFileAfterApplyingRefactorAtMarker(markerName, expectedContent, refactorNameToApply, formattingOptions);
}
public rangeIs(expectedText: string, includeWhiteSpace?: boolean): void {
this.state.verifyRangeIs(expectedText, includeWhiteSpace);
}
public getAndApplyCodeFix(errorCode?: number, index?: number): void {
this.state.getAndApplyCodeActions(errorCode, index);
}
public importFixAtPosition(expectedTextArray: string[], errorCode?: number): void {
this.state.verifyImportFixAtPosition(expectedTextArray, errorCode);
}
-1
View File
@@ -857,7 +857,6 @@ namespace Harness {
export function getDefaultLibFileName(options: ts.CompilerOptions): string {
switch (options.target) {
case ts.ScriptTarget.ESNext:
case ts.ScriptTarget.ES2017:
return "lib.es2017.d.ts";
case ts.ScriptTarget.ES2016:
+3 -6
View File
@@ -232,14 +232,11 @@ namespace Playback {
// different entry).
// TODO (yuisu): We can certainly remove these once we recapture the RWC using new API
const normalizedPath = ts.normalizePath(path).toLowerCase();
const result: string[] = [];
for (const directory of replayLog.directoriesRead) {
return ts.flatMap(replayLog.directoriesRead, directory => {
if (ts.normalizeSlashes(directory.path).toLowerCase() === normalizedPath) {
result.push(...directory.result);
return directory.result;
}
}
return result;
});
});
wrapper.writeFile = recordReplay(wrapper.writeFile, underlying)(
+1 -1
View File
@@ -113,7 +113,7 @@ namespace ts {
start: undefined,
length: undefined,
}, {
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.",
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'.",
category: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.category,
code: ts.Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
@@ -155,7 +155,7 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015', 'esnext'.",
messageText: "Argument for '--module' option must be: 'none', 'commonjs', 'amd', 'system', 'umd', 'es6', 'es2015'.",
code: Diagnostics.Argument_for_0_option_must_be_Colon_1.code,
category: Diagnostics.Argument_for_0_option_must_be_Colon_1.category
}]
+2 -1
View File
@@ -250,7 +250,8 @@ namespace ts.projectSystem {
}
getEvent<T extends server.ProjectServiceEvent>(eventName: T["eventName"], mayBeMore = false): T["data"] {
if (mayBeMore) assert(this.events.length !== 0); else assert.equal(this.events.length, 1);
if (mayBeMore) { assert(this.events.length !== 0); }
else { assert.equal(this.events.length, 1); }
const event = this.events.shift();
assert.equal(event.eventName, eventName);
return event.data;
+30 -14
View File
@@ -106,6 +106,7 @@ namespace ts.server {
private rootFiles: ScriptInfo[] = [];
private rootFilesMap: FileMap<ScriptInfo> = createFileMap<ScriptInfo>();
private program: ts.Program;
private externalFiles: SortedReadonlyArray<string>;
private cachedUnresolvedImportsPerFile = new UnresolvedImportsMap();
private lastCachedUnresolvedImportsList: SortedReadonlyArray<string>;
@@ -268,8 +269,8 @@ namespace ts.server {
abstract getProjectRootPath(): string | undefined;
abstract getTypeAcquisition(): TypeAcquisition;
getExternalFiles(): string[] {
return [];
getExternalFiles(): SortedReadonlyArray<string> {
return emptyArray as SortedReadonlyArray<string>;
}
getSourceFile(path: Path) {
@@ -598,6 +599,24 @@ namespace ts.server {
}
}
}
const oldExternalFiles = this.externalFiles || emptyArray as SortedReadonlyArray<string>;
this.externalFiles = this.getExternalFiles();
enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles,
// Ensure a ScriptInfo is created for new external files. This is performed indirectly
// by the LSHost for files in the program when the program is retrieved above but
// the program doesn't contain external files so this must be done explicitly.
inserted => {
const scriptInfo = this.projectService.getOrCreateScriptInfo(inserted, /*openedByClient*/ false);
scriptInfo.attachToProject(this);
},
removed => {
const scriptInfoToDetach = this.projectService.getScriptInfo(removed);
if (scriptInfoToDetach) {
scriptInfoToDetach.detachFromProject(this);
}
});
return hasChanges;
}
@@ -993,19 +1012,16 @@ namespace ts.server {
return this.typeAcquisition;
}
getExternalFiles(): string[] {
const items: string[] = [];
for (const plugin of this.plugins) {
if (typeof plugin.getExternalFiles === "function") {
try {
items.push(...plugin.getExternalFiles(this));
}
catch (e) {
this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`);
}
getExternalFiles(): SortedReadonlyArray<string> {
return toSortedReadonlyArray(flatMap(this.plugins, plugin => {
if (typeof plugin.getExternalFiles !== "function") return;
try {
return plugin.getExternalFiles(this);
}
}
return items;
catch (e) {
this.projectService.logger.info(`A plugin threw an exception in getExternalFiles: ${e}`);
}
}));
}
watchConfigFile(callback: (project: ConfiguredProject) => void) {
+31
View File
@@ -195,6 +195,37 @@ namespace ts.server {
return <any>arr;
}
export function enumerateInsertsAndDeletes<T>(a: SortedReadonlyArray<T>, b: SortedReadonlyArray<T>, inserted: (item: T) => void, deleted: (item: T) => void, compare?: (a: T, b: T) => Comparison) {
compare = compare || ts.compareValues;
let aIndex = 0;
let bIndex = 0;
const aLen = a.length;
const bLen = b.length;
while (aIndex < aLen && bIndex < bLen) {
const aItem = a[aIndex];
const bItem = b[bIndex];
const compareResult = compare(aItem, bItem);
if (compareResult === Comparison.LessThan) {
inserted(aItem);
aIndex++;
}
else if (compareResult === Comparison.GreaterThan) {
deleted(bItem);
bIndex++;
}
else {
aIndex++;
bIndex++;
}
}
while (aIndex < aLen) {
inserted(a[aIndex++]);
}
while (bIndex < bLen) {
deleted(b[bIndex++]);
}
}
export class ThrottledOperations {
private pendingTimeouts: Map<any> = createMap<any>();
constructor(private readonly host: ServerHost) {
+125 -54
View File
@@ -8,107 +8,161 @@ namespace ts.codefix {
function getActionsForAddMissingMember(context: CodeFixContext): CodeAction[] | undefined {
const sourceFile = context.sourceFile;
const tokenSourceFile = context.sourceFile;
const start = context.span.start;
// This is the identifier of the missing property. eg:
// The identifier of the missing property. eg:
// this.missing = 1;
// ^^^^^^^
const token = getTokenAtPosition(sourceFile, start, /*includeJsDocComment*/ false);
const token = getTokenAtPosition(tokenSourceFile, start, /*includeJsDocComment*/ false);
if (token.kind !== SyntaxKind.Identifier) {
return undefined;
}
if (!isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== SyntaxKind.ThisKeyword) {
if (!isPropertyAccessExpression(token.parent)) {
return undefined;
}
const classMemberDeclaration = getThisContainer(token, /*includeArrowFunctions*/ false);
if (!isClassElement(classMemberDeclaration)) {
return undefined;
const tokenName = token.getText(tokenSourceFile);
let makeStatic = false;
let classDeclaration: ClassLikeDeclaration;
if (token.parent.expression.kind === SyntaxKind.ThisKeyword) {
const containingClassMemberDeclaration = getThisContainer(token, /*includeArrowFunctions*/ false);
if (!isClassElement(containingClassMemberDeclaration)) {
return undefined;
}
classDeclaration = <ClassLikeDeclaration>containingClassMemberDeclaration.parent;
// Property accesses on `this` in a static method are accesses of a static member.
makeStatic = classDeclaration && hasModifier(containingClassMemberDeclaration, ModifierFlags.Static);
}
else {
const checker = context.program.getTypeChecker();
const leftExpression = token.parent.expression;
const leftExpressionType = checker.getTypeAtLocation(leftExpression);
if (leftExpressionType.flags & TypeFlags.Object) {
const symbol = leftExpressionType.symbol;
if (symbol.flags & SymbolFlags.Class) {
classDeclaration = symbol.declarations && <ClassLikeDeclaration>symbol.declarations[0];
if (leftExpressionType !== checker.getDeclaredTypeOfSymbol(symbol)) {
// The expression is a class symbol but the type is not the instance-side.
makeStatic = true;
}
}
}
}
const classDeclaration = <ClassLikeDeclaration>classMemberDeclaration.parent;
if (!classDeclaration || !isClassLike(classDeclaration)) {
return undefined;
}
const isStatic = hasModifier(classMemberDeclaration, ModifierFlags.Static);
const classDeclarationSourceFile = getSourceFileOfNode(classDeclaration);
const classOpenBrace = getOpenBraceOfClassLike(classDeclaration, classDeclarationSourceFile);
return isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile();
return isInJavaScriptFile(classDeclarationSourceFile) ?
getActionsForAddMissingMemberInJavaScriptFile(classDeclaration, makeStatic) :
getActionsForAddMissingMemberInTypeScriptFile(classDeclaration, makeStatic);
function getActionsForAddMissingMemberInJavaScriptFile(): CodeAction[] | undefined {
const memberName = token.getText();
function getActionsForAddMissingMemberInJavaScriptFile(classDeclaration: ClassLikeDeclaration, makeStatic: boolean): CodeAction[] | undefined {
let actions: CodeAction[];
if (isStatic) {
const methodCodeAction = getActionForMethodDeclaration(/*includeTypeScriptSyntax*/ false);
if (methodCodeAction) {
actions = [methodCodeAction];
}
if (makeStatic) {
if (classDeclaration.kind === SyntaxKind.ClassExpression) {
return undefined;
return actions;
}
const className = classDeclaration.name.getText();
return [{
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_static_property_0), [memberName]),
changes: [{
fileName: sourceFile.fileName,
textChanges: [{
span: { start: classDeclaration.getEnd(), length: 0 },
newText: `${context.newLineCharacter}${className}.${memberName} = undefined;${context.newLineCharacter}`
}]
}]
}];
const staticInitialization = createStatement(createAssignment(
createPropertyAccess(createIdentifier(className), tokenName),
createIdentifier("undefined")));
const staticInitializationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
staticInitializationChangeTracker.insertNodeAfter(
classDeclarationSourceFile,
classDeclaration,
staticInitialization,
{ suffix: context.newLineCharacter });
const initializeStaticAction = {
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_static_property_0), [tokenName]),
changes: staticInitializationChangeTracker.getChanges()
};
(actions || (actions = [])).push(initializeStaticAction);
return actions;
}
else {
const classConstructor = getFirstConstructorWithBody(classDeclaration);
if (!classConstructor) {
return undefined;
return actions;
}
return [{
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [memberName]),
changes: [{
fileName: sourceFile.fileName,
textChanges: [{
span: { start: classConstructor.body.getEnd() - 1, length: 0 },
newText: `this.${memberName} = undefined;${context.newLineCharacter}`
}]
}]
}];
const propertyInitialization = createStatement(createAssignment(
createPropertyAccess(createThis(), tokenName),
createIdentifier("undefined")));
const propertyInitializationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
propertyInitializationChangeTracker.insertNodeAt(
classDeclarationSourceFile,
classConstructor.body.getEnd() - 1,
propertyInitialization,
{ prefix: context.newLineCharacter, suffix: context.newLineCharacter });
const initializeAction = {
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Initialize_property_0_in_the_constructor), [tokenName]),
changes: propertyInitializationChangeTracker.getChanges()
};
(actions || (actions = [])).push(initializeAction);
return actions;
}
}
function getActionsForAddMissingMemberInTypeScriptFile(): CodeAction[] | undefined {
let typeNode: TypeNode;
function getActionsForAddMissingMemberInTypeScriptFile(classDeclaration: ClassLikeDeclaration, makeStatic: boolean): CodeAction[] | undefined {
let actions: CodeAction[];
if (token.parent.parent.kind === SyntaxKind.BinaryExpression) {
const binaryExpression = token.parent.parent as BinaryExpression;
const checker = context.program.getTypeChecker();
const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right)));
typeNode = checker.typeToTypeNode(widenedType, classDeclaration);
const methodCodeAction = getActionForMethodDeclaration(/*includeTypeScriptSyntax*/ true);
if (methodCodeAction) {
actions = [methodCodeAction];
}
let typeNode: TypeNode;
if (token.parent.parent.kind === SyntaxKind.BinaryExpression) {
const binaryExpression = token.parent.parent as BinaryExpression;
const otherExpression = token.parent === binaryExpression.left ? binaryExpression.right : binaryExpression.left;
const checker = context.program.getTypeChecker();
const widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(otherExpression)));
typeNode = checker.typeToTypeNode(widenedType, classDeclaration);
}
typeNode = typeNode || createKeywordTypeNode(SyntaxKind.AnyKeyword);
const openBrace = getOpenBraceOfClassLike(classDeclaration, sourceFile);
const property = createProperty(
/*decorators*/undefined,
/*modifiers*/ isStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined,
token.getText(sourceFile),
/*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined,
tokenName,
/*questionToken*/ undefined,
typeNode,
/*initializer*/ undefined);
const propertyChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter });
propertyChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, property, { suffix: context.newLineCharacter });
const actions = [{
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]),
(actions || (actions = [])).push({
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Declare_property_0), [tokenName]),
changes: propertyChangeTracker.getChanges()
}];
});
if (!isStatic) {
if (!makeStatic) {
// Index signatures cannot have the static modifier.
const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword);
const indexingParameter = createParameter(
/*decorators*/ undefined,
@@ -125,15 +179,32 @@ namespace ts.codefix {
typeNode);
const indexSignatureChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter });
indexSignatureChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, indexSignature, { suffix: context.newLineCharacter });
actions.push({
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]),
description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Add_index_signature_for_property_0), [tokenName]),
changes: indexSignatureChangeTracker.getChanges()
});
}
return actions;
}
function getActionForMethodDeclaration(includeTypeScriptSyntax: boolean): CodeAction | undefined {
if (token.parent.parent.kind === SyntaxKind.CallExpression) {
const callExpression = <CallExpression>token.parent.parent;
const methodDeclaration = createMethodFromCallExpression(callExpression, tokenName, includeTypeScriptSyntax, makeStatic);
const methodDeclarationChangeTracker = textChanges.ChangeTracker.fromCodeFixContext(context);
methodDeclarationChangeTracker.insertNodeAfter(classDeclarationSourceFile, classOpenBrace, methodDeclaration, { suffix: context.newLineCharacter });
return {
description: formatStringFromArgs(getLocaleSpecificMessage(makeStatic ?
Diagnostics.Declare_method_0 :
Diagnostics.Declare_static_method_0),
[tokenName]),
changes: methodDeclarationChangeTracker.getChanges()
};
}
}
}
}
+45 -13
View File
@@ -142,6 +142,50 @@ namespace ts.codefix {
}
}
export function createMethodFromCallExpression(callExpression: CallExpression, methodName: string, includeTypeScriptSyntax: boolean, makeStatic: boolean): MethodDeclaration {
const parameters = createDummyParameters(callExpression.arguments.length, /*names*/ undefined, /*minArgumentCount*/ undefined, includeTypeScriptSyntax);
let typeParameters: TypeParameterDeclaration[];
if (includeTypeScriptSyntax) {
const typeArgCount = length(callExpression.typeArguments);
for (let i = 0; i < typeArgCount; i++) {
const name = typeArgCount < 8 ? String.fromCharCode(CharacterCodes.T + i) : `T${i}`;
const typeParameter = createTypeParameterDeclaration(name, /*constraint*/ undefined, /*defaultType*/ undefined);
(typeParameters ? typeParameters : typeParameters = []).push(typeParameter);
}
}
const newMethod = createMethod(
/*decorators*/ undefined,
/*modifiers*/ makeStatic ? [createToken(SyntaxKind.StaticKeyword)] : undefined,
/*asteriskToken*/ undefined,
methodName,
/*questionToken*/ undefined,
typeParameters,
parameters,
/*type*/ includeTypeScriptSyntax ? createKeywordTypeNode(SyntaxKind.AnyKeyword) : undefined,
createStubbedMethodBody()
);
return newMethod;
}
function createDummyParameters(argCount: number, names: string[] | undefined, minArgumentCount: number | undefined, addAnyType: boolean) {
const parameters: ParameterDeclaration[] = [];
for (let i = 0; i < argCount; i++) {
const newParameter = createParameter(
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*dotDotDotToken*/ undefined,
/*name*/ names && names[i] || `arg${i}`,
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined,
/*type*/ addAnyType ? createKeywordTypeNode(SyntaxKind.AnyKeyword) : undefined,
/*initializer*/ undefined);
parameters.push(newParameter);
}
return parameters;
}
function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration {
/** This is *a* signature with the maximal number of arguments,
* such that if there is a "maximal" signature without rest arguments,
@@ -163,19 +207,7 @@ namespace ts.codefix {
const maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0);
const maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(symbol => symbol.getName());
const parameters: ParameterDeclaration[] = [];
for (let i = 0; i < maxNonRestArgs; i++) {
const anyType = createKeywordTypeNode(SyntaxKind.AnyKeyword);
const newParameter = createParameter(
/*decorators*/ undefined,
/*modifiers*/ undefined,
/*dotDotDotToken*/ undefined,
maxArgsParameterSymbolNames[i],
/*questionToken*/ i >= minArgumentCount ? createToken(SyntaxKind.QuestionToken) : undefined,
anyType,
/*initializer*/ undefined);
parameters.push(newParameter);
}
const parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, minArgumentCount, /*addAnyType*/ true);
if (someSigHasRestParameter) {
const anyArrayType = createArrayTypeNode(createKeywordTypeNode(SyntaxKind.AnyKeyword));
+27 -11
View File
@@ -138,8 +138,23 @@ namespace ts.codefix {
const currentTokenMeaning = getMeaningFromLocation(token);
if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
const symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token));
return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true);
const umdSymbol = checker.getSymbolAtLocation(token);
let symbol: ts.Symbol;
let symbolName: string;
if (umdSymbol.flags & ts.SymbolFlags.Alias) {
symbol = checker.getAliasedSymbol(umdSymbol);
symbolName = name;
}
else if (isJsxOpeningLikeElement(token.parent) && token.parent.tagName === token) {
// The error wasn't for the symbolAtLocation, it was for the JSX tag itself, which needs access to e.g. `React`.
symbol = checker.getAliasedSymbol(checker.resolveNameAtLocation(token, checker.getJsxNamespace(), SymbolFlags.Value));
symbolName = symbol.name;
}
else {
Debug.fail("Either the symbol or the JSX namespace should be a UMD global if we got here");
}
return getCodeActionForImport(symbol, symbolName, /*isDefault*/ false, /*isNamespaceImport*/ true);
}
const candidateModules = checker.getAmbientModules();
@@ -159,7 +174,7 @@ namespace ts.codefix {
if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) {
// check if this symbol is already used
const symbolId = getUniqueSymbolId(localSymbol);
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefault*/ true));
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name, /*isDefault*/ true));
}
}
@@ -167,7 +182,7 @@ namespace ts.codefix {
const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol);
if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName);
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol));
symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, name));
}
}
@@ -218,7 +233,7 @@ namespace ts.codefix {
return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false;
}
function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] {
function getCodeActionForImport(moduleSymbol: Symbol, symbolName: string, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] {
const existingDeclarations = getImportDeclarations(moduleSymbol);
if (existingDeclarations.length > 0) {
// With an existing import statement, there are more than one actions the user can do.
@@ -375,10 +390,10 @@ namespace ts.codefix {
const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport());
const changeTracker = createChangeTracker();
const importClause = isDefault
? createImportClause(createIdentifier(name), /*namedBindings*/ undefined)
? createImportClause(createIdentifier(symbolName), /*namedBindings*/ undefined)
: isNamespaceImport
? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name)))
: createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))]));
? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(symbolName)))
: createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(symbolName))]));
const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes));
if (!lastImportDeclaration) {
changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` });
@@ -392,7 +407,7 @@ namespace ts.codefix {
// are there are already a new line seperating code and import statements.
return createCodeAction(
Diagnostics.Import_0_from_1,
[name, `"${moduleSpecifierWithoutQuotes}"`],
[symbolName, `"${moduleSpecifierWithoutQuotes}"`],
changeTracker.getChanges(),
"NewImport",
moduleSpecifierWithoutQuotes
@@ -412,8 +427,9 @@ namespace ts.codefix {
removeFileExtension(getRelativePath(moduleFileName, sourceDirectory));
function tryGetModuleNameFromAmbientModule(): string {
if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) {
return moduleSymbol.name;
const decl = moduleSymbol.valueDeclaration;
if (isModuleDeclaration(decl) && isStringLiteral(decl.name)) {
return decl.name.text;
}
}
+20 -18
View File
@@ -20,6 +20,22 @@ namespace ts.Completions {
const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName, requestJsDocTag, hasFilteredClassMemberKeywords } = completionData;
if (sourceFile.languageVariant === LanguageVariant.JSX &&
location && location.parent && location.parent.kind === SyntaxKind.JsxClosingElement) {
// In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag,
// instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element.
// For example:
// var x = <div> </ /*1*/> completion list at "1" will contain "div" with type any
const tagName = (<JsxElement>location.parent.parent).openingElement.tagName;
return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: false,
entries: [{
name: (<JsxTagNameExpression>tagName).getFullText(),
kind: ScriptElementKind.classElement,
kindModifiers: undefined,
sortText: "0",
}]};
}
if (requestJsDocTagName) {
// If the current position is a jsDoc tag name, only tag names should be provided for completion
return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: JsDoc.getJSDocTagNameCompletions() };
@@ -38,21 +54,7 @@ namespace ts.Completions {
}
else {
if (!symbols || symbols.length === 0) {
if (sourceFile.languageVariant === LanguageVariant.JSX &&
location.parent && location.parent.kind === SyntaxKind.JsxClosingElement) {
// In the TypeScript JSX element, if such element is not defined. When users query for completion at closing tag,
// instead of simply giving unknown value, the completion will return the tag-name of an associated opening-element.
// For example:
// var x = <div> </ /*1*/> completion list at "1" will contain "div" with type any
const tagName = (<JsxElement>location.parent.parent).openingElement.tagName;
entries.push({
name: (<Identifier>tagName).text,
kind: undefined,
kindModifiers: undefined,
sortText: "0",
});
}
else if (!hasFilteredClassMemberKeywords) {
if (!hasFilteredClassMemberKeywords) {
return undefined;
}
}
@@ -495,7 +497,7 @@ namespace ts.Completions {
// It has a left-hand side, so we're not in an opening JSX tag.
break;
}
// falls through
// falls through
case SyntaxKind.JsxSelfClosingElement:
case SyntaxKind.JsxElement:
@@ -1050,7 +1052,7 @@ namespace ts.Completions {
default:
if (isFromClassElementDeclaration(contextToken) &&
(isClassMemberCompletionKeyword(contextToken.kind) ||
isClassMemberCompletionKeywordText(contextToken.getText()))) {
isClassMemberCompletionKeywordText(contextToken.getText()))) {
return contextToken.parent.parent as ClassLikeDeclaration;
}
}
@@ -1213,7 +1215,7 @@ namespace ts.Completions {
if (isFromClassElementDeclaration(contextToken)) {
return false;
}
// falls through
// falls through
case SyntaxKind.ClassKeyword:
case SyntaxKind.EnumKeyword:
case SyntaxKind.InterfaceKeyword:
+2 -1
View File
@@ -185,7 +185,8 @@ namespace ts.FindAllReferences {
if (entry.type === "node") {
const { node } = entry;
return { textSpan: getTextSpan(node), fileName: node.getSourceFile().fileName, ...implementationKindDisplayParts(node, checker) };
} else {
}
else {
const { textSpan, fileName } = entry;
return { textSpan, fileName, kind: ScriptElementKind.unknown, displayParts: [] };
}
+2 -1
View File
@@ -530,7 +530,8 @@ namespace ts.FindAllReferences {
if (parent.kind === SyntaxKind.VariableDeclaration) {
const p = parent as ts.VariableDeclaration;
return p.parent.kind === ts.SyntaxKind.CatchClause ? undefined : p.parent.parent.kind === SyntaxKind.VariableStatement ? p.parent.parent : undefined;
} else {
}
else {
return parent;
}
}
+1 -11
View File
@@ -52,18 +52,8 @@ namespace ts {
}
export function getRefactorCodeActions(context: RefactorContext, refactorName: string): CodeAction[] | undefined {
let result: CodeAction[];
const refactor = refactors.get(refactorName);
if (!refactor) {
return undefined;
}
const codeActions = refactor.getCodeActions(context);
if (codeActions) {
addRange((result || (result = [])), codeActions);
}
return result;
return refactor && refactor.getCodeActions(context);
}
}
}
+1 -2
View File
@@ -368,7 +368,7 @@ namespace ts {
_primaryExpressionBrand: any;
_memberExpressionBrand: any;
_leftHandSideExpressionBrand: any;
_updateExpressionBrand: any;
_incrementExpressionBrand: any;
_unaryExpressionBrand: any;
_expressionBrand: any;
/*@internal*/typeArguments: NodeArray<TypeNode>;
@@ -521,7 +521,6 @@ namespace ts {
private namedDeclarations: Map<Declaration[]>;
public ambientModuleNames: string[];
public checkJsDirective: CheckJsDirective | undefined;
public possiblyContainDynamicImport: boolean;
constructor(kind: SyntaxKind, pos: number, end: number) {
super(kind, pos, end);
@@ -0,0 +1,15 @@
//// [tests/cases/compiler/blockScopedClassDeclarationAcrossFiles.ts] ////
//// [c.ts]
let foo: typeof C;
//// [b.ts]
class C { }
//// [foo.js]
var foo;
var C = (function () {
function C() {
}
return C;
}());
@@ -0,0 +1,9 @@
=== tests/cases/compiler/c.ts ===
let foo: typeof C;
>foo : Symbol(foo, Decl(c.ts, 0, 3))
>C : Symbol(C, Decl(b.ts, 0, 0))
=== tests/cases/compiler/b.ts ===
class C { }
>C : Symbol(C, Decl(b.ts, 0, 0))
@@ -0,0 +1,9 @@
=== tests/cases/compiler/c.ts ===
let foo: typeof C;
>foo : typeof C
>C : typeof C
=== tests/cases/compiler/b.ts ===
class C { }
>C : C
@@ -0,0 +1,16 @@
tests/cases/compiler/exactSpellingSuggestion.ts(9,4): error TS2551: Property 'bit_2' does not exist on type 'typeof U8'. Did you mean 'BIT_2'?
==== tests/cases/compiler/exactSpellingSuggestion.ts (1 errors) ====
// Fixes #16245 -- always suggest the exact match, even when
// other options are very close
enum U8 {
BIT_0 = 1 << 0,
BIT_1 = 1 << 1,
BIT_2 = 1 << 2
}
U8.bit_2
~~~~~
!!! error TS2551: Property 'bit_2' does not exist on type 'typeof U8'. Did you mean 'BIT_2'?
@@ -0,0 +1,22 @@
//// [exactSpellingSuggestion.ts]
// Fixes #16245 -- always suggest the exact match, even when
// other options are very close
enum U8 {
BIT_0 = 1 << 0,
BIT_1 = 1 << 1,
BIT_2 = 1 << 2
}
U8.bit_2
//// [exactSpellingSuggestion.js]
// Fixes #16245 -- always suggest the exact match, even when
// other options are very close
var U8;
(function (U8) {
U8[U8["BIT_0"] = 1] = "BIT_0";
U8[U8["BIT_1"] = 2] = "BIT_1";
U8[U8["BIT_2"] = 4] = "BIT_2";
})(U8 || (U8 = {}));
U8.bit_2;
@@ -1,27 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpression1ESNext.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
})
function foo() {
const p2 = import("./0");
}
//// [0.js]
export function foo() { return "foo"; }
//// [1.js]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}
@@ -1,28 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
var p1 = import("./0");
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
p1.then(zero => {
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
return zero.foo();
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
>foo : Symbol(foo, Decl(0.ts, 0, 0))
})
function foo() {
>foo : Symbol(foo, Decl(1.ts, 4, 2))
const p2 = import("./0");
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
}
@@ -1,39 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
})
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
}
@@ -1,29 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpression2ESNext.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
//// [2.ts]
function foo(x: Promise<any>) {
x.then(value => {
let b = new value.B();
b.print();
})
}
foo(import("./0"));
//// [0.js]
export class B {
print() { return "I am B"; }
}
//// [2.js]
function foo(x) {
x.then(value => {
let b = new value.B();
b.print();
});
}
foo(import("./0"));
@@ -1,33 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : Symbol(B, Decl(0.ts, 0, 0))
print() { return "I am B"}
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
=== tests/cases/conformance/dynamicImport/2.ts ===
function foo(x: Promise<any>) {
>foo : Symbol(foo, Decl(2.ts, 0, 0))
>x : Symbol(x, Decl(2.ts, 0, 13))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
x.then(value => {
>x.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(2.ts, 0, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>value : Symbol(value, Decl(2.ts, 1, 11))
let b = new value.B();
>b : Symbol(b, Decl(2.ts, 2, 11))
>value : Symbol(value, Decl(2.ts, 1, 11))
b.print();
>b : Symbol(b, Decl(2.ts, 2, 11))
})
}
foo(import("./0"));
>foo : Symbol(foo, Decl(2.ts, 0, 0))
@@ -1,45 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : B
print() { return "I am B"}
>print : () => string
>"I am B" : "I am B"
}
=== tests/cases/conformance/dynamicImport/2.ts ===
function foo(x: Promise<any>) {
>foo : (x: Promise<any>) => void
>x : Promise<any>
>Promise : Promise<T>
x.then(value => {
>x.then(value => { let b = new value.B(); b.print(); }) : Promise<void>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>x : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>value => { let b = new value.B(); b.print(); } : (value: any) => void
>value : any
let b = new value.B();
>b : any
>new value.B() : any
>value.B : any
>value : any
>B : any
b.print();
>b.print() : any
>b.print : any
>b : any
>print : any
})
}
foo(import("./0"));
>foo(import("./0")) : void
>foo : (x: Promise<any>) => void
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
@@ -1,27 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpression3ESNext.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
//// [2.ts]
async function foo() {
class C extends (await import("./0")).B {}
var c = new C();
c.print();
}
foo();
//// [0.js]
export class B {
print() { return "I am B"; }
}
//// [2.js]
async function foo() {
class C extends (await import("./0")).B {
}
var c = new C();
c.print();
}
foo();
@@ -1,29 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : Symbol(B, Decl(0.ts, 0, 0))
print() { return "I am B"}
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
=== tests/cases/conformance/dynamicImport/2.ts ===
async function foo() {
>foo : Symbol(foo, Decl(2.ts, 0, 0))
class C extends (await import("./0")).B {}
>C : Symbol(C, Decl(2.ts, 0, 22))
>(await import("./0")).B : Symbol(B, Decl(0.ts, 0, 0))
>B : Symbol(B, Decl(0.ts, 0, 0))
var c = new C();
>c : Symbol(c, Decl(2.ts, 2, 7))
>C : Symbol(C, Decl(2.ts, 0, 22))
c.print();
>c.print : Symbol(B.print, Decl(0.ts, 0, 16))
>c : Symbol(c, Decl(2.ts, 2, 7))
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
foo();
>foo : Symbol(foo, Decl(2.ts, 0, 0))
@@ -1,37 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : B
print() { return "I am B"}
>print : () => string
>"I am B" : "I am B"
}
=== tests/cases/conformance/dynamicImport/2.ts ===
async function foo() {
>foo : () => Promise<void>
class C extends (await import("./0")).B {}
>C : C
>(await import("./0")).B : B
>(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0"
>await import("./0") : typeof "tests/cases/conformance/dynamicImport/0"
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
>B : typeof B
var c = new C();
>c : C
>new C() : C
>C : typeof C
c.print();
>c.print() : string
>c.print : () => string
>c : C
>print : () => string
}
foo();
>foo() : Promise<void>
>foo : () => Promise<void>
@@ -1,49 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpression4ESNext.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
export function foo() { return "foo" }
//// [1.ts]
export function backup() { return "backup"; }
//// [2.ts]
declare var console: any;
class C {
private myModule = import("./0");
method() {
this.myModule.then(Zero => {
console.log(Zero.foo());
}, async err => {
console.log(err);
let one = await import("./1");
console.log(one.backup());
});
}
}
//// [0.js]
export class B {
print() { return "I am B"; }
}
export function foo() { return "foo"; }
//// [1.js]
export function backup() { return "backup"; }
//// [2.js]
class C {
constructor() {
this.myModule = import("./0");
}
method() {
this.myModule.then(Zero => {
console.log(Zero.foo());
}, async (err) => {
console.log(err);
let one = await import("./1");
console.log(one.backup());
});
}
}
@@ -1,61 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : Symbol(B, Decl(0.ts, 0, 0))
print() { return "I am B"}
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
export function foo() { return "foo" }
>foo : Symbol(foo, Decl(0.ts, 2, 1))
=== tests/cases/conformance/dynamicImport/1.ts ===
export function backup() { return "backup"; }
>backup : Symbol(backup, Decl(1.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/2.ts ===
declare var console: any;
>console : Symbol(console, Decl(2.ts, 0, 11))
class C {
>C : Symbol(C, Decl(2.ts, 0, 25))
private myModule = import("./0");
>myModule : Symbol(C.myModule, Decl(2.ts, 1, 9))
method() {
>method : Symbol(C.method, Decl(2.ts, 2, 37))
this.myModule.then(Zero => {
>this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>this.myModule : Symbol(C.myModule, Decl(2.ts, 1, 9))
>this : Symbol(C, Decl(2.ts, 0, 25))
>myModule : Symbol(C.myModule, Decl(2.ts, 1, 9))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>Zero : Symbol(Zero, Decl(2.ts, 4, 27))
console.log(Zero.foo());
>console : Symbol(console, Decl(2.ts, 0, 11))
>Zero.foo : Symbol(foo, Decl(0.ts, 2, 1))
>Zero : Symbol(Zero, Decl(2.ts, 4, 27))
>foo : Symbol(foo, Decl(0.ts, 2, 1))
}, async err => {
>err : Symbol(err, Decl(2.ts, 6, 16))
console.log(err);
>console : Symbol(console, Decl(2.ts, 0, 11))
>err : Symbol(err, Decl(2.ts, 6, 16))
let one = await import("./1");
>one : Symbol(one, Decl(2.ts, 8, 15))
console.log(one.backup());
>console : Symbol(console, Decl(2.ts, 0, 11))
>one.backup : Symbol(backup, Decl(1.ts, 0, 0))
>one : Symbol(one, Decl(2.ts, 8, 15))
>backup : Symbol(backup, Decl(1.ts, 0, 0))
});
}
}
@@ -1,83 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : B
print() { return "I am B"}
>print : () => string
>"I am B" : "I am B"
}
export function foo() { return "foo" }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
export function backup() { return "backup"; }
>backup : () => string
>"backup" : "backup"
=== tests/cases/conformance/dynamicImport/2.ts ===
declare var console: any;
>console : any
class C {
>C : C
private myModule = import("./0");
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
method() {
>method : () => void
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
console.log(Zero.foo());
>console.log(Zero.foo()) : any
>console.log : any
>console : any
>log : any
>Zero.foo() : string
>Zero.foo : () => string
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
}, async err => {
>async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); } : (err: any) => Promise<void>
>err : any
console.log(err);
>console.log(err) : any
>console.log : any
>console : any
>log : any
>err : any
let one = await import("./1");
>one : typeof "tests/cases/conformance/dynamicImport/1"
>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1"
>import("./1") : Promise<typeof "tests/cases/conformance/dynamicImport/1">
>"./1" : "./1"
console.log(one.backup());
>console.log(one.backup()) : any
>console.log : any
>console : any
>log : any
>one.backup() : string
>one.backup : () => string
>one : typeof "tests/cases/conformance/dynamicImport/1"
>backup : () => string
});
}
}
@@ -1,31 +0,0 @@
tests/cases/conformance/dynamicImport/2.ts(3,23): error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./0" | undefined'.
tests/cases/conformance/dynamicImport/2.ts(4,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'undefined'.
tests/cases/conformance/dynamicImport/2.ts(5,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./1" | null'.
tests/cases/conformance/dynamicImport/2.ts(6,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'null'.
==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ====
export class B {
print() { return "I am B"}
}
export function foo() { return "foo" }
==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ====
export function backup() { return "backup"; }
==== tests/cases/conformance/dynamicImport/2.ts (4 errors) ====
declare function bar(): boolean;
const specify = bar() ? "./0" : undefined;
let myModule = import(specify);
~~~~~~~
!!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./0" | undefined'.
let myModule1 = import(undefined);
~~~~~~~~~
!!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'undefined'.
let myModule2 = import(bar() ? "./1" : null);
~~~~~~~~~~~~~~~~~~~~
!!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type '"./1" | null'.
let myModule3 = import(null);
~~~~
!!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'null'.
@@ -1,33 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpression5ESNext.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
export function foo() { return "foo" }
//// [1.ts]
export function backup() { return "backup"; }
//// [2.ts]
declare function bar(): boolean;
const specify = bar() ? "./0" : undefined;
let myModule = import(specify);
let myModule1 = import(undefined);
let myModule2 = import(bar() ? "./1" : null);
let myModule3 = import(null);
//// [0.js]
export class B {
print() { return "I am B"; }
}
export function foo() { return "foo"; }
//// [1.js]
export function backup() { return "backup"; }
//// [2.js]
const specify = bar() ? "./0" : undefined;
let myModule = import(specify);
let myModule1 = import(undefined);
let myModule2 = import(bar() ? "./1" : null);
let myModule3 = import(null);
@@ -1,25 +0,0 @@
tests/cases/conformance/dynamicImport/2.ts(4,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'undefined'.
tests/cases/conformance/dynamicImport/2.ts(6,24): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'null'.
==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ====
export class B {
print() { return "I am B"}
}
export function foo() { return "foo" }
==== tests/cases/conformance/dynamicImport/1.ts (0 errors) ====
export function backup() { return "backup"; }
==== tests/cases/conformance/dynamicImport/2.ts (2 errors) ====
declare function bar(): boolean;
const specify = bar() ? "./0" : undefined;
let myModule = import(specify);
let myModule1 = import(undefined);
~~~~~~~~~
!!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'undefined'.
let myModule2 = import(bar() ? "./1" : null);
let myModule3 = import(null);
~~~~
!!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'null'.
@@ -1,33 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpression6ESNext.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
export function foo() { return "foo" }
//// [1.ts]
export function backup() { return "backup"; }
//// [2.ts]
declare function bar(): boolean;
const specify = bar() ? "./0" : undefined;
let myModule = import(specify);
let myModule1 = import(undefined);
let myModule2 = import(bar() ? "./1" : null);
let myModule3 = import(null);
//// [0.js]
export class B {
print() { return "I am B"; }
}
export function foo() { return "foo"; }
//// [1.js]
export function backup() { return "backup"; }
//// [2.js]
const specify = bar() ? "./0" : undefined;
let myModule = import(specify);
let myModule1 = import(undefined);
let myModule2 = import(bar() ? "./1" : null);
let myModule3 = import(null);
@@ -1,30 +0,0 @@
tests/cases/conformance/dynamicImport/1.ts(4,5): error TS2322: Type 'Promise<typeof "tests/cases/conformance/dynamicImport/defaultPath">' is not assignable to type 'Promise<typeof "tests/cases/conformance/dynamicImport/anotherModule">'.
Type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"' is not assignable to type 'typeof "tests/cases/conformance/dynamicImport/anotherModule"'.
Property 'D' is missing in type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"'.
tests/cases/conformance/dynamicImport/1.ts(5,10): error TS2352: Type 'Promise<typeof "tests/cases/conformance/dynamicImport/defaultPath">' cannot be converted to type 'Promise<typeof "tests/cases/conformance/dynamicImport/anotherModule">'.
Type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"' is not comparable to type 'typeof "tests/cases/conformance/dynamicImport/anotherModule"'.
Property 'D' is missing in type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"'.
==== tests/cases/conformance/dynamicImport/anotherModule.ts (0 errors) ====
export class D{}
==== tests/cases/conformance/dynamicImport/defaultPath.ts (0 errors) ====
export class C {}
==== tests/cases/conformance/dynamicImport/1.ts (2 errors) ====
import * as defaultModule from "./defaultPath";
import * as anotherModule from "./anotherModule";
let p1: Promise<typeof anotherModule> = import("./defaultPath");
~~
!!! error TS2322: Type 'Promise<typeof "tests/cases/conformance/dynamicImport/defaultPath">' is not assignable to type 'Promise<typeof "tests/cases/conformance/dynamicImport/anotherModule">'.
!!! error TS2322: Type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"' is not assignable to type 'typeof "tests/cases/conformance/dynamicImport/anotherModule"'.
!!! error TS2322: Property 'D' is missing in type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"'.
let p2 = import("./defaultPath") as Promise<typeof anotherModule>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2352: Type 'Promise<typeof "tests/cases/conformance/dynamicImport/defaultPath">' cannot be converted to type 'Promise<typeof "tests/cases/conformance/dynamicImport/anotherModule">'.
!!! error TS2352: Type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"' is not comparable to type 'typeof "tests/cases/conformance/dynamicImport/anotherModule"'.
!!! error TS2352: Property 'D' is missing in type 'typeof "tests/cases/conformance/dynamicImport/defaultPath"'.
let p3: Promise<any> = import("./defaultPath");
@@ -1,35 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionCheckReturntype1.ts] ////
//// [anotherModule.ts]
export class D{}
//// [defaultPath.ts]
export class C {}
//// [1.ts]
import * as defaultModule from "./defaultPath";
import * as anotherModule from "./anotherModule";
let p1: Promise<typeof anotherModule> = import("./defaultPath");
let p2 = import("./defaultPath") as Promise<typeof anotherModule>;
let p3: Promise<any> = import("./defaultPath");
//// [anotherModule.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class D {
}
exports.D = D;
//// [defaultPath.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class C {
}
exports.C = C;
//// [1.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
let p1 = Promise.resolve().then(function () { return require("./defaultPath"); });
let p2 = Promise.resolve().then(function () { return require("./defaultPath"); });
let p3 = Promise.resolve().then(function () { return require("./defaultPath"); });
@@ -1,35 +0,0 @@
//// [importCallExpressionDeclarationEmit1.ts]
declare function getSpecifier(): string;
declare var whatToLoad: boolean;
declare const directory: string;
declare const moduleFile: number;
import(getSpecifier());
var p0 = import(`${directory}\${moduleFile}`);
var p1 = import(getSpecifier());
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
function returnDynamicLoad(path: string) {
return import(path);
}
//// [importCallExpressionDeclarationEmit1.js]
Promise.resolve().then(function () { return require(getSpecifier()); });
var p0 = Promise.resolve().then(function () { return require(`${directory}\${moduleFile}`); });
var p1 = Promise.resolve().then(function () { return require(getSpecifier()); });
const p2 = Promise.resolve().then(function () { return require(whatToLoad ? getSpecifier() : "defaulPath"); });
function returnDynamicLoad(path) {
return Promise.resolve().then(function () { return require(path); });
}
//// [importCallExpressionDeclarationEmit1.d.ts]
declare function getSpecifier(): string;
declare var whatToLoad: boolean;
declare const directory: string;
declare const moduleFile: number;
declare var p0: Promise<any>;
declare var p1: Promise<any>;
declare const p2: Promise<any>;
declare function returnDynamicLoad(path: string): Promise<any>;
@@ -1,36 +0,0 @@
=== tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit1.ts ===
declare function getSpecifier(): string;
>getSpecifier : Symbol(getSpecifier, Decl(importCallExpressionDeclarationEmit1.ts, 0, 0))
declare var whatToLoad: boolean;
>whatToLoad : Symbol(whatToLoad, Decl(importCallExpressionDeclarationEmit1.ts, 1, 11))
declare const directory: string;
>directory : Symbol(directory, Decl(importCallExpressionDeclarationEmit1.ts, 2, 13))
declare const moduleFile: number;
>moduleFile : Symbol(moduleFile, Decl(importCallExpressionDeclarationEmit1.ts, 3, 13))
import(getSpecifier());
>getSpecifier : Symbol(getSpecifier, Decl(importCallExpressionDeclarationEmit1.ts, 0, 0))
var p0 = import(`${directory}\${moduleFile}`);
>p0 : Symbol(p0, Decl(importCallExpressionDeclarationEmit1.ts, 7, 3))
>directory : Symbol(directory, Decl(importCallExpressionDeclarationEmit1.ts, 2, 13))
var p1 = import(getSpecifier());
>p1 : Symbol(p1, Decl(importCallExpressionDeclarationEmit1.ts, 8, 3))
>getSpecifier : Symbol(getSpecifier, Decl(importCallExpressionDeclarationEmit1.ts, 0, 0))
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
>p2 : Symbol(p2, Decl(importCallExpressionDeclarationEmit1.ts, 9, 5))
>whatToLoad : Symbol(whatToLoad, Decl(importCallExpressionDeclarationEmit1.ts, 1, 11))
>getSpecifier : Symbol(getSpecifier, Decl(importCallExpressionDeclarationEmit1.ts, 0, 0))
function returnDynamicLoad(path: string) {
>returnDynamicLoad : Symbol(returnDynamicLoad, Decl(importCallExpressionDeclarationEmit1.ts, 9, 61))
>path : Symbol(path, Decl(importCallExpressionDeclarationEmit1.ts, 11, 27))
return import(path);
>path : Symbol(path, Decl(importCallExpressionDeclarationEmit1.ts, 11, 27))
}
@@ -1,47 +0,0 @@
=== tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit1.ts ===
declare function getSpecifier(): string;
>getSpecifier : () => string
declare var whatToLoad: boolean;
>whatToLoad : boolean
declare const directory: string;
>directory : string
declare const moduleFile: number;
>moduleFile : number
import(getSpecifier());
>import(getSpecifier()) : Promise<any>
>getSpecifier() : string
>getSpecifier : () => string
var p0 = import(`${directory}\${moduleFile}`);
>p0 : Promise<any>
>import(`${directory}\${moduleFile}`) : Promise<any>
>`${directory}\${moduleFile}` : string
>directory : string
var p1 = import(getSpecifier());
>p1 : Promise<any>
>import(getSpecifier()) : Promise<any>
>getSpecifier() : string
>getSpecifier : () => string
const p2 = import(whatToLoad ? getSpecifier() : "defaulPath")
>p2 : Promise<any>
>import(whatToLoad ? getSpecifier() : "defaulPath") : Promise<any>
>whatToLoad ? getSpecifier() : "defaulPath" : string
>whatToLoad : boolean
>getSpecifier() : string
>getSpecifier : () => string
>"defaulPath" : "defaulPath"
function returnDynamicLoad(path: string) {
>returnDynamicLoad : (path: string) => Promise<any>
>path : string
return import(path);
>import(path) : Promise<any>
>path : string
}
@@ -1,10 +0,0 @@
tests/cases/conformance/dynamicImport/1.ts(1,5): error TS4023: Exported variable 'p1' has or is using name '"tests/cases/conformance/dynamicImport/0"' from external module "tests/cases/conformance/dynamicImport/0" but cannot be named.
==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ====
export function foo() { return "foo"; }
==== tests/cases/conformance/dynamicImport/1.ts (1 errors) ====
var p1 = import("./0");
~~
!!! error TS4023: Exported variable 'p1' has or is using name '"tests/cases/conformance/dynamicImport/0"' from external module "tests/cases/conformance/dynamicImport/0" but cannot be named.
@@ -1,16 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit2.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
var p1 = import("./0");
//// [0.js]
export function foo() { return "foo"; }
//// [1.js]
var p1 = import("./0");
//// [0.d.ts]
export declare function foo(): string;
@@ -1,31 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionDeclarationEmit3.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
declare function getPath(): string;
import * as Zero from "./0";
import("./0");
export var p0: Promise<typeof Zero> = import(getPath());
export var p1: Promise<typeof Zero> = import("./0");
export var p2: Promise<any> = import("./0");
//// [0.js]
export function foo() { return "foo"; }
//// [1.js]
import("./0");
export var p0 = import(getPath());
export var p1 = import("./0");
export var p2 = import("./0");
//// [0.d.ts]
export declare function foo(): string;
//// [1.d.ts]
import * as Zero from "./0";
export declare var p0: Promise<typeof Zero>;
export declare var p1: Promise<typeof Zero>;
export declare var p2: Promise<any>;
@@ -1,28 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
declare function getPath(): string;
>getPath : Symbol(getPath, Decl(1.ts, 0, 0))
import * as Zero from "./0";
>Zero : Symbol(Zero, Decl(1.ts, 1, 6))
import("./0");
export var p0: Promise<typeof Zero> = import(getPath());
>p0 : Symbol(p0, Decl(1.ts, 4, 10))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Zero : Symbol(Zero, Decl(1.ts, 1, 6))
>getPath : Symbol(getPath, Decl(1.ts, 0, 0))
export var p1: Promise<typeof Zero> = import("./0");
>p1 : Symbol(p1, Decl(1.ts, 5, 10))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
>Zero : Symbol(Zero, Decl(1.ts, 1, 6))
export var p2: Promise<any> = import("./0");
>p2 : Symbol(p2, Decl(1.ts, 6, 10))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
@@ -1,37 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
declare function getPath(): string;
>getPath : () => string
import * as Zero from "./0";
>Zero : typeof Zero
import("./0");
>import("./0") : Promise<typeof Zero>
>"./0" : "./0"
export var p0: Promise<typeof Zero> = import(getPath());
>p0 : Promise<typeof Zero>
>Promise : Promise<T>
>Zero : typeof Zero
>import(getPath()) : Promise<any>
>getPath() : string
>getPath : () => string
export var p1: Promise<typeof Zero> = import("./0");
>p1 : Promise<typeof Zero>
>Promise : Promise<T>
>Zero : typeof Zero
>import("./0") : Promise<typeof Zero>
>"./0" : "./0"
export var p2: Promise<any> = import("./0");
>p2 : Promise<any>
>Promise : Promise<T>
>import("./0") : Promise<typeof Zero>
>"./0" : "./0"
@@ -1,35 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionES5AMD.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}
//// [0.js]
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function foo() { return "foo"; }
exports.foo = foo;
});
//// [1.js]
define(["require", "exports"], function (require, exports) {
"use strict";
new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); });
var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); });
p1.then(function (zero) {
return zero.foo();
});
function foo() {
var p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); });
}
});
@@ -1,28 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
var p1 = import("./0");
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
p1.then(zero => {
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
return zero.foo();
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
>foo : Symbol(foo, Decl(0.ts, 0, 0))
});
function foo() {
>foo : Symbol(foo, Decl(1.ts, 4, 3))
const p2 = import("./0");
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
}
@@ -1,39 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
});
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
}
@@ -1,30 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionES5CJS.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}
//// [0.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function foo() { return "foo"; }
exports.foo = foo;
//// [1.js]
Promise.resolve().then(function () { return require("./0"); });
var p1 = Promise.resolve().then(function () { return require("./0"); });
p1.then(function (zero) {
return zero.foo();
});
function foo() {
var p2 = Promise.resolve().then(function () { return require("./0"); });
}
@@ -1,28 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
var p1 = import("./0");
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
p1.then(zero => {
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
return zero.foo();
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
>foo : Symbol(foo, Decl(0.ts, 0, 0))
});
function foo() {
>foo : Symbol(foo, Decl(1.ts, 4, 3))
const p2 = import("./0");
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
}
@@ -1,39 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
});
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
}
@@ -1,46 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionES5System.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}
//// [0.js]
System.register([], function (exports_1, context_1) {
"use strict";
var __moduleName = context_1 && context_1.id;
function foo() { return "foo"; }
exports_1("foo", foo);
return {
setters: [],
execute: function () {
}
};
});
//// [1.js]
System.register([], function (exports_1, context_1) {
var __moduleName = context_1 && context_1.id;
function foo() {
var p2 = context_1.import("./0");
}
var p1;
return {
setters: [],
execute: function () {
context_1.import("./0");
p1 = context_1.import("./0");
p1.then(function (zero) {
return zero.foo();
});
}
};
});
@@ -1,28 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
var p1 = import("./0");
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
p1.then(zero => {
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
return zero.foo();
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
>foo : Symbol(foo, Decl(0.ts, 0, 0))
});
function foo() {
>foo : Symbol(foo, Decl(1.ts, 4, 3))
const p2 = import("./0");
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
}
@@ -1,39 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
});
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
}
@@ -1,52 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionES5UMD.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}
//// [0.js]
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function foo() { return "foo"; }
exports.foo = foo;
});
//// [1.js]
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
__syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); });
var p1 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); });
p1.then(function (zero) {
return zero.foo();
});
function foo() {
var p2 = __syncRequire ? Promise.resolve().then(function () { return require("./0"); }) : new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); });
}
});
@@ -1,28 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
var p1 = import("./0");
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
p1.then(zero => {
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
return zero.foo();
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
>foo : Symbol(foo, Decl(0.ts, 0, 0))
});
function foo() {
>foo : Symbol(foo, Decl(1.ts, 4, 3))
const p2 = import("./0");
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
}
@@ -1,39 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
});
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
}
@@ -1,24 +0,0 @@
tests/cases/conformance/dynamicImport/1.ts(1,1): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
tests/cases/conformance/dynamicImport/1.ts(2,10): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
tests/cases/conformance/dynamicImport/1.ts(8,16): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
==== tests/cases/conformance/dynamicImport/0.ts (0 errors) ====
export function foo() { return "foo"; }
==== tests/cases/conformance/dynamicImport/1.ts (3 errors) ====
import("./0");
~~~~~~~~~~~~~
!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
var p1 = import("./0");
~~~~~~~~~~~~~
!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
p1.then(zero => {
return zero.foo();
})
function foo() {
const p2 = import("./0");
~~~~~~~~~~~~~
!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
}
@@ -1,27 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionErrorInES2015.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
})
function foo() {
const p2 = import("./0");
}
//// [0.js]
export function foo() { return "foo"; }
//// [1.js]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}
@@ -1,34 +0,0 @@
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(5,8): error TS1325: Specifier of dynamic import cannot be spread element.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(7,17): error TS1325: Specifier of dynamic import cannot be spread element.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(8,12): error TS1324: Dynamic import must have one specifier as an argument.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,19): error TS1135: Argument expression expected.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(9,19): error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'undefined'.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(10,12): error TS1324: Dynamic import must have one specifier as an argument.
tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts(10,19): error TS2307: Cannot find module 'pathToModule'.
==== tests/cases/conformance/dynamicImport/importCallExpressionGrammarError.ts (7 errors) ====
declare function getSpecifier(): string;
declare var whatToLoad: boolean;
var a = ["./0"];
import(...["PathModule"]);
~~~~~~~~~~~~~~~~~
!!! error TS1325: Specifier of dynamic import cannot be spread element.
var p1 = import(...a);
~~~~
!!! error TS1325: Specifier of dynamic import cannot be spread element.
const p2 = import();
~~~~~~~~
!!! error TS1324: Dynamic import must have one specifier as an argument.
const p3 = import(,);
!!! error TS1135: Argument expression expected.
!!! error TS7036: Dynamic import's specifier must be of type 'string', but here has type 'undefined'.
const p4 = import("pathToModule", "secondModule");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1324: Dynamic import must have one specifier as an argument.
~~~~~~~~~~~~~~
!!! error TS2307: Cannot find module 'pathToModule'.
@@ -1,19 +0,0 @@
//// [importCallExpressionGrammarError.ts]
declare function getSpecifier(): string;
declare var whatToLoad: boolean;
var a = ["./0"];
import(...["PathModule"]);
var p1 = import(...a);
const p2 = import();
const p3 = import(,);
const p4 = import("pathToModule", "secondModule");
//// [importCallExpressionGrammarError.js]
var a = ["./0"];
Promise.resolve().then(function () { return require(...["PathModule"]); });
var p1 = Promise.resolve().then(function () { return require(...a); });
const p2 = Promise.resolve().then(function () { return require(); });
const p3 = Promise.resolve().then(function () { return require(); });
const p4 = Promise.resolve().then(function () { return require("pathToModule", "secondModule"); });
@@ -1,35 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionInAMD1.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}
//// [0.js]
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function foo() { return "foo"; }
exports.foo = foo;
});
//// [1.js]
define(["require", "exports"], function (require, exports) {
"use strict";
new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); });
var p1 = new Promise(function (resolve_2, reject_2) { require(["./0"], resolve_2, reject_2); });
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = new Promise(function (resolve_3, reject_3) { require(["./0"], resolve_3, reject_3); });
}
});
@@ -1,28 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
var p1 = import("./0");
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
p1.then(zero => {
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
return zero.foo();
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
>foo : Symbol(foo, Decl(0.ts, 0, 0))
});
function foo() {
>foo : Symbol(foo, Decl(1.ts, 4, 3))
const p2 = import("./0");
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
}
@@ -1,39 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
});
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
}
@@ -1,39 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionInAMD2.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
//// [2.ts]
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x: Promise<any>) {
x.then(value => {
let b = new value.B();
b.print();
})
}
foo(import("./0"));
//// [0.js]
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class B {
print() { return "I am B"; }
}
exports.B = B;
});
//// [2.js]
define(["require", "exports"], function (require, exports) {
"use strict";
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x) {
x.then(value => {
let b = new value.B();
b.print();
});
}
foo(new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); }));
});
@@ -1,34 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : Symbol(B, Decl(0.ts, 0, 0))
print() { return "I am B"}
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
=== tests/cases/conformance/dynamicImport/2.ts ===
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x: Promise<any>) {
>foo : Symbol(foo, Decl(2.ts, 0, 0))
>x : Symbol(x, Decl(2.ts, 1, 13))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
x.then(value => {
>x.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(2.ts, 1, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>value : Symbol(value, Decl(2.ts, 2, 11))
let b = new value.B();
>b : Symbol(b, Decl(2.ts, 3, 11))
>value : Symbol(value, Decl(2.ts, 2, 11))
b.print();
>b : Symbol(b, Decl(2.ts, 3, 11))
})
}
foo(import("./0"));
>foo : Symbol(foo, Decl(2.ts, 0, 0))
@@ -1,46 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : B
print() { return "I am B"}
>print : () => string
>"I am B" : "I am B"
}
=== tests/cases/conformance/dynamicImport/2.ts ===
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x: Promise<any>) {
>foo : (x: Promise<any>) => void
>x : Promise<any>
>Promise : Promise<T>
x.then(value => {
>x.then(value => { let b = new value.B(); b.print(); }) : Promise<void>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>x : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>value => { let b = new value.B(); b.print(); } : (value: any) => void
>value : any
let b = new value.B();
>b : any
>new value.B() : any
>value.B : any
>value : any
>B : any
b.print();
>b.print() : any
>b.print : any
>b : any
>print : any
})
}
foo(import("./0"));
>foo(import("./0")) : void
>foo : (x: Promise<any>) => void
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
@@ -1,35 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionInAMD3.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
//// [2.ts]
async function foo() {
class C extends (await import("./0")).B {}
var c = new C();
c.print();
}
foo();
//// [0.js]
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class B {
print() { return "I am B"; }
}
exports.B = B;
});
//// [2.js]
define(["require", "exports"], function (require, exports) {
"use strict";
async function foo() {
class C extends (await new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); })).B {
}
var c = new C();
c.print();
}
foo();
});
@@ -1,29 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : Symbol(B, Decl(0.ts, 0, 0))
print() { return "I am B"}
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
=== tests/cases/conformance/dynamicImport/2.ts ===
async function foo() {
>foo : Symbol(foo, Decl(2.ts, 0, 0))
class C extends (await import("./0")).B {}
>C : Symbol(C, Decl(2.ts, 0, 22))
>(await import("./0")).B : Symbol(B, Decl(0.ts, 0, 0))
>B : Symbol(B, Decl(0.ts, 0, 0))
var c = new C();
>c : Symbol(c, Decl(2.ts, 2, 7))
>C : Symbol(C, Decl(2.ts, 0, 22))
c.print();
>c.print : Symbol(B.print, Decl(0.ts, 0, 16))
>c : Symbol(c, Decl(2.ts, 2, 7))
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
foo();
>foo : Symbol(foo, Decl(2.ts, 0, 0))
@@ -1,37 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : B
print() { return "I am B"}
>print : () => string
>"I am B" : "I am B"
}
=== tests/cases/conformance/dynamicImport/2.ts ===
async function foo() {
>foo : () => Promise<void>
class C extends (await import("./0")).B {}
>C : C
>(await import("./0")).B : B
>(await import("./0")) : typeof "tests/cases/conformance/dynamicImport/0"
>await import("./0") : typeof "tests/cases/conformance/dynamicImport/0"
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
>B : typeof B
var c = new C();
>c : C
>new C() : C
>C : typeof C
c.print();
>c.print() : string
>c.print : () => string
>c : C
>print : () => string
}
foo();
>foo() : Promise<void>
>foo : () => Promise<void>
@@ -1,63 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionInAMD4.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
export function foo() { return "foo" }
//// [1.ts]
export function backup() { return "backup"; }
//// [2.ts]
declare var console: any;
class C {
private myModule = import("./0");
method() {
this.myModule.then(Zero => {
console.log(Zero.foo());
}, async err => {
console.log(err);
let one = await import("./1");
console.log(one.backup());
});
}
}
//// [0.js]
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class B {
print() { return "I am B"; }
}
exports.B = B;
function foo() { return "foo"; }
exports.foo = foo;
});
//// [1.js]
define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function backup() { return "backup"; }
exports.backup = backup;
});
//// [2.js]
define(["require", "exports"], function (require, exports) {
"use strict";
class C {
constructor() {
this.myModule = new Promise(function (resolve_1, reject_1) { require(["./0"], resolve_1, reject_1); });
}
method() {
this.myModule.then(Zero => {
console.log(Zero.foo());
}, async (err) => {
console.log(err);
let one = await new Promise(function (resolve_2, reject_2) { require(["./1"], resolve_2, reject_2); });
console.log(one.backup());
});
}
}
});
@@ -1,61 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : Symbol(B, Decl(0.ts, 0, 0))
print() { return "I am B"}
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
export function foo() { return "foo" }
>foo : Symbol(foo, Decl(0.ts, 2, 1))
=== tests/cases/conformance/dynamicImport/1.ts ===
export function backup() { return "backup"; }
>backup : Symbol(backup, Decl(1.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/2.ts ===
declare var console: any;
>console : Symbol(console, Decl(2.ts, 0, 11))
class C {
>C : Symbol(C, Decl(2.ts, 0, 25))
private myModule = import("./0");
>myModule : Symbol(C.myModule, Decl(2.ts, 1, 9))
method() {
>method : Symbol(C.method, Decl(2.ts, 2, 37))
this.myModule.then(Zero => {
>this.myModule.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>this.myModule : Symbol(C.myModule, Decl(2.ts, 1, 9))
>this : Symbol(C, Decl(2.ts, 0, 25))
>myModule : Symbol(C.myModule, Decl(2.ts, 1, 9))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>Zero : Symbol(Zero, Decl(2.ts, 4, 27))
console.log(Zero.foo());
>console : Symbol(console, Decl(2.ts, 0, 11))
>Zero.foo : Symbol(foo, Decl(0.ts, 2, 1))
>Zero : Symbol(Zero, Decl(2.ts, 4, 27))
>foo : Symbol(foo, Decl(0.ts, 2, 1))
}, async err => {
>err : Symbol(err, Decl(2.ts, 6, 16))
console.log(err);
>console : Symbol(console, Decl(2.ts, 0, 11))
>err : Symbol(err, Decl(2.ts, 6, 16))
let one = await import("./1");
>one : Symbol(one, Decl(2.ts, 8, 15))
console.log(one.backup());
>console : Symbol(console, Decl(2.ts, 0, 11))
>one.backup : Symbol(backup, Decl(1.ts, 0, 0))
>one : Symbol(one, Decl(2.ts, 8, 15))
>backup : Symbol(backup, Decl(1.ts, 0, 0))
});
}
}
@@ -1,83 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : B
print() { return "I am B"}
>print : () => string
>"I am B" : "I am B"
}
export function foo() { return "foo" }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
export function backup() { return "backup"; }
>backup : () => string
>"backup" : "backup"
=== tests/cases/conformance/dynamicImport/2.ts ===
declare var console: any;
>console : any
class C {
>C : C
private myModule = import("./0");
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
method() {
>method : () => void
this.myModule.then(Zero => {
>this.myModule.then(Zero => { console.log(Zero.foo()); }, async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); }) : Promise<void>
>this.myModule.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>this.myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>this : this
>myModule : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>Zero => { console.log(Zero.foo()); } : (Zero: typeof "tests/cases/conformance/dynamicImport/0") => void
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
console.log(Zero.foo());
>console.log(Zero.foo()) : any
>console.log : any
>console : any
>log : any
>Zero.foo() : string
>Zero.foo : () => string
>Zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
}, async err => {
>async err => { console.log(err); let one = await import("./1"); console.log(one.backup()); } : (err: any) => Promise<void>
>err : any
console.log(err);
>console.log(err) : any
>console.log : any
>console : any
>log : any
>err : any
let one = await import("./1");
>one : typeof "tests/cases/conformance/dynamicImport/1"
>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1"
>import("./1") : Promise<typeof "tests/cases/conformance/dynamicImport/1">
>"./1" : "./1"
console.log(one.backup());
>console.log(one.backup()) : any
>console.log : any
>console : any
>log : any
>one.backup() : string
>one.backup : () => string
>one : typeof "tests/cases/conformance/dynamicImport/1"
>backup : () => string
});
}
}
@@ -1,30 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionInCJS1.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
import("./0");
var p1 = import("./0");
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = import("./0");
}
//// [0.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function foo() { return "foo"; }
exports.foo = foo;
//// [1.js]
Promise.resolve().then(function () { return require("./0"); });
var p1 = Promise.resolve().then(function () { return require("./0"); });
p1.then(zero => {
return zero.foo();
});
function foo() {
const p2 = Promise.resolve().then(function () { return require("./0"); });
}
@@ -1,28 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
var p1 = import("./0");
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
p1.then(zero => {
>p1.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>p1 : Symbol(p1, Decl(1.ts, 1, 3))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
return zero.foo();
>zero.foo : Symbol(foo, Decl(0.ts, 0, 0))
>zero : Symbol(zero, Decl(1.ts, 2, 8))
>foo : Symbol(foo, Decl(0.ts, 0, 0))
});
function foo() {
>foo : Symbol(foo, Decl(1.ts, 4, 3))
const p2 = import("./0");
>p2 : Symbol(p2, Decl(1.ts, 7, 9))
}
@@ -1,39 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
import("./0");
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
var p1 = import("./0");
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
p1.then(zero => {
>p1.then(zero => { return zero.foo();}) : Promise<string>
>p1.then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>p1 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>then : <TResult1 = typeof "tests/cases/conformance/dynamicImport/0", TResult2 = never>(onfulfilled?: (value: typeof "tests/cases/conformance/dynamicImport/0") => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>zero => { return zero.foo();} : (zero: typeof "tests/cases/conformance/dynamicImport/0") => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
return zero.foo();
>zero.foo() : string
>zero.foo : () => string
>zero : typeof "tests/cases/conformance/dynamicImport/0"
>foo : () => string
});
function foo() {
>foo : () => void
const p2 = import("./0");
>p2 : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
}
@@ -1,40 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionInCJS2.ts] ////
//// [0.ts]
export function foo() { return "foo"; }
//// [1.ts]
export function backup() { return "backup"; }
//// [2.ts]
async function compute(promise: Promise<any>) {
let j = await promise;
if (!j) {
j = await import("./1");
return j.backup();
}
return j.foo();
}
compute(import("./0"));
//// [0.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function foo() { return "foo"; }
exports.foo = foo;
//// [1.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function backup() { return "backup"; }
exports.backup = backup;
//// [2.js]
async function compute(promise) {
let j = await promise;
if (!j) {
j = await Promise.resolve().then(function () { return require("./1"); });
return j.backup();
}
return j.foo();
}
compute(Promise.resolve().then(function () { return require("./0"); }));
@@ -1,34 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : Symbol(foo, Decl(0.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/1.ts ===
export function backup() { return "backup"; }
>backup : Symbol(backup, Decl(1.ts, 0, 0))
=== tests/cases/conformance/dynamicImport/2.ts ===
async function compute(promise: Promise<any>) {
>compute : Symbol(compute, Decl(2.ts, 0, 0))
>promise : Symbol(promise, Decl(2.ts, 0, 23))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
let j = await promise;
>j : Symbol(j, Decl(2.ts, 1, 7))
>promise : Symbol(promise, Decl(2.ts, 0, 23))
if (!j) {
>j : Symbol(j, Decl(2.ts, 1, 7))
j = await import("./1");
>j : Symbol(j, Decl(2.ts, 1, 7))
return j.backup();
>j : Symbol(j, Decl(2.ts, 1, 7))
}
return j.foo();
>j : Symbol(j, Decl(2.ts, 1, 7))
}
compute(import("./0"));
>compute : Symbol(compute, Decl(2.ts, 0, 0))
@@ -1,51 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export function foo() { return "foo"; }
>foo : () => string
>"foo" : "foo"
=== tests/cases/conformance/dynamicImport/1.ts ===
export function backup() { return "backup"; }
>backup : () => string
>"backup" : "backup"
=== tests/cases/conformance/dynamicImport/2.ts ===
async function compute(promise: Promise<any>) {
>compute : (promise: Promise<any>) => Promise<any>
>promise : Promise<any>
>Promise : Promise<T>
let j = await promise;
>j : any
>await promise : any
>promise : Promise<any>
if (!j) {
>!j : boolean
>j : any
j = await import("./1");
>j = await import("./1") : typeof "tests/cases/conformance/dynamicImport/1"
>j : any
>await import("./1") : typeof "tests/cases/conformance/dynamicImport/1"
>import("./1") : Promise<typeof "tests/cases/conformance/dynamicImport/1">
>"./1" : "./1"
return j.backup();
>j.backup() : any
>j.backup : any
>j : any
>backup : any
}
return j.foo();
>j.foo() : any
>j.foo : any
>j : any
>foo : any
}
compute(import("./0"));
>compute(import("./0")) : Promise<any>
>compute : (promise: Promise<any>) => Promise<any>
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"
@@ -1,34 +0,0 @@
//// [tests/cases/conformance/dynamicImport/importCallExpressionInCJS3.ts] ////
//// [0.ts]
export class B {
print() { return "I am B"}
}
//// [2.ts]
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x: Promise<any>) {
x.then(value => {
let b = new value.B();
b.print();
})
}
foo(import("./0"));
//// [0.js]
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class B {
print() { return "I am B"; }
}
exports.B = B;
//// [2.js]
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x) {
x.then(value => {
let b = new value.B();
b.print();
});
}
foo(Promise.resolve().then(function () { return require("./0"); }));
@@ -1,34 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : Symbol(B, Decl(0.ts, 0, 0))
print() { return "I am B"}
>print : Symbol(B.print, Decl(0.ts, 0, 16))
}
=== tests/cases/conformance/dynamicImport/2.ts ===
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x: Promise<any>) {
>foo : Symbol(foo, Decl(2.ts, 0, 0))
>x : Symbol(x, Decl(2.ts, 1, 13))
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --))
x.then(value => {
>x.then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(2.ts, 1, 13))
>then : Symbol(Promise.then, Decl(lib.es5.d.ts, --, --))
>value : Symbol(value, Decl(2.ts, 2, 11))
let b = new value.B();
>b : Symbol(b, Decl(2.ts, 3, 11))
>value : Symbol(value, Decl(2.ts, 2, 11))
b.print();
>b : Symbol(b, Decl(2.ts, 3, 11))
})
}
foo(import("./0"));
>foo : Symbol(foo, Decl(2.ts, 0, 0))
@@ -1,46 +0,0 @@
=== tests/cases/conformance/dynamicImport/0.ts ===
export class B {
>B : B
print() { return "I am B"}
>print : () => string
>"I am B" : "I am B"
}
=== tests/cases/conformance/dynamicImport/2.ts ===
// We use Promise<any> for now as there is no way to specify shape of module object
function foo(x: Promise<any>) {
>foo : (x: Promise<any>) => void
>x : Promise<any>
>Promise : Promise<T>
x.then(value => {
>x.then(value => { let b = new value.B(); b.print(); }) : Promise<void>
>x.then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>x : Promise<any>
>then : <TResult1 = any, TResult2 = never>(onfulfilled?: (value: any) => TResult1 | PromiseLike<TResult1>, onrejected?: (reason: any) => TResult2 | PromiseLike<TResult2>) => Promise<TResult1 | TResult2>
>value => { let b = new value.B(); b.print(); } : (value: any) => void
>value : any
let b = new value.B();
>b : any
>new value.B() : any
>value.B : any
>value : any
>B : any
b.print();
>b.print() : any
>b.print : any
>b : any
>print : any
})
}
foo(import("./0"));
>foo(import("./0")) : void
>foo : (x: Promise<any>) => void
>import("./0") : Promise<typeof "tests/cases/conformance/dynamicImport/0">
>"./0" : "./0"

Some files were not shown because too many files have changed in this diff Show More