mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
34 lines
1.3 KiB
Plaintext
34 lines
1.3 KiB
Plaintext
coAndContraVariantInferences5.ts(9,9): error TS2322: Type '(status: Thing | null) => void' is not assignable to type '(key: string) => void'.
|
|
Types of parameters 'status' and 'key' are incompatible.
|
|
Type 'string' is not assignable to type 'Thing | null'.
|
|
|
|
|
|
==== coAndContraVariantInferences5.ts (1 errors) ====
|
|
type Thing = 'a' | 'b';
|
|
|
|
function f(
|
|
options: SelectOptions<Thing>,
|
|
onChange: (status: Thing | null) => void,
|
|
): void {
|
|
select({
|
|
options,
|
|
onChange,
|
|
~~~~~~~~
|
|
!!! error TS2322: Type '(status: Thing | null) => void' is not assignable to type '(key: string) => void'.
|
|
!!! error TS2322: Types of parameters 'status' and 'key' are incompatible.
|
|
!!! error TS2322: Type 'string' is not assignable to type 'Thing | null'.
|
|
!!! related TS6500 coAndContraVariantInferences5.ts:17:5: The expected type comes from property 'onChange' which is declared here on type 'SelectProps<string>'
|
|
});
|
|
}
|
|
|
|
declare function select<KeyT extends string>(props: SelectProps<KeyT>): void;
|
|
|
|
type SelectProps<KeyT extends string> = {
|
|
options?: SelectOptions<KeyT>;
|
|
onChange: (key: KeyT) => void;
|
|
};
|
|
|
|
type SelectOptions<KeyT extends string> =
|
|
| Array<{key: KeyT}>
|
|
| Array<KeyT>;
|
|
|