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

Exception when parsing JSDocFunctionType #1301

Closed
bradzacher opened this issue Dec 4, 2019 · 3 comments · Fixed by #1525
Closed

Exception when parsing JSDocFunctionType #1301

bradzacher opened this issue Dec 4, 2019 · 3 comments · Fixed by #1525
Assignees
Labels
bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree

Comments

@bradzacher
Copy link
Member

What code were you trying to parse?

var a: function(b): c;

What actually happened?

Cannot set property 'typeAnnotation' of null

I haven't debugged this at all, but I assume it's because the variable's type declaration is of kind JSDocFunctionType, which we do not have any handling for.

https://astexplorer.net/#/gist/a1a5bcad94191c0d730eb920ced2e24b/f10df5321aaf8ceef561d14ce57a0ab59eee0ac5

@bradzacher bradzacher added bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree labels Dec 4, 2019
@armano2
Copy link
Member

armano2 commented Dec 16, 2019

This syntax is invalid if used in code, typescript reports error code 8020,

error happens when we are trying to convert b -> Parameter

typescript does not return correct ast node (there is no name) and parameter is created as null

} else {
parameter = result = this.convertChild(node.name, parent);
}
if (node.type) {
parameter.typeAnnotation = this.convertTypeAnnotation(
node.type,
node,
);

we should enable error code 8020

@armano2 armano2 assigned armano2 and unassigned armano2 Dec 22, 2019
@armano2
Copy link
Member

armano2 commented Jan 17, 2020

what do you think about throwing parse error when we encounter nodes from range FirstJSDocNode and LastJSDocNode? as this is going to to produce incorrect ast anyway (in unexpected ways).

@bradzacher
Copy link
Member Author

I don't see why not - it's a TS error anyways.

@armano2 armano2 self-assigned this Jan 25, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants