You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// TODO: fix private methods, probs dependent on https://github.com/microsoft/TypeScript/issues/22677
import{AnyFunction}from'tsdef'/** * converts a non-arrow function type to an arrow function type. arrow functions are checked more strictly than * non-arrow functions * @see https://github.com/microsoft/TypeScript/pull/18654 * @example * declare class Foo<T = unknown> { * notArrowFunction(value: T): void * isArrowFunction: (value: T) => void * } * type ArrowFunction = ToArrowFunction<Foo['notArrowFunction']> */exporttypeToArrowFunction<TextendsAnyFunction>={fn: (...args: Parameters<T>)=>ReturnType<T>}['fn']/** * converts an arrow function type to a non-arrow function type. arrow functions are checked more strictly than * non-arrow functions * @see https://github.com/microsoft/TypeScript/pull/18654 * @example * declare class Foo<T = unknown> { * notArrowFunction(value: T): void * isArrowFunction: (value: T) => void * } * type NotArrowFunction = ToNonArrowFunction<Foo['isArrowFunction']> */exporttypeToNonArrowFunction<TextendsAnyFunction>={fn(...args: Parameters<T>): ReturnType<T>}['fn']/** * transforms all methods in `T` into arrow functions, which makes typescript check it more strictly * @see https://github.com/microsoft/TypeScript/pull/18654 */exporttypeSafeVariance<T>={wrapped: T&{[KeyinkeyofT]: T[Key]extendsAnyFunction ? ToArrowFunction<T[Key]> : T[Key]}}['wrapped']/** * transforms all methods in `T` into non-arrow functions, which turns off variance checks * * **WARNING:** doesn't work properly with private/protected methods * @see https://github.com/microsoft/TypeScript/pull/18654 */// TODO: fix private methods, probs dependent on https://github.com/microsoft/TypeScript/issues/22677exporttypeUnsafeVariance<T>={wrapped: {[KeyinkeyofT]: T[Key]extendsAnyFunction ? ToNonArrowFunction<T[Key]> : T[Key]}}['wrapped']
The text was updated successfully, but these errors were encountered:
DetachHead
changed the title
fix private methods, probs dependent on https://github.com/microsoft/TypeScript/...
fix private methods with UnsafeVarianceJun 25, 2022
ts-helpers/src/utilityTypes/Function.ts
Line 50 in 32d918e
The text was updated successfully, but these errors were encountered: