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

TypeScript: Fix TSInferType .typeParameter type. #7967

Merged

Conversation

benjamn
Copy link
Contributor

@benjamn benjamn commented May 18, 2018

Q                       A
Fixed Issues? Various ast-types test failures, e.g. https://travis-ci.org/benjamn/ast-types/jobs/369634972
Patch: Bug Fix? yes
Major: Breaking Change? no
Minor: New Feature? no
Tests Added + Pass? Fixed existing tests that expected TypeParameter
Documentation PR no
Any Dependency Changes? no
License MIT

Follow-up to #7404

There is no TypeParameter type in the Babylon TypeScript AST hierarchy. Flow does have a TypeParameter type, but it should not be confused with the TypeScript TSTypeParameter, since Flow !== TypeScript, and the types have totally different fields. Instead, the .typeParameter.type of a Babylon-parsed TSInferType node should be TSTypeParameter.

It would probably be fine to leave the declared type of the TSInferType .typeParameter field as TSType instead of TSTypeParameter, but the more specific TSTypeParameter type should be safe/correct, since the TypeScript parseInferType function always uses SyntaxKind.TypeParameter.

I noticed this typo because it has been causing ast-types test failures lately, e.g. https://travis-ci.org/benjamn/ast-types/jobs/369634972

Follow-up to babel#7404

There is no TypeParameter type in the Babylon TypeScript AST hierarchy.
Flow does have a TypeParameter type, but it should not be confused with
the TypeScript TSTypeParameter, since Flow !== TypeScript, and the types
have totally different fields. Instead, the .typeParameter.type of a
Babylon-parsed TSInferType node should be TSTypeParameter.

It would probably be fine to leave the declared type of the TSInferType
.typeParameter field as TSType instead of TSTypeParameter, but the more
specific TSTypeParameter type should be safe/correct, since the TypeScript
parseInferType function always uses SyntaxKind.TypeParameter:
https://github.com/Microsoft/TypeScript/blob/66d6e5e6e007ce3ac70b7371c3e7ac46a99a0fcd/src/compiler/parser.ts#L3006

I noticed this typo because it has been causing ast-types test failures
lately, e.g. https://travis-ci.org/benjamn/ast-types/jobs/369634972
@benjamn
Copy link
Contributor Author

benjamn commented May 18, 2018

@andy-ms does this seem reasonable?

@babel-bot
Copy link
Collaborator

babel-bot commented May 18, 2018

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/8015/

benjamn added a commit to benjamn/ast-types that referenced this pull request May 18, 2018
That is, until babel/babel#7967 is released.

This should fix the tests that have been failing on PRs lately.
@existentialism existentialism merged commit 70eb206 into babel:master May 18, 2018
@existentialism existentialism added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label May 18, 2018
bnjmnt4n added a commit to bnjmnt4n/ast-types that referenced this pull request Feb 6, 2019
babel/babel#7967 has been released since @babel/parser@v7.0.0-beta.48.

Ref. 9777ef7
benjamn pushed a commit to benjamn/ast-types that referenced this pull request Feb 6, 2019
babel/babel#7967 has been released since @babel/parser@v7.0.0-beta.48.

Ref. 9777ef7
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants