Skip to content

Commit

Permalink
Merge pull request #19428 from amiller-gh/patch-2
Browse files Browse the repository at this point in the history
Add all missing `babel-core` option properties and alphabetize for better maintainability.
  • Loading branch information
sandersn committed Sep 7, 2017
2 parents d5ef16a + a2f49b8 commit 7a3b23d
Showing 1 changed file with 79 additions and 55 deletions.
134 changes: 79 additions & 55 deletions types/babel-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ export { t as types };
export type Node = t.Node;
export import template = require('babel-template');
export const version: string;
import traverse, { Visitor } from "babel-traverse";
import traverse, { Visitor, NodePath } from "babel-traverse";
export { traverse, Visitor };
import { BabylonOptions } from "babylon";
export { BabylonOptions };
import { GeneratorOptions } from "babel-generator";
export { GeneratorOptions };

// A babel plugin is a simple function which must return an object matching
// the following interface. Babel will throw if it finds unknown properties.
Expand All @@ -38,14 +42,29 @@ 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;
/** Include the AST in the returned object. Default: `true`. */
ast?: boolean;

/** Filename relative to `sourceRoot`. */
filenameRelative?: string;
/** Attach a comment after all non-user injected code. */
auxiliaryCommentAfter?: string;

/** A source map object that the output source map will be based on. */
inputSourceMap?: object;
/** 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:
Expand All @@ -55,50 +74,77 @@ 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;

/** Enable/disable ANSI syntax highlighting of code frames. Default: `true`. */
highlightCode?: boolean;
/** Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown". */
filename?: string;

/** List of presets (a set of plugins) to load and use. */
presets?: any[];
/** Filename relative to `sourceRoot`. */
filenameRelative?: string;

/** List of plugins to load and use. */
plugins?: any[];
/** 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 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<string | RegExp>;

/** 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
* `shouldPrintComment(commentContents)`. **NOTE**: This overrides the `comments` option when used.
*/
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`
Expand All @@ -110,38 +156,16 @@ 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;

/** 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.
*/
getModuleId?(moduleName: string): string;

/** Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. */
moduleRoot?: string;
/** Indicate the mode the code should be parsed in. Can be either “script” or “module”. Default: "module" */
sourceType?: "script" | "module";

/**
* If truthy, insert an explicit id for modules. By default, all modules are anonymous.
* (Not available for `common` modules).
/** 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.
*/
moduleIds?: boolean;

/** Specify a custom name for module ids. */
moduleId?: string;
wrapPluginVisitorMethod?(pluginAlias: string, visitorType: 'enter' | 'exit', callback: (path: NodePath, state: any) => void): (path: NodePath, state: any) => void ;
}

export interface BabelFileResult {
Expand Down

0 comments on commit 7a3b23d

Please sign in to comment.