Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: tidy up conditional imports importing
- Loading branch information
1 parent
374bdf3
commit 5fd2cc1
Showing
5 changed files
with
50 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './tsutils'; | ||
export * from './typescript'; |
8 changes: 4 additions & 4 deletions
8
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type * as tsutils from 'tsutils'; | ||
import type * as tsutilsType from 'tsutils'; | ||
|
||
// Conditionally loaded tsutils but only if it is available. | ||
const conditionalTsutils = ((): typeof tsutils | Error => { | ||
const tsutils = ((): typeof tsutilsType | Error => { | ||
try { | ||
return require('tsutils') as typeof tsutils; | ||
return require('tsutils') as typeof tsutilsType; | ||
} catch { | ||
return new Error('Cannot find local tsutils peer depenancy.'); | ||
} | ||
})(); | ||
|
||
export { conditionalTsutils }; | ||
export { tsutils }; |
8 changes: 4 additions & 4 deletions
8
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type * as ts from 'typescript'; | ||
import type * as tsType from 'typescript'; | ||
|
||
// Conditionally loaded TypeScript but only if it is available. | ||
const conditionalTypeScript = ((): typeof ts | Error => { | ||
const ts = ((): typeof tsType | Error => { | ||
try { | ||
return require('typescript') as typeof ts; | ||
return require('typescript') as typeof tsType; | ||
} catch { | ||
return new Error('Cannot find local typescript peer depenancy.'); | ||
} | ||
})(); | ||
|
||
export { conditionalTypeScript }; | ||
export { 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
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