Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: conditionally load typescript and tsutils
- Loading branch information
1 parent
0424cad
commit 441d55b
Showing
5 changed files
with
78 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/experimental-utils/src/conditional-imports/tsutils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type * as tsutils from 'tsutils'; | ||
|
||
// Conditionally loaded tsutils but only if it is available. | ||
const conditionalTsutils = ((): typeof tsutils | Error => { | ||
try { | ||
return require('tsutils') as typeof tsutils; | ||
} catch { | ||
return new Error('Cannot find local tsutils peer depenancy.'); | ||
} | ||
})(); | ||
|
||
export { conditionalTsutils }; |
12 changes: 12 additions & 0 deletions
12
packages/experimental-utils/src/conditional-imports/typescript.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type * as ts from 'typescript'; | ||
|
||
// Conditionally loaded TypeScript but only if it is available. | ||
const conditionalTypeScript = ((): typeof ts | Error => { | ||
try { | ||
return require('typescript') as typeof ts; | ||
} catch { | ||
return new Error('Cannot find local typescript peer depenancy.'); | ||
} | ||
})(); | ||
|
||
export { conditionalTypeScript }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters