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

API: expose IntrinsicType #22269

Open
ajafff opened this issue Mar 1, 2018 · 1 comment
Open

API: expose IntrinsicType #22269

ajafff opened this issue Mar 1, 2018 · 1 comment
Labels
API Relates to the public API for TypeScript In Discussion Not yet reached consensus Suggestion An idea for TypeScript

Comments

@ajafff
Copy link
Contributor

ajafff commented Mar 1, 2018

TypeScript Version: 2.7.2, 2.8.0-dev.20180228

Search Terms: IntrinsicType

There's currently no (official) way to distinguish the literal types true and false.

Although ts.TypeFlags.BooleanLiteral is included in ts.TypeFlags.Literal it's no ts.LiteralType. Therefore I cannot access the value of the literal. I need access to the internal ts.IntrinsicType for that.

TSLint just declared the type in their project, which might break at any time...

My current workaround is checker.typeToString(type) === 'false'.

If you expose ts.IntrinsicType, does it make sense to expose ts.TypeFlags.Intrisic too?

@mhegazy mhegazy added Suggestion An idea for TypeScript API Relates to the public API for TypeScript labels Mar 9, 2018
@honewatson
Copy link

honewatson commented Jun 14, 2018

+1 for exposing IntrinsicType.

Currently the declaration file returns Type for getTypeAtLocation however this will return a variety of child interfaces of Type. At run time you end up having properties which are not part of the Type interface. It would be easier to work with getTypeAtLocation if it returned a Union Type of the Type interface derivatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Relates to the public API for TypeScript In Discussion Not yet reached consensus Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants