Skip to content

Commit 00b1dae

Browse files
committed
refactor(types): decrease type build output
1 parent c9707a2 commit 00b1dae

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

src/core/types/escape.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import type { Input } from '../inputs'
22
import { InputSource } from './sources'
33

4-
// prettier-ignore
5-
type ExactEscapeChar = '.' | '*' | '+' | '?' | '^' | '$' | '{' | '}' | '(' | ')' | '|' | '[' | ']' | '/'
6-
type Escape<
4+
export type Escape<
75
T extends string,
86
EscapeChar extends string
97
> = T extends `${infer Start}${EscapeChar}${string}`
@@ -18,12 +16,11 @@ type Escape<
1816
: never
1917
: T
2018

21-
type CharEscapeCharacter = '\\' | '^' | '-' | ']'
22-
export type EscapeChar<T extends string> = Escape<T, CharEscapeCharacter>
19+
export type EscapeChar<T extends string> = Escape<T, '\\' | '^' | '-' | ']'>
2320
export type StripEscapes<T extends string> = T extends `${infer A}\\${infer B}` ? `${A}${B}` : T
2421

2522
export type GetValue<T extends InputSource> = T extends string
26-
? Escape<T, ExactEscapeChar>
23+
? EscapeChar<T>
2724
: T extends Input<infer R>
2825
? R
2926
: never

src/core/wrap.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { Input } from './internal'
22
import { StripEscapes } from './types/escape'
33

4-
export type IfUnwrapped<
5-
Value extends string,
6-
Yes extends string,
7-
No extends string
8-
> = Value extends `(${string})`
4+
export type IfUnwrapped<Value extends string, Yes, No> = Value extends `(${string})`
95
? No
106
: StripEscapes<Value> extends `${infer A}${infer B}`
117
? A extends ''

0 commit comments

Comments
 (0)