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

Expose getStringLiteralType and getNumberLiteralType on the TypeChecker, plus remove /** @internal */ from several useful methods. #52473

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sstchur
Copy link

@sstchur sstchur commented Jan 28, 2023

Expose the following on the TypeChecker:

  • getStringType
  • getStringLiteralType
  • getNumberType
  • getNumberLiteralType
  • getBooleanType
  • getFalseType
  • getTrueType
  • getUndefinedType
  • getNullType
  • isTypeAssignableTo

Fixes #50694

I opened a suggestion issue #50694 to suggest exposing getStringLiteralType and getNumberLiteralType. The rationale was that they would help avoid questionable and hacky code in an ES-Lint rule I was working on and that they would be useful to other developers using the TypeChecker. All of the other methods were technically available on the TypeChecker, but not "visibile" due to having been marked /** @internal */. This PR exposes the two recommended in #50694 and removes the Internal designation on several others that are useful for developers leveraging the TypeChecker.

@andrewbranch suggested that I create the PR myself, so I did :-)

I read the Contributing.md, and I'm aware of the following:

Features (things that add new or improved functionality to TypeScript) may be accepted, but will need to first be approved (labelled "help wanted" or in the "Backlog" milestone) by a TypeScript project maintainer in the suggestion issue. Features with language design impact, or that are adequately satisfied with external tools, will not be accepted."

And I'm also aware that I don't have such a label from a TS project maintainer, but at Andrew's suggestion, I have created the PR anyway. Please let me know if there is anything else I can do to make the PR better or the review process easier.

…iteralType, getBooleanType, getFalseType, getTrueType, getUndefinedType, getNullType, and isTypeAssignableTo on the TypeChecker
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jan 28, 2023
@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #50694. If you can get it accepted, this PR will have a better chance of being reviewed.

@jakebailey
Copy link
Member

See also #9879 (since this PR seems to contain a partial export of what that proposal suggests should be exported). @weswigham

@sstchur
Copy link
Author

sstchur commented Jan 28, 2023

See also #9879 (since this PR seems to contain a partial export of what that proposal suggests should be exported). @weswigham

If there is broad agreement on the TS team that everything in that proposal should be exposed, I could take a crack at handling all of it. LMK.

@jakebailey
Copy link
Member

If there is broad agreement on the TS team that everything in that proposal should be exposed, I could take a crack at handling all of it. LMK.

I'm not aware of any quite yet, but it did come up today in the context of #52467 and #52470.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Request to expose zeroType emptyStringType and isTypeAssignableTo on the TS TypeChecker
3 participants