Skip to content

[Bug]: parser(ts), ast, TSTypePredicate and TSEnumDeclaration returns additional index property in loc.start #14590

@armano2

Description

@armano2

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

export declare const enum Foo {
    foo = 1,
    bar
}
export declare enum Foo {
    foo = 1,
    bar
}
class AssertsFoo {
  isBar(): asserts this is string {
    return;
  }
  isBaz = (): asserts this is string => {
    return;
  }
}

Configuration file name

No response

Configuration

  require('@babel/parser').parse(text, {
    sourceType: 'unambiguous',
    allowImportExportEverywhere: true,
    allowReturnOutsideFunction: true,
    ranges: true,
    plugins: [
      [ 'estree', { classFeatures: true }, ],
      'decorators-legacy',
      'classStaticBlock',
      'importAssertions',
      'typescript',
    ],
  });

Current and expected behavior

"index" property is added to loc.start of TSTypePredicate and TSEnumDeclaration

this property is present only on those 2 nodes and it's with us since version 7.17.x

{
  "end": { "column": 1, "line": 4 },
- "start": { "column": 7, "index": 7, "line": 1 }
+ "start": { "column": 7, "line": 1 }
}

Environment

  • Babel: 7.18.2

Possible solution

No response

Additional context

https://github.com/typescript-eslint/typescript-eslint/blob/1fb31a4b3e05734f801ade0450fea33494e4d5e6/packages/typescript-estree/tests/ast-alignment/utils.ts#L284-L297

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions