Skip to content

Bug: Types seem to have gotten broken from 9.19.0 to 9.20.0 #19414

@Jason3S

Description

@Jason3S

Environment

ESLint version: 9.20.0

What parser are you using?

Default (Espree)

What did you do?

Updated from 9.19.0 to 9.20.0.

Seems to be related to: #19157

Property 'getLocFromIndex' does not exist on type 'SourceCode<{ LangOptions: LanguageOptions; RootNode: unknown; SyntaxElementWithLoc: unknown; ConfigNode: unknown; }>'.
  Property 'getLocFromIndex' does not exist on type 'TextSourceCode<{ LangOptions: LanguageOptions; RootNode: unknown; SyntaxElementWithLoc: unknown; ConfigNode: unknown; }>'.
import type { Rule } from 'eslint';

export function getPositionFromIndex(
  context: Rule.RuleContext,
  offset: number
) {
  const code = context.sourceCode;
  const pos = code.getLocFromIndex(offset);
  return pos;
}

It used to compile using TypeScript. I don't think getLocFromIndex has been removed, so it seem to be limited to the types getting broken.

What did you expect to happen?

To compile like 9.19.0.

What actually happened?

See above.

Image

Link to Minimal Reproducible Example

https://stackblitz.com/edit/stackblitz-starters-m8ciayku

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionbugESLint is working incorrectlypatch candidateThis issue may necessitate a patch release in the next few daysregressionSomething brokerepro:yesIssues with a reproducible exampletypesRelated to TypeScript types

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions