-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathts.ts
More file actions
31 lines (29 loc) · 599 Bytes
/
ts.ts
File metadata and controls
31 lines (29 loc) · 599 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* @file Regular Expressions - EXT_TS_REGEX
* @module ext-regex/regex/ts
*/
/**
* TypeScript file extension regex.
*
* Supported extensions:
*
* - `.cts`
* - `.d.cts`
* - `.d.mts`
* - `.d.ts`
* - `.mts`
* - `.ts`
* - `.tsx`
*
* Named capturing groups:
*
* - `dts`: Letter `'d'` if extension is declaration file extension
* - `type`: Letter between `'.'` and `'ts'` in file extension
*
* @see https://regex101.com/r/pE2tKy
*
* @const {RegExp} EXT_TS_REGEX
*/
const EXT_TS_REGEX: RegExp =
/\.(?:(?:(?<dts>d)\.)?(?<type>[cm])?ts|tsx)(?=\s*$)/
export default EXT_TS_REGEX