-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Arrow function don't see never
as a return type, while normal functions do
#55351
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
Is it a bug or an undocumented feature? |
It's working as intended and documented here: #32695 This issue has been raised many many times. It should be added to the FAQ. |
In particular, this rule:
|
Setting the type of const consoleErrorAndThrow_2: (errorMessage: string) => never = (errorMessage: string): never => { // <--- Arrow function
console.error(errorMessage);
throw new Error(errorMessage);
} |
For performance reasons only identifiers with type annotations are analyzed. |
Make sense, thx! |
π Search Terms
"typescript function that throws", "typescript function that always throws"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play?ts=4.6.4#code/GYVwdgxgLglg9mABBBBnOAbApgUQE55x4CCYAJgCoAWhA7gPoCMAFFgUQLJaqoCGA5lgBciVFDwww-AJQiwWAG5tEAb0QB6dYgA8AWn2IAckQC2vDIlCRYCALAAoRE+RpMWAHRtCeVuzxceASxpAG4HZ0QoGjhaRHlY-G9fbwC+QVCHAF8HBxQwMURaPF4ABxK2ADFwaHgwJkQAXkRmdBMsADVePDkQEwAjNmlGgD5VcMQYYGbWjq6dRABWIZVxiLwsKBA8JBnOvDDHREzELAxULDHDiLz0bESiUkpohhYAA3u8Qt5USzhwMgAhK8ModsvZMgdcmgoC58m4Po9qHR6AAmRrNLycbhpYSicSSGRyRTKBqjNQaLR6AzEdixKw1OyHG5uTx+ZJYwLpA5OKJ0OJYBJszH+bFBEFgqH5GFFUrlPBVay1VHolpwNp7Hr9QYjVQUoxwGHmCwoMgXEq8KI-dabbaIXiIBTmEAeZoAdgADABmd3SVYTKaq9VzbSLZZ+tYbLY7NWzfZ+46nc6XCLXVx3PyI56o5jvPxfH7AP7kIEgiJgiEOIA
π» Code
π Actual behavior
Get error
Not all code paths return a value. (7030)
π Expected behavior
No error
The text was updated successfully, but these errors were encountered: