@@ -3068,63 +3068,63 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
30683068 return isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer);
30693069 }
30703070
3071- function isUsedInFunctionOrInstanceProperty(usage: Node, declaration: Node) {
3072- return isUsedInFunctionOrInstancePropertyWorker(usage, declaration);
3073- }
3071+ function isUsedInFunctionOrInstanceProperty(usage: Node, declaration: Node) {
3072+ return isUsedInFunctionOrInstancePropertyWorker(usage, declaration);
3073+ }
30743074
3075- function isUsedInFunctionOrInstancePropertyWorker(usage: Node, declaration: Node): boolean {
3076- return !!findAncestor(usage, current => {
3077- if (current === declContainer) {
3078- return "quit";
3079- }
3080- if (isFunctionLike(current)) {
3081- return !getImmediatelyInvokedFunctionExpression(current);
3082- }
3083- if (isClassStaticBlockDeclaration(current)) {
3084- return declaration.pos < usage.pos;
3085- }
3075+ function isUsedInFunctionOrInstancePropertyWorker(usage: Node, declaration: Node): boolean {
3076+ return !!findAncestor(usage, current => {
3077+ if (current === declContainer) {
3078+ return "quit";
3079+ }
3080+ if (isFunctionLike(current)) {
3081+ return !getImmediatelyInvokedFunctionExpression(current);
3082+ }
3083+ if (isClassStaticBlockDeclaration(current)) {
3084+ return declaration.pos < usage.pos;
3085+ }
30863086
3087- const propertyDeclaration = tryCast(current.parent, isPropertyDeclaration);
3088- if (propertyDeclaration) {
3089- const initializerOfProperty = propertyDeclaration.initializer === current;
3090- if (initializerOfProperty) {
3091- if (isStatic(current.parent)) {
3092- if (declaration.kind === SyntaxKind.MethodDeclaration) {
3093- return true;
3094- }
3095- if (isPropertyDeclaration(declaration) && getContainingClass(usage) === getContainingClass(declaration)) {
3096- const propName = declaration.name;
3097- if (isIdentifier(propName) || isPrivateIdentifier(propName)) {
3098- const type = getTypeOfSymbol(getSymbolOfDeclaration(declaration));
3099- const staticBlocks = filter(declaration.parent.members, isClassStaticBlockDeclaration);
3100- if (isPropertyInitializedInStaticBlocks(propName, type, staticBlocks, declaration.parent.pos, current.pos)) {
3101- return true;
3102- }
3087+ const propertyDeclaration = tryCast(current.parent, isPropertyDeclaration);
3088+ if (propertyDeclaration) {
3089+ const initializerOfProperty = propertyDeclaration.initializer === current;
3090+ if (initializerOfProperty) {
3091+ if (isStatic(current.parent)) {
3092+ if (declaration.kind === SyntaxKind.MethodDeclaration) {
3093+ return true;
3094+ }
3095+ if (isPropertyDeclaration(declaration) && getContainingClass(usage) === getContainingClass(declaration)) {
3096+ const propName = declaration.name;
3097+ if (isIdentifier(propName) || isPrivateIdentifier(propName)) {
3098+ const type = getTypeOfSymbol(getSymbolOfDeclaration(declaration));
3099+ const staticBlocks = filter(declaration.parent.members, isClassStaticBlockDeclaration);
3100+ if (isPropertyInitializedInStaticBlocks(propName, type, staticBlocks, declaration.parent.pos, current.pos)) {
3101+ return true;
31033102 }
31043103 }
31053104 }
3106- else {
3107- const isDeclarationInstanceProperty = declaration.kind === SyntaxKind.PropertyDeclaration && !isStatic(declaration);
3108- if (! isDeclarationInstanceProperty || getContainingClass(usage) !== getContainingClass (declaration)) {
3109- return true;
3110- }
3105+ }
3106+ else {
3107+ const isDeclarationInstanceProperty = declaration.kind === SyntaxKind.PropertyDeclaration && !isStatic (declaration);
3108+ if (!isDeclarationInstanceProperty || getContainingClass(usage) !== getContainingClass(declaration)) {
3109+ return true;
31113110 }
31123111 }
31133112 }
3113+ }
31143114
3115- const decorator = tryCast(current.parent, isDecorator);
3116- if (decorator && decorator.expression === current) {
3117- if (isParameter(decorator.parent)) {
3118- return isUsedInFunctionOrInstancePropertyWorker(decorator.parent.parent.parent, declaration) ? true : "quit";
3119- }
3120- if (isMethodDeclaration(decorator.parent)) {
3121- return isUsedInFunctionOrInstancePropertyWorker(decorator.parent.parent, declaration) ? true : "quit";
3122- }
3115+ const decorator = tryCast(current.parent, isDecorator);
3116+ if (decorator && decorator.expression === current) {
3117+ if (isParameter(decorator.parent)) {
3118+ return isUsedInFunctionOrInstancePropertyWorker(decorator.parent.parent.parent, declaration) ? true : "quit";
31233119 }
3120+ if (isMethodDeclaration(decorator.parent)) {
3121+ return isUsedInFunctionOrInstancePropertyWorker(decorator.parent.parent, declaration) ? true : "quit";
3122+ }
3123+ }
31243124
3125- return false;
3126- });
3127- }
3125+ return false;
3126+ });
3127+ }
31283128
31293129 /** stopAtAnyPropertyDeclaration is used for detecting ES-standard class field use-before-def errors */
31303130 function isPropertyImmediatelyReferencedWithinDeclaration(declaration: PropertyDeclaration | ParameterPropertyDeclaration, usage: Node, stopAtAnyPropertyDeclaration: boolean) {
0 commit comments