mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
24 lines
862 B
Plaintext
24 lines
862 B
Plaintext
genericInferenceFromWrapperUnion.ts(15,7): error TS2322: Type 'string | undefined' is not assignable to type 'number | undefined'.
|
|
Type 'string' is not assignable to type 'number'.
|
|
|
|
|
|
==== genericInferenceFromWrapperUnion.ts (1 errors) ====
|
|
// https://github.com/microsoft/typescript-go/issues/4817
|
|
|
|
type MaybeRef<T> = T | { value: T };
|
|
|
|
declare function f<D = string>(options: {
|
|
select?: MaybeRef<(data: string) => D>;
|
|
}): D | undefined;
|
|
|
|
declare const arg: {
|
|
select?: MaybeRef<(data: string) => string>;
|
|
} & {
|
|
select: (data: string) => number;
|
|
};
|
|
|
|
const n: number | undefined = f(arg);
|
|
~
|
|
!!! error TS2322: Type 'string | undefined' is not assignable to type 'number | undefined'.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
|
|