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

Question: Should this be parse error? #9000

Closed
fisker opened this issue Jan 31, 2023 · 3 comments
Closed

Question: Should this be parse error? #9000

fisker opened this issue Jan 31, 2023 · 3 comments

Comments

@fisker
Copy link

fisker commented Jan 31, 2023

I was working on Prettier to make tests run both flow and babel-flow parser prettier/prettier#14245, and found an edge case.

var fn2 : function<string> = function() { return 'foo'; } // error, arity 0

flow can parse function as identifier, but babel can't, and I found other keywords like class/while can't be used there.

Should it be valid or invalid?

@gkz
Copy link
Member

gkz commented Jan 31, 2023

I found it surprising and weird that function (lowercase) can be used as a type. Support for this was added when support for the Function type was added, back in 2015, but I am not aware of anyone actually using this (or even being aware of this). I would be happy to remove support for this and make this an error.

For now feel free to delete this test case from Prettier.

@fisker
Copy link
Author

fisker commented Feb 1, 2023

Thanks for the explanation, feel free to close if it not worth to fix.

@gkz
Copy link
Member

gkz commented Feb 1, 2023

I have a diff in progress to make it an error, just needs to be reviewed (internally)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants