type RemoveIndexSignature<T> = {
[K in keyof T as {} extends Record<K, true> ? never : K]: T[K]
}
Solution by MohammadArasteh #35272
// your answers
type RemoveIndexSignature<T> = {
[key in keyof T as string extends key
? never
: number extends key
? never
: symbol extends key ? never : key]: T[key];
Solution by AndreGeng #34753
type RemoveIndexSignature<T, P = PropertyKey> = {
[K in keyof T as P extends K ? never : (K extends P ? K : never)]: T[K]
}
Solution by devshinthant #34627
/**
*
* δΈ»θ¦ζ―ζοΌ
* - [key: string]:any
* - [key: number]:any
* - [key: symbol]:any
* ηιζ
* η¨ keyof ιεθΏε δΈͺε±ζ§ζΆοΌη»ζεε«ζ―οΌ
* string
* number
* symbol
*/
type RemoveIndexSignature<T> = {
[k in keyof T
as string extends k ? never :
number extends k ? never :
symbol extends k ? never : k]
: T[k]
}
Solution by Jayce-liang #34625
type RemoveIndexSignature<T> = {
[K in keyof T as string extends K ? never : number extends K ? never : symbol extends K ? never : K]: T[K]
}
Solution by ouzexi #34042
// your answers
type IsIndexSignature<T, K = PropertyKey> = T extends T ? K extends T ? 1 : 2 : never
type RemoveIndexSignature<T> = {
[P in keyof T as IsIndexSignature<P> extends 2 ? P : never]: T[P]
}
Solution by heyuelan #33684
type RemoveIndexSignature<T, L = string | number | symbol> = {
[K in keyof T as (L extends K ? 0 : 1) extends 1 ? K : never]: T[K]
}
Solution by all-user #33116
// your answers
type RemoveIndexSignature<T> = {
[key in keyof T as Extract<PropertyKey,key> extends never ? key: never] : T[key]
}
Solution by sciencefunq #32910
// your answers
type RemoveIndexSignature<T, P = PropertyKey> = {
[key in keyof T as P extends key ? never : key extends P ? key : never]: T[key]
}
Solution by pea-sys #32703
type RemoveIndexSignature<T, P = PropertyKey> = {
[K in keyof T as K extends P ? (P extends K ? never : K) : never]: T[K];
};
Solution by jinyoung234 #32475
type RemoveIndexSignature<T, P=PropertyKey> = {
[K in keyof T as P extends K ? never : K extends P ? K : never]: T[K]
}
λ°°μ΄κ²
Solution by dev-hobin #32442
type RemoveIndexSignature<T, P = string | number | symbol> = {
[K in keyof T as (
K extends P
? P extends K
? never
: K
: never
)]: T[K]
}
Solution by SazonovV #31334
// your answers
type RemoveIndexSignature<T> = {
[K in keyof T as string extends K
? never
: number extends K
? never
: symbol extends K
? never
: K
]: T[K]
};
Solution by d1zzzzy #31266
// your answers
type RemoveIndexSignature<T> = {[K in keyof T as number extends K?never: string extends K?never:symbol extends K?never:K]:T[K]}
Solution by kangaroona #31018
type IsEqual<T, U> = (<P>() => P extends T ? 1 : 2) extends (<P>() => P extends U ? 1 : 2) ? true : false
type IndexSignatureType<T> = IsEqual<T, string> | IsEqual<T, number> | IsEqual<T, symbol>
type IsIndexSignature<T> = T extends true ? true : never
type RemoveIndexSignature<T> = {
[P in keyof T as [IsIndexSignature<IndexSignatureType<P>>] extends [never] ? P : never]: T[P]
}
Solution by Yirujet #29821
type RemoveIndexSignature<T> = { [Key in keyof T as string extends Key ? never : number extends Key ? never : symbol extends Key ? never : Key]: T[Key] }
Solution by hajeonghun #28868
type RemoveIndexSignature<T,Key=PropertyKey> = { [K in keyof T as Key extends K?never:K extends Key?K:never]:T[K] };
Solution by DoubleWoodLin #28657
type RemoveIndexSignature<T> = {
[
K in keyof T as number extends K ? never :
string extends K ? never :
symbol extends K ? never :
K
]: T[K]
}
Solution by jjswifty #27580
type RemoveIndexSignature<T> = { [k in keyof T as string extends k ? never : number extends k? never : symbol extends k ? never : k]: T[k] }
Solution by smileboyi #26869
type RemoveIndexSignature<T, P = PropertyKey> = {
[key in keyof T as P extends key ? never : key extends P ? key : never]: T[key]
}
Solution by AwesomeYelim #26861
type RemoveIndexSignature<T> = {
[P in keyof T as string extends P ? never : number extends P ? never : symbol extends P ? never : P]: T[P]
}```
Solution by 8471919 #26800
type RemoveIndexSignature<T extends {}> = {
[K in keyof T as K extends `${infer R}` ? R : never]: T[K];
};
Solution by ryuji-1to #26742
type RemoveIndexSignature<T, P=PropertyKey> = {
[K in keyof T as P extends K? never : K extends P ? K : never]: T[K]
}
Solution by kakasoo #26361
// your answers
type RemoveIndexSignature<T> = {
[K in keyof T as (PropertyKey extends keyof T[K] ? never : K)]: T[K];
};
Solution by CheolMinBae #25515
type RemoveIndexSignature<T> = { [P in keyof T as string extends P ? never : number extends P ? never : symbol extends P ? never : P]: T[P] }
Solution by jsujeong #25514
// your answers
type RemoveIndexSignature<T> = {
[key in keyof T as number extends key ? never : string extends key ? never : symbol extends key ? never : key]: T[key]
};
Solution by rayjayjin #25465
// your answers
type RemoveIndexSignature<T> = {
[Key in keyof T as ( string extends Key ? never : number extends Key ? never : symbol extends Key ? never : Key)]: T[Key]
}
Solution by hhk9292 #25345
type CheckIndexSignature<V, T = PropertyKey> = T extends V ? true : false
type RemoveIndexSignature<T extends Record<PropertyKey, unknown>>
= {
[
Key in keyof T
// as string extends Key ? never
// : number extends Key ? never
// : symbol extends Key ? never
// : Key
as CheckIndexSignature<Key> extends false ? Key : never
]: T[Key]
}
Solution by tokyo9pm #25248
'a' extends string μ΄λ©΄ string extends 'a'λ μλλΌλ μ μ μ΄μ©. keyλ string, number, symbol μ΄μ΄μΌ νλ€.
type RemoveIndexSignature<T> = {
[K in keyof T as string extends K ? never: number extends K ? never: symbol extends K ? never: K]: T[K]
}
Solution by isntkyu #25150
type RemoveIndexSignature<T, P = PropertyKey> = {
[
K in keyof T as P extends K
? never
: K extends P ? K : never
]: T[K]
}
// type PropertyKey = string | number | symbol
P extends K ?
to filter out index signatures [key: string]
[key: symbol]
Solution by se030 #24551