From 30b79efdd086ab006d2c391b6d868fe3f1efb8e5 Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Sun, 30 Mar 2025 23:20:00 -0400 Subject: [PATCH 01/12] export `ConditionalSimplify` and `ConditionalSimplifyDeep` --- index.d.ts | 2 + readme.md | 2 + source/conditional-pick-deep.d.ts | 2 +- source/conditional-simplify-deep.d.ts | 62 ++++++++++++++++++++++++ source/conditional-simplify.d.ts | 52 +++++++++++--------- source/merge-deep.d.ts | 2 +- source/simplify-deep.d.ts | 2 +- test-d/conditional-simplify-deep.ts | 70 +++++++++++++++++++++++++++ test-d/conditional-simplify.ts | 65 +------------------------ 9 files changed, 168 insertions(+), 91 deletions(-) create mode 100644 source/conditional-simplify-deep.d.ts create mode 100644 test-d/conditional-simplify-deep.ts diff --git a/index.d.ts b/index.d.ts index c8c021f36..dd7a97b0b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -167,6 +167,8 @@ export type {StringRepeat} from './source/string-repeat'; export type {Includes} from './source/includes'; export type {Get} from './source/get'; export type {LastArrayElement} from './source/last-array-element'; +export type {ConditionalSimplify} from './source/conditional-simplify'; +export type {ConditionalSimplifyDeep} from './source/conditional-simplify-deep'; // Miscellaneous export type {GlobalThis} from './source/global-this'; diff --git a/readme.md b/readme.md index e74c9572e..074aecbda 100644 --- a/readme.md +++ b/readme.md @@ -211,6 +211,8 @@ Click the type names for complete docs. - [`NonEmptyTuple`](source/non-empty-tuple.d.ts) - Matches any non-empty tuple. - [`FindGlobalType`](source/find-global-type.d.ts) - Tries to find the type of a global with the given name. - [`FindGlobalInstanceType`](source/find-global-type.d.ts) - Tries to find one or more types from their globally-defined constructors. +- [`ConditionalSimplify`](source/conditional-simplify.d.ts) - Simplifies a type while including and/or excluding certain types from being simplified. +- [`ConditionalSimplifyDeep`](source/conditional-simplify-deep.d.ts) - Recursively simplifies a type while including and/or excluding certain types from being simplified. ### Type Guard diff --git a/source/conditional-pick-deep.d.ts b/source/conditional-pick-deep.d.ts index 561df238d..6aec19de3 100644 --- a/source/conditional-pick-deep.d.ts +++ b/source/conditional-pick-deep.d.ts @@ -1,6 +1,6 @@ import type {IsEqual} from './is-equal'; import type {ConditionalExcept} from './conditional-except'; -import type {ConditionalSimplifyDeep} from './conditional-simplify'; +import type {ConditionalSimplifyDeep} from './conditional-simplify-deep'; import type {UnknownRecord} from './unknown-record'; import type {EmptyObject} from './empty-object'; import type {ApplyDefaultOptions, IsPlainObject} from './internal'; diff --git a/source/conditional-simplify-deep.d.ts b/source/conditional-simplify-deep.d.ts new file mode 100644 index 000000000..e404fe14f --- /dev/null +++ b/source/conditional-simplify-deep.d.ts @@ -0,0 +1,62 @@ +/** +Recursively simplifies a type while including and/or excluding certain types from being simplified. +@example +```ts +import type {ConditionalSimplifyDeep} from 'type-fest'; +type TypeA = { + foo: { + a: string + } +}; +type TypeB = { + foo: { + b: string + } +}; +type SimplifyDeepTypeAB = ConditionalSimplifyDeep; +//=> {foo: {a: string, b: string}} +``` +@example +```ts +import type {ConditionalSimplifyDeep} from 'type-fest'; +type SomeComplexType1 = { + a1: string + b1: number + c1: boolean + ... +} +type SomeComplexType2 = { + a2: string + b2: number + c2: boolean + ... +} +type TypeA = { + foo: { + a: string + complexType: SomeComplexType1 + } +}; +type TypeB = { + foo: { + b: string + complexType: SomeComplexType2 + } +}; +type SimplifyDeepTypeAB = ConditionalSimplifyDeep; +//=> { +// foo: { +// a: string, +// b: string, +// complexType: SomeComplexType1 | SomeComplexType2 +// } +// } +``` +@see SimplifyDeep +@category Object +*/ +export type ConditionalSimplifyDeep = Type extends ExcludeType + ? Type + : Type extends IncludeType + ? {[TypeKey in keyof Type]: ConditionalSimplifyDeep} + : Type; diff --git a/source/conditional-simplify.d.ts b/source/conditional-simplify.d.ts index 03cd506b4..e39075706 100644 --- a/source/conditional-simplify.d.ts +++ b/source/conditional-simplify.d.ts @@ -1,11 +1,32 @@ /** -Simplifies a type while including and/or excluding certain types from being simplified. Useful to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability. - -This type is **experimental** and was introduced as a result of this {@link https://github.com/sindresorhus/type-fest/issues/436 issue}. It should be used with caution. - -@internal -@experimental -@see Simplify +Simplifies a type while including and/or excluding certain types from being simplified. +Useful to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability. +@example +```ts +import type {ConditionalSimplify} from 'type-fest'; +type TypeA = { + a: string +} +type TypeB = { + b: string +} +type TypeAB = TypeA & TypeB +//=> {a: string} & {b: string} +type SimplifyTypeAB = ConditionalSimplify +//=> {a: string, b: string} +``` +@example +```ts +import type {ConditionalSimplify} from 'type-fest'; +type Simplify = ConditionalSimplify | Map | unknown[], object>; +type A = Simplify & Set>; +//=> Set & Set +type B = Simplify & Map>; +//=> Map & Map +type C = Simplify<{ a: number } & { b: string }>; +//=> {a: number, b: string} +``` +@see ConditionalSimplifyDeep @category Object */ export type ConditionalSimplify = Type extends ExcludeType @@ -13,20 +34,3 @@ export type ConditionalSimplify = Type extends ExcludeType - ? Type - : Type extends IncludeType - ? {[TypeKey in keyof Type]: ConditionalSimplifyDeep} - : Type; diff --git a/source/merge-deep.d.ts b/source/merge-deep.d.ts index b0c0fd72a..c3db5ec01 100644 --- a/source/merge-deep.d.ts +++ b/source/merge-deep.d.ts @@ -1,4 +1,4 @@ -import type {ConditionalSimplifyDeep} from './conditional-simplify'; +import type {ConditionalSimplifyDeep} from './conditional-simplify-deep'; import type {OmitIndexSignature} from './omit-index-signature'; import type {PickIndexSignature} from './pick-index-signature'; import type {Merge} from './merge'; diff --git a/source/simplify-deep.d.ts b/source/simplify-deep.d.ts index a5653fce6..f973dda85 100644 --- a/source/simplify-deep.d.ts +++ b/source/simplify-deep.d.ts @@ -1,4 +1,4 @@ -import type {ConditionalSimplifyDeep} from './conditional-simplify'; +import type {ConditionalSimplifyDeep} from './conditional-simplify-deep'; import type {NonRecursiveType} from './internal'; /** diff --git a/test-d/conditional-simplify-deep.ts b/test-d/conditional-simplify-deep.ts new file mode 100644 index 000000000..cd95ce063 --- /dev/null +++ b/test-d/conditional-simplify-deep.ts @@ -0,0 +1,70 @@ +import {expectNotAssignable, expectType} from 'tsd'; +import type {ConditionalSimplifyDeep} from '../index'; + +type Position = {top: number; left: number}; +type Size = {width: number; height: number}; + +// In your editor, hovering over `PositionAndSizeSimplified` will show a simplified object with all the properties. +type PositionAndSizeIntersection = Position & Size; + +const position = {top: 120, left: 240}; +const size = {width: 480, height: 600}; +const positionAndSize = {...position, ...size}; + +// Should simplify interface deeply. +type SomeNode = { + parent: PositionAndSizeIntersection; + childs: Array<{parent: PositionAndSizeIntersection}>; +}; + +// In your editor, hovering over `SomeNodeSimplified` will show a simplified object with all the properties. +type SomeNodeSimplified = ConditionalSimplifyDeep; + +const someNode = {parent: positionAndSize, childs: [{parent: positionAndSize}, {parent: positionAndSize}]}; +expectType(someNode); + +// Should simplify interface deeply excluding Function type. +// TODO: Convert this to a `type`. +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions +interface MovablePosition extends Position { + move(position: Position): Position; +} + +type MovableCollection = { + position: MovablePosition; + top: {position: MovablePosition; size: Size}; + left: {position: MovablePosition; size: Size}; +}; + +type MovableNodeSimplifiedFail = ConditionalSimplifyDeep; +type MovableNodeSimplifiedPass = ConditionalSimplifyDeep; + +declare const movableNodeSimplifiedFail: MovableNodeSimplifiedFail; +declare const movableNodeSimplifiedPass: MovableNodeSimplifiedPass; + +expectNotAssignable(movableNodeSimplifiedFail); +expectType(movableNodeSimplifiedPass); + +const movablePosition = { + top: 42, + left: 42, + move(position: Position) { + return position; + }, +}; + +const movableNode = { + position: movablePosition, + top: {position: movablePosition, size}, + left: {position: movablePosition, size}, +}; + +expectType(movableNode); + +// Should exclude `Function` and `Size` type (mainly visual, mouse over the statement). +type ExcludeFunctionAndSize1 = ConditionalSimplifyDeep; +expectType(movableNode); + +// Same as above but using `IncludeType` parameter (mainly visual, mouse over the statement). +type ExcludeFunctionAndSize2 = ConditionalSimplifyDeep; +expectType(movableNode); diff --git a/test-d/conditional-simplify.ts b/test-d/conditional-simplify.ts index 1e1d3a1bf..543d5e67c 100644 --- a/test-d/conditional-simplify.ts +++ b/test-d/conditional-simplify.ts @@ -1,83 +1,20 @@ import {expectNotAssignable, expectType} from 'tsd'; -import type {ConditionalSimplify, ConditionalSimplifyDeep} from '../source/conditional-simplify'; +import type {ConditionalSimplify} from '../index'; type Position = {top: number; left: number}; type Size = {width: number; height: number}; - // In your editor, hovering over `PositionAndSizeSimplified` will show a simplified object with all the properties. type PositionAndSizeIntersection = Position & Size; type PositionAndSizeSimplified = ConditionalSimplify; - const position = {top: 120, left: 240}; const size = {width: 480, height: 600}; const positionAndSize = {...position, ...size}; expectType(positionAndSize); - // Exclude function type to be simplified. type SomeFunction = (type: string) => string; type SimplifiedFunctionFail = ConditionalSimplify; // Return '{}' type SimplifiedFunctionPass = ConditionalSimplify; // Return '(type: string) => string' - declare const simplifiedFunctionFail: SimplifiedFunctionFail; declare const simplifiedFunctionPass: SimplifiedFunctionPass; - expectNotAssignable(simplifiedFunctionFail); expectType(simplifiedFunctionPass); - -// Should simplify interface deeply. -type SomeNode = { - parent: PositionAndSizeIntersection; - childs: Array<{parent: PositionAndSizeIntersection}>; -}; - -// In your editor, hovering over `SomeNodeSimplified` will show a simplified object with all the properties. -type SomeNodeSimplified = ConditionalSimplifyDeep; - -const someNode = {parent: positionAndSize, childs: [{parent: positionAndSize}, {parent: positionAndSize}]}; -expectType(someNode); - -// Should simplify interface deeply excluding Function type. -// TODO: Convert this to a `type`. -// eslint-disable-next-line @typescript-eslint/consistent-type-definitions -interface MovablePosition extends Position { - move(position: Position): Position; -} - -type MovableCollection = { - position: MovablePosition; - top: {position: MovablePosition; size: Size}; - left: {position: MovablePosition; size: Size}; -}; - -type MovableNodeSimplifiedFail = ConditionalSimplifyDeep; -type MovableNodeSimplifiedPass = ConditionalSimplifyDeep; - -declare const movableNodeSimplifiedFail: MovableNodeSimplifiedFail; -declare const movableNodeSimplifiedPass: MovableNodeSimplifiedPass; - -expectNotAssignable(movableNodeSimplifiedFail); -expectType(movableNodeSimplifiedPass); - -const movablePosition = { - top: 42, - left: 42, - move(position: Position) { - return position; - }, -}; - -const movableNode = { - position: movablePosition, - top: {position: movablePosition, size}, - left: {position: movablePosition, size}, -}; - -expectType(movableNode); - -// Should exclude `Function` and `Size` type (mainly visual, mouse over the statement). -type ExcludeFunctionAndSize1 = ConditionalSimplifyDeep; -expectType(movableNode); - -// Same as above but using `IncludeType` parameter (mainly visual, mouse over the statement). -type ExcludeFunctionAndSize2 = ConditionalSimplifyDeep; -expectType(movableNode); From d6901159a2d984ddd84dd709e8956dba2751c3f9 Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Thu, 3 Apr 2025 09:44:27 -0400 Subject: [PATCH 02/12] Update conditional-simplify-deep.d.ts --- source/conditional-simplify-deep.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/source/conditional-simplify-deep.d.ts b/source/conditional-simplify-deep.d.ts index e404fe14f..6e39181e4 100644 --- a/source/conditional-simplify-deep.d.ts +++ b/source/conditional-simplify-deep.d.ts @@ -1,5 +1,6 @@ /** Recursively simplifies a type while including and/or excluding certain types from being simplified. + @example ```ts import type {ConditionalSimplifyDeep} from 'type-fest'; From 1dac47c55e7f34fb545ef48a31eb95888f8f2d4e Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Wed, 7 May 2025 14:14:18 +0800 Subject: [PATCH 03/12] Update conditional-simplify-deep.d.ts --- source/conditional-simplify-deep.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/conditional-simplify-deep.d.ts b/source/conditional-simplify-deep.d.ts index 6e39181e4..7ed266525 100644 --- a/source/conditional-simplify-deep.d.ts +++ b/source/conditional-simplify-deep.d.ts @@ -17,6 +17,7 @@ type TypeB = { type SimplifyDeepTypeAB = ConditionalSimplifyDeep; //=> {foo: {a: string, b: string}} ``` + @example ```ts import type {ConditionalSimplifyDeep} from 'type-fest'; @@ -53,6 +54,7 @@ type SimplifyDeepTypeAB = ConditionalSimplifyDeep Date: Wed, 7 May 2025 14:15:20 +0800 Subject: [PATCH 04/12] Update conditional-simplify-deep.d.ts --- source/conditional-simplify-deep.d.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/source/conditional-simplify-deep.d.ts b/source/conditional-simplify-deep.d.ts index 7ed266525..40001c065 100644 --- a/source/conditional-simplify-deep.d.ts +++ b/source/conditional-simplify-deep.d.ts @@ -4,16 +4,19 @@ Recursively simplifies a type while including and/or excluding certain types fro @example ```ts import type {ConditionalSimplifyDeep} from 'type-fest'; + type TypeA = { foo: { a: string } }; + type TypeB = { foo: { b: string } }; + type SimplifyDeepTypeAB = ConditionalSimplifyDeep; //=> {foo: {a: string, b: string}} ``` @@ -21,30 +24,35 @@ type SimplifyDeepTypeAB = ConditionalSimplifyDeep; @example ```ts import type {ConditionalSimplifyDeep} from 'type-fest'; + type SomeComplexType1 = { a1: string b1: number c1: boolean ... -} +}; + type SomeComplexType2 = { a2: string b2: number c2: boolean ... -} +}; + type TypeA = { foo: { a: string complexType: SomeComplexType1 } }; + type TypeB = { foo: { b: string complexType: SomeComplexType2 } }; + type SimplifyDeepTypeAB = ConditionalSimplifyDeep; //=> { // foo: { From 53e39b3fea880fa5ff56bf6b3c0c1af4cd70d0f6 Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Wed, 7 May 2025 14:16:38 +0800 Subject: [PATCH 05/12] Update conditional-simplify.d.ts --- source/conditional-simplify.d.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/source/conditional-simplify.d.ts b/source/conditional-simplify.d.ts index e39075706..fb7cd6942 100644 --- a/source/conditional-simplify.d.ts +++ b/source/conditional-simplify.d.ts @@ -1,31 +1,43 @@ /** Simplifies a type while including and/or excluding certain types from being simplified. + Useful to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability. + @example ```ts import type {ConditionalSimplify} from 'type-fest'; + type TypeA = { a: string -} +}; + type TypeB = { b: string -} -type TypeAB = TypeA & TypeB +}; + +type TypeAB = TypeA & TypeB; //=> {a: string} & {b: string} -type SimplifyTypeAB = ConditionalSimplify + +type SimplifyTypeAB = ConditionalSimplify; //=> {a: string, b: string} ``` + @example ```ts import type {ConditionalSimplify} from 'type-fest'; + type Simplify = ConditionalSimplify | Map | unknown[], object>; + type A = Simplify & Set>; //=> Set & Set + type B = Simplify & Map>; //=> Map & Map + type C = Simplify<{ a: number } & { b: string }>; //=> {a: number, b: string} ``` + @see ConditionalSimplifyDeep @category Object */ From be8adf03cd0a1fe4292aaa25e2efdbf072a6357a Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Thu, 8 May 2025 17:36:50 +0800 Subject: [PATCH 06/12] Update conditional-simplify.ts --- test-d/conditional-simplify.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test-d/conditional-simplify.ts b/test-d/conditional-simplify.ts index 543d5e67c..23b60e97b 100644 --- a/test-d/conditional-simplify.ts +++ b/test-d/conditional-simplify.ts @@ -6,15 +6,19 @@ type Size = {width: number; height: number}; // In your editor, hovering over `PositionAndSizeSimplified` will show a simplified object with all the properties. type PositionAndSizeIntersection = Position & Size; type PositionAndSizeSimplified = ConditionalSimplify; + const position = {top: 120, left: 240}; const size = {width: 480, height: 600}; const positionAndSize = {...position, ...size}; expectType(positionAndSize); + // Exclude function type to be simplified. type SomeFunction = (type: string) => string; type SimplifiedFunctionFail = ConditionalSimplify; // Return '{}' type SimplifiedFunctionPass = ConditionalSimplify; // Return '(type: string) => string' + declare const simplifiedFunctionFail: SimplifiedFunctionFail; declare const simplifiedFunctionPass: SimplifiedFunctionPass; + expectNotAssignable(simplifiedFunctionFail); expectType(simplifiedFunctionPass); From 34718d3e57067cb802474fea808e6e737669d293 Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Thu, 8 May 2025 17:37:20 +0800 Subject: [PATCH 07/12] Update conditional-simplify.ts --- test-d/conditional-simplify.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test-d/conditional-simplify.ts b/test-d/conditional-simplify.ts index 23b60e97b..232316a85 100644 --- a/test-d/conditional-simplify.ts +++ b/test-d/conditional-simplify.ts @@ -3,6 +3,7 @@ import type {ConditionalSimplify} from '../index'; type Position = {top: number; left: number}; type Size = {width: number; height: number}; + // In your editor, hovering over `PositionAndSizeSimplified` will show a simplified object with all the properties. type PositionAndSizeIntersection = Position & Size; type PositionAndSizeSimplified = ConditionalSimplify; From c04fb38165e6c1151964ca308e4ad442170d416f Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Thu, 8 May 2025 17:43:51 +0800 Subject: [PATCH 08/12] Update merge-deep.d.ts --- source/merge-deep.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/source/merge-deep.d.ts b/source/merge-deep.d.ts index e590999d0..195086c45 100644 --- a/source/merge-deep.d.ts +++ b/source/merge-deep.d.ts @@ -1,5 +1,4 @@ import type {ConditionalSimplifyDeep} from './conditional-simplify-deep.d.ts'; -import type {ConditionalSimplifyDeep} from './conditional-simplify.d.ts'; import type {OmitIndexSignature} from './omit-index-signature.d.ts'; import type {PickIndexSignature} from './pick-index-signature.d.ts'; import type {Merge} from './merge.d.ts'; From 2d19f42b62d6802c6e1578c9ea262f0288c99491 Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Thu, 8 May 2025 17:47:53 +0800 Subject: [PATCH 09/12] Update index.d.ts --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 49e5b9f5a..47081d7c5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -171,8 +171,8 @@ export type {StringRepeat} from './source/string-repeat.d.ts'; export type {Includes} from './source/includes.d.ts'; export type {Get} from './source/get.d.ts'; export type {LastArrayElement} from './source/last-array-element.d.ts'; -export type {ConditionalSimplify} from './source/conditional-simplify'; -export type {ConditionalSimplifyDeep} from './source/conditional-simplify-deep'; +export type {ConditionalSimplify} from './source/conditional-simplify.d.ts'; +export type {ConditionalSimplifyDeep} from './source/conditional-simplify-deep.d.ts'; // Miscellaneous export type {GlobalThis} from './source/global-this.d.ts'; From 9a1f0f289e880f8d49dcafaef5e37cf2b6e1928e Mon Sep 17 00:00:00 2001 From: Roman Wu Date: Thu, 8 May 2025 17:48:47 +0800 Subject: [PATCH 10/12] Update conditional-simplify-deep.ts --- test-d/conditional-simplify-deep.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-d/conditional-simplify-deep.ts b/test-d/conditional-simplify-deep.ts index cd95ce063..1802973be 100644 --- a/test-d/conditional-simplify-deep.ts +++ b/test-d/conditional-simplify-deep.ts @@ -1,5 +1,5 @@ import {expectNotAssignable, expectType} from 'tsd'; -import type {ConditionalSimplifyDeep} from '../index'; +import type {ConditionalSimplifyDeep} from '../index.d.ts'; type Position = {top: number; left: number}; type Size = {width: number; height: number}; From a76e4cb5735826701226ce769cc50f5e2f154758 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 8 May 2025 17:12:35 +0700 Subject: [PATCH 11/12] Update conditional-simplify-deep.d.ts --- source/conditional-simplify-deep.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/conditional-simplify-deep.d.ts b/source/conditional-simplify-deep.d.ts index 40001c065..ef1444dfe 100644 --- a/source/conditional-simplify-deep.d.ts +++ b/source/conditional-simplify-deep.d.ts @@ -2,7 +2,7 @@ Recursively simplifies a type while including and/or excluding certain types from being simplified. @example -```ts +``` import type {ConditionalSimplifyDeep} from 'type-fest'; type TypeA = { @@ -22,21 +22,21 @@ type SimplifyDeepTypeAB = ConditionalSimplifyDeep; ``` @example -```ts +``` import type {ConditionalSimplifyDeep} from 'type-fest'; type SomeComplexType1 = { a1: string b1: number c1: boolean - ... + // … }; type SomeComplexType2 = { a2: string b2: number c2: boolean - ... + // … }; type TypeA = { From 1a4f47dfec66185900fd1c69e3e5e3cc5bb9c17d Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 8 May 2025 17:13:35 +0700 Subject: [PATCH 12/12] Update conditional-simplify.d.ts --- source/conditional-simplify.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/conditional-simplify.d.ts b/source/conditional-simplify.d.ts index fb7cd6942..fa234f3ea 100644 --- a/source/conditional-simplify.d.ts +++ b/source/conditional-simplify.d.ts @@ -4,7 +4,7 @@ Simplifies a type while including and/or excluding certain types from being simp Useful to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability. @example -```ts +``` import type {ConditionalSimplify} from 'type-fest'; type TypeA = { @@ -23,7 +23,7 @@ type SimplifyTypeAB = ConditionalSimplify; ``` @example -```ts +``` import type {ConditionalSimplify} from 'type-fest'; type Simplify = ConditionalSimplify | Map | unknown[], object>; @@ -34,7 +34,7 @@ type A = Simplify & Set>; type B = Simplify & Map>; //=> Map & Map -type C = Simplify<{ a: number } & { b: string }>; +type C = Simplify<{a: number} & {b: string}>; //=> {a: number, b: string} ```