From 721f4209150a04efd59efc4fb2e514495a5b7a2f Mon Sep 17 00:00:00 2001 From: Adam Miller Date: Sun, 3 Sep 2017 16:42:46 -0700 Subject: [PATCH] Add all missing properties to interface for @types/babel-core. Order properties alphabetically for maintainability. --- types/babel-core/index.d.ts | 133 +++++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 56 deletions(-) diff --git a/types/babel-core/index.d.ts b/types/babel-core/index.d.ts index 698a074ced..999000f051 100644 --- a/types/babel-core/index.d.ts +++ b/types/babel-core/index.d.ts @@ -12,6 +12,8 @@ export import template = require('babel-template'); export const version: string; import traverse, { Visitor } from "babel-traverse"; export { traverse, Visitor }; +import { BabylonOptions } from "babylon"; +import { GeneratorOptions } from "babel-generator"; // A babel plugin is a simple function which must return an object matching // the following interface. Babel will throw if it finds unknown properties. @@ -38,14 +40,30 @@ export function transformFileSync(filename: string, opts?: TransformOptions): Ba export function transformFromAst(ast: Node, code?: string, opts?: TransformOptions): BabelFileResult; export interface TransformOptions { - /** Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown". */ - filename?: string; - /** Filename relative to `sourceRoot`. */ - filenameRelative?: string; + /** Include the AST in the returned object. Default: `true`. */ + ast?: boolean; - /** A source map object that the output source map will be based on. */ - inputSourceMap?: object; + /** Attach a comment after all non-user injected code. */ + auxiliaryCommentAfter?: string; + + /** Attach a comment before all non-user injected code. */ + auxiliaryCommentBefore?: string; + + /** Specify whether or not to use `.babelrc` and `.babelignore` files. Default: `true`. */ + babelrc?: boolean; + + /** Enable code generation. Default: `true`. */ + code?: boolean; + + /** write comments to generated output. Default: `true`. */ + comments?: boolean; + + /** + * Do not include superfluous whitespace characters and line terminators. When set to `"auto"`, `compact` is set to + * `true` on input sizes of >100KB. + */ + compact?: boolean | "auto"; /** * This is an object of keys that represent different environments. For example, you may have: @@ -55,38 +73,68 @@ export interface TransformOptions { */ env?: object; - /** Retain line numbers - will result in really ugly code. Default: `false` */ - retainLines?: boolean; + /** A path to an .babelrc file to extend. */ + extends?: string; + + /** Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown". */ + filename?: string; + + /** Filename relative to `sourceRoot`. */ + filenameRelative?: string; + + /** An object containing the options to be passed down to the babel code generator, babel-generator. Default: `{}` */ + generatorOpts?: GeneratorOptions; + + /** + * Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`. + * If falsy value is returned then the generated module id is used. + */ + getModuleId?(moduleName: string): string; /** Enable/disable ANSI syntax highlighting of code frames. Default: `true`. */ highlightCode?: boolean; - /** List of presets (a set of plugins) to load and use. */ - presets?: any[]; - - /** List of plugins to load and use. */ - plugins?: any[]; - /** list of glob paths to **not** compile. Opposite to the `only` option. */ ignore?: string[]; + /** A source map object that the output source map will be based on. */ + inputSourceMap?: object; + + /** Should the output be minified. Default: `false` */ + minified?: boolean; + + /** Specify a custom name for module ids. */ + moduleId?: string; + + /** + * If truthy, insert an explicit id for modules. By default, all modules are anonymous. + * (Not available for `common` modules). + */ + moduleIds?: boolean; + + /** Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. */ + moduleRoot?: string; + /** * A glob, regex, or mixed array of both, matching paths to only compile. Can also be an array of arrays containing * paths to explicitly match. When attempting to compile a non-matching file it's returned verbatim. */ only?: string | RegExp | Array; - /** Enable code generation. Default: `true`. */ - code?: boolean; + /** Babylon parser options. */ + parserOpts?: BabylonOptions; - /** Include the AST in the returned object. Default: `true`. */ - ast?: boolean; + /** List of plugins to load and use. */ + plugins?: any[]; - /** A path to an .babelrc file to extend. */ - extends?: string; + /** List of presets (a set of plugins) to load and use. */ + presets?: any[]; - /** write comments to generated output. Default: `true`. */ - comments?: boolean; + /** Retain line numbers - will result in really ugly code. Default: `false` */ + retainLines?: boolean; + + /** Resolve a module source ie. import "SOURCE"; to a custom value. */ + resolveModuleSource?(source: string, filename: string): string; /** * An optional callback that controls whether a comment should be output or not. Called as @@ -94,11 +142,8 @@ export interface TransformOptions { */ shouldPrintComment?(comment: string): boolean; - /** - * Do not include superfluous whitespace characters and line terminators. When set to `"auto"`, `compact` is set to - * `true` on input sizes of >100KB. - */ - compact?: boolean | "auto"; + /** Set `sources[0]` on returned source map. */ + sourceFileName?: string; /** * If truthy, adds a `map` property to returned output. If set to `"inline"`, a comment with a `sourceMappingURL` @@ -110,41 +155,17 @@ export interface TransformOptions { /** Set `file` on returned source map. */ sourceMapTarget?: string; - /** Set `sources[0]` on returned source map. */ - sourceFileName?: string; - /** The root from which all sources are relative. */ sourceRoot?: string; - /** Specify whether or not to use `.babelrc` and `.babelignore` files. Default: `true`. */ - babelrc?: boolean; + /** Indicate the mode the code should be parsed in. Can be either “script” or “module”. Default: "module" */ + sourceType?: "script" | "module"; - /** Attach a comment before all non-user injected code. */ - auxiliaryCommentBefore?: string; - - /** Attach a comment after all non-user injected code. */ - auxiliaryCommentAfter?: string; - - /** - * Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`. - * If falsy value is returned then the generated module id is used. + /** An optional callback that can be used to wrap visitor methods. + * NOTE: This is useful for things like introspection, and not really needed for implementing anything. */ - getModuleId?(moduleName: string): string; + wrapPluginVisitorMethod?(pluginAlias: string, visitorType: string, callback: Function): Function; - /** Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. */ - moduleRoot?: string; - - /** - * If truthy, insert an explicit id for modules. By default, all modules are anonymous. - * (Not available for `common` modules). - */ - moduleIds?: boolean; - - /** Specify a custom name for module ids. */ - moduleId?: string; - - /** Babylon parser options. */ - parserOpts?: Object; } export interface BabelFileResult {