Skip to content

Expose hasOnlyExpressionInitializer as a public type guard #33229

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

Merged
merged 2 commits into from
Feb 5, 2020

Conversation

ayazhafiz
Copy link
Contributor

@ayazhafiz ayazhafiz commented Sep 4, 2019

Exposes hasOnlyExpressionInitializer as a public function so users of
TypeScript compiler APIs do not have to roll their own
HasExpressionInitializer type guards.

Closes #33115.

@ayazhafiz
Copy link
Contributor Author

Does the TypeScript project have automated code formatter or formatting configuration other than the wiki coding guidelines?

@Jessidhia
Copy link

(this is not this PR's fault but) the isHasExpressionInitializer name is highly confusing. What is a "Has expression"? 🙃

Copy link
Member

@sheetalkamat sheetalkamat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think we want to add new api/utility function that we ourselves are not using ..,

Exposes `hasOnlyExpressionInitializer` as a public function so users of
TypeScript compiler APIs do not have to roll their own
`HasExpressionInitializer` type guards.
@ayazhafiz ayazhafiz force-pushed the feat/feat-isHasInitializer branch from 758c21b to 94bf5f8 Compare September 4, 2019 12:31
@ayazhafiz ayazhafiz changed the title Expose a public isHasExpressionInitializer type guard Expose hasOnlyExpressionInitializer as a public type guard Sep 4, 2019
@ayazhafiz
Copy link
Contributor Author

(this is not this PR's fault but) the isHasExpressionInitializer name is highly confusing. What is a "Has expression"? 🙃

I agree, the name is rather confusing especially if the HasExpressionInitializer type is not already known about. I've exposed hasOnlyExpressionInitializer instead, which should make more sense.

I don’t think we want to add new api/utility function that we ourselves are not using ..,

Fixed by exposing hasOnlyExpressionInitializer publicly and modifying it to be a true type-safe guard (checking node types rather than the existence of a initializer field). Please let me know if this is an unsuitable solution.

@sandersn sandersn added the Housekeeping Housekeeping PRs label Feb 1, 2020
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change itself seems correct and likely to be faster than checking for .initializer and then excluding things.

@sandersn sandersn merged commit 0944110 into microsoft:master Feb 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Housekeeping Housekeeping PRs
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Expose a isExpressionInitializer type guard function
4 participants