-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypescript.ts
More file actions
31 lines (29 loc) · 846 Bytes
/
typescript.ts
File metadata and controls
31 lines (29 loc) · 846 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
/**
* @fileoverview TypeScript availability detection.
* Exports small getters that probe whether the `typescript` package's type
* definitions and lib files are resolvable from the current project.
*/
/**
* Check whether TypeScript's `lib/` directory is resolvable from the current
* project by probing `typescript/lib`.
*
* @returns `true` when the `typescript` package's libs can be resolved.
*/
export function getTsLibsAvailable(): boolean {
try {
require.resolve('typescript/lib')
return true
} catch {
return false
}
}
export function getTsTypesAvailable(): boolean {
try {
require.resolve('typescript/lib/lib.d.ts')
return true
} catch {
/* c8 ignore next - TypeScript is a project devDep; the catch
only fires when consumers run without typescript installed. */
return false
}
}