Improve Flow typing for @babel/template

Summary:
The current typing is incorrectly marking the second parameter as required. The options object is optional.

Also added the special defaults for clarity.

Reviewed By: davidaurelio

Differential Revision: D7168409

fbshipit-source-id: e01b651f92b33175b750d188f9e6db99bdc4ab64
This commit is contained in:
Peter van der Zee 2018-03-07 04:18:13 -08:00 committed by Facebook Github Bot
parent 0e9e2505dd
commit 243fe983b7
1 changed files with 7 additions and 2 deletions

View File

@ -220,15 +220,20 @@ type BabelCoreOptions = {|
) => void,
|};
// https://github.com/babel/babel/tree/master/packages/babel-template
type TemplateOptions = Babylon7Options & {|
// note: template defaults for these options;
// allowReturnOutsideFunction = true
// allowSuperOutsideMethod = true
// sourceType = module
placeholderWhitelist?: Set<string>,
placeholderPattern?: RegExp | false,
preserveComments?: boolean,
|};
type Templatable = ({|[tokenName: string]: string|}) => BabelNode;
type Templatable = ({[tokenName: string]: string}) => BabelNode;
type TemplateFunc = (tpl: string, options: TemplateOptions) => Templatable;
type TemplateFunc = (tpl: string, options?: TemplateOptions) => Templatable;
// note: ast is not optional, babel will throw if it would be empty:
// https://github.com/babel/babel/blob/98969b8a7335e831c069164f5c56132111847224/packages/babel-core/src/transform-ast.js#L52