Skip to content

BigInt Literal not parsed in Typescript interface declaration #11555

Closed
@vedantroy

Description

Bug Report

  • [] I would like to work on a fix!
  • Not right now, but in a week or two if that's ok!

Current Behavior
BigInt literal is not being parsed in Typescript interface declaration:
https://babeljs.io/en/repl#?browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=AQSwdgLgpgTgZgQwMZWAcSmWInAN4BQwxUAXMAIwAMYA3EQL4EED0LANlBMNAM4TkMWGDmABefGUo0mnbqgnUwQA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=typescript&prettier=false&targets=&version=7.9.6&externalPlugins=%40babel%2Fplugin-syntax-bigint%407.8.3

Input Code

 interface Generic {
   e: 10n;
 }

let test: Generic = {e: 10n}

Expected behavior/code
Should be parsed.

Whatever config the repl I linked is using. It is using the typescript preset and @babel/plugin-syntax-bigint

Environment
Whatever environment the repl is using.

Additional context/Screenshots
Working in Typescript playground: https://www.typescriptlang.org/play/?ssl=1&ssc=1&pln=7&pc=3#code/AQSwdgLgpgTgZgQwMZWAcSmWInAN4BQwxUAXMAIwAMYA3EQL4EEA2UEw0AzhORljBzAAvPjKUaDIA

This is true even if the BigInt syntax plugin is installed. I suspect the Typescript plugin needs to be made aware of the BigInt plugin or something.

I also noticed that in the Babel typescript definitions (the official ones, not the ones in DefinitelyTyped), the following definition exists:

export interface TSLiteralType extends BaseNode {
  type: "TSLiteralType";
  literal: NumericLiteral | StringLiteral | BooleanLiteral;
} 

This definition seems to be missing "BigIntLiteral" as a possible type for the literal.

Metadata

Assignees

No one assigned

    Labels

    Has PRarea: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions