我有一个类型:
export type MyType = 'something' | 'another' | 'else';
Run Code Online (Sandbox Code Playgroud)
然后我想使用它的一些选项:
Interface MyInterface {
selection: Pick<MyType, 'something' | 'another'>
}
Run Code Online (Sandbox Code Playgroud)
但出现错误type doesn't satisfy the constraint
难道不能在类型上使用 Pick 而只能在接口上使用吗?
type MyType = 'something' | 'another' | 'else';
interface MyInterface {
selection: Extract<MyType, 'something' | 'another'>;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
532 次 |
| 最近记录: |