Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

Commit

Permalink
feat(typescript): RegexString
Browse files Browse the repository at this point in the history
  • Loading branch information
unicornware committed Oct 9, 2021
1 parent b2b180d commit 0303124
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/interfaces/trext-options.interface.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TransformOptions } from '@babel/core'
import type { TrextTo } from '@trext/types'
import type { RegexString, TrextTo } from '@trext/types'

/**
* @file Interfaces - TrextOptions
Expand All @@ -23,7 +23,7 @@ interface TrextOptions<F extends string = string, T extends string = string> {
*
* @default /\..+$/
*/
pattern?: RegExp | string
pattern?: RegexString

/**
* Babel transformation options.
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

export type { default as FileExtension } from './file-extension.type'
export type { default as RegexString } from './regex-string.type'
export type { default as TrextDefaults } from './trext-defaults.type'
export type { default as TrextToFn } from './trext-to-fn.type'
export type { default as TrextTo } from './trext-to.type'
11 changes: 11 additions & 0 deletions src/types/regex-string.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @file Type Definitions - RegexString
* @module trext/types/RegexString
*/

/**
* Value that can be a `RegExp` object or string literal.
*/
type RegexString = RegExp | string

export default RegexString
3 changes: 2 additions & 1 deletion src/types/trext-to-fn.type.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type FileExtension from './file-extension.type'
import type RegexString from './regex-string.type'

/**
* @file Type Definitions - TrextToFn
Expand All @@ -13,7 +14,7 @@ import type FileExtension from './file-extension.type'
* [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/replace#specifying_a_function_as_a_parameter
*/
type TrextToFn<T extends string = string> = (
match: string,
match: RegexString,
...args: any[]
) => FileExtension<T>

Expand Down

0 comments on commit 0303124

Please sign in to comment.