Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions types/typeUtils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ type UnionToIntersection<T> = (T extends object ? (k: T) => void : never) extend
/** Extracts the type of the 'this' parameter of a function type, or 'unknown' if the function type has no 'this' parameter. */
type ThisParameterType<T> = T extends (this: infer U, ...args: Array<any>) => any ? U : unknown;

/** Renames the `this` parameter to `self`, this allows passing compiler's noIndexWithoutCall diagnostic */
type InlineThisParameter<T> = T extends (...args: infer A) => infer R ? (self: any, ...args: A) => R : T;

/** Removes the 'this' parameter from a function type. */
type OmitThisParameter<T> = unknown extends ThisParameterType<T>
? T
Expand Down