Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
3 tasks done
kirkwaiblinger opened this issue Oct 22, 2024 · 4 comments · May be fixed by #535
Open
3 tasks done

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

kirkwaiblinger opened this issue Oct 22, 2024 · 4 comments · May be fixed by #535
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: bug Something isn't working :( 🐛

Comments

@kirkwaiblinger
Copy link
Contributor

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

@kirkwaiblinger kirkwaiblinger added the type: bug Something isn't working :( 🐛 label Oct 22, 2024
@JoshuaKGoldberg
Copy link
Owner

Spooky. Maybe it used to exist, but no longer does?

@JoshuaKGoldberg JoshuaKGoldberg added the status: accepting prs Please, send a pull request to resolve this! 🙏 label Oct 22, 2024
@JoshuaKGoldberg
Copy link
Owner

@all-contributors please add @kirkwaiblinger for bug.

🤖 Beep boop! This comment was added automatically by all-contributors-auto-action.
Not all contributions can be detected from Git & GitHub alone. Please comment any missing contribution types this bot missed.
...and of course, thank you for contributing! 💙

Copy link
Contributor

@JoshuaKGoldberg

I've put up a pull request to add @kirkwaiblinger! 🎉

@kirkwaiblinger
Copy link
Contributor Author

Spooky. Maybe it used to exist, but no longer does?

Yeah, I was wondering that, too - didn't see it on any of the TS versions available on the playground, so, if so, maybe it hasn't been that way for a while? 🤷‍♂️

JoshuaKGoldberg pushed a commit that referenced this issue Oct 22, 2024
Adds @kirkwaiblinger as a contributor for bug.

This was requested by JoshuaKGoldberg [in this
comment](#528 (comment))

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! 🙏 type: bug Something isn't working :( 🐛
Projects
None yet
2 participants