mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Merge branch 'master' into refactor-jsdoc-types-to-typescript
This commit is contained in:
@@ -15675,34 +15675,32 @@ namespace ts {
|
||||
return getInferredTypes(context);
|
||||
}
|
||||
|
||||
function checkTypeArguments(signature: Signature, typeArgumentNodes: ReadonlyArray<TypeNode>, typeArgumentTypes: Type[], reportErrors: boolean, headMessage?: DiagnosticMessage): boolean {
|
||||
function checkTypeArguments(signature: Signature, typeArgumentNodes: ReadonlyArray<TypeNode>, reportErrors: boolean, headMessage?: DiagnosticMessage): Type[] | false {
|
||||
const isJavascript = isInJavaScriptFile(signature.declaration);
|
||||
const typeParameters = signature.typeParameters;
|
||||
let typeArgumentsAreAssignable = true;
|
||||
const typeArgumentTypes = fillMissingTypeArguments(map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
|
||||
let mapper: TypeMapper;
|
||||
for (let i = 0; i < typeArgumentNodes.length; i++) {
|
||||
if (typeArgumentsAreAssignable /* so far */) {
|
||||
const constraint = getConstraintOfTypeParameter(typeParameters[i]);
|
||||
if (constraint) {
|
||||
let errorInfo: DiagnosticMessageChain;
|
||||
let typeArgumentHeadMessage = Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
|
||||
if (reportErrors && headMessage) {
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, typeArgumentHeadMessage);
|
||||
typeArgumentHeadMessage = headMessage;
|
||||
}
|
||||
if (!mapper) {
|
||||
mapper = createTypeMapper(typeParameters, typeArgumentTypes);
|
||||
}
|
||||
const typeArgument = typeArgumentTypes[i];
|
||||
typeArgumentsAreAssignable = checkTypeAssignableTo(
|
||||
typeArgument,
|
||||
getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument),
|
||||
reportErrors ? typeArgumentNodes[i] : undefined,
|
||||
typeArgumentHeadMessage,
|
||||
errorInfo);
|
||||
}
|
||||
Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments");
|
||||
const constraint = getConstraintOfTypeParameter(typeParameters[i]);
|
||||
if (!constraint) continue;
|
||||
|
||||
const errorInfo = reportErrors && headMessage && chainDiagnosticMessages(/*details*/ undefined, Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
|
||||
const typeArgumentHeadMessage = headMessage || Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
|
||||
if (!mapper) {
|
||||
mapper = createTypeMapper(typeParameters, typeArgumentTypes);
|
||||
}
|
||||
const typeArgument = typeArgumentTypes[i];
|
||||
if (!checkTypeAssignableTo(
|
||||
typeArgument,
|
||||
getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument),
|
||||
reportErrors ? typeArgumentNodes[i] : undefined,
|
||||
typeArgumentHeadMessage,
|
||||
errorInfo)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return typeArgumentsAreAssignable;
|
||||
return typeArgumentTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -16235,8 +16233,7 @@ namespace ts {
|
||||
checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, /*excludeArgument*/ undefined, /*reportErrors*/ true);
|
||||
}
|
||||
else if (candidateForTypeArgumentError) {
|
||||
const typeArguments = (<CallExpression>node).typeArguments;
|
||||
checkTypeArguments(candidateForTypeArgumentError, typeArguments, map(typeArguments, getTypeFromTypeNode), /*reportErrors*/ true, fallbackError);
|
||||
checkTypeArguments(candidateForTypeArgumentError, (node as CallExpression).typeArguments, /*reportErrors*/ true, fallbackError);
|
||||
}
|
||||
else if (typeArguments && every(signatures, sig => length(sig.typeParameters) !== typeArguments.length)) {
|
||||
let min = Number.POSITIVE_INFINITY;
|
||||
@@ -16335,10 +16332,12 @@ namespace ts {
|
||||
candidate = originalCandidate;
|
||||
if (candidate.typeParameters) {
|
||||
let typeArgumentTypes: Type[];
|
||||
const isJavascript = isInJavaScriptFile(candidate.declaration);
|
||||
if (typeArguments) {
|
||||
typeArgumentTypes = fillMissingTypeArguments(map(typeArguments, getTypeFromTypeNode), candidate.typeParameters, getMinTypeArgumentCount(candidate.typeParameters), isJavascript);
|
||||
if (!checkTypeArguments(candidate, typeArguments, typeArgumentTypes, /*reportErrors*/ false)) {
|
||||
const typeArgumentResult = checkTypeArguments(candidate, typeArguments, /*reportErrors*/ false);
|
||||
if (typeArgumentResult) {
|
||||
typeArgumentTypes = typeArgumentResult;
|
||||
}
|
||||
else {
|
||||
candidateForTypeArgumentError = originalCandidate;
|
||||
break;
|
||||
}
|
||||
@@ -16346,6 +16345,7 @@ namespace ts {
|
||||
else {
|
||||
typeArgumentTypes = inferTypeArguments(node, candidate, args, excludeArgument, inferenceContext);
|
||||
}
|
||||
const isJavascript = isInJavaScriptFile(candidate.declaration);
|
||||
candidate = getSignatureInstantiation(candidate, typeArgumentTypes, isJavascript);
|
||||
}
|
||||
if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) {
|
||||
|
||||
@@ -2612,6 +2612,16 @@ namespace ts {
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets flags that control emit behavior of a node.
|
||||
*/
|
||||
/* @internal */
|
||||
export function addEmitFlags<T extends Node>(node: T, emitFlags: EmitFlags) {
|
||||
const emitNode = getOrCreateEmitNode(node);
|
||||
emitNode.flags = emitNode.flags | emitFlags;
|
||||
return node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a custom text range to use when emitting source maps.
|
||||
*/
|
||||
|
||||
@@ -1112,7 +1112,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitCallExpression(node: CallExpression) {
|
||||
if (forEach(node.arguments, containsYield)) {
|
||||
if (!isImportCall(node) && forEach(node.arguments, containsYield)) {
|
||||
// [source]
|
||||
// a.b(1, yield, 2);
|
||||
//
|
||||
@@ -1123,7 +1123,6 @@ namespace ts {
|
||||
// .yield resumeLabel
|
||||
// .mark resumeLabel
|
||||
// _b.apply(_a, _c.concat([%sent%, 2]));
|
||||
|
||||
const { target, thisArg } = createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, /*cacheIdentifiers*/ true);
|
||||
return setOriginalNode(
|
||||
createFunctionApply(
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace ts {
|
||||
|
||||
const {
|
||||
startLexicalEnvironment,
|
||||
endLexicalEnvironment
|
||||
endLexicalEnvironment,
|
||||
hoistVariableDeclaration
|
||||
} = context;
|
||||
|
||||
const compilerOptions = context.getCompilerOptions();
|
||||
@@ -519,18 +520,20 @@ namespace ts {
|
||||
}
|
||||
|
||||
function visitImportCallExpression(node: ImportCall): Expression {
|
||||
const argument = visitNode(firstOrUndefined(node.arguments), importCallExpressionVisitor);
|
||||
const containsLexicalThis = !!(node.transformFlags & TransformFlags.ContainsLexicalThis);
|
||||
switch (compilerOptions.module) {
|
||||
case ModuleKind.AMD:
|
||||
return transformImportCallExpressionAMD(node);
|
||||
return createImportCallExpressionAMD(argument, containsLexicalThis);
|
||||
case ModuleKind.UMD:
|
||||
return transformImportCallExpressionUMD(node);
|
||||
return createImportCallExpressionUMD(argument, containsLexicalThis);
|
||||
case ModuleKind.CommonJS:
|
||||
default:
|
||||
return transformImportCallExpressionCommonJS(node);
|
||||
return createImportCallExpressionCommonJS(argument, containsLexicalThis);
|
||||
}
|
||||
}
|
||||
|
||||
function transformImportCallExpressionUMD(node: ImportCall): Expression {
|
||||
function createImportCallExpressionUMD(arg: Expression | undefined, containsLexicalThis: boolean): Expression {
|
||||
// (function (factory) {
|
||||
// ... (regular UMD)
|
||||
// }
|
||||
@@ -545,14 +548,25 @@ namespace ts {
|
||||
// : new Promise(function (_a, _b) { require([x], _a, _b); }); /*Amd Require*/
|
||||
// });
|
||||
needUMDDynamicImportHelper = true;
|
||||
return createConditional(
|
||||
/*condition*/ createIdentifier("__syncRequire"),
|
||||
/*whenTrue*/ transformImportCallExpressionCommonJS(node),
|
||||
/*whenFalse*/ transformImportCallExpressionAMD(node)
|
||||
);
|
||||
if (isSimpleCopiableExpression(arg)) {
|
||||
const argClone = isGeneratedIdentifier(arg) ? arg : isStringLiteral(arg) ? createLiteral(arg) : setEmitFlags(setTextRange(getSynthesizedClone(arg), arg), EmitFlags.NoComments);
|
||||
return createConditional(
|
||||
/*condition*/ createIdentifier("__syncRequire"),
|
||||
/*whenTrue*/ createImportCallExpressionCommonJS(arg, containsLexicalThis),
|
||||
/*whenFalse*/ createImportCallExpressionAMD(argClone, containsLexicalThis)
|
||||
);
|
||||
}
|
||||
else {
|
||||
const temp = createTempVariable(hoistVariableDeclaration);
|
||||
return createComma(createAssignment(temp, arg), createConditional(
|
||||
/*condition*/ createIdentifier("__syncRequire"),
|
||||
/*whenTrue*/ createImportCallExpressionCommonJS(temp, containsLexicalThis),
|
||||
/*whenFalse*/ createImportCallExpressionAMD(temp, containsLexicalThis)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function transformImportCallExpressionAMD(node: ImportCall): Expression {
|
||||
function createImportCallExpressionAMD(arg: Expression | undefined, containsLexicalThis: boolean): Expression {
|
||||
// improt("./blah")
|
||||
// emit as
|
||||
// define(["require", "exports", "blah"], function (require, exports) {
|
||||
@@ -570,7 +584,7 @@ namespace ts {
|
||||
createCall(
|
||||
createIdentifier("require"),
|
||||
/*typeArguments*/ undefined,
|
||||
[createArrayLiteral([firstOrUndefined(node.arguments) || createOmittedExpression()]), resolve, reject]
|
||||
[createArrayLiteral([arg || createOmittedExpression()]), resolve, reject]
|
||||
)
|
||||
)
|
||||
]);
|
||||
@@ -598,7 +612,7 @@ namespace ts {
|
||||
// if there is a lexical 'this' in the import call arguments, ensure we indicate
|
||||
// that this new function expression indicates it captures 'this' so that the
|
||||
// es2015 transformer will properly substitute 'this' with '_this'.
|
||||
if (node.transformFlags & TransformFlags.ContainsLexicalThis) {
|
||||
if (containsLexicalThis) {
|
||||
setEmitFlags(func, EmitFlags.CapturesThis);
|
||||
}
|
||||
}
|
||||
@@ -606,14 +620,14 @@ namespace ts {
|
||||
return createNew(createIdentifier("Promise"), /*typeArguments*/ undefined, [func]);
|
||||
}
|
||||
|
||||
function transformImportCallExpressionCommonJS(node: ImportCall): Expression {
|
||||
function createImportCallExpressionCommonJS(arg: Expression | undefined, containsLexicalThis: boolean): 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
|
||||
const promiseResolveCall = createCall(createPropertyAccess(createIdentifier("Promise"), "resolve"), /*typeArguments*/ undefined, /*argumentsArray*/ []);
|
||||
const requireCall = createCall(createIdentifier("require"), /*typeArguments*/ undefined, node.arguments);
|
||||
const requireCall = createCall(createIdentifier("require"), /*typeArguments*/ undefined, arg ? [arg] : []);
|
||||
|
||||
let func: FunctionExpression | ArrowFunction;
|
||||
if (languageVersion >= ScriptTarget.ES2015) {
|
||||
@@ -638,7 +652,7 @@ namespace ts {
|
||||
// if there is a lexical 'this' in the import call arguments, ensure we indicate
|
||||
// that this new function expression indicates it captures 'this' so that the
|
||||
// es2015 transformer will properly substitute 'this' with '_this'.
|
||||
if (node.transformFlags & TransformFlags.ContainsLexicalThis) {
|
||||
if (containsLexicalThis) {
|
||||
setEmitFlags(func, EmitFlags.CapturesThis);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1495,7 +1495,7 @@ namespace ts {
|
||||
createIdentifier("import")
|
||||
),
|
||||
/*typeArguments*/ undefined,
|
||||
node.arguments
|
||||
some(node.arguments) ? [visitNode(node.arguments[0], destructuringAndImportCallVisitor)] : []
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -178,4 +178,17 @@ namespace ts {
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used in the module transformer to check if an expression is reasonably without sideeffect,
|
||||
* and thus better to copy into multiple places rather than to cache in a temporary variable
|
||||
* - this is mostly subjective beyond the requirement that the expression not be sideeffecting
|
||||
*/
|
||||
export function isSimpleCopiableExpression(expression: Expression) {
|
||||
return expression.kind === SyntaxKind.StringLiteral ||
|
||||
expression.kind === SyntaxKind.NumericLiteral ||
|
||||
expression.kind === SyntaxKind.NoSubstitutionTemplateLiteral ||
|
||||
isKeyword(expression.kind) ||
|
||||
isIdentifier(expression);
|
||||
}
|
||||
}
|
||||
@@ -223,6 +223,14 @@ const f = () => {
|
||||
testExtractConstant("extractConstant_ArrowFunction_Expression",
|
||||
`const f = () => [#|2 + 1|];`);
|
||||
|
||||
testExtractConstant("extractConstant_PreserveTrivia", `
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ [#|1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2|] /*k*/ //l
|
||||
/*m*/; /*n*/ //o`);
|
||||
|
||||
testExtractConstantFailed("extractConstant_Void", `
|
||||
function f(): void { }
|
||||
[#|f();|]`);
|
||||
@@ -230,6 +238,30 @@ function f(): void { }
|
||||
testExtractConstantFailed("extractConstant_Never", `
|
||||
function f(): never { }
|
||||
[#|f();|]`);
|
||||
|
||||
testExtractConstant("extractConstant_This_Constructor", `
|
||||
class C {
|
||||
constructor() {
|
||||
[#|this.m2()|];
|
||||
}
|
||||
m2() { return 1; }
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_This_Method", `
|
||||
class C {
|
||||
m1() {
|
||||
[#|this.m2()|];
|
||||
}
|
||||
m2() { return 1; }
|
||||
}`);
|
||||
|
||||
testExtractConstant("extractConstant_This_Property", `
|
||||
namespace N { // Force this test to be TS-only
|
||||
class C {
|
||||
x = 1;
|
||||
y = [#|this.x|];
|
||||
}
|
||||
}`);
|
||||
});
|
||||
|
||||
function testExtractConstant(caption: string, text: string) {
|
||||
|
||||
@@ -532,6 +532,14 @@ function f() {
|
||||
[#|let x;|]
|
||||
return { x };
|
||||
}`);
|
||||
|
||||
testExtractFunction("extractFunction_PreserveTrivia", `
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ [#|1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2|] /*k*/ //l
|
||||
/*m*/; /*n*/ //o`);
|
||||
});
|
||||
|
||||
function testExtractFunction(caption: string, text: string) {
|
||||
|
||||
@@ -152,6 +152,16 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
`);
|
||||
testExtractRange(`
|
||||
function f(x: number) {
|
||||
[#|[$|try {
|
||||
x++;
|
||||
}
|
||||
finally {
|
||||
return 1;
|
||||
}|]|]
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed1",
|
||||
@@ -313,6 +323,23 @@ switch (x) {
|
||||
refactor.extractSymbol.Messages.CannotExtractRange.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extractRangeFailed11",
|
||||
`
|
||||
function f(x: number) {
|
||||
while (true) {
|
||||
[#|try {
|
||||
x++;
|
||||
}
|
||||
finally {
|
||||
break;
|
||||
}|]
|
||||
}
|
||||
}
|
||||
`,
|
||||
[
|
||||
refactor.extractSymbol.Messages.CannotExtractRangeContainingConditionalBreakOrContinueStatements.message
|
||||
]);
|
||||
|
||||
testExtractRangeFailed("extract-method-not-for-token-expression-statement", `[#|a|]`, [refactor.extractSymbol.Messages.CannotExtractIdentifier.message]);
|
||||
});
|
||||
}
|
||||
@@ -281,11 +281,11 @@ namespace ts.projectSystem {
|
||||
checkNumberOfProjects(this, count);
|
||||
}
|
||||
}
|
||||
export function createProjectService(host: server.ServerHost, parameters: CreateProjectServiceParameters = {}) {
|
||||
export function createProjectService(host: server.ServerHost, parameters: CreateProjectServiceParameters = {}, options?: Partial<server.ProjectServiceOptions>) {
|
||||
const cancellationToken = parameters.cancellationToken || server.nullCancellationToken;
|
||||
const logger = parameters.logger || nullLogger;
|
||||
const useSingleInferredProject = parameters.useSingleInferredProject !== undefined ? parameters.useSingleInferredProject : false;
|
||||
return new TestProjectService(host, logger, cancellationToken, useSingleInferredProject, parameters.typingsInstaller, parameters.eventHandler);
|
||||
return new TestProjectService(host, logger, cancellationToken, useSingleInferredProject, parameters.typingsInstaller, parameters.eventHandler, options);
|
||||
}
|
||||
|
||||
export function checkNumberOfConfiguredProjects(projectService: server.ProjectService, expected: number) {
|
||||
@@ -3784,6 +3784,113 @@ namespace ts.projectSystem {
|
||||
assert.equal(projectService.inferredProjects[1].getCompilationSettings().target, ScriptTarget.ESNext);
|
||||
assert.equal(projectService.inferredProjects[2].getCompilationSettings().target, ScriptTarget.ES2015);
|
||||
});
|
||||
|
||||
function checkInferredProject(inferredProject: server.InferredProject, actualFiles: FileOrFolder[], target: ScriptTarget) {
|
||||
checkProjectActualFiles(inferredProject, actualFiles.map(f => f.path));
|
||||
assert.equal(inferredProject.getCompilationSettings().target, target);
|
||||
}
|
||||
|
||||
function verifyProjectRootWithCaseSensitivity(useCaseSensitiveFileNames: boolean) {
|
||||
const files: [FileOrFolder, FileOrFolder, FileOrFolder, FileOrFolder] = [
|
||||
{ path: "/a/file1.ts", content: "let x = 1;" },
|
||||
{ path: "/A/file2.ts", content: "let y = 2;" },
|
||||
{ path: "/b/file2.ts", content: "let x = 3;" },
|
||||
{ path: "/c/file3.ts", content: "let z = 4;" }
|
||||
];
|
||||
const host = createServerHost(files, { useCaseSensitiveFileNames });
|
||||
const projectService = createProjectService(host, { useSingleInferredProject: true, }, { useInferredProjectPerProjectRoot: true });
|
||||
projectService.setCompilerOptionsForInferredProjects({
|
||||
allowJs: true,
|
||||
target: ScriptTarget.ESNext
|
||||
});
|
||||
projectService.setCompilerOptionsForInferredProjects({
|
||||
allowJs: true,
|
||||
target: ScriptTarget.ES2015
|
||||
}, "/a");
|
||||
|
||||
openClientFiles(["/a", "/a", "/b", undefined]);
|
||||
verifyInferredProjectsState([
|
||||
[[files[3]], ScriptTarget.ESNext],
|
||||
[[files[0], files[1]], ScriptTarget.ES2015],
|
||||
[[files[2]], ScriptTarget.ESNext]
|
||||
]);
|
||||
closeClientFiles();
|
||||
|
||||
openClientFiles(["/a", "/A", "/b", undefined]);
|
||||
if (useCaseSensitiveFileNames) {
|
||||
verifyInferredProjectsState([
|
||||
[[files[3]], ScriptTarget.ESNext],
|
||||
[[files[0]], ScriptTarget.ES2015],
|
||||
[[files[1]], ScriptTarget.ESNext],
|
||||
[[files[2]], ScriptTarget.ESNext]
|
||||
]);
|
||||
}
|
||||
else {
|
||||
verifyInferredProjectsState([
|
||||
[[files[3]], ScriptTarget.ESNext],
|
||||
[[files[0], files[1]], ScriptTarget.ES2015],
|
||||
[[files[2]], ScriptTarget.ESNext]
|
||||
]);
|
||||
}
|
||||
closeClientFiles();
|
||||
|
||||
projectService.setCompilerOptionsForInferredProjects({
|
||||
allowJs: true,
|
||||
target: ScriptTarget.ES2017
|
||||
}, "/A");
|
||||
|
||||
openClientFiles(["/a", "/a", "/b", undefined]);
|
||||
verifyInferredProjectsState([
|
||||
[[files[3]], ScriptTarget.ESNext],
|
||||
[[files[0], files[1]], useCaseSensitiveFileNames ? ScriptTarget.ES2015 : ScriptTarget.ES2017],
|
||||
[[files[2]], ScriptTarget.ESNext]
|
||||
]);
|
||||
closeClientFiles();
|
||||
|
||||
openClientFiles(["/a", "/A", "/b", undefined]);
|
||||
if (useCaseSensitiveFileNames) {
|
||||
verifyInferredProjectsState([
|
||||
[[files[3]], ScriptTarget.ESNext],
|
||||
[[files[0]], ScriptTarget.ES2015],
|
||||
[[files[1]], ScriptTarget.ES2017],
|
||||
[[files[2]], ScriptTarget.ESNext]
|
||||
]);
|
||||
}
|
||||
else {
|
||||
verifyInferredProjectsState([
|
||||
[[files[3]], ScriptTarget.ESNext],
|
||||
[[files[0], files[1]], ScriptTarget.ES2017],
|
||||
[[files[2]], ScriptTarget.ESNext]
|
||||
]);
|
||||
}
|
||||
closeClientFiles();
|
||||
|
||||
function openClientFiles(projectRoots: [string | undefined, string | undefined, string | undefined, string | undefined]) {
|
||||
files.forEach((file, index) => {
|
||||
projectService.openClientFile(file.path, file.content, ScriptKind.JS, projectRoots[index]);
|
||||
});
|
||||
}
|
||||
|
||||
function closeClientFiles() {
|
||||
files.forEach(file => projectService.closeClientFile(file.path));
|
||||
}
|
||||
|
||||
function verifyInferredProjectsState(expected: [FileOrFolder[], ScriptTarget][]) {
|
||||
checkNumberOfProjects(projectService, { inferredProjects: expected.length });
|
||||
projectService.inferredProjects.forEach((p, index) => {
|
||||
const [actualFiles, target] = expected[index];
|
||||
checkInferredProject(p, actualFiles, target);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
it("inferred projects per project root with case sensitive system", () => {
|
||||
verifyProjectRootWithCaseSensitivity(/*useCaseSensitiveFileNames*/ true);
|
||||
});
|
||||
|
||||
it("inferred projects per project root with case insensitive system", () => {
|
||||
verifyProjectRootWithCaseSensitivity(/*useCaseSensitiveFileNames*/ false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("No overwrite emit error", () => {
|
||||
@@ -4412,9 +4519,9 @@ namespace ts.projectSystem {
|
||||
fileName: "/a.ts",
|
||||
textChanges: [
|
||||
{
|
||||
start: { line: 2, offset: 1 },
|
||||
end: { line: 3, offset: 1 },
|
||||
newText: " newFunction();\n",
|
||||
start: { line: 2, offset: 3 },
|
||||
end: { line: 2, offset: 5 },
|
||||
newText: "newFunction();",
|
||||
},
|
||||
{
|
||||
start: { line: 3, offset: 2 },
|
||||
|
||||
@@ -590,9 +590,9 @@ namespace ts.server {
|
||||
// always set 'allowNonTsExtensions' for inferred projects since user cannot configure it from the outside
|
||||
// previously we did not expose a way for user to change these settings and this option was enabled by default
|
||||
compilerOptions.allowNonTsExtensions = true;
|
||||
|
||||
if (projectRootPath) {
|
||||
this.compilerOptionsForInferredProjectsPerProjectRoot.set(projectRootPath, compilerOptions);
|
||||
const canonicalProjectRootPath = projectRootPath && this.toCanonicalFileName(projectRootPath);
|
||||
if (canonicalProjectRootPath) {
|
||||
this.compilerOptionsForInferredProjectsPerProjectRoot.set(canonicalProjectRootPath, compilerOptions);
|
||||
}
|
||||
else {
|
||||
this.compilerOptionsForInferredProjects = compilerOptions;
|
||||
@@ -608,9 +608,9 @@ namespace ts.server {
|
||||
// root path
|
||||
// - Inferred projects with a projectRootPath, if the new options apply to that
|
||||
// project root path.
|
||||
if (projectRootPath ?
|
||||
project.projectRootPath === projectRootPath :
|
||||
!project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) {
|
||||
if (canonicalProjectRootPath ?
|
||||
project.projectRootPath === canonicalProjectRootPath :
|
||||
!project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) {
|
||||
project.setCompilerOptions(compilerOptions);
|
||||
project.compileOnSaveEnabled = compilerOptions.compileOnSave;
|
||||
project.markAsDirty();
|
||||
@@ -1599,9 +1599,10 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
if (projectRootPath) {
|
||||
const canonicalProjectRootPath = this.toCanonicalFileName(projectRootPath);
|
||||
// if we have an explicit project root path, find (or create) the matching inferred project.
|
||||
for (const project of this.inferredProjects) {
|
||||
if (project.projectRootPath === projectRootPath) {
|
||||
if (project.projectRootPath === canonicalProjectRootPath) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1047,12 +1047,15 @@ namespace ts.server {
|
||||
super.setCompilerOptions(newOptions);
|
||||
}
|
||||
|
||||
/** this is canonical project root path */
|
||||
readonly projectRootPath: string | undefined;
|
||||
|
||||
/*@internal*/
|
||||
constructor(
|
||||
projectService: ProjectService,
|
||||
documentRegistry: DocumentRegistry,
|
||||
compilerOptions: CompilerOptions,
|
||||
readonly projectRootPath: string | undefined,
|
||||
projectRootPath: string | undefined,
|
||||
currentDirectory: string | undefined) {
|
||||
super(InferredProject.newName(),
|
||||
ProjectKind.Inferred,
|
||||
@@ -1064,6 +1067,7 @@ namespace ts.server {
|
||||
/*compileOnSaveEnabled*/ false,
|
||||
projectService.host,
|
||||
currentDirectory);
|
||||
this.projectRootPath = projectRootPath && projectService.toCanonicalFileName(projectRootPath);
|
||||
}
|
||||
|
||||
addRoot(info: ScriptInfo) {
|
||||
|
||||
@@ -476,7 +476,10 @@ namespace ts.refactor.extractSymbol {
|
||||
// if range uses this as keyword or as type inside the class then it can only be extracted to a method of the containing class
|
||||
const containingClass = getContainingClass(current);
|
||||
if (containingClass) {
|
||||
return [containingClass];
|
||||
const containingFunction = findAncestor(current, isFunctionLikeDeclaration);
|
||||
return containingFunction
|
||||
? [containingFunction, containingClass]
|
||||
: [containingClass];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,6 +740,8 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
|
||||
const { body, returnValueProperty } = transformFunctionBody(node, exposedVariableDeclarations, writes, substitutions, !!(range.facts & RangeFacts.HasReturn));
|
||||
suppressLeadingAndTrailingTrivia(body);
|
||||
|
||||
let newFunction: MethodDeclaration | FunctionDeclaration;
|
||||
|
||||
if (isClassLike(scope)) {
|
||||
@@ -923,15 +928,10 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
}
|
||||
|
||||
if (isReadonlyArray(range.range)) {
|
||||
changeTracker.replaceNodesWithNodes(context.file, range.range, newNodes, {
|
||||
nodeSeparator: context.newLineCharacter,
|
||||
suffix: context.newLineCharacter // insert newline only when replacing statements
|
||||
});
|
||||
}
|
||||
else {
|
||||
changeTracker.replaceNodeWithNodes(context.file, range.range, newNodes, { nodeSeparator: context.newLineCharacter });
|
||||
}
|
||||
const replacementRange = isReadonlyArray(range.range)
|
||||
? { pos: first(range.range).getStart(), end: last(range.range).end }
|
||||
: { pos: range.range.getStart(), end: range.range.end };
|
||||
changeTracker.replaceRangeWithNodes(context.file, replacementRange, newNodes, { nodeSeparator: context.newLineCharacter });
|
||||
|
||||
const edits = changeTracker.getChanges();
|
||||
const renameRange = isReadonlyArray(range.range) ? first(range.range) : range.range;
|
||||
@@ -979,6 +979,7 @@ namespace ts.refactor.extractSymbol {
|
||||
: checker.typeToTypeNode(checker.getContextualType(node), scope, NodeBuilderFlags.NoTruncation);
|
||||
|
||||
const initializer = transformConstantInitializer(node, substitutions);
|
||||
suppressLeadingAndTrailingTrivia(initializer);
|
||||
|
||||
const changeTracker = textChanges.ChangeTracker.fromContext(context);
|
||||
|
||||
@@ -1011,7 +1012,7 @@ namespace ts.refactor.extractSymbol {
|
||||
changeTracker.insertNodeBefore(context.file, nodeToInsertBefore, newVariable, { suffix: context.newLineCharacter + context.newLineCharacter });
|
||||
|
||||
// Consume
|
||||
changeTracker.replaceNodeWithNodes(context.file, node, [localReference], { nodeSeparator: context.newLineCharacter });
|
||||
changeTracker.replaceRange(context.file, { pos: node.getStart(), end: node.end }, localReference);
|
||||
}
|
||||
else {
|
||||
const newVariableDeclaration = createVariableDeclaration(localNameText, variableType, initializer);
|
||||
|
||||
@@ -1369,4 +1369,39 @@ namespace ts {
|
||||
|
||||
return visited;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets EmitFlags to suppress leading and trailing trivia on the node.
|
||||
*/
|
||||
/* @internal */
|
||||
export function suppressLeadingAndTrailingTrivia(node: Node) {
|
||||
Debug.assert(node !== undefined);
|
||||
|
||||
suppressLeading(node);
|
||||
suppressTrailing(node);
|
||||
|
||||
function suppressLeading(node: Node) {
|
||||
addEmitFlags(node, EmitFlags.NoLeadingComments);
|
||||
|
||||
const firstChild = forEachChild(node, child => child);
|
||||
firstChild && suppressLeading(firstChild);
|
||||
}
|
||||
|
||||
function suppressTrailing(node: Node) {
|
||||
addEmitFlags(node, EmitFlags.NoTrailingComments);
|
||||
|
||||
let lastChild: Node = undefined;
|
||||
forEachChild(
|
||||
node,
|
||||
child => (lastChild = child, undefined),
|
||||
children => {
|
||||
// As an optimization, jump straight to the end of the list.
|
||||
if (children.length) {
|
||||
lastChild = last(children);
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
lastChild && suppressTrailing(lastChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7188,11 +7188,12 @@ declare namespace ts.server {
|
||||
* the file and its imports/references are put into an InferredProject.
|
||||
*/
|
||||
class InferredProject extends Project {
|
||||
readonly projectRootPath: string | undefined;
|
||||
private static readonly newName;
|
||||
private _isJsInferredProject;
|
||||
toggleJsInferredProject(isJsInferredProject: boolean): void;
|
||||
setCompilerOptions(options?: CompilerOptions): void;
|
||||
/** this is canonical project root path */
|
||||
readonly projectRootPath: string | undefined;
|
||||
addRoot(info: ScriptInfo): void;
|
||||
removeRoot(info: ScriptInfo): void;
|
||||
isProjectWithSingleRoot(): boolean;
|
||||
|
||||
58
tests/baselines/reference/asyncImportNestedYield.js
Normal file
58
tests/baselines/reference/asyncImportNestedYield.js
Normal file
@@ -0,0 +1,58 @@
|
||||
//// [asyncImportNestedYield.ts]
|
||||
async function* foo() {
|
||||
import((await import(yield "foo")).default);
|
||||
}
|
||||
|
||||
//// [asyncImportNestedYield.js]
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
||||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
||||
function fulfill(value) { resume("next", value); }
|
||||
function reject(value) { resume("throw", value); }
|
||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
||||
};
|
||||
function foo() {
|
||||
return __asyncGenerator(this, arguments, function foo_1() {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, "foo"];
|
||||
case 1: return [4 /*yield*/, __await.apply(void 0, [Promise.resolve().then(function () { return require(_a.sent()); })])];
|
||||
case 2:
|
||||
Promise.resolve().then(function () { return require((_a.sent())["default"]); });
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
6
tests/baselines/reference/asyncImportNestedYield.symbols
Normal file
6
tests/baselines/reference/asyncImportNestedYield.symbols
Normal file
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/compiler/asyncImportNestedYield.ts ===
|
||||
async function* foo() {
|
||||
>foo : Symbol(foo, Decl(asyncImportNestedYield.ts, 0, 0))
|
||||
|
||||
import((await import(yield "foo")).default);
|
||||
}
|
||||
14
tests/baselines/reference/asyncImportNestedYield.types
Normal file
14
tests/baselines/reference/asyncImportNestedYield.types
Normal file
@@ -0,0 +1,14 @@
|
||||
=== tests/cases/compiler/asyncImportNestedYield.ts ===
|
||||
async function* foo() {
|
||||
>foo : () => AsyncIterableIterator<"foo">
|
||||
|
||||
import((await import(yield "foo")).default);
|
||||
>import((await import(yield "foo")).default) : Promise<any>
|
||||
>(await import(yield "foo")).default : any
|
||||
>(await import(yield "foo")) : any
|
||||
>await import(yield "foo") : any
|
||||
>import(yield "foo") : Promise<any>
|
||||
>yield "foo" : any
|
||||
>"foo" : "foo"
|
||||
>default : any
|
||||
}
|
||||
@@ -29,7 +29,8 @@ c.dynamic();
|
||||
this._path = './other';
|
||||
}
|
||||
dynamic() {
|
||||
return __syncRequire ? Promise.resolve().then(() => require(this._path)) : new Promise((resolve_1, reject_1) => { require([this._path], resolve_1, reject_1); });
|
||||
return _a = this._path, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_1, reject_1) => { require([_a], resolve_1, reject_1); });
|
||||
var _a;
|
||||
}
|
||||
}
|
||||
const c = new C();
|
||||
|
||||
@@ -30,7 +30,8 @@ c.dynamic();
|
||||
}
|
||||
C.prototype.dynamic = function () {
|
||||
var _this = this;
|
||||
return __syncRequire ? Promise.resolve().then(function () { return require(_this._path); }) : new Promise(function (resolve_1, reject_1) { require([_this._path], resolve_1, reject_1); });
|
||||
return _a = this._path, __syncRequire ? Promise.resolve().then(function () { return require(_a); }) : new Promise(function (resolve_1, reject_1) { require([_a], resolve_1, reject_1); });
|
||||
var _a;
|
||||
};
|
||||
return C;
|
||||
}());
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ /*[#|*/1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2/*|]*/ /*k*/ //l
|
||||
/*m*/; /*n*/ //o
|
||||
// ==SCOPE::Extract to constant in enclosing scope==
|
||||
const newLocal = 1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2;
|
||||
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ /*RENAME*/newLocal /*k*/ //l
|
||||
/*m*/; /*n*/ //o
|
||||
@@ -0,0 +1,17 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ /*[#|*/1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2/*|]*/ /*k*/ //l
|
||||
/*m*/; /*n*/ //o
|
||||
// ==SCOPE::Extract to constant in enclosing scope==
|
||||
const newLocal = 1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2;
|
||||
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ /*RENAME*/newLocal /*k*/ //l
|
||||
/*m*/; /*n*/ //o
|
||||
@@ -0,0 +1,16 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
class C {
|
||||
constructor() {
|
||||
/*[#|*/this.m2()/*|]*/;
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
// ==SCOPE::Extract to constant in enclosing scope==
|
||||
|
||||
class C {
|
||||
constructor() {
|
||||
const /*RENAME*/newLocal = this.m2();
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
class C {
|
||||
constructor() {
|
||||
/*[#|*/this.m2()/*|]*/;
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
// ==SCOPE::Extract to constant in enclosing scope==
|
||||
|
||||
class C {
|
||||
constructor() {
|
||||
const /*RENAME*/newLocal = this.m2();
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
// ==SCOPE::Extract to readonly field in class 'C'==
|
||||
|
||||
class C {
|
||||
private readonly newProperty = this.m2();
|
||||
|
||||
constructor() {
|
||||
this./*RENAME*/newProperty;
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
class C {
|
||||
m1() {
|
||||
/*[#|*/this.m2()/*|]*/;
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
// ==SCOPE::Extract to constant in enclosing scope==
|
||||
|
||||
class C {
|
||||
m1() {
|
||||
const /*RENAME*/newLocal = this.m2();
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
class C {
|
||||
m1() {
|
||||
/*[#|*/this.m2()/*|]*/;
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
// ==SCOPE::Extract to constant in enclosing scope==
|
||||
|
||||
class C {
|
||||
m1() {
|
||||
const /*RENAME*/newLocal = this.m2();
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
// ==SCOPE::Extract to readonly field in class 'C'==
|
||||
|
||||
class C {
|
||||
private readonly newProperty = this.m2();
|
||||
|
||||
m1() {
|
||||
this./*RENAME*/newProperty;
|
||||
}
|
||||
m2() { return 1; }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
namespace N { // Force this test to be TS-only
|
||||
class C {
|
||||
x = 1;
|
||||
y = /*[#|*/this.x/*|]*/;
|
||||
}
|
||||
}
|
||||
// ==SCOPE::Extract to readonly field in class 'C'==
|
||||
|
||||
namespace N { // Force this test to be TS-only
|
||||
class C {
|
||||
x = 1;
|
||||
private readonly newProperty = this.x;
|
||||
|
||||
y = this./*RENAME*/newProperty;
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@
|
||||
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
|
||||
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
|
||||
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
|
||||
/*RENAME*/newFunction<U3a>(u3a);
|
||||
/*RENAME*/newFunction<U3a>(u3a);
|
||||
}
|
||||
|
||||
function newFunction<U3a>(u3a: U3a) {
|
||||
@@ -40,7 +40,7 @@
|
||||
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
|
||||
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
|
||||
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
|
||||
/*RENAME*/newFunction<U2a, T2a, U3a>(t2a, u2a, u3a);
|
||||
/*RENAME*/newFunction<U2a, T2a, U3a>(t2a, u2a, u3a);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,7 +60,7 @@
|
||||
<U2a, U2b>(u2a: U2a, u2b: U2b) => {
|
||||
function F2<T2a, T2b>(t2a: T2a, t2b: T2b) {
|
||||
<U3a, U3b>(u3a: U3a, u3b: U3b) => {
|
||||
/*RENAME*/newFunction<U1a, T1a, U2a, T2a, U3a>(t1a, t2a, u1a, u2a, u3a);
|
||||
/*RENAME*/newFunction<U1a, T1a, U2a, T2a, U3a>(t1a, t2a, u1a, u2a, u3a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ /*[#|*/1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2/*|]*/ /*k*/ //l
|
||||
/*m*/; /*n*/ //o
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ /*RENAME*/newFunction() /*k*/ //l
|
||||
/*m*/; /*n*/ //o
|
||||
function newFunction() {
|
||||
return 1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// ==ORIGINAL==
|
||||
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ /*[#|*/1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2/*|]*/ /*k*/ //l
|
||||
/*m*/; /*n*/ //o
|
||||
// ==SCOPE::Extract to function in global scope==
|
||||
|
||||
// a
|
||||
var q = /*b*/ //c
|
||||
/*d*/ /*RENAME*/newFunction() /*k*/ //l
|
||||
/*m*/; /*n*/ //o
|
||||
function newFunction() {
|
||||
return 1 /*e*/ //f
|
||||
/*g*/ + /*h*/ //i
|
||||
/*j*/ 2;
|
||||
}
|
||||
@@ -16,4 +16,4 @@ Promise.resolve().then(() => require(...["PathModule"]));
|
||||
var p1 = Promise.resolve().then(() => require(...a));
|
||||
const p2 = Promise.resolve().then(() => require());
|
||||
const p3 = Promise.resolve().then(() => require());
|
||||
const p4 = Promise.resolve().then(() => require("pathToModule", "secondModule"));
|
||||
const p4 = Promise.resolve().then(() => require("pathToModule"));
|
||||
|
||||
33
tests/baselines/reference/importCallExpressionNestedAMD.js
Normal file
33
tests/baselines/reference/importCallExpressionNestedAMD.js
Normal file
@@ -0,0 +1,33 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedAMD.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = "./foo";
|
||||
});
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield new Promise((resolve_1, reject_1) => { require([(yield new Promise((resolve_2, reject_2) => { require(["./foo"], resolve_2, reject_2); })).default], resolve_1, reject_1); });
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
66
tests/baselines/reference/importCallExpressionNestedAMD2.js
Normal file
66
tests/baselines/reference/importCallExpressionNestedAMD2.js
Normal file
@@ -0,0 +1,66 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedAMD2.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = "./foo";
|
||||
});
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
"use strict";
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })];
|
||||
case 1: return [4 /*yield*/, new Promise(function (resolve_2, reject_2) { require([(_a.sent()).default], resolve_2, reject_2); })];
|
||||
case 2: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
28
tests/baselines/reference/importCallExpressionNestedCJS.js
Normal file
28
tests/baselines/reference/importCallExpressionNestedCJS.js
Normal file
@@ -0,0 +1,28 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedCJS.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = "./foo";
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield Promise.resolve().then(() => require((yield Promise.resolve().then(() => require("./foo"))).default));
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
61
tests/baselines/reference/importCallExpressionNestedCJS2.js
Normal file
61
tests/baselines/reference/importCallExpressionNestedCJS2.js
Normal file
@@ -0,0 +1,61 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedCJS2.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = "./foo";
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, Promise.resolve().then(function () { return require("./foo"); })];
|
||||
case 1: return [4 /*yield*/, Promise.resolve().then(function () { return require((_a.sent()).default); })];
|
||||
case 2: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
|
||||
tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
|
||||
|
||||
|
||||
==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ====
|
||||
export default "./foo";
|
||||
|
||||
==== tests/cases/conformance/dynamicImport/index.ts (2 errors) ====
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedES2015.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
export default "./foo";
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield import((yield import("./foo")).default);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/dynamicImport/index.ts(2,18): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
|
||||
tests/cases/conformance/dynamicImport/index.ts(2,32): error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
|
||||
|
||||
|
||||
==== tests/cases/conformance/dynamicImport/foo.ts (0 errors) ====
|
||||
export default "./foo";
|
||||
|
||||
==== tests/cases/conformance/dynamicImport/index.ts (2 errors) ====
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS1323: Dynamic import cannot be used when targeting ECMAScript 2015 modules.
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedES20152.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
export default "./foo";
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, import("./foo")];
|
||||
case 1: return [4 /*yield*/, import((_a.sent()).default)];
|
||||
case 2: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedESNext.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
export default "./foo";
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield import((yield import("./foo")).default);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedESNext2.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
export default "./foo";
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, import("./foo")];
|
||||
case 1: return [4 /*yield*/, import((_a.sent()).default)];
|
||||
case 2: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedSystem.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("default", "./foo");
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [index.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield context_1.import((yield context_1.import("./foo")).default);
|
||||
});
|
||||
}
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedSystem2.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
"use strict";
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
exports_1("default", "./foo");
|
||||
}
|
||||
};
|
||||
});
|
||||
//// [index.js]
|
||||
System.register([], function (exports_1, context_1) {
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
var __moduleName = context_1 && context_1.id;
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, context_1.import("./foo")];
|
||||
case 1: return [4 /*yield*/, context_1.import((_a.sent()).default)];
|
||||
case 2: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
51
tests/baselines/reference/importCallExpressionNestedUMD.js
Normal file
51
tests/baselines/reference/importCallExpressionNestedUMD.js
Normal file
@@ -0,0 +1,51 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedUMD.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.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 });
|
||||
exports.default = "./foo";
|
||||
});
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
(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";
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return yield _a = (yield __syncRequire ? Promise.resolve().then(() => require("./foo")) : new Promise((resolve_1, reject_1) => { require(["./foo"], resolve_1, reject_1); })).default, __syncRequire ? Promise.resolve().then(() => require(_a)) : new Promise((resolve_2, reject_2) => { require([_a], resolve_2, reject_2); });
|
||||
var _a;
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
84
tests/baselines/reference/importCallExpressionNestedUMD2.js
Normal file
84
tests/baselines/reference/importCallExpressionNestedUMD2.js
Normal file
@@ -0,0 +1,84 @@
|
||||
//// [tests/cases/conformance/dynamicImport/importCallExpressionNestedUMD2.ts] ////
|
||||
|
||||
//// [foo.ts]
|
||||
export default "./foo";
|
||||
|
||||
//// [index.ts]
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
|
||||
//// [foo.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 });
|
||||
exports.default = "./foo";
|
||||
});
|
||||
//// [index.js]
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
(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";
|
||||
function foo() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, __syncRequire ? Promise.resolve().then(function () { return require("./foo"); }) : new Promise(function (resolve_1, reject_1) { require(["./foo"], resolve_1, reject_1); })];
|
||||
case 1: return [4 /*yield*/, (_b = (_a.sent()).default, __syncRequire ? Promise.resolve().then(function () { return require(_b); }) : new Promise(function (resolve_2, reject_2) { require([_b], resolve_2, reject_2); }))];
|
||||
case 2: return [2 /*return*/, _a.sent()];
|
||||
}
|
||||
var _b;
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : Symbol(foo, Decl(index.ts, 0, 0))
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>(await import("./foo")).default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
>"./foo" : Symbol("tests/cases/conformance/dynamicImport/foo", Decl(foo.ts, 0, 0))
|
||||
>default : Symbol(default, Decl(foo.ts, 0, 0))
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/dynamicImport/foo.ts ===
|
||||
export default "./foo";
|
||||
No type information for this code.
|
||||
No type information for this code.=== tests/cases/conformance/dynamicImport/index.ts ===
|
||||
async function foo() {
|
||||
>foo : () => Promise<any>
|
||||
|
||||
return await import((await import("./foo")).default);
|
||||
>await import((await import("./foo")).default) : any
|
||||
>import((await import("./foo")).default) : Promise<any>
|
||||
>(await import("./foo")).default : "./foo"
|
||||
>(await import("./foo")) : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>await import("./foo") : typeof "tests/cases/conformance/dynamicImport/foo"
|
||||
>import("./foo") : Promise<typeof "tests/cases/conformance/dynamicImport/foo">
|
||||
>"./foo" : "./foo"
|
||||
>default : "./foo"
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
tests/cases/compiler/incorrectNumberOfTypeArgumentsDuringErrorReporting.ts(18,4): error TS2559: Type 'MyObjA' has no properties in common with type 'ObjA'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/incorrectNumberOfTypeArgumentsDuringErrorReporting.ts (1 errors) ====
|
||||
interface ObjA {
|
||||
y?:string,
|
||||
}
|
||||
|
||||
interface ObjB {[key:string]:any}
|
||||
|
||||
interface Opts<A, B> {a:A, b:B}
|
||||
|
||||
const fn = <
|
||||
A extends ObjA,
|
||||
B extends ObjB = ObjB
|
||||
>(opts:Opts<A, B>):string => 'Z'
|
||||
|
||||
interface MyObjA {
|
||||
x:string,
|
||||
}
|
||||
|
||||
fn<MyObjA>({
|
||||
~~~~~~
|
||||
!!! error TS2559: Type 'MyObjA' has no properties in common with type 'ObjA'.
|
||||
a: {x: 'X', y: 'Y'},
|
||||
b: {},
|
||||
})
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//// [incorrectNumberOfTypeArgumentsDuringErrorReporting.ts]
|
||||
interface ObjA {
|
||||
y?:string,
|
||||
}
|
||||
|
||||
interface ObjB {[key:string]:any}
|
||||
|
||||
interface Opts<A, B> {a:A, b:B}
|
||||
|
||||
const fn = <
|
||||
A extends ObjA,
|
||||
B extends ObjB = ObjB
|
||||
>(opts:Opts<A, B>):string => 'Z'
|
||||
|
||||
interface MyObjA {
|
||||
x:string,
|
||||
}
|
||||
|
||||
fn<MyObjA>({
|
||||
a: {x: 'X', y: 'Y'},
|
||||
b: {},
|
||||
})
|
||||
|
||||
|
||||
//// [incorrectNumberOfTypeArgumentsDuringErrorReporting.js]
|
||||
var fn = function (opts) { return 'Z'; };
|
||||
fn({
|
||||
a: { x: 'X', y: 'Y' },
|
||||
b: {}
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
=== tests/cases/compiler/incorrectNumberOfTypeArgumentsDuringErrorReporting.ts ===
|
||||
interface ObjA {
|
||||
>ObjA : Symbol(ObjA, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 0, 0))
|
||||
|
||||
y?:string,
|
||||
>y : Symbol(ObjA.y, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 0, 16))
|
||||
}
|
||||
|
||||
interface ObjB {[key:string]:any}
|
||||
>ObjB : Symbol(ObjB, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 2, 1))
|
||||
>key : Symbol(key, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 4, 17))
|
||||
|
||||
interface Opts<A, B> {a:A, b:B}
|
||||
>Opts : Symbol(Opts, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 4, 33))
|
||||
>A : Symbol(A, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 6, 15))
|
||||
>B : Symbol(B, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 6, 17))
|
||||
>a : Symbol(Opts.a, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 6, 22))
|
||||
>A : Symbol(A, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 6, 15))
|
||||
>b : Symbol(Opts.b, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 6, 26))
|
||||
>B : Symbol(B, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 6, 17))
|
||||
|
||||
const fn = <
|
||||
>fn : Symbol(fn, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 8, 5))
|
||||
|
||||
A extends ObjA,
|
||||
>A : Symbol(A, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 8, 12))
|
||||
>ObjA : Symbol(ObjA, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 0, 0))
|
||||
|
||||
B extends ObjB = ObjB
|
||||
>B : Symbol(B, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 9, 17))
|
||||
>ObjB : Symbol(ObjB, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 2, 1))
|
||||
>ObjB : Symbol(ObjB, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 2, 1))
|
||||
|
||||
>(opts:Opts<A, B>):string => 'Z'
|
||||
>opts : Symbol(opts, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 11, 2))
|
||||
>Opts : Symbol(Opts, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 4, 33))
|
||||
>A : Symbol(A, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 8, 12))
|
||||
>B : Symbol(B, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 9, 17))
|
||||
|
||||
interface MyObjA {
|
||||
>MyObjA : Symbol(MyObjA, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 11, 32))
|
||||
|
||||
x:string,
|
||||
>x : Symbol(MyObjA.x, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 13, 18))
|
||||
}
|
||||
|
||||
fn<MyObjA>({
|
||||
>fn : Symbol(fn, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 8, 5))
|
||||
>MyObjA : Symbol(MyObjA, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 11, 32))
|
||||
|
||||
a: {x: 'X', y: 'Y'},
|
||||
>a : Symbol(a, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 17, 12))
|
||||
>x : Symbol(x, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 18, 6))
|
||||
>y : Symbol(y, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 18, 13))
|
||||
|
||||
b: {},
|
||||
>b : Symbol(b, Decl(incorrectNumberOfTypeArgumentsDuringErrorReporting.ts, 18, 22))
|
||||
|
||||
})
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
=== tests/cases/compiler/incorrectNumberOfTypeArgumentsDuringErrorReporting.ts ===
|
||||
interface ObjA {
|
||||
>ObjA : ObjA
|
||||
|
||||
y?:string,
|
||||
>y : string
|
||||
}
|
||||
|
||||
interface ObjB {[key:string]:any}
|
||||
>ObjB : ObjB
|
||||
>key : string
|
||||
|
||||
interface Opts<A, B> {a:A, b:B}
|
||||
>Opts : Opts<A, B>
|
||||
>A : A
|
||||
>B : B
|
||||
>a : A
|
||||
>A : A
|
||||
>b : B
|
||||
>B : B
|
||||
|
||||
const fn = <
|
||||
>fn : <A extends ObjA, B extends ObjB = ObjB>(opts: Opts<A, B>) => string
|
||||
>< A extends ObjA, B extends ObjB = ObjB>(opts:Opts<A, B>):string => 'Z' : <A extends ObjA, B extends ObjB = ObjB>(opts: Opts<A, B>) => string
|
||||
|
||||
A extends ObjA,
|
||||
>A : A
|
||||
>ObjA : ObjA
|
||||
|
||||
B extends ObjB = ObjB
|
||||
>B : B
|
||||
>ObjB : ObjB
|
||||
>ObjB : ObjB
|
||||
|
||||
>(opts:Opts<A, B>):string => 'Z'
|
||||
>opts : Opts<A, B>
|
||||
>Opts : Opts<A, B>
|
||||
>A : A
|
||||
>B : B
|
||||
>'Z' : "Z"
|
||||
|
||||
interface MyObjA {
|
||||
>MyObjA : MyObjA
|
||||
|
||||
x:string,
|
||||
>x : string
|
||||
}
|
||||
|
||||
fn<MyObjA>({
|
||||
>fn<MyObjA>({ a: {x: 'X', y: 'Y'}, b: {},}) : any
|
||||
>fn : <A extends ObjA, B extends ObjB = ObjB>(opts: Opts<A, B>) => string
|
||||
>MyObjA : MyObjA
|
||||
>{ a: {x: 'X', y: 'Y'}, b: {},} : { a: { x: string; y: string; }; b: {}; }
|
||||
|
||||
a: {x: 'X', y: 'Y'},
|
||||
>a : { x: string; y: string; }
|
||||
>{x: 'X', y: 'Y'} : { x: string; y: string; }
|
||||
>x : string
|
||||
>'X' : "X"
|
||||
>y : string
|
||||
>'Y' : "Y"
|
||||
|
||||
b: {},
|
||||
>b : {}
|
||||
>{} : {}
|
||||
|
||||
})
|
||||
|
||||
4
tests/cases/compiler/asyncImportNestedYield.ts
Normal file
4
tests/cases/compiler/asyncImportNestedYield.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// @lib: esnext
|
||||
async function* foo() {
|
||||
import((await import(yield "foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
interface ObjA {
|
||||
y?:string,
|
||||
}
|
||||
|
||||
interface ObjB {[key:string]:any}
|
||||
|
||||
interface Opts<A, B> {a:A, b:B}
|
||||
|
||||
const fn = <
|
||||
A extends ObjA,
|
||||
B extends ObjB = ObjB
|
||||
>(opts:Opts<A, B>):string => 'Z'
|
||||
|
||||
interface MyObjA {
|
||||
x:string,
|
||||
}
|
||||
|
||||
fn<MyObjA>({
|
||||
a: {x: 'X', y: 'Y'},
|
||||
b: {},
|
||||
})
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: amd
|
||||
// @target: es6
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: amd
|
||||
// @target: es5
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: commonjs
|
||||
// @target: es6
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: commonjs
|
||||
// @target: es5
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: es2015
|
||||
// @target: es6
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: es2015
|
||||
// @target: es5
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: esnext
|
||||
// @target: es6
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: esnext
|
||||
// @target: es5
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: system
|
||||
// @target: es6
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: system
|
||||
// @target: es5
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: umd
|
||||
// @target: es6
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// @module: umd
|
||||
// @target: es5
|
||||
// @skipLibCheck: true
|
||||
// @lib: es6
|
||||
// @filename: foo.ts
|
||||
export default "./foo";
|
||||
|
||||
// @filename: index.ts
|
||||
async function foo() {
|
||||
return await import((await import("./foo")).default);
|
||||
}
|
||||
@@ -11,10 +11,9 @@ edit.applyRefactor({
|
||||
actionName: "function_scope_0",
|
||||
actionDescription: "Extract to function in global scope",
|
||||
newContent:
|
||||
`/*RENAME*/newFunction_1();
|
||||
|
||||
`// newFunction
|
||||
/*RENAME*/newFunction_1();
|
||||
function newFunction_1() {
|
||||
// newFunction
|
||||
1 + 1;
|
||||
}
|
||||
`
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
//// }
|
||||
|
||||
goTo.select('a', 'b')
|
||||
verify.refactorAvailable('Extract Symbol', 'function_scope_0');
|
||||
verify.not.refactorAvailable('Extract Symbol', 'function_scope_1');
|
||||
verify.not.refactorAvailable('Extract Symbol', 'function_scope_0');
|
||||
verify.refactorAvailable('Extract Symbol', 'function_scope_1');
|
||||
verify.not.refactorAvailable('Extract Symbol', 'function_scope_2');
|
||||
|
||||
Reference in New Issue
Block a user