Skip to content

🐛 Bug: .value does not exist in BooleanLiteralType #528

@kirkwaiblinger

Description

@kirkwaiblinger

Bug Report Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have pulled the latest main branch of the repository.
  • I have searched for related issues and found none that matched my issue.

Expected

In this snippet

if (tsapiutils.isBooleanLiteralType(type)) {
    assert(typeof type.value === 'boolean'); 
}

I expect the assertion to pass.

Actual

It fails; there is no .value field in the TS type, so the type is undefined.

Additional Info

The type is defined like so:

/**
* A boolean literal.
* i.e. Either a "true" or "false" literal.
* @category Type Types
*/
export interface BooleanLiteralType extends UnknownLiteralType {
intrinsicName: "false" | "true";
value: boolean;
}

typescript-eslint playground link where you can see .value isn't there.

Workaround in use case in typescript-eslint:
https://github.com/typescript-eslint/typescript-eslint/blob/07a6e23f489be8908ff690885343378398012130/packages/eslint-plugin/src/rules/no-unnecessary-condition.ts#L66-L88

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: accepting prsPlease, send a pull request to resolve this! 🙏type: bugSomething isn't working 🐛

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions