-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Description
TypeScript Version: nightly (2.1.0-dev.20160915)
Code
declare class Maybe<T> {
static nothing<T>(): Maybe<T>;
// valueOrThrow(error?: Error): T;
}
function muchAdoAbout(m: Maybe<string>): void {}
muchAdoAbout(Maybe.nothing())Expected behavior:
When the commented out line is uncommented, the code should still type-check (the nothing on the last line should get its type found to be string by use-site inference like it does already).
Actual behavior:
When you uncomment the valueOrThrow line, the type inferred at the call site becomes {} and the code does not type-check anymore.
I'm not sure why adding that line has this effect. Note that it works if you do instead:
// valueOrThrow<T>(error?: Error): T;But I'd like to understand if the behavior shown here is a bug or intended...
Not sure if related to:
#5254
Metadata
Metadata
Assignees
Labels
No labels