Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(scope-manager): support static class blocks#4211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 1 commit intotypescript-eslint:mainfromjuank1809:class-static-scope
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletionspackages/scope-manager/src/ScopeManager.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ import {
WithScope,
} from './scope';
import { ClassFieldInitializerScope } from './scope/ClassFieldInitializerScope';
import { ClassStaticBlockScope } from './scope/ClassStaticBlockScope';

import { Variable } from './variable';

Expand DownExpand Up@@ -178,6 +179,15 @@ class ScopeManager {
);
}

public nestClassStaticBlockScope(
node: ClassStaticBlockScope['block'],
): ClassStaticBlockScope {
assert(this.currentScope);
return this.nestScope(
new ClassStaticBlockScope(this, this.currentScope, node),
);
}

public nestConditionalTypeScope(
node: ConditionalTypeScope['block'],
): ConditionalTypeScope {
Expand Down
21 changes: 21 additions & 0 deletionspackages/scope-manager/src/scope/ClassStaticBlockScope.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
import { TSESTree } from '@typescript-eslint/types';
import { Scope } from './Scope';
import { ScopeBase } from './ScopeBase';
import { ScopeType } from './ScopeType';
import { ScopeManager } from '../ScopeManager';

class ClassStaticBlockScope extends ScopeBase<
ScopeType.classStaticBlock,
TSESTree.Expression,
Scope
> {
constructor(
scopeManager: ScopeManager,
upperScope: ClassStaticBlockScope['upper'],
block: ClassStaticBlockScope['block'],
) {
super(scopeManager, ScopeType.classStaticBlock, upperScope, block, false);
}
}

export { ClassStaticBlockScope };
2 changes: 2 additions & 0 deletionspackages/scope-manager/src/scope/Scope.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
import { BlockScope } from './BlockScope';
import { CatchScope } from './CatchScope';
import { ClassFieldInitializerScope } from './ClassFieldInitializerScope';
import { ClassStaticBlockScope } from './ClassStaticBlockScope';
import { ClassScope } from './ClassScope';
import { ConditionalTypeScope } from './ConditionalTypeScope';
import { ForScope } from './ForScope';
Expand All@@ -21,6 +22,7 @@ type Scope =
| CatchScope
| ClassScope
| ClassFieldInitializerScope
| ClassStaticBlockScope
| ConditionalTypeScope
| ForScope
| FunctionExpressionNameScope
Expand Down
1 change: 1 addition & 0 deletionspackages/scope-manager/src/scope/ScopeBase.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,6 +126,7 @@ const generator = createIdGenerator();
type VariableScope = GlobalScope | FunctionScope | ModuleScope | TSModuleScope;
const VARIABLE_SCOPE_TYPES = new Set([
ScopeType.classFieldInitializer,
ScopeType.classStaticBlock,
ScopeType.function,
ScopeType.global,
ScopeType.module,
Expand Down
1 change: 1 addition & 0 deletionspackages/scope-manager/src/scope/ScopeType.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ enum ScopeType {
catch = 'catch',
class = 'class',
classFieldInitializer = 'class-field-initializer',
classStaticBlock = 'class-static-block',
conditionalType = 'conditionalType',
for = 'for',
function = 'function',
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp