-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 3.5.2
Search Terms: rxjs startWith generics union consolidate same
Code
declare const create: <T>(
t: T,
) => {
startWith: <D>(v1: D) => T | D;
};
// Succeeds
// $ExpectType { foo: number } | { bar: number }
const r1 = create({ foo: 1 }).startWith({ bar: 1 });
// Fails
// $ExpectType { foo: number }
// Actual: { foo: number } | { foo: number }
const r2 = create({ foo: 1 }).startWith({ foo: 1 });Although the expected/actual types are compatible, it's slightly irritating to deal with a union type T | T instead of a consolidated type T, as it makes type inspection in VS Code much more difficult (especially when the types are large or deeply nested).
Real world use case: ReactiveX/rxjs#4866
dragomirtitian
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript