-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
@babel/template
from Flow to TS
Co-authored-by: Bogdan Savluk <savluk.bogdan@gmail.com>
- Loading branch information
1 parent
78f9172
commit dfe15bd
Showing
10 changed files
with
171 additions
and
157 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,36 @@ | ||
declare module "@babel/template" { | ||
declare type PublicOpts = { | ||
placeholderWhitelist?: ?Set<string>, | ||
placeholderPattern?: ?(RegExp | false), | ||
preserveComments?: ?boolean, | ||
syntacticPlaceholders?: ?boolean, | ||
}; | ||
|
||
declare type PublicReplacements = { [string]: mixed } | Array<mixed>; | ||
|
||
declare type TemplateBuilder<T> = { | ||
ast: { | ||
(tpl: string, opts: ?PublicOpts): T, | ||
(tpl: Array<string>, ...args: Array<mixed>): T, | ||
}, | ||
(opts: PublicOpts): TemplateBuilder<T>, | ||
(tpl: string, opts: ?PublicOpts): (?PublicReplacements) => T, | ||
(tpl: Array<string>, ...args: Array<mixed>): (?PublicReplacements) => T, | ||
}; | ||
|
||
declare type Smart = TemplateBuilder< | ||
Array<BabelNodeStatement> | BabelNodeStatement | ||
>; | ||
declare type Statement = TemplateBuilder<BabelNodeStatement>; | ||
declare type Statements = TemplateBuilder<Array<BabelNodeStatement>>; | ||
declare type Expression = TemplateBuilder<BabelNodeExpression>; | ||
declare type Program = TemplateBuilder<BabelNodeProgram>; | ||
|
||
declare export default Smart & { | ||
smart: Smart, | ||
statement: Statement, | ||
statements: Statements, | ||
expression: Expression, | ||
program: Program, | ||
}; | ||
} |
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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
import * as formatters from "./formatters"; | ||
import createTemplateBuilder from "./builder"; | ||
|
||
export const smart = createTemplateBuilder(formatters.smart); | ||
export const statement = createTemplateBuilder(formatters.statement); | ||
export const statements = createTemplateBuilder(formatters.statements); | ||
export const expression = createTemplateBuilder(formatters.expression); | ||
export const program = createTemplateBuilder(formatters.program); | ||
|
||
type DefaultTemplateBuilder = typeof smart & { | ||
smart: typeof smart; | ||
statement: typeof statement; | ||
statements: typeof statements; | ||
expression: typeof expression; | ||
program: typeof program; | ||
}; | ||
|
||
export default Object.assign(smart.bind(undefined) as DefaultTemplateBuilder, { | ||
smart, | ||
statement, | ||
statements, | ||
expression, | ||
program, | ||
ast: smart.ast, | ||
}); |
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
Oops, something went wrong.