-
Notifications
You must be signed in to change notification settings - Fork 12.8k
doesn't work return params for function #46603
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
Comments
This is not a crash. Number 2 is working as intended. The implementation is not checked against the overloaded signatures. It's a duplicate of #13235. |
Thanks. What about the first option? |
That’s a duplicate of #33912 I think |
I also have a similar error const data = ["a", "b", "c", 1, 2, 3];
// Type '(string | number)[]' is not assignable to type 'number[]'
const result: number[] = data.filter((i) => typeof i === 'number');
console.log(result); // [1, 2, 3] |
@4lessandrodev That's completed unrelated, and is working as intended. Your inner function is not a type guard, it's just a function returning a |
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
🔎 Search Terms
doesn't work return params for function
function return parmas doesn't work
return function params with generic type don't work
🕗 Version & Regression Information
⏯ Playground Link
Playground link with relevant code #1
Playground link with relevant code #2
💻 Code
#1
#2
🙁 Actual behavior
#1 has error Type '{ x: 10; }' is not assignable to type 'GetType'.(2322);
#2 has not error with wrong return type
🙂 Expected behavior
#1 there should be no mistake. Should be has correct type by generic
#2 has error with wrong return type
The text was updated successfully, but these errors were encountered: