Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Only infer 'never' in function expressions and arrow functions#8767

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ahejlsberg merged 4 commits intomasterfromneverTypeInference
May 23, 2016

Conversation

@ahejlsberg
Copy link
Member

This PR modifies the type inference rules such that we only infer a function result ofnever in function expressions and arrow functions. For regular functions and methods, in cases where we would have inferrednever we now instead infervoid. This matches the behavior we had before the introduction ofnever and ensures better backwards compatibility. For example:

classBase{overrideMe(){thrownewError("You forgot to override me!");}}classDerived{overrideMe(){// Code that actually returns here}}

The above pattern is reasonably common and was broken because anever returning method cannot be overridden by avoid returning method.

This PR only affects return typeinference. It has no impact on functions and methods that explicitly specify a return type.

@mhegazy
Copy link
Contributor

👍

basarat reacted with thumbs up emoji

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@ahejlsberg@mhegazy@msftclas

[8]ページ先頭

©2009-2025 Movatter.jp