mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
Clean up unused imports and apply formatting
Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
This commit is contained in:
parent
486c12af19
commit
f163c167b7
@ -91,10 +91,10 @@ import {
|
||||
isAmbientModule,
|
||||
isArray,
|
||||
isArrayBindingElement,
|
||||
isBinaryExpression,
|
||||
isBindingElement,
|
||||
isBindingPattern,
|
||||
isCallExpression,
|
||||
isBinaryExpression,
|
||||
isBindingElement,
|
||||
isBindingPattern,
|
||||
isCallExpression,
|
||||
isClassDeclaration,
|
||||
isClassElement,
|
||||
isComputedPropertyName,
|
||||
@ -325,20 +325,22 @@ export function transformDeclarations(context: TransformationContext): Transform
|
||||
}
|
||||
});
|
||||
}
|
||||
function reportInferenceFallback(node: Node) {
|
||||
if (!isolatedDeclarations || isSourceFileJS(currentSourceFile)) return;
|
||||
if (getSourceFileOfNode(node) !== currentSourceFile) return; // Nested error on a declaration in another file - ignore, will be reemitted if file is in the output file set
|
||||
if (isVariableDeclaration(node) && resolver.isExpandoFunctionDeclaration(node)) {
|
||||
reportExpandoFunctionErrors(node);
|
||||
}
|
||||
else {
|
||||
// Don't report errors for function expressions that are arguments to call expressions
|
||||
if ((node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction) &&
|
||||
isCallExpression(node.parent)) {
|
||||
return;
|
||||
}
|
||||
context.addDiagnostic(getIsolatedDeclarationError(node));
|
||||
}
|
||||
function reportInferenceFallback(node: Node) {
|
||||
if (!isolatedDeclarations || isSourceFileJS(currentSourceFile)) return;
|
||||
if (getSourceFileOfNode(node) !== currentSourceFile) return; // Nested error on a declaration in another file - ignore, will be reemitted if file is in the output file set
|
||||
if (isVariableDeclaration(node) && resolver.isExpandoFunctionDeclaration(node)) {
|
||||
reportExpandoFunctionErrors(node);
|
||||
}
|
||||
else {
|
||||
// Don't report errors for function expressions that are arguments to call expressions
|
||||
if (
|
||||
(node.kind === SyntaxKind.FunctionExpression || node.kind === SyntaxKind.ArrowFunction) &&
|
||||
isCallExpression(node.parent)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
context.addDiagnostic(getIsolatedDeclarationError(node));
|
||||
}
|
||||
}
|
||||
function handleSymbolAccessibilityError(symbolAccessibilityResult: SymbolAccessibilityResult) {
|
||||
if (symbolAccessibilityResult.accessibility === SymbolAccessibility.Accessible) {
|
||||
|
||||
@ -1,101 +1,100 @@
|
||||
import {
|
||||
addRelatedInfo,
|
||||
ArrayLiteralExpression,
|
||||
ArrowFunction,
|
||||
assertType,
|
||||
BinaryExpression,
|
||||
BindingElement,
|
||||
CallSignatureDeclaration,
|
||||
ClassExpression,
|
||||
ComputedPropertyName,
|
||||
ConstructorDeclaration,
|
||||
ConstructSignatureDeclaration,
|
||||
createDiagnosticForNode,
|
||||
Debug,
|
||||
Declaration,
|
||||
DeclarationName,
|
||||
DiagnosticMessage,
|
||||
Diagnostics,
|
||||
DiagnosticWithLocation,
|
||||
ElementAccessExpression,
|
||||
EmitResolver,
|
||||
EntityNameOrEntityNameExpression,
|
||||
ExportAssignment,
|
||||
Expression,
|
||||
ExpressionWithTypeArguments,
|
||||
findAncestor,
|
||||
FunctionDeclaration,
|
||||
FunctionExpression,
|
||||
FunctionLikeDeclaration,
|
||||
GetAccessorDeclaration,
|
||||
getAllAccessorDeclarations,
|
||||
getNameOfDeclaration,
|
||||
getTextOfNode,
|
||||
hasSyntacticModifier,
|
||||
ImportEqualsDeclaration,
|
||||
IndexSignatureDeclaration,
|
||||
isAsExpression,
|
||||
isBinaryExpression,
|
||||
isBindingElement,
|
||||
isCallExpression,
|
||||
isCallSignatureDeclaration,
|
||||
isClassDeclaration,
|
||||
isConstructorDeclaration,
|
||||
isConstructSignatureDeclaration,
|
||||
isElementAccessExpression,
|
||||
isEntityName,
|
||||
isEntityNameExpression,
|
||||
isExportAssignment,
|
||||
isExpressionWithTypeArguments,
|
||||
isFunctionDeclaration,
|
||||
isFunctionLikeDeclaration,
|
||||
isGetAccessor,
|
||||
isHeritageClause,
|
||||
isImportEqualsDeclaration,
|
||||
isIndexSignatureDeclaration,
|
||||
isJSDocTypeAlias,
|
||||
isMethodDeclaration,
|
||||
isMethodSignature,
|
||||
isParameter,
|
||||
isParameterPropertyDeclaration,
|
||||
isParenthesizedExpression,
|
||||
isPartOfTypeNode,
|
||||
isPropertyAccessExpression,
|
||||
isPropertyDeclaration,
|
||||
isPropertySignature,
|
||||
isReturnStatement,
|
||||
isSetAccessor,
|
||||
isStatement,
|
||||
isStatic,
|
||||
isTypeAliasDeclaration,
|
||||
isTypeAssertionExpression,
|
||||
isTypeParameterDeclaration,
|
||||
isTypeQueryNode,
|
||||
isVariableDeclaration,
|
||||
JSDocCallbackTag,
|
||||
JSDocEnumTag,
|
||||
JSDocTypedefTag,
|
||||
MethodDeclaration,
|
||||
MethodSignature,
|
||||
ModifierFlags,
|
||||
NamedDeclaration,
|
||||
Node,
|
||||
ParameterDeclaration,
|
||||
PropertyAccessExpression,
|
||||
PropertyAssignment,
|
||||
PropertyDeclaration,
|
||||
PropertySignature,
|
||||
QualifiedName,
|
||||
SetAccessorDeclaration,
|
||||
ShorthandPropertyAssignment,
|
||||
SpreadAssignment,
|
||||
SpreadElement,
|
||||
SymbolAccessibility,
|
||||
SymbolAccessibilityResult,
|
||||
SyntaxKind,
|
||||
TypeAliasDeclaration,
|
||||
TypeParameterDeclaration,
|
||||
VariableDeclaration,
|
||||
import {
|
||||
addRelatedInfo,
|
||||
ArrayLiteralExpression,
|
||||
ArrowFunction,
|
||||
assertType,
|
||||
BinaryExpression,
|
||||
BindingElement,
|
||||
CallSignatureDeclaration,
|
||||
ClassExpression,
|
||||
ComputedPropertyName,
|
||||
ConstructorDeclaration,
|
||||
ConstructSignatureDeclaration,
|
||||
createDiagnosticForNode,
|
||||
Debug,
|
||||
Declaration,
|
||||
DeclarationName,
|
||||
DiagnosticMessage,
|
||||
Diagnostics,
|
||||
DiagnosticWithLocation,
|
||||
ElementAccessExpression,
|
||||
EmitResolver,
|
||||
EntityNameOrEntityNameExpression,
|
||||
ExportAssignment,
|
||||
Expression,
|
||||
ExpressionWithTypeArguments,
|
||||
findAncestor,
|
||||
FunctionDeclaration,
|
||||
FunctionExpression,
|
||||
FunctionLikeDeclaration,
|
||||
GetAccessorDeclaration,
|
||||
getAllAccessorDeclarations,
|
||||
getNameOfDeclaration,
|
||||
getTextOfNode,
|
||||
hasSyntacticModifier,
|
||||
ImportEqualsDeclaration,
|
||||
IndexSignatureDeclaration,
|
||||
isAsExpression,
|
||||
isBinaryExpression,
|
||||
isBindingElement,
|
||||
isCallSignatureDeclaration,
|
||||
isClassDeclaration,
|
||||
isConstructorDeclaration,
|
||||
isConstructSignatureDeclaration,
|
||||
isElementAccessExpression,
|
||||
isEntityName,
|
||||
isEntityNameExpression,
|
||||
isExportAssignment,
|
||||
isExpressionWithTypeArguments,
|
||||
isFunctionDeclaration,
|
||||
isFunctionLikeDeclaration,
|
||||
isGetAccessor,
|
||||
isHeritageClause,
|
||||
isImportEqualsDeclaration,
|
||||
isIndexSignatureDeclaration,
|
||||
isJSDocTypeAlias,
|
||||
isMethodDeclaration,
|
||||
isMethodSignature,
|
||||
isParameter,
|
||||
isParameterPropertyDeclaration,
|
||||
isParenthesizedExpression,
|
||||
isPartOfTypeNode,
|
||||
isPropertyAccessExpression,
|
||||
isPropertyDeclaration,
|
||||
isPropertySignature,
|
||||
isReturnStatement,
|
||||
isSetAccessor,
|
||||
isStatement,
|
||||
isStatic,
|
||||
isTypeAliasDeclaration,
|
||||
isTypeAssertionExpression,
|
||||
isTypeParameterDeclaration,
|
||||
isTypeQueryNode,
|
||||
isVariableDeclaration,
|
||||
JSDocCallbackTag,
|
||||
JSDocEnumTag,
|
||||
JSDocTypedefTag,
|
||||
MethodDeclaration,
|
||||
MethodSignature,
|
||||
ModifierFlags,
|
||||
NamedDeclaration,
|
||||
Node,
|
||||
ParameterDeclaration,
|
||||
PropertyAccessExpression,
|
||||
PropertyAssignment,
|
||||
PropertyDeclaration,
|
||||
PropertySignature,
|
||||
QualifiedName,
|
||||
SetAccessorDeclaration,
|
||||
ShorthandPropertyAssignment,
|
||||
SpreadAssignment,
|
||||
SpreadElement,
|
||||
SymbolAccessibility,
|
||||
SymbolAccessibilityResult,
|
||||
SyntaxKind,
|
||||
TypeAliasDeclaration,
|
||||
TypeParameterDeclaration,
|
||||
VariableDeclaration,
|
||||
} from "../../_namespaces/ts.js";
|
||||
|
||||
/** @internal */
|
||||
@ -662,47 +661,47 @@ export function createGetIsolatedDeclarationErrors(resolver: EmitResolver): (nod
|
||||
| PropertyAssignment
|
||||
| ClassExpression;
|
||||
|
||||
function getDiagnostic(node: Node) {
|
||||
const heritageClause = findAncestor(node, isHeritageClause);
|
||||
if (heritageClause) {
|
||||
return createDiagnosticForNode(node, Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations);
|
||||
}
|
||||
if ((isPartOfTypeNode(node) || isTypeQueryNode(node.parent)) && (isEntityName(node) || isEntityNameExpression(node))) {
|
||||
return createEntityInTypeNodeError(node);
|
||||
}
|
||||
Debug.type<WithIsolatedDeclarationDiagnostic>(node);
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return createAccessorTypeError(node);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
return createObjectLiteralError(node);
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.SpreadElement:
|
||||
return createArrayLiteralError(node);
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return createReturnTypeError(node);
|
||||
case SyntaxKind.BindingElement:
|
||||
return createBindingElementError(node);
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return createVariableOrPropertyError(node);
|
||||
case SyntaxKind.Parameter:
|
||||
return createParameterError(node);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return createExpressionError(node.initializer);
|
||||
case SyntaxKind.ClassExpression:
|
||||
return createClassExpressionError(node);
|
||||
default:
|
||||
assertType<never>(node);
|
||||
return createExpressionError(node as Expression);
|
||||
}
|
||||
function getDiagnostic(node: Node) {
|
||||
const heritageClause = findAncestor(node, isHeritageClause);
|
||||
if (heritageClause) {
|
||||
return createDiagnosticForNode(node, Diagnostics.Extends_clause_can_t_contain_an_expression_with_isolatedDeclarations);
|
||||
}
|
||||
if ((isPartOfTypeNode(node) || isTypeQueryNode(node.parent)) && (isEntityName(node) || isEntityNameExpression(node))) {
|
||||
return createEntityInTypeNodeError(node);
|
||||
}
|
||||
Debug.type<WithIsolatedDeclarationDiagnostic>(node);
|
||||
switch (node.kind) {
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
return createAccessorTypeError(node);
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
case SyntaxKind.SpreadAssignment:
|
||||
return createObjectLiteralError(node);
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
case SyntaxKind.SpreadElement:
|
||||
return createArrayLiteralError(node);
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.ConstructSignature:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
return createReturnTypeError(node);
|
||||
case SyntaxKind.BindingElement:
|
||||
return createBindingElementError(node);
|
||||
case SyntaxKind.PropertyDeclaration:
|
||||
case SyntaxKind.VariableDeclaration:
|
||||
return createVariableOrPropertyError(node);
|
||||
case SyntaxKind.Parameter:
|
||||
return createParameterError(node);
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return createExpressionError(node.initializer);
|
||||
case SyntaxKind.ClassExpression:
|
||||
return createClassExpressionError(node);
|
||||
default:
|
||||
assertType<never>(node);
|
||||
return createExpressionError(node as Expression);
|
||||
}
|
||||
}
|
||||
|
||||
function findNearestDeclaration(node: Node) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user