Skip to content

Bug: scope-manager throws unhelpful aaa error message #11727

@abrahamguo

Description

@abrahamguo

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

scope-manager

Playground Link

No response

Repro Code

// Code example adapted from typescript-eslint.io/packages/scope-manager

import { analyze } from '@typescript-eslint/scope-manager';
import { parse } from '@typescript-eslint/typescript-estree';

analyze(parse(`const hello: string = 'world';`).body[0]);

ESLint Config

No ESLint config.

tsconfig

{ "compilerOptions": { "module": "nodenext", "noEmit": true, "strict": true } }

Expected Result

It should either:

  • work at runtime, or
  • fail at compile time with a TS error, AND fail at runtime with a helpful error message.

Actual Result

  • At compile time, tsc reports no errors, indicating that this is a valid usage.
  • At runtime, @typescript-eslint/scope-manager throws aaa:
node_modules/@typescript-eslint/scope-manager/dist/assert.js:7
        throw new Error(message);
              ^

Error: aaa
    at assert (node_modules/@typescript-eslint/scope-manager/dist/assert.js:7:15)
    at Referencer.currentScope (node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.js:65:33)
    at Referencer.VariableDeclaration (node_modules/@typescript-eslint/scope-manager/dist/referencer/Referencer.js:516:20)
    at Referencer.visit (node_modules/@typescript-eslint/scope-manager/dist/referencer/VisitorBase.js:59:21)
    at analyze (node_modules/@typescript-eslint/scope-manager/dist/analyze.js:39:16)
    at index.ts:4:1

Additional Info

Looks like this error message has been present in the source code since the introduction of @typescript-eslint/scope-manager by @bradzacher in #1939.

Versions

package version
@typescript-eslint/scope-manager 8.46.2
@typescript-eslint/typescript-estree 8.46.2
TypeScript 5.9.3
node 25.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workingpackage: scope-managerIssues related to @typescript-eslint/scope-manager

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions