This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ad80b2
commit 4c155ab
Showing
2 changed files
with
38 additions
and
0 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
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,37 @@ | ||
import type { BabelFileResult } from '@babel/core' | ||
import type { File } from '@babel/types' | ||
|
||
/** | ||
* @file Type Definitions - TrextFileResult | ||
* @module trext/types/TrextFileResult | ||
*/ | ||
|
||
/** | ||
* Return value of `Trext.trextFile`. | ||
* | ||
* ! Note: For some reason, `@babel/core` does not export the [`FileResult`][1] | ||
* ! type (nor is it correctly defined in the repository). Additionally, [types | ||
* ! needed to correctly implement this type are also not available][2]. | ||
* | ||
* @template T - File extension name(s) | ||
* | ||
* [1]: https://github.com/babel/babel/blob/v7.15.8/packages/babel-core/src/transformation/index.ts | ||
* [2]: https://github.com/babel/babel/blob/v7.15.8/packages/babel-core/src/config/validation/options.ts | ||
*/ | ||
type TrextFileResult = { | ||
ast: File | null | ||
code: string | null | ||
ignored?: NonNullable<BabelFileResult['ignored']> | ||
map: NonNullable<BabelFileResult['map']> | ||
metadata: Record<never, never> | NonNullable<BabelFileResult['metadata']> | ||
|
||
/** | ||
* ! `@babel/core` library does not export `InputOptions` type either. | ||
* | ||
* @see https://github.com/babel/babel/blob/c4b13725aa65446974d8b78b63a7da8ec826ff76/packages/babel-core/src/config/validation/options.ts#L132 | ||
*/ | ||
options?: Record<string, any> | ||
sourceType: 'module' | 'string' | ||
} | ||
|
||
export default TrextFileResult |