我想预设一个键,但是我不想限制用户仅使用这些键。
type B = {
a: string;
b: number;
}
type T = keyof B | string;
function someFunc(key: T) {}
someFunc(); // key type is `T`
In the above case, I want to get autocomplete for a
and b
, but users can also use any string they want. Is it possible?
With working auto completion. Check out here