Skip to content

The type of bitwise operations on 'any' operands should be 'number | bigint'Β #42125

Open
@fasttime

Description

@fasttime

Bug Report

πŸ”Ž Search Terms

  • bigint
  • bitwise

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about bigint.

⏯ Playground Link

Workbench Repro

πŸ’» Code

//@target: ES2020
const v1 = 1n as any;
const v2 = 2n as never;
const v3 = v1 | v2; // v3 should be typed (number | bigint), but is number

πŸ™ Actual behavior

The result of the bitwise operations &, |, ^ and ~ is assumed to be a number when all the operands have unspecified type, like any or never.

πŸ™‚ Expected behavior

The result of bitwise operations with unspecified type operands should be number | bigint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureHas ReproThis issue has compiler-backed repros: https://aka.ms/ts-reprosSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions