Skip to content

Commit 3e46960

Browse files
authored
Merge pull request #188 from webdeveric/dev
Added `Simplify`
2 parents aa2cabc + be53163 commit 3e46960

3 files changed

Lines changed: 54 additions & 32 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"devDependencies": {
8888
"@commitlint/config-conventional": "^19.8.1",
8989
"@commitlint/types": "^19.8.1",
90-
"@types/node": "^22.15.16",
90+
"@types/node": "^22.15.17",
9191
"@vitest/coverage-v8": "^3.1.3",
9292
"@webdeveric/eslint-config-ts": "^0.11.0",
9393
"@webdeveric/prettier-config": "^0.3.0",

pnpm-lock.yaml

Lines changed: 30 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/types/utils.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
1+
/* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types */
22

33
export type IfNever<Type, T, F> = [Type] extends [never] ? T : F;
44

@@ -125,3 +125,25 @@ export type UnionOf<T extends unknown[]> = T extends [infer First, ...infer Rest
125125
export type Pretty<Type> = {
126126
[Property in keyof Type]: Type[Property];
127127
} & unknown;
128+
129+
export type Simplify<Type> = Type extends string
130+
? string
131+
: Type extends number
132+
? number
133+
: Type extends boolean
134+
? boolean
135+
: Type extends bigint
136+
? bigint
137+
: Type extends symbol
138+
? symbol
139+
: Type extends undefined
140+
? undefined
141+
: Type extends null
142+
? null
143+
: Type extends Function
144+
? Type
145+
: Type extends object
146+
? {
147+
[Key in keyof Type]: Simplify<Type[Key]>;
148+
}
149+
: Type;

0 commit comments

Comments
 (0)