Skip to content

Allow omitting return type in callback arrow functions #874

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 5 commits into from
Sep 29, 2019
Merged

Allow omitting return type in callback arrow functions #874

merged 5 commits into from
Sep 29, 2019

Conversation

emillaine
Copy link
Contributor

Fixes #819.

Also makes the linter detect arrow function return types that are now unnecessary, and fixes those cases.

Also I think npm clean should be npm run clean in the readme, so fixed that as well.

@MaxGraey
Copy link
Member

Hi, thanks for PR. You should add yourself to NOTICE file

@emillaine
Copy link
Contributor Author

@MaxGraey Added myself to NOTICE.

Also add nameof and lengthof as special cases for the linter to require return type annotations.
@dcodeIO
Copy link
Member

dcodeIO commented Sep 29, 2019

LGTM to get things working today, potentially improving the requiresReturnType check in the future. What the compiler does there internally is, if the contextual type has a function signature, it allows omitting types and compiles the function expression according to the given signature instead. Means: A return type is necessary if that's not the case, like if the d.ts uses any, Function or a placeholder like T with type parameters omitted on the call.

@dcodeIO dcodeIO merged commit 228afea into AssemblyScript:master Sep 29, 2019
@emillaine emillaine deleted the allow-skipping-return-type-for-callbacks branch September 29, 2019 18:37
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

Successfully merging this pull request may close these issues.

[Tests] Need improve custom rule for allowing skip return type declaration for callbacks
3 participants