diff --git a/src/__snapshots__/mapped-types.spec.ts.snap b/src/__snapshots__/mapped-types.spec.ts.snap index 56598e5..b8e2e49 100644 --- a/src/__snapshots__/mapped-types.spec.ts.snap +++ b/src/__snapshots__/mapped-types.spec.ts.snap @@ -139,21 +139,25 @@ exports[`Omit testType>() (type) should match snapshot 1`] = exports[`Omit testType>() (type) should match snapshot 1`] = `"Pick>"`; -exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`OmitByValue testType>() (type) should match snapshot 1`] = `"\\"reqUndef\\" | \\"opt\\" | \\"optUndef\\""`; -exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; + +exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; + +exports[`OmitByValueExact testType>() (type) should match snapshot 1`] = `"\\"reqUndef\\" | \\"opt\\" | \\"optUndef\\""`; exports[`Optional testType>({ name: 'Yolo' }) (type) should match snapshot 1`] = `"Optional"`; @@ -169,21 +173,25 @@ exports[`Overwrite const result: Overwrite, T> = rest (type) shou exports[`Overwrite testType>() (type) should match snapshot 1`] = `"Pick & Pick, \\"name\\" | \\"age\\" | \\"visible\\">"`; -exports[`PickByValue testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`PickByValue testType>() (type) should match snapshot 1`] = `"Pick"`; + +exports[`PickByValue testType>() (type) should match snapshot 1`] = `"Pick"`; + +exports[`PickByValue testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`PickByValue testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`PickByValue testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`PickByValue testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`PickByValue testType>() (type) should match snapshot 1`] = `"\\"req\\""`; -exports[`PickByValue testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; -exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"Pick"`; +exports[`PickByValueExact testType>() (type) should match snapshot 1`] = `"\\"req\\""`; exports[`PromiseType testType>>() (type) should match snapshot 1`] = `"string"`; diff --git a/src/mapped-types.spec.snap.ts b/src/mapped-types.spec.snap.ts index ab1f567..a4397ac 100644 --- a/src/mapped-types.spec.snap.ts +++ b/src/mapped-types.spec.snap.ts @@ -142,30 +142,34 @@ type RequiredOptionalProps = { // @dts-jest:group PickByValue { - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); + // @dts-jest:pass:snap -> "req" + testType>(); const fn = (props: T) => { - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); }; } // @dts-jest:group PickByValueExact { - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); + // @dts-jest:pass:snap -> "req" + testType>(); const fn = (props: T) => { - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); }; } @@ -189,30 +193,34 @@ type RequiredOptionalProps = { // @dts-jest:group OmitByValue { - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); + // @dts-jest:pass:snap -> "reqUndef" | "opt" | "optUndef" + testType>(); const fn = (props: T) => { - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); }; } // @dts-jest:group OmitByValueExact { - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); + // @dts-jest:pass:snap -> "reqUndef" | "opt" | "optUndef" + testType>(); const fn = (props: T) => { - // @dts-jest:pass:snap -> Pick + // @dts-jest:pass:snap -> Pick testType>(); }; } diff --git a/src/mapped-types.spec.ts b/src/mapped-types.spec.ts index f828cde..a6de52c 100644 --- a/src/mapped-types.spec.ts +++ b/src/mapped-types.spec.ts @@ -148,6 +148,8 @@ type RequiredOptionalProps = { testType>(); // @dts-jest:pass:snap testType>(); + // @dts-jest:pass:snap + testType>(); const fn = (props: T) => { // @dts-jest:pass:snap @@ -163,6 +165,8 @@ type RequiredOptionalProps = { testType>(); // @dts-jest:pass:snap testType>(); + // @dts-jest:pass:snap + testType>(); const fn = (props: T) => { // @dts-jest:pass:snap @@ -195,6 +199,8 @@ type RequiredOptionalProps = { testType>(); // @dts-jest:pass:snap testType>(); + // @dts-jest:pass:snap + testType>(); const fn = (props: T) => { // @dts-jest:pass:snap @@ -210,6 +216,8 @@ type RequiredOptionalProps = { testType>(); // @dts-jest:pass:snap testType>(); + // @dts-jest:pass:snap + testType>(); const fn = (props: T) => { // @dts-jest:pass:snap diff --git a/src/mapped-types.ts b/src/mapped-types.ts index 2acbe0d..54395d9 100644 --- a/src/mapped-types.ts +++ b/src/mapped-types.ts @@ -190,7 +190,7 @@ namespace Pick {} */ export type PickByValue = Pick< T, - { [Key in keyof T]: T[Key] extends ValueType ? Key : never }[keyof T] + { [Key in keyof T]-?: T[Key] extends ValueType ? Key : never }[keyof T] >; /** @@ -207,7 +207,7 @@ export type PickByValue = Pick< export type PickByValueExact = Pick< T, { - [Key in keyof T]: [ValueType] extends [T[Key]] + [Key in keyof T]-?: [ValueType] extends [T[Key]] ? [T[Key]] extends [ValueType] ? Key : never @@ -240,7 +240,7 @@ export type Omit = Pick>; */ export type OmitByValue = Pick< T, - { [Key in keyof T]: T[Key] extends ValueType ? never : Key }[keyof T] + { [Key in keyof T]-?: T[Key] extends ValueType ? never : Key }[keyof T] >; /** @@ -257,7 +257,7 @@ export type OmitByValue = Pick< export type OmitByValueExact = Pick< T, { - [Key in keyof T]: [ValueType] extends [T[Key]] + [Key in keyof T]-?: [ValueType] extends [T[Key]] ? [T[Key]] extends [ValueType] ? never : Key