-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: parser
typings for plugins
#15094
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,3 +1,85 @@ | ||
// This file is auto-generated! Do not modify it directly. | ||
/* eslint-disable import/no-extraneous-dependencies, @typescript-eslint/consistent-type-imports, prettier/prettier */ | ||
import * as _babel_types from '@babel/types'; | ||
|
||
type Plugin = | ||
| "asyncDoExpressions" | ||
| "asyncGenerators" | ||
| "bigInt" | ||
| "classPrivateMethods" | ||
| "classPrivateProperties" | ||
| "classProperties" | ||
| "classStaticBlock" // Enabled by default | ||
| "decimal" | ||
| "decorators-legacy" | ||
| "decoratorAutoAccessors" | ||
| "destructuringPrivate" | ||
| "doExpressions" | ||
| "dynamicImport" | ||
| "explicitResourceManagement" | ||
| "exportDefaultFrom" | ||
| "exportNamespaceFrom" // deprecated | ||
| "flow" | ||
| "flowComments" | ||
| "functionBind" | ||
| "functionSent" | ||
| "importMeta" | ||
| "jsx" | ||
| "logicalAssignment" | ||
| "importAssertions" | ||
| "importReflection" | ||
| "moduleBlocks" | ||
| "moduleStringNames" | ||
| "nullishCoalescingOperator" | ||
| "numericSeparator" | ||
| "objectRestSpread" | ||
| "optionalCatchBinding" | ||
| "optionalChaining" | ||
| "partialApplication" | ||
| "placeholders" | ||
| "privateIn" // Enabled by default | ||
| "regexpUnicodeSets" | ||
| "throwExpressions" | ||
| "topLevelAwait" | ||
| "v8intrinsic" | ||
| ParserPluginWithOptions[0]; | ||
|
||
type ParserPluginWithOptions = | ||
| ["decorators", DecoratorsPluginOptions] | ||
| ["estree", { classFeatures?: boolean }] | ||
// @deprecated | ||
| ["moduleAttributes", { version: "may-2020" }] | ||
| ["pipelineOperator", PipelineOperatorPluginOptions] | ||
| ["recordAndTuple", RecordAndTuplePluginOptions] | ||
| ["flow", FlowPluginOptions] | ||
| ["typescript", TypeScriptPluginOptions]; | ||
|
||
type PluginConfig = Plugin | ParserPluginWithOptions; | ||
|
||
interface DecoratorsPluginOptions { | ||
decoratorsBeforeExport?: boolean; | ||
allowCallParenthesized?: boolean; | ||
} | ||
|
||
interface PipelineOperatorPluginOptions { | ||
proposal: "minimal" | "fsharp" | "hack" | "smart"; | ||
topicToken?: "%" | "#" | "@@" | "^^" | "^"; | ||
} | ||
|
||
interface RecordAndTuplePluginOptions { | ||
syntaxType: "bar" | "hash"; | ||
} | ||
|
||
interface FlowPluginOptions { | ||
all?: boolean; | ||
enums?: boolean; | ||
} | ||
|
||
interface TypeScriptPluginOptions { | ||
dts?: boolean; | ||
disallowAmbiguousJSXLike?: boolean; | ||
} | ||
|
||
// Type definitions for @babel/parser | ||
// Project: https://github.com/babel/babel/tree/main/packages/babel-parser | ||
// Definitions by: Troy Gerwien <https://github.com/yortus> | ||
|
@@ -8,20 +90,20 @@ | |
/** | ||
* Parse the provided code as an entire ECMAScript program. | ||
*/ | ||
export function parse( | ||
declare function parse( | ||
input: string, | ||
options?: ParserOptions | ||
): ParseResult<import("@babel/types").File>; | ||
): ParseResult<_babel_types.File>; | ||
|
||
/** | ||
* Parse the provided code as a single expression. | ||
*/ | ||
export function parseExpression( | ||
declare function parseExpression( | ||
input: string, | ||
options?: ParserOptions | ||
): ParseResult<import("@babel/types").Expression>; | ||
): ParseResult<_babel_types.Expression>; | ||
|
||
export interface ParserOptions { | ||
interface ParserOptions { | ||
/** | ||
* By default, import and export declarations can only appear at a program's top level. | ||
* Setting this option to true allows them anywhere where a statement is allowed. | ||
|
@@ -125,91 +207,21 @@ export interface ParserOptions { | |
createParenthesizedExpressions?: boolean; | ||
} | ||
|
||
export type ParserPlugin = | ||
| "asyncDoExpressions" | ||
| "asyncGenerators" | ||
| "bigInt" | ||
| "classPrivateMethods" | ||
| "classPrivateProperties" | ||
| "classProperties" | ||
| "classStaticBlock" // Enabled by default | ||
| "decimal" | ||
| "decorators" | ||
| "decorators-legacy" | ||
| "decoratorAutoAccessors" | ||
| "destructuringPrivate" | ||
| "doExpressions" | ||
| "dynamicImport" | ||
| "estree" | ||
| "exportDefaultFrom" | ||
| "exportNamespaceFrom" // deprecated | ||
| "flow" | ||
| "flowComments" | ||
| "functionBind" | ||
| "functionSent" | ||
| "importMeta" | ||
| "jsx" | ||
| "logicalAssignment" | ||
| "importAssertions" | ||
| "moduleBlocks" | ||
| "moduleStringNames" | ||
| "nullishCoalescingOperator" | ||
| "numericSeparator" | ||
| "objectRestSpread" | ||
| "optionalCatchBinding" | ||
| "optionalChaining" | ||
| "partialApplication" | ||
| "pipelineOperator" | ||
| "placeholders" | ||
| "privateIn" // Enabled by default | ||
| "recordAndTuple" | ||
| "regexpUnicodeSets" | ||
| "throwExpressions" | ||
| "topLevelAwait" | ||
| "typescript" | ||
| "v8intrinsic" | ||
| ParserPluginWithOptions; | ||
|
||
export type ParserPluginWithOptions = | ||
| ["decorators", DecoratorsPluginOptions] | ||
| ["pipelineOperator", PipelineOperatorPluginOptions] | ||
| ["recordAndTuple", RecordAndTuplePluginOptions] | ||
| ["flow", FlowPluginOptions] | ||
| ["typescript", TypeScriptPluginOptions]; | ||
|
||
export interface DecoratorsPluginOptions { | ||
decoratorsBeforeExport?: boolean; | ||
} | ||
|
||
export interface PipelineOperatorPluginOptions { | ||
proposal: "minimal" | "fsharp" | "hack" | "smart"; | ||
topicToken?: "%" | "#" | "@@" | "^^" | "^"; | ||
} | ||
type ParserPlugin = PluginConfig; | ||
|
||
export interface RecordAndTuplePluginOptions { | ||
syntaxType?: "bar" | "hash"; | ||
} | ||
|
||
export interface FlowPluginOptions { | ||
all?: boolean; | ||
enums?: boolean; | ||
} | ||
|
||
export interface TypeScriptPluginOptions { | ||
dts?: boolean; | ||
disallowAmbiguousJSXLike?: boolean; | ||
} | ||
|
||
export const tokTypes: { | ||
declare const tokTypes: { | ||
// todo(flow->ts) real token type | ||
[name: string]: any; | ||
}; | ||
|
||
export interface ParseError { | ||
interface ParseError { | ||
code: string; | ||
reasonCode: string; | ||
} | ||
|
||
type ParseResult<Result> = Result & { | ||
errors: ParseError[]; | ||
}; | ||
|
||
export { DecoratorsPluginOptions, FlowPluginOptions, ParseError, ParserOptions, ParserPlugin, ParserPluginWithOptions, PipelineOperatorPluginOptions, RecordAndTuplePluginOptions, TypeScriptPluginOptions, parse, parseExpression, tokTypes }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's about to export There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @liuxingbaoyu @nicolo-ribaudo WDYT? |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
babel-parser.d.ts
is generated, please leave a note at the top of this file. So new contributors will know this file is not supposed to be edited.