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): throws unhelpfulaaa error message becauseanalyze expectsProgram#11747

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

Draft
nayounsang wants to merge4 commits intotypescript-eslint:main
base:main
Choose a base branch
Loading
fromnayounsang:scope-aaa
Draft
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
2 changes: 1 addition & 1 deletionpackages/scope-manager/src/analyze.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -81,7 +81,7 @@ const DEFAULT_OPTIONS: Required<AnalyzeOptions> = {
* Takes an AST and returns the analyzed scopes.
*/
export function analyze(
tree: TSESTree.Node,
tree: TSESTree.Program,
providedOptions?: AnalyzeOptions,
): ScopeManager {
const options: Required<AnalyzeOptions> = {
Expand Down
5 changes: 4 additions & 1 deletionpackages/scope-manager/src/referencer/Referencer.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,7 +93,10 @@ export class Referencer extends Visitor {
public currentScope(throwOnNull: true): Scope | null;
public currentScope(dontThrowOnNull?: true): Scope | null {
if (!dontThrowOnNull) {
assert(this.scopeManager.currentScope, 'aaa');
assert(
this.scopeManager.currentScope,
'Expected currentScope to exist. This usually happens when analyze() is called with an incomplete AST node instead of a complete Program node.',
);
}
return this.scopeManager.currentScope;
}
Expand Down
16 changes: 16 additions & 0 deletionspackages/scope-manager/tests/analyze.test.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
import { analyze } from '../src';
import { parse } from './test-utils';

describe('analyze()', () => {
it('should throw error when passed a partial AST node', () => {
const ast = parse(`const hello: string = 'world';`, {
range: true,
});
const partialNode = ast.body[0];

expect(() => {
// @ts-expect-error -- to reproduce https://github.com/typescript-eslint/typescript-eslint/issues/11727
analyze(partialNode);
}).toThrow();
});
});
Loading

[8]ページ先頭

©2009-2025 Movatter.jp