mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-24 11:43:18 -05:00
Init (#44206)
This commit is contained in:
committed by
GitHub
parent
7c293c8d46
commit
69cc9ba5e4
@@ -215,7 +215,6 @@ namespace ts.refactor.extractSymbol {
|
||||
export const cannotExtractReadonlyPropertyInitializerOutsideConstructor = createMessage("Cannot move initialization of read-only class property outside of the constructor");
|
||||
export const cannotExtractAmbientBlock = createMessage("Cannot extract code from ambient contexts");
|
||||
export const cannotAccessVariablesFromNestedScopes = createMessage("Cannot access variables from nested scopes");
|
||||
export const cannotExtractToOtherFunctionLike = createMessage("Cannot extract method to a function-like scope that is not a function");
|
||||
export const cannotExtractToJSClass = createMessage("Cannot extract constant to a class scope in JS");
|
||||
export const cannotExtractToExpressionArrowFunction = createMessage("Cannot extract constant to an arrow function without a block");
|
||||
}
|
||||
@@ -1624,10 +1623,7 @@ namespace ts.refactor.extractSymbol {
|
||||
usagesPerScope.push({ usages: new Map<string, UsageEntry>(), typeParameterUsages: new Map<string, TypeParameter>(), substitutions: new Map<string, Expression>() });
|
||||
substitutionsPerScope.push(new Map<string, Expression>());
|
||||
|
||||
functionErrorsPerScope.push(
|
||||
isFunctionLikeDeclaration(scope) && scope.kind !== SyntaxKind.FunctionDeclaration
|
||||
? [createDiagnosticForNode(scope, Messages.cannotExtractToOtherFunctionLike)]
|
||||
: []);
|
||||
functionErrorsPerScope.push([]);
|
||||
|
||||
const constantErrors = [];
|
||||
if (expressionDiagnostic) {
|
||||
|
||||
@@ -352,6 +352,11 @@ function parsePrimaryExpression(): any {
|
||||
`function F() {
|
||||
[#|function G() { }|]
|
||||
}`);
|
||||
// Arrow function
|
||||
testExtractFunction("extractFunction34",
|
||||
`const F = () => {
|
||||
[#|function G() { }|]
|
||||
};`);
|
||||
|
||||
testExtractFunction("extractFunction_RepeatedSubstitution",
|
||||
`namespace X {
|
||||
|
||||
Reference in New Issue
Block a user