Remove Index Signature
提出詳細
type IsIndexSignature<K,P=PropertyKey> = P extends K ? true : never type RemoveIndexSignature<T> = { [K in keyof T as true extends IsIndexSignature<K> ? never : K]: T[K] }
提出日時 | 2023-09-15 01:23:06 |
---|---|
問題 | Remove Index Signature |
ユーザー | sankantsu |
ステータス | Accepted |
import type { Equal, Expect } from '@type-challenges/utils' type Foo = { [key: string]: any foo(): void } type Bar = { [key: number]: any bar(): void } type FooBar = { [key: symbol]: any foobar(): void } type Baz = { bar(): void baz: string } type cases = [ Expect<Equal<RemoveIndexSignature<Foo>, { foo(): void }>>, Expect<Equal<RemoveIndexSignature<Bar>, { bar(): void }>>, Expect<Equal<RemoveIndexSignature<FooBar>, { foobar(): void }>>, Expect<Equal<RemoveIndexSignature<Baz>, { bar(): void; baz: string }>>, ]