Microsoft/TypeScript
Ver no GitHub5.6 regression: Incorrect param type inference for type with all optional props
Open
#59.656 aberto em 16 de ago. de 2024
BugDomain: check: Type InferenceHelp Wanted
Métricas do repositório
- Stars
- (48.455 stars)
- Métricas de merge de PR
- (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)
Description
🔎 Search Terms
inference, param
🕗 Version & Regression Information
- This changed between versions 5.5.4 and 5.6.0
⏯ Playground Link
💻 Code
interface SomeType {
// On 5.6.0, experiment by making this prop required.
uniqueProp?: string;
}
declare const obs: Observable<SomeType>;
function argGetsWrongType(): Observable<{}> {
return obs.pipe(tap(arg => {
arg;
//^?
// Expected: SomeType in 5.5.4
// Actual: {} in v5.6.0-beta to 5.6.0-dev.20240816 (at least)
}));
}
function argGetsCorrectType() {
return obs.pipe(tap(arg => {
arg;
//^?
// Always correct
}));
}
interface Observable<T> {
pipe<A>(op: OperatorFunction<T, A>): Observable<A>;
}
interface UnaryFunction<T, R> { (source: T): R; }
interface OperatorFunction<T, R> extends UnaryFunction<Observable<T>, Observable<R>> { }
interface MonoTypeOperatorFunction<T> extends OperatorFunction<T, T> { }
declare function tap<T>(next: (value: T) => void): MonoTypeOperatorFunction<T>;
🙁 Actual behavior
arg is inferred as {}
🙂 Expected behavior
arg is inferred as SomeType as was consistent in v5.5.4
Additional information about the issue
(Google note: See http://cl/664889390 for local workaround)