build: remove vendored Babel typings (#33226)

These were getting included in the @angular/localize package.
Instead, patch the upstream files to work with TS typeRoots option

See bazelbuild/rules_nodejs#1033

PR Close #33226
This commit is contained in:
Alex Eagle 2019-10-14 18:00:17 -07:00 committed by Matias Niemelä
parent 7b64680670
commit 422eb14dc0
20 changed files with 96 additions and 1897 deletions

View File

@ -40,7 +40,7 @@
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */ "typeRoots": ["node_modules/@types"], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */ // "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */

View File

@ -3,12 +3,10 @@
"@angular/core@file:../../dist/packages-dist/core": "@angular/core@file:../../dist/packages-dist/core":
version "8.0.0-beta.13" version "9.0.0-next.10"
dependencies:
tslib "^1.9.0"
"@angular/language-service@file:../../dist/packages-dist/language-service": "@angular/language-service@file:../../dist/packages-dist/language-service":
version "8.0.0-beta.13" version "9.0.0-next.10"
"@types/node@file:../../node_modules/@types/node": "@types/node@file:../../node_modules/@types/node":
version "10.9.4" version "10.9.4"
@ -91,13 +89,8 @@ path-is-absolute@^1.0.0:
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18=
tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==
"typescript@file:../../node_modules/typescript": "typescript@file:../../node_modules/typescript":
version "3.4.2" version "3.5.3"
wrappy@1: wrappy@1:
version "1.0.2" version "1.0.2"

View File

@ -39,7 +39,7 @@
"@angular-devkit/core": "^8.0.0-beta.15", "@angular-devkit/core": "^8.0.0-beta.15",
"@angular-devkit/schematics": "^8.0.0-beta.15", "@angular-devkit/schematics": "^8.0.0-beta.15",
"@angular/bazel": "file:./tools/npm/@angular_bazel", "@angular/bazel": "file:./tools/npm/@angular_bazel",
"@babel/core": "^7.5.5", "@babel/core": "^7.6.4",
"@bazel/jasmine": "0.38.3", "@bazel/jasmine": "0.38.3",
"@bazel/karma": "0.38.3", "@bazel/karma": "0.38.3",
"@bazel/protractor": "0.38.3", "@bazel/protractor": "0.38.3",
@ -47,6 +47,7 @@
"@microsoft/api-extractor": "^7.3.9", "@microsoft/api-extractor": "^7.3.9",
"@schematics/angular": "^8.0.0-beta.15", "@schematics/angular": "^8.0.0-beta.15",
"@types/angular": "^1.6.47", "@types/angular": "^1.6.47",
"@types/babel__core": "^7.1.3",
"@types/base64-js": "1.2.5", "@types/base64-js": "1.2.5",
"@types/bluebird": "^3.5.27", "@types/bluebird": "^3.5.27",
"@types/chai": "^4.1.2", "@types/chai": "^4.1.2",

View File

@ -15,7 +15,8 @@
"noImplicitAny": true, "noImplicitAny": true,
"outDir": "../node_modules/flat_module", "outDir": "../node_modules/flat_module",
"rootDir": "", "rootDir": "",
"target": "es5" "target": "es5",
"typeRoots": ["../node_modules/@types"]
}, },
"files": ["public-api.ts"] "files": ["public-api.ts"]

View File

@ -13,6 +13,7 @@
"noImplicitAny": true, "noImplicitAny": true,
"outDir": "../node_modules/third_party", "outDir": "../node_modules/third_party",
"rootDir": "", "rootDir": "",
"target": "es5" "target": "es5",
"typeRoots": ["../node_modules/@types"]
} }
} }

View File

@ -23,7 +23,8 @@
// compatible with the option. Disabled until the integration test support the strict flag. // compatible with the option. Disabled until the integration test support the strict flag.
// TODO(devversion): this has been enabled without the integration test code being // TODO(devversion): this has been enabled without the integration test code being
"strictPropertyInitialization": false, "strictPropertyInitialization": false,
"target": "es5" "target": "es5",
"typeRoots": ["node_modules/@types"]
}, },
"files": [ "files": [

View File

@ -15,7 +15,8 @@
"outDir": "./xi18n-out", "outDir": "./xi18n-out",
"rootDir": "", "rootDir": "",
"skipLibCheck": true, "skipLibCheck": true,
"target": "es5" "target": "es5",
"typeRoots": ["node_modules/@types"]
}, },
"files": [ "files": [

View File

@ -22,6 +22,8 @@ ts_library(
"//packages/localize", "//packages/localize",
"@npm//@babel/core", "@npm//@babel/core",
"@npm//@babel/types", "@npm//@babel/types",
"@npm//@types/babel__core",
"@npm//@types/babel__traverse",
"@npm//@types/glob", "@npm//@types/glob",
"@npm//@types/node", "@npm//@types/node",
"@npm//@types/yargs", "@npm//@types/yargs",

View File

@ -15,7 +15,7 @@ import {Diagnostics} from '../../diagnostics';
* @param expression The expression to check. * @param expression The expression to check.
*/ */
export function isNamedIdentifier( export function isNamedIdentifier(
expression: NodePath<t.Expression>, name: string): expression is NodePath<t.Identifier> { expression: NodePath, name: string): expression is NodePath<t.Identifier> {
return expression.isIdentifier() && expression.node.name === name; return expression.isIdentifier() && expression.node.name === name;
} }
@ -309,7 +309,7 @@ export function translate(
export class BabelParseError extends Error { export class BabelParseError extends Error {
private readonly type = 'BabelParseError'; private readonly type = 'BabelParseError';
constructor(public node: t.BaseNode, message: string) { super(message); } constructor(public node: t.Node, message: string) { super(message); }
} }
export function isBabelParseError(e: any): e is BabelParseError { export function isBabelParseError(e: any): e is BabelParseError {

View File

@ -12,6 +12,9 @@ ts_library(
"//packages/localize", "//packages/localize",
"//packages/localize/src/tools", "//packages/localize/src/tools",
"@npm//@babel/types", "@npm//@babel/types",
"@npm//@types/babel__core",
"@npm//@types/babel__generator",
"@npm//@types/babel__template",
"@npm//@types/glob", "@npm//@types/glob",
], ],
) )

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) Microsoft Corporation. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE

View File

@ -1,11 +0,0 @@
# @babel/... external types
The Bazel `ts_library` rule does not understand how to map imports of the form `@babel/core` to
external typings of the form `@types/babel__core`. Note the double underscore to account for the
namespaced package.
See https://github.com/bazelbuild/rules_nodejs/issues/1033.
This folder is a workaround to this by copying the typings directly into the project. Once the
issue with `ts_library` is resolved we can remove this folder and add appropriate npm dependencies
for the typings

View File

@ -1,734 +0,0 @@
declare module '@babel/core' {
// Type definitions for @babel/core 7.1
// Project: https://github.com/babel/babel/tree/master/packages/babel-core, https://babeljs.io
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Melvin Groenhoff <https://github.com/mgroenhoff>
// Jessica Franco <https://github.com/Jessidhia>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
import {GeneratorOptions} from '@babel/generator';
import traverse, {Visitor, NodePath} from '@babel/traverse';
import template from '@babel/template';
import * as t from '@babel/types';
import {ParserOptions} from '@babel/parser';
export {ParserOptions, GeneratorOptions, t as types, template, traverse, NodePath, Visitor};
export type Node = t.Node;
export type ParseResult = t.File | t.Program;
export const version: string;
export const DEFAULT_EXTENSIONS: ['.js', '.jsx', '.es6', '.es', '.mjs'];
export interface TransformOptions {
/**
* Include the AST in the returned object
*
* Default: `false`
*/
ast?: boolean|null;
/**
* Attach a comment after all non-user injected code
*
* Default: `null`
*/
auxiliaryCommentAfter?: string|null;
/**
* Attach a comment before all non-user injected code
*
* Default: `null`
*/
auxiliaryCommentBefore?: string|null;
/**
* Specify the "root" folder that defines the location to search for "babel.config.js", and the
* default folder to allow `.babelrc` files inside of.
*
* Default: `"."`
*/
root?: string|null;
/**
* This option, combined with the "root" value, defines how Babel chooses its project root.
* The different modes define different ways that Babel can process the "root" value to get
* the final project root.
*
* @see https://babeljs.io/docs/en/next/options#rootmode
*/
rootMode?: 'root'|'upward'|'upward-optional';
/**
* The config file to load Babel's config from. Defaults to searching for "babel.config.js"
* inside the "root" folder. `false` will disable searching for config files.
*
* Default: `undefined`
*/
configFile?: string|false|null;
/**
* Specify whether or not to use .babelrc and
* .babelignore files.
*
* Default: `true`
*/
babelrc?: boolean|null;
/**
* Specify which packages should be search for .babelrc files when they are being compiled.
* `true` to always search, or a path string or an array of paths to packages to search
* inside of. Defaults to only searching the "root" package.
*
* Default: `(root)`
*/
babelrcRoots?: true|string|string[]|null;
/**
* Defaults to environment variable `BABEL_ENV` if set, or else `NODE_ENV` if set, or else it
* defaults to `"development"`
*
* Default: env vars
*/
envName?: string;
/**
* Enable code generation
*
* Default: `true`
*/
code?: boolean|null;
/**
* Output comments in generated output
*
* Default: `true`
*/
comments?: boolean|null;
/**
* Do not include superfluous whitespace characters and line terminators. When set to `"auto"`
* compact is set to `true` on input sizes of >500KB
*
* Default: `"auto"`
*/
compact?: boolean|'auto'|null;
/**
* The working directory that Babel's programmatic options are loaded relative to.
*
* Default: `"."`
*/
cwd?: string|null;
/**
* Utilities may pass a caller object to identify themselves to Babel and
* pass capability-related flags for use by configs, presets and plugins.
*
* @see https://babeljs.io/docs/en/next/options#caller
*/
caller?: TransformCaller;
/**
* This is an object of keys that represent different environments. For example, you may have:
* `{ env: { production: { \/* specific options *\/ } } }`
* which will use those options when the `envName` is `production`
*
* Default: `{}`
*/
env?: {[index: string]: TransformOptions | null | undefined;}|null;
/**
* A path to a `.babelrc` file to extend
*
* Default: `null`
*/
extends?: string|null;
/**
* Filename for use in errors etc
*
* Default: `"unknown"`
*/
filename?: string|null;
/**
* Filename relative to `sourceRoot`
*
* Default: `(filename)`
*/
filenameRelative?: string|null;
/**
* An object containing the options to be passed down to the babel code generator,
* @babel/generator
*
* Default: `{}`
*/
generatorOpts?: GeneratorOptions|null;
/**
* 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
*
* Default: `null`
*/
getModuleId?: ((moduleName: string) => string | null | undefined)|null;
/**
* ANSI highlight syntax error code frames
*
* Default: `true`
*/
highlightCode?: boolean|null;
/**
* Opposite to the `only` option. `ignore` is disregarded if `only` is specified
*
* Default: `null`
*/
ignore?: string[]|null;
/**
* A source map object that the output source map will be based on
*
* Default: `null`
*/
inputSourceMap?: object|null;
/**
* Should the output be minified (not printing last semicolons in blocks, printing literal
* string values instead of escaped ones, stripping `()` from `new` when safe)
*
* Default: `false`
*/
minified?: boolean|null;
/**
* Specify a custom name for module ids
*
* Default: `null`
*/
moduleId?: string|null;
/**
* If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not
* available for `common` modules)
*
* Default: `false`
*/
moduleIds?: boolean|null;
/**
* Optional prefix for the AMD module formatter that will be prepend to the filename on module
* definitions
*
* Default: `(sourceRoot)`
*/
moduleRoot?: string|null;
/**
* 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
*
* Default: `null`
*/
only?: string|RegExp|Array<string|RegExp>|null;
/**
* An object containing the options to be passed down to the babel parser, @babel/parser
*
* Default: `{}`
*/
parserOpts?: ParserOptions|null;
/**
* List of plugins to load and use
*
* Default: `[]`
*/
plugins?: PluginItem[]|null;
/**
* List of presets (a set of plugins) to load and use
*
* Default: `[]`
*/
presets?: PluginItem[]|null;
/**
* Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't
* use source maps. (**NOTE**: This will not retain the columns)
*
* Default: `false`
*/
retainLines?: boolean|null;
/**
* An optional callback that controls whether a comment should be output or not. Called as
* `shouldPrintComment(commentContents)`. **NOTE**: This overrides the `comment` option when
* used
*
* Default: `null`
*/
shouldPrintComment?: ((commentContents: string) => boolean)|null;
/**
* Set `sources[0]` on returned source map
*
* Default: `(filenameRelative)`
*/
sourceFileName?: string|null;
/**
* If truthy, adds a `map` property to returned output. If set to `"inline"`, a comment with a
* sourceMappingURL directive is added to the bottom of the returned code. If set to `"both"`
* then a `map` property is returned as well as a source map comment appended. **This does not
* emit sourcemap files by itself!**
*
* Default: `false`
*/
sourceMaps?: boolean|'inline'|'both'|null;
/**
* The root from which all sources are relative
*
* Default: `(moduleRoot)`
*/
sourceRoot?: string|null;
/**
* Indicate the mode the code should be parsed in. Can be one of "script", "module", or
* "unambiguous". `"unambiguous"` will make Babel attempt to guess, based on the presence of ES6
* `import` or `export` statements. Files with ES6 `import`s and `export`s are considered
* `"module"` and are otherwise `"script"`.
*
* Default: `("module")`
*/
sourceType?: 'script'|'module'|'unambiguous'|null;
/**
* 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. Called as
* `wrapPluginVisitorMethod(pluginAlias, visitorType, callback)`.
*/
wrapPluginVisitorMethod?:
((pluginAlias: string, visitorType: 'enter'|'exit',
callback:
(path: NodePath, state: any) => void) => (path: NodePath, state: any) => void)|null;
}
export interface TransformCaller {
// the only required property
name: string;
// e.g. set to true by `babel-loader` and false by `babel-jest`
supportsStaticESM?: boolean;
// augment this with a "declare module '@babel/core' { ... }" if you need more keys
}
export type FileResultCallback = (err: Error | null, result: BabelFileResult | null) => any;
/**
* Transforms the passed in code. Calling a callback with an object with the generated code,
* source map, and AST.
*/
export function transform(code: string, callback: FileResultCallback): void;
/**
* Transforms the passed in code. Calling a callback with an object with the generated code,
* source map, and AST.
*/
export function transform(
code: string, opts: TransformOptions | undefined, callback: FileResultCallback): void;
/**
* Here for backward-compatibility. Ideally use `transformSync` if you want a synchronous API.
*/
export function transform(code: string, opts?: TransformOptions): BabelFileResult|null;
/**
* Transforms the passed in code. Returning an object with the generated code, source map, and
* AST.
*/
export function transformSync(code: string, opts?: TransformOptions): BabelFileResult|null;
/**
* Transforms the passed in code. Calling a callback with an object with the generated code,
* source map, and AST.
*/
export function transformAsync(
code: string, opts?: TransformOptions): Promise<BabelFileResult|null>;
/**
* Asynchronously transforms the entire contents of a file.
*/
export function transformFile(filename: string, callback: FileResultCallback): void;
/**
* Asynchronously transforms the entire contents of a file.
*/
export function transformFile(
filename: string, opts: TransformOptions | undefined, callback: FileResultCallback): void;
/**
* Synchronous version of `babel.transformFile`. Returns the transformed contents of the
* `filename`.
*/
export function transformFileSync(filename: string, opts?: TransformOptions): BabelFileResult|
null;
/**
* Asynchronously transforms the entire contents of a file.
*/
export function transformFileAsync(
filename: string, opts?: TransformOptions): Promise<BabelFileResult|null>;
/**
* Given an AST, transform it.
*/
export function transformFromAst(
ast: Node, code: string | undefined, callback: FileResultCallback): void;
/**
* Given an AST, transform it.
*/
export function transformFromAst(
ast: Node, code: string | undefined, opts: TransformOptions | undefined,
callback: FileResultCallback): void;
/**
* Here for backward-compatibility. Ideally use ".transformSync" if you want a synchronous API.
*/
export function transformFromAstSync(
ast: Node, code?: string, opts?: TransformOptions): BabelFileResult|null;
/**
* Given an AST, transform it.
*/
export function transformFromAstAsync(
ast: Node, code?: string, opts?: TransformOptions): Promise<BabelFileResult|null>;
// A babel plugin is a simple function which must return an object matching
// the following interface. Babel will throw if it finds unknown properties.
// The list of allowed plugin keys is here:
// https://github.com/babel/babel/blob/4e50b2d9d9c376cee7a2cbf56553fe5b982ea53c/packages/babel-core/src/config/option-manager.js#L71
export interface PluginObj<S = {}> {
name?: string;
manipulateOptions?(opts: any, parserOpts: any): void;
pre?(this: S, state: any): void;
visitor: Visitor<S>;
post?(this: S, state: any): void;
inherits?: any;
}
export interface BabelFileResult {
ast?: t.File|null;
code?: string|null;
ignored?: boolean;
map?: {
version: number; sources: string[]; names: string[]; sourceRoot?: string;
sourcesContent?: string[];
mappings: string;
file: string;
}|null;
metadata?: BabelFileMetadata;
}
export interface BabelFileMetadata {
usedHelpers: string[];
marked: Array < {
type: string;
message: string;
loc: object;
}
> ;
modules: BabelFileModulesMetadata;
}
export interface BabelFileModulesMetadata {
imports: object[];
exports: {exported: object[]; specifiers: object[];};
}
export type FileParseCallback = (err: Error | null, result: ParseResult | null) => any;
/**
* Given some code, parse it using Babel's standard behavior.
* Referenced presets and plugins will be loaded such that optional syntax plugins are
* automatically enabled.
*/
export function parse(code: string, callback: FileParseCallback): void;
/**
* Given some code, parse it using Babel's standard behavior.
* Referenced presets and plugins will be loaded such that optional syntax plugins are
* automatically enabled.
*/
export function parse(
code: string, options: TransformOptions | undefined, callback: FileParseCallback): void;
/**
* Given some code, parse it using Babel's standard behavior.
* Referenced presets and plugins will be loaded such that optional syntax plugins are
* automatically enabled.
*/
export function parse(code: string, options?: TransformOptions): ParseResult|null;
/**
* Given some code, parse it using Babel's standard behavior.
* Referenced presets and plugins will be loaded such that optional syntax plugins are
* automatically enabled.
*/
export function parseSync(code: string, options?: TransformOptions): ParseResult|null;
/**
* Given some code, parse it using Babel's standard behavior.
* Referenced presets and plugins will be loaded such that optional syntax plugins are
* automatically enabled.
*/
export function parseAsync(code: string, options?: TransformOptions): Promise<ParseResult|null>;
/**
* Resolve Babel's options fully, resulting in an options object where:
*
* * opts.plugins is a full list of Plugin instances.
* * opts.presets is empty and all presets are flattened into opts.
* * It can be safely passed back to Babel. Fields like babelrc have been set to false so that
* later calls to Babel
* will not make a second attempt to load config files.
*
* Plugin instances aren't meant to be manipulated directly, but often callers will serialize this
* opts to JSON to
* use it as a cache key representing the options Babel has received. Caching on this isn't 100%
* guaranteed to
* invalidate properly, but it is the best we have at the moment.
*/
export function loadOptions(options?: TransformOptions): object|null;
/**
* To allow systems to easily manipulate and validate a user's config, this function resolves the
* plugins and
* presets and proceeds no further. The expectation is that callers will take the config's
* .options, manipulate it
* as then see fit and pass it back to Babel again.
*
* * `babelrc: string | void` - The path of the `.babelrc` file, if there was one.
* * `babelignore: string | void` - The path of the `.babelignore` file, if there was one.
* * `options: ValidatedOptions` - The partially resolved options, which can be manipulated and
* passed back
* to Babel again.
* * `plugins: Array<ConfigItem>` - See below.
* * `presets: Array<ConfigItem>` - See below.
* * It can be safely passed back to Babel. Fields like `babelrc` have been set to false so that
* later calls to
* Babel will not make a second attempt to load config files.
*
* `ConfigItem` instances expose properties to introspect the values, but each item should be
* treated as
* immutable. If changes are desired, the item should be removed from the list and replaced with
* either a normal
* Babel config value, or with a replacement item created by `babel.createConfigItem`. See that
* function for
* information about `ConfigItem` fields.
*/
export function loadPartialConfig(options?: TransformOptions): Readonly<PartialConfig>|null;
export interface PartialConfig {
options: TransformOptions;
babelrc?: string;
babelignore?: string;
config?: string;
}
export interface ConfigItem {
/**
* The name that the user gave the plugin instance, e.g. `plugins: [ ['env', {}, 'my-env'] ]`
*/
name?: string;
/**
* The resolved value of the plugin.
*/
value: object|((...args: any[]) => any);
/**
* The options object passed to the plugin.
*/
options?: object|false;
/**
* The path that the options are relative to.
*/
dirname: string;
/**
* Information about the plugin's file, if Babel knows it.
* *
*/
file?: {
/**
* The file that the user requested, e.g. `"@babel/env"`
*/
request: string;
/**
* The full path of the resolved file, e.g.
* `"/tmp/node_modules/@babel/preset-env/lib/index.js"`
*/
resolved: string;
}|null;
}
export type PluginOptions = object | undefined | false;
export type PluginTarget = string | object | ((...args: any[]) => any);
export type PluginItem = ConfigItem | PluginObj<any>| PluginTarget |
[PluginTarget, PluginOptions] | [PluginTarget, PluginOptions, string | undefined];
export interface CreateConfigItemOptions {
dirname?: string;
type?: 'preset'|'plugin';
}
/**
* Allows build tooling to create and cache config items up front. If this function is called
* multiple times for a
* given plugin, Babel will call the plugin's function itself multiple times. If you have a clear
* set of expected
* plugins and presets to inject, pre-constructing the config items would be recommended.
*/
export function createConfigItem(
value: PluginTarget | [PluginTarget, PluginOptions] |
[PluginTarget, PluginOptions, string | undefined],
options?: CreateConfigItemOptions): ConfigItem;
// NOTE: the documentation says the ConfigAPI also exposes @babel/core's exports, but it actually
// doesn't
/**
* @see https://babeljs.io/docs/en/next/config-files#config-function-api
*/
export interface ConfigAPI {
/**
* The version string for the Babel version that is loading the config file.
*
* @see https://babeljs.io/docs/en/next/config-files#apiversion
*/
version: string;
/**
* @see https://babeljs.io/docs/en/next/config-files#apicache
*/
cache: SimpleCacheConfigurator;
/**
* @see https://babeljs.io/docs/en/next/config-files#apienv
*/
env: EnvFunction;
// undocumented; currently hardcoded to return 'false'
// async(): boolean
/**
* This API is used as a way to access the `caller` data that has been passed to Babel.
* Since many instances of Babel may be running in the same process with different `caller` values,
* this API is designed to automatically configure `api.cache`, the same way `api.env()` does.
*
* The `caller` value is available as the first parameter of the callback function.
* It is best used with something like this to toggle configuration behavior
* based on a specific environment:
*
* @example
* function isBabelRegister(caller?: { name: string }) {
* return !!(caller && caller.name === "@babel/register")
* }
* api.caller(isBabelRegister)
*
* @see https://babeljs.io/docs/en/next/config-files#apicallercb
*/
caller<T extends SimpleCacheKey>(callerCallback: (caller: TransformOptions['caller']) => T): T;
/**
* While `api.version` can be useful in general, it's sometimes nice to just declare your version.
* This API exposes a simple way to do that with:
*
* @example
* api.assertVersion(7) // major version only
* api.assertVersion("^7.2")
*
* @see https://babeljs.io/docs/en/next/config-files#apiassertversionrange
*/
assertVersion(versionRange: number|string): boolean;
// NOTE: this is an undocumented reexport from "@babel/parser" but it's missing from its types
// tokTypes: typeof tokTypes
}
/**
* JS configs are great because they can compute a config on the fly,
* but the downside there is that it makes caching harder.
* Babel wants to avoid re-executing the config function every time a file is compiled,
* because then it would also need to re-execute any plugin and preset functions
* referenced in that config.
*
* To avoid this, Babel expects users of config functions to tell it how to manage caching
* within a config file.
*
* @see https://babeljs.io/docs/en/next/config-files#apicache
*/
export interface SimpleCacheConfigurator {
// there is an undocumented call signature that is a shorthand for forever()/never()/using().
// (ever: boolean): void
// <T extends SimpleCacheKey>(callback: CacheCallback<T>): T
/**
* Permacache the computed config and never call the function again.
*/
forever(): void;
/**
* Do not cache this config, and re-execute the function every time.
*/
never(): void;
/**
* Any time the using callback returns a value other than the one that was expected,
* the overall config function will be called again and a new entry will be added to the cache.
*
* @example
* api.cache.using(() => process.env.NODE_ENV)
*/
using<T extends SimpleCacheKey>(callback: SimpleCacheCallback<T>): T;
/**
* Any time the using callback returns a value other than the one that was expected,
* the overall config function will be called again and all entries in the cache will
* be replaced with the result.
*
* @example
* api.cache.invalidate(() => process.env.NODE_ENV)
*/
invalidate<T extends SimpleCacheKey>(callback: SimpleCacheCallback<T>): T;
}
// https://github.com/babel/babel/blob/v7.3.3/packages/babel-core/src/config/caching.js#L231
export type SimpleCacheKey = string | boolean | number | null | undefined;
export type SimpleCacheCallback<T extends SimpleCacheKey> = () => T;
/**
* Since `NODE_ENV` is a fairly common way to toggle behavior, Babel also includes an API function
* meant specifically for that. This API is used as a quick way to check the `"envName"` that Babel
* was loaded with, which takes `NODE_ENV` into account if no other overriding environment is set.
*
* @see https://babeljs.io/docs/en/next/config-files#apienv
*/
export interface EnvFunction {
/**
* @returns the current `envName` string
*/
(): string;
/**
* @returns `true` if the `envName` is `===` any of the given strings
*/
(envName: string|ReadonlyArray<string>): boolean;
// the official documentation is misleading for this one...
// this just passes the callback to `cache.using` but with an additional argument.
// it returns its result instead of necessarily returning a boolean.
<T extends SimpleCacheKey>(
envCallback: (envName: NonNullable<TransformOptions['envName']>) => T): T;
}
export type ConfigFunction = (api: ConfigAPI) => TransformOptions;
}

View File

@ -1,123 +0,0 @@
declare module '@babel/generator' {
// Type definitions for @babel/generator 7.0
// Project: https://github.com/babel/babel/tree/master/packages/babel-generator,
// https://babeljs.io
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Johnny Estilles <https://github.com/johnnyestilles>
// Melvin Groenhoff <https://github.com/mgroenhoff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
import * as t from '@babel/types';
export interface GeneratorOptions {
/**
* Optional string to add as a block comment at the start of the output file.
*/
auxiliaryCommentBefore?: string;
/**
* Optional string to add as a block comment at the end of the output file.
*/
auxiliaryCommentAfter?: string;
/**
* Function that takes a comment (as a string) and returns true if the comment should be
* included in the output.
* By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is
* `false` and the comment
* contains `@preserve` or `@license`.
*/
shouldPrintComment?(comment: string): boolean;
/**
* Attempt to use the same line numbers in the output code as in the source code (helps preserve
* stack traces).
* Defaults to `false`.
*/
retainLines?: boolean;
/**
* Should comments be included in output? Defaults to `true`.
*/
comments?: boolean;
/**
* Set to true to avoid adding whitespace for formatting. Defaults to the value of
* `opts.minified`.
*/
compact?: boolean|'auto';
/**
* Should the output be minified. Defaults to `false`.
*/
minified?: boolean;
/**
* Set to true to reduce whitespace (but not as much as opts.compact). Defaults to `false`.
*/
concise?: boolean;
/**
* The type of quote to use in the output. If omitted, autodetects based on `ast.tokens`.
*/
quotes?: 'single'|'double';
/**
* Used in warning messages
*/
filename?: string;
/**
* Enable generating source maps. Defaults to `false`.
*/
sourceMaps?: boolean;
/**
* The filename of the generated code that the source map will be associated with.
*/
sourceMapTarget?: string;
/**
* A root for all relative URLs in the source map.
*/
sourceRoot?: string;
/**
* The filename for the source code (i.e. the code in the `code` argument).
* This will only be used if `code` is a string.
*/
sourceFileName?: string;
/**
* Set to true to run jsesc with "json": true to print "\u00A9" vs. "©";
*/
jsonCompatibleStrings?: boolean;
}
export class CodeGenerator {
constructor(ast: t.Node, opts?: GeneratorOptions, code?: string);
generate(): GeneratorResult;
}
/**
* Turns an AST into code, maintaining sourcemaps, user preferences, and valid output.
* @param ast - the abstract syntax tree from which to generate output code.
* @param opts - used for specifying options for code generation.
* @param code - the original source code, used for source maps.
* @returns - an object containing the output code and source map.
*/
export default function generate(ast: t.Node, opts?: GeneratorOptions, code?: string | {
[filename: string]: string;
}): GeneratorResult;
export interface GeneratorResult {
code: string;
map: {
version: number; sources: string[]; names: string[]; sourceRoot?: string;
sourcesContent?: string[];
mappings: string;
file: string;
}|null;
}
}

View File

@ -1,78 +0,0 @@
declare module '@babel/template' {
// Type definitions for @babel/template 7.0
// Project: https://github.com/babel/babel/tree/master/packages/babel-template, https://babeljs.io
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Melvin Groenhoff <https://github.com/mgroenhoff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
import {ParserOptions} from '@babel/parser';
import {Expression, File, Program, Statement} from '@babel/types';
export interface TemplateBuilderOptions extends ParserOptions {
/**
* A set of placeholder names to automatically accept. Items in this list do not need to match
* the given placeholder pattern.
*/
placeholderWhitelist?: Set<string>;
/**
* A pattern to search for when looking for Identifier and StringLiteral nodes that should be
* considered placeholders. `false` will
* disable placeholder searching entirely, leaving only the `placeholderWhitelist` value to find
* placeholders.
*/
placeholderPattern?: RegExp|false;
/**
* Set this to `true` to preserve any comments from the `code` parameter.
*/
preserveComments?: boolean;
}
export interface TemplateBuilder<T> {
/**
* Build a new builder, merging the given options with the previous ones.
*/
(opts: TemplateBuilderOptions): TemplateBuilder<T>;
/**
* Building from a string produces an AST builder function by default.
*/
(code: string, opts?: TemplateBuilderOptions): (arg?: PublicReplacements) => T;
/**
* Building from a template literal produces an AST builder function by default.
*/
(tpl: TemplateStringsArray, ...args: any[]): (arg?: PublicReplacements) => T;
// Allow users to explicitly create templates that produce ASTs, skipping the need for an
// intermediate function.
ast: {
(tpl: string, opts?: TemplateBuilderOptions): T;
(tpl: TemplateStringsArray, ...args: any[]): T;
};
}
export type PublicReplacements = {[index: string]: any;} | any[];
export const smart: TemplateBuilder<Statement|Statement[]>;
export const statement: TemplateBuilder<Statement>;
export const statements: TemplateBuilder<Statement[]>;
export const expression: TemplateBuilder<Expression>;
export const program: TemplateBuilder<Program>;
type DefaultTemplateBuilder = typeof smart & {
smart: typeof smart;
statement: typeof statement;
statements: typeof statements;
expression: typeof expression;
program: typeof program;
ast: typeof smart.ast;
};
const templateBuilder: DefaultTemplateBuilder;
export default templateBuilder;
}

View File

@ -1,827 +0,0 @@
declare module '@babel/traverse' {
// Type definitions for @babel/traverse 7.0
// Project: https://github.com/babel/babel/tree/master/packages/babel-traverse, https://babeljs.io
// Definitions by: Troy Gerwien <https://github.com/yortus>
// Marvin Hagemeister <https://github.com/marvinhagemeister>
// Ryan Petrich <https://github.com/rpetrich>
// Melvin Groenhoff <https://github.com/mgroenhoff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.9
import * as t from '@babel/types';
export type Node = t.Node;
export default function traverse<S>(
parent: Node | Node[], opts: TraverseOptions<S>, scope: Scope | undefined, state: S,
parentPath?: NodePath, ): void;
export default function traverse(
parent: Node | Node[], opts: TraverseOptions, scope?: Scope, state?: any,
parentPath?: NodePath, ): void;
export interface TraverseOptions<S = Node> extends Visitor<S> {
scope?: Scope;
noScope?: boolean;
}
export class Scope {
constructor(path: NodePath, parentScope?: Scope);
path: NodePath;
block: Node;
parentBlock: Node;
parent: Scope;
hub: Hub;
bindings: {[name: string]: Binding;};
/** Traverse node with current scope and path. */
traverse<S>(node: Node|Node[], opts: TraverseOptions<S>, state: S): void;
traverse(node: Node|Node[], opts?: TraverseOptions, state?: any): void;
/** Generate a unique identifier and add it to the current scope. */
generateDeclaredUidIdentifier(name?: string): t.Identifier;
/** Generate a unique identifier. */
generateUidIdentifier(name?: string): t.Identifier;
/** Generate a unique `_id1` binding. */
generateUid(name?: string): string;
/** Generate a unique identifier based on a node. */
generateUidIdentifierBasedOnNode(parent: Node, defaultName?: string): t.Identifier;
/**
* Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
* evaluating it wont result in potentially arbitrary code from being ran. The following are
* whitelisted and determined not to cause side effects:
*
* - `this` expressions
* - `super` expressions
* - Bound identifiers
*/
isStatic(node: Node): boolean;
/** Possibly generate a memoised identifier if it is not static and has consequences. */
maybeGenerateMemoised(node: Node, dontPush?: boolean): t.Identifier;
checkBlockScopedCollisions(local: Node, kind: string, name: string, id: object): void;
rename(oldName: string, newName?: string, block?: Node): void;
dump(): void;
toArray(node: Node, i?: number): Node;
registerDeclaration(path: NodePath): void;
buildUndefinedNode(): Node;
registerConstantViolation(path: NodePath): void;
registerBinding(kind: string, path: NodePath, bindingPath?: NodePath): void;
addGlobal(node: Node): void;
hasUid(name: string): boolean;
hasGlobal(name: string): boolean;
hasReference(name: string): boolean;
isPure(node: Node, constantsOnly?: boolean): boolean;
setData(key: string, val: any): any;
getData(key: string): any;
removeData(key: string): void;
push(opts: {
id: t.LVal,
init?: t.Expression,
unique?: boolean,
kind?: 'var'|'let'|'const',
}): void;
getProgramParent(): Scope;
getFunctionParent(): Scope|null;
getBlockParent(): Scope;
/** Walks the scope tree and gathers **all** bindings. */
getAllBindings(...kinds: string[]): object;
bindingIdentifierEquals(name: string, node: Node): boolean;
getBinding(name: string): Binding|undefined;
getOwnBinding(name: string): Binding|undefined;
getBindingIdentifier(name: string): t.Identifier;
getOwnBindingIdentifier(name: string): t.Identifier;
hasOwnBinding(name: string): boolean;
hasBinding(name: string, noGlobals?: boolean): boolean;
parentHasBinding(name: string, noGlobals?: boolean): boolean;
/** Move a binding of `name` to another `scope`. */
moveBindingTo(name: string, scope: Scope): void;
removeOwnBinding(name: string): void;
removeBinding(name: string): void;
}
export class Binding {
constructor(opts: {
existing: Binding; identifier: t.Identifier; scope: Scope; path: NodePath;
kind: 'var' | 'let' | 'const';
});
identifier: t.Identifier;
scope: Scope;
path: NodePath;
kind: 'var'|'let'|'const'|'module';
referenced: boolean;
references: number;
referencePaths: NodePath[];
constant: boolean;
constantViolations: NodePath[];
}
export type Visitor<S = {}> = VisitNodeObject<S, Node>& {
[Type in Node['type']]?: VisitNode < S, Extract < Node, { type: Type; }
>> ;
}
&{[K in keyof t.Aliases]?: VisitNode<S, t.Aliases[K]>};
export type VisitNode<S, P> = VisitNodeFunction<S, P>| VisitNodeObject<S, P>;
export type VisitNodeFunction<S, P> = (this: S, path: NodePath<P>, state: S) => void;
export interface VisitNodeObject<S, P> {
enter?: VisitNodeFunction<S, P>;
exit?: VisitNodeFunction<S, P>;
}
export class NodePath<T = Node> {
constructor(hub: Hub, parent: Node);
parent: Node;
hub: Hub;
contexts: TraversalContext[];
data: object;
shouldSkip: boolean;
shouldStop: boolean;
removed: boolean;
state: any;
opts: object;
skipKeys: object;
parentPath: NodePath;
context: TraversalContext;
container: object|object[];
listKey: string;
inList: boolean;
parentKey: string;
key: string|number;
node: T;
scope: Scope;
type: T extends undefined|null? string|null: string;
typeAnnotation: object;
getScope(scope: Scope): Scope;
setData(key: string, val: any): any;
getData(key: string, def?: any): any;
buildCodeFrameError<TError extends Error>(msg: string, Error?: new (msg: string) => TError):
TError;
traverse<T>(visitor: Visitor<T>, state: T): void;
traverse(visitor: Visitor): void;
set(key: string, node: Node): void;
getPathLocation(): string;
// Example:
// https://github.com/babel/babel/blob/63204ae51e020d84a5b246312f5eeb4d981ab952/packages/babel-traverse/src/path/modification.js#L83
debug(buildMessage: () => string): void;
// ------------------------- ancestry -------------------------
/**
* Call the provided `callback` with the `NodePath`s of all the parents.
* When the `callback` returns a truthy value, we return that node path.
*/
findParent(callback: (path: NodePath) => boolean): NodePath;
find(callback: (path: NodePath) => boolean): NodePath;
/** Get the parent function of the current path. */
getFunctionParent(): NodePath<t.Function>;
/** Walk up the tree until we hit a parent node path in a list. */
getStatementParent(): NodePath<t.Statement>;
/**
* Get the deepest common ancestor and then from it, get the earliest relationship path
* to that ancestor.
*
* Earliest is defined as being "before" all the other nodes in terms of list container
* position and visiting key.
*/
getEarliestCommonAncestorFrom(paths: NodePath[]): NodePath[];
/** Get the earliest path in the tree where the provided `paths` intersect. */
getDeepestCommonAncestorFrom(
paths: NodePath[],
filter?: (deepest: Node, i: number, ancestries: NodePath[]) => NodePath): NodePath;
/**
* Build an array of node paths containing the entire ancestry of the current node path.
*
* NOTE: The current node path is included in this.
*/
getAncestry(): NodePath[];
inType(...candidateTypes: string[]): boolean;
// ------------------------- inference -------------------------
/** Infer the type of the current `NodePath`. */
getTypeAnnotation(): t.FlowType;
isBaseType(baseName: string, soft?: boolean): boolean;
couldBeBaseType(name: string): boolean;
baseTypeStrictlyMatches(right: NodePath): boolean;
isGenericType(genericName: string): boolean;
// ------------------------- replacement -------------------------
/**
* Replace a node with an array of multiple. This method performs the following steps:
*
* - Inherit the comments of first provided node with that of the current node.
* - Insert the provided nodes after the current node.
* - Remove the current node.
*/
replaceWithMultiple(nodes: Node[]): void;
/**
* Parse a string as an expression and replace the current node with the result.
*
* NOTE: This is typically not a good idea to use. Building source strings when
* transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's
* easier to use, your transforms will be extremely brittle.
*/
replaceWithSourceString(replacement: any): void;
/** Replace the current node with another. */
replaceWith(replacement: Node|NodePath): void;
/**
* This method takes an array of statements nodes and then explodes it
* into expressions. This method retains completion records which is
* extremely important to retain original semantics.
*/
replaceExpressionWithStatements(nodes: Node[]): Node;
replaceInline(nodes: Node|Node[]): void;
// ------------------------- evaluation -------------------------
/**
* Walk the input `node` and statically evaluate if it's truthy.
*
* Returning `true` when we're sure that the expression will evaluate to a
* truthy value, `false` if we're sure that it will evaluate to a falsy
* value and `undefined` if we aren't sure. Because of this please do not
* rely on coercion when using this method and check with === if it's false.
*/
evaluateTruthy(): boolean;
/**
* Walk the input `node` and statically evaluate it.
*
* Returns an object in the form `{ confident, value }`. `confident` indicates
* whether or not we had to drop out of evaluating the expression because of
* hitting an unknown node that we couldn't confidently find the value of.
*
* Example:
*
* t.evaluate(parse("5 + 5")) // { confident: true, value: 10 }
* t.evaluate(parse("!true")) // { confident: true, value: false }
* t.evaluate(parse("foo + foo")) // { confident: false, value: undefined }
*/
evaluate(): {confident: boolean; value: any};
// ------------------------- introspection -------------------------
/**
* Match the current node if it matches the provided `pattern`.
*
* For example, given the match `React.createClass` it would match the
* parsed nodes of `React.createClass` and `React["createClass"]`.
*/
matchesPattern(pattern: string, allowPartial?: boolean): boolean;
/**
* Check whether we have the input `key`. If the `key` references an array then we check
* if the array has any items, otherwise we just check if it's falsy.
*/
has(key: string): boolean;
isStatic(): boolean;
/** Alias of `has`. */
is(key: string): boolean;
/** Opposite of `has`. */
isnt(key: string): boolean;
/** Check whether the path node `key` strict equals `value`. */
equals(key: string, value: any): boolean;
/**
* Check the type against our stored internal type of the node. This is handy when a node has
* been removed yet we still internally know the type and need it to calculate node replacement.
*/
isNodeType(type: string): boolean;
/**
* This checks whether or not we're in one of the following positions:
*
* for (KEY in right);
* for (KEY;;);
*
* This is because these spots allow VariableDeclarations AND normal expressions so we need
* to tell the path replacement that it's ok to replace this with an expression.
*/
canHaveVariableDeclarationOrExpression(): boolean;
/**
* This checks whether we are swapping an arrow function's body between an
* expression and a block statement (or vice versa).
*
* This is because arrow functions may implicitly return an expression, which
* is the same as containing a block statement.
*/
canSwapBetweenExpressionAndStatement(replacement: Node): boolean;
/** Check whether the current path references a completion record */
isCompletionRecord(allowInsideFunction?: boolean): boolean;
/**
* Check whether or not the current `key` allows either a single statement or block statement
* so we can explode it if necessary.
*/
isStatementOrBlock(): boolean;
/** Check if the currently assigned path references the `importName` of `moduleSource`. */
referencesImport(moduleSource: string, importName: string): boolean;
/** Get the source code associated with this node. */
getSource(): string;
/** Check if the current path will maybe execute before another path */
willIMaybeExecuteBefore(path: NodePath): boolean;
// ------------------------- context -------------------------
call(key: string): boolean;
isBlacklisted(): boolean;
visit(): boolean;
skip(): void;
skipKey(key: string): void;
stop(): void;
setScope(): void;
setContext(context: TraversalContext): NodePath<T>;
popContext(): void;
pushContext(context: TraversalContext): void;
// ------------------------- removal -------------------------
remove(): void;
// ------------------------- modification -------------------------
/** Insert the provided nodes before the current one. */
insertBefore(nodes: Node|Node[]): any;
/**
* Insert the provided nodes after the current one. When inserting nodes after an
* expression, ensure that the completion record is correct by pushing the current node.
*/
insertAfter(nodes: Node|Node[]): any;
/** Update all sibling node paths after `fromIndex` by `incrementBy`. */
updateSiblingKeys(fromIndex: number, incrementBy: number): void;
/** Hoist the current node to the highest scope possible and return a UID referencing it. */
hoist(scope: Scope): void;
// ------------------------- family -------------------------
getOpposite(): NodePath;
getCompletionRecords(): NodePath[];
getSibling(key: string|number): NodePath;
getAllPrevSiblings(): NodePath[];
getAllNextSiblings(): NodePath[];
get<K extends keyof T>(key: K, context?: boolean|TraversalContext):
T[K] extends Array<Node|null|undefined>? Array<NodePath<T[K][number]>>: T[K] extends Node
|null|undefined? NodePath<T[K]>: never;
get(key: string, context?: boolean|TraversalContext): NodePath|NodePath[];
getBindingIdentifiers(duplicates?: boolean): Node[];
getOuterBindingIdentifiers(duplicates?: boolean): Node[];
// ------------------------- comments -------------------------
/** Share comments amongst siblings. */
shareCommentsWithSiblings(): void;
addComment(type: string, content: string, line?: boolean): void;
/** Give node `comments` of the specified `type`. */
addComments(type: string, comments: any[]): void;
// ------------------------- isXXX -------------------------
isArrayExpression(opts?: object): this is NodePath<t.ArrayExpression>;
isAssignmentExpression(opts?: object): this is NodePath<t.AssignmentExpression>;
isBinaryExpression(opts?: object): this is NodePath<t.BinaryExpression>;
isDirective(opts?: object): this is NodePath<t.Directive>;
isDirectiveLiteral(opts?: object): this is NodePath<t.DirectiveLiteral>;
isBlockStatement(opts?: object): this is NodePath<t.BlockStatement>;
isBreakStatement(opts?: object): this is NodePath<t.BreakStatement>;
isCallExpression(opts?: object): this is NodePath<t.CallExpression>;
isCatchClause(opts?: object): this is NodePath<t.CatchClause>;
isConditionalExpression(opts?: object): this is NodePath<t.ConditionalExpression>;
isContinueStatement(opts?: object): this is NodePath<t.ContinueStatement>;
isDebuggerStatement(opts?: object): this is NodePath<t.DebuggerStatement>;
isDoWhileStatement(opts?: object): this is NodePath<t.DoWhileStatement>;
isEmptyStatement(opts?: object): this is NodePath<t.EmptyStatement>;
isExpressionStatement(opts?: object): this is NodePath<t.ExpressionStatement>;
isFile(opts?: object): this is NodePath<t.File>;
isForInStatement(opts?: object): this is NodePath<t.ForInStatement>;
isForStatement(opts?: object): this is NodePath<t.ForStatement>;
isFunctionDeclaration(opts?: object): this is NodePath<t.FunctionDeclaration>;
isFunctionExpression(opts?: object): this is NodePath<t.FunctionExpression>;
isIdentifier(opts?: object): this is NodePath<t.Identifier>;
isIfStatement(opts?: object): this is NodePath<t.IfStatement>;
isLabeledStatement(opts?: object): this is NodePath<t.LabeledStatement>;
isStringLiteral(opts?: object): this is NodePath<t.StringLiteral>;
isNumericLiteral(opts?: object): this is NodePath<t.NumericLiteral>;
isNullLiteral(opts?: object): this is NodePath<t.NullLiteral>;
isBooleanLiteral(opts?: object): this is NodePath<t.BooleanLiteral>;
isRegExpLiteral(opts?: object): this is NodePath<t.RegExpLiteral>;
isLogicalExpression(opts?: object): this is NodePath<t.LogicalExpression>;
isMemberExpression(opts?: object): this is NodePath<t.MemberExpression>;
isNewExpression(opts?: object): this is NodePath<t.NewExpression>;
isProgram(opts?: object): this is NodePath<t.Program>;
isObjectExpression(opts?: object): this is NodePath<t.ObjectExpression>;
isObjectMethod(opts?: object): this is NodePath<t.ObjectMethod>;
isObjectProperty(opts?: object): this is NodePath<t.ObjectProperty>;
isRestElement(opts?: object): this is NodePath<t.RestElement>;
isReturnStatement(opts?: object): this is NodePath<t.ReturnStatement>;
isSequenceExpression(opts?: object): this is NodePath<t.SequenceExpression>;
isSwitchCase(opts?: object): this is NodePath<t.SwitchCase>;
isSwitchStatement(opts?: object): this is NodePath<t.SwitchStatement>;
isThisExpression(opts?: object): this is NodePath<t.ThisExpression>;
isThrowStatement(opts?: object): this is NodePath<t.ThrowStatement>;
isTryStatement(opts?: object): this is NodePath<t.TryStatement>;
isUnaryExpression(opts?: object): this is NodePath<t.UnaryExpression>;
isUpdateExpression(opts?: object): this is NodePath<t.UpdateExpression>;
isVariableDeclaration(opts?: object): this is NodePath<t.VariableDeclaration>;
isVariableDeclarator(opts?: object): this is NodePath<t.VariableDeclarator>;
isWhileStatement(opts?: object): this is NodePath<t.WhileStatement>;
isWithStatement(opts?: object): this is NodePath<t.WithStatement>;
isAssignmentPattern(opts?: object): this is NodePath<t.AssignmentPattern>;
isArrayPattern(opts?: object): this is NodePath<t.ArrayPattern>;
isArrowFunctionExpression(opts?: object): this is NodePath<t.ArrowFunctionExpression>;
isClassBody(opts?: object): this is NodePath<t.ClassBody>;
isClassDeclaration(opts?: object): this is NodePath<t.ClassDeclaration>;
isClassExpression(opts?: object): this is NodePath<t.ClassExpression>;
isExportAllDeclaration(opts?: object): this is NodePath<t.ExportAllDeclaration>;
isExportDefaultDeclaration(opts?: object): this is NodePath<t.ExportDefaultDeclaration>;
isExportNamedDeclaration(opts?: object): this is NodePath<t.ExportNamedDeclaration>;
isExportSpecifier(opts?: object): this is NodePath<t.ExportSpecifier>;
isForOfStatement(opts?: object): this is NodePath<t.ForOfStatement>;
isImportDeclaration(opts?: object): this is NodePath<t.ImportDeclaration>;
isImportDefaultSpecifier(opts?: object): this is NodePath<t.ImportDefaultSpecifier>;
isImportNamespaceSpecifier(opts?: object): this is NodePath<t.ImportNamespaceSpecifier>;
isImportSpecifier(opts?: object): this is NodePath<t.ImportSpecifier>;
isMetaProperty(opts?: object): this is NodePath<t.MetaProperty>;
isClassMethod(opts?: object): this is NodePath<t.ClassMethod>;
isObjectPattern(opts?: object): this is NodePath<t.ObjectPattern>;
isSpreadElement(opts?: object): this is NodePath<t.SpreadElement>;
isSuper(opts?: object): this is NodePath<t.Super>;
isTaggedTemplateExpression(opts?: object): this is NodePath<t.TaggedTemplateExpression>;
isTemplateElement(opts?: object): this is NodePath<t.TemplateElement>;
isTemplateLiteral(opts?: object): this is NodePath<t.TemplateLiteral>;
isYieldExpression(opts?: object): this is NodePath<t.YieldExpression>;
isAnyTypeAnnotation(opts?: object): this is NodePath<t.AnyTypeAnnotation>;
isArrayTypeAnnotation(opts?: object): this is NodePath<t.ArrayTypeAnnotation>;
isBooleanTypeAnnotation(opts?: object): this is NodePath<t.BooleanTypeAnnotation>;
isBooleanLiteralTypeAnnotation(opts?: object): this is NodePath<t.BooleanLiteralTypeAnnotation>;
isNullLiteralTypeAnnotation(opts?: object): this is NodePath<t.NullLiteralTypeAnnotation>;
isClassImplements(opts?: object): this is NodePath<t.ClassImplements>;
isClassProperty(opts?: object): this is NodePath<t.ClassProperty>;
isDeclareClass(opts?: object): this is NodePath<t.DeclareClass>;
isDeclareFunction(opts?: object): this is NodePath<t.DeclareFunction>;
isDeclareInterface(opts?: object): this is NodePath<t.DeclareInterface>;
isDeclareModule(opts?: object): this is NodePath<t.DeclareModule>;
isDeclareTypeAlias(opts?: object): this is NodePath<t.DeclareTypeAlias>;
isDeclareVariable(opts?: object): this is NodePath<t.DeclareVariable>;
isFunctionTypeAnnotation(opts?: object): this is NodePath<t.FunctionTypeAnnotation>;
isFunctionTypeParam(opts?: object): this is NodePath<t.FunctionTypeParam>;
isGenericTypeAnnotation(opts?: object): this is NodePath<t.GenericTypeAnnotation>;
isInterfaceExtends(opts?: object): this is NodePath<t.InterfaceExtends>;
isInterfaceDeclaration(opts?: object): this is NodePath<t.InterfaceDeclaration>;
isIntersectionTypeAnnotation(opts?: object): this is NodePath<t.IntersectionTypeAnnotation>;
isMixedTypeAnnotation(opts?: object): this is NodePath<t.MixedTypeAnnotation>;
isNullableTypeAnnotation(opts?: object): this is NodePath<t.NullableTypeAnnotation>;
isNumberTypeAnnotation(opts?: object): this is NodePath<t.NumberTypeAnnotation>;
isStringLiteralTypeAnnotation(opts?: object): this is NodePath<t.StringLiteralTypeAnnotation>;
isStringTypeAnnotation(opts?: object): this is NodePath<t.StringTypeAnnotation>;
isThisTypeAnnotation(opts?: object): this is NodePath<t.ThisTypeAnnotation>;
isTupleTypeAnnotation(opts?: object): this is NodePath<t.TupleTypeAnnotation>;
isTypeofTypeAnnotation(opts?: object): this is NodePath<t.TypeofTypeAnnotation>;
isTypeAlias(opts?: object): this is NodePath<t.TypeAlias>;
isTypeAnnotation(opts?: object): this is NodePath<t.TypeAnnotation>;
isTypeCastExpression(opts?: object): this is NodePath<t.TypeCastExpression>;
isTypeParameterDeclaration(opts?: object): this is NodePath<t.TypeParameterDeclaration>;
isTypeParameterInstantiation(opts?: object): this is NodePath<t.TypeParameterInstantiation>;
isObjectTypeAnnotation(opts?: object): this is NodePath<t.ObjectTypeAnnotation>;
isObjectTypeCallProperty(opts?: object): this is NodePath<t.ObjectTypeCallProperty>;
isObjectTypeIndexer(opts?: object): this is NodePath<t.ObjectTypeIndexer>;
isObjectTypeProperty(opts?: object): this is NodePath<t.ObjectTypeProperty>;
isQualifiedTypeIdentifier(opts?: object): this is NodePath<t.QualifiedTypeIdentifier>;
isUnionTypeAnnotation(opts?: object): this is NodePath<t.UnionTypeAnnotation>;
isVoidTypeAnnotation(opts?: object): this is NodePath<t.VoidTypeAnnotation>;
isJSXAttribute(opts?: object): this is NodePath<t.JSXAttribute>;
isJSXClosingElement(opts?: object): this is NodePath<t.JSXClosingElement>;
isJSXElement(opts?: object): this is NodePath<t.JSXElement>;
isJSXEmptyExpression(opts?: object): this is NodePath<t.JSXEmptyExpression>;
isJSXExpressionContainer(opts?: object): this is NodePath<t.JSXExpressionContainer>;
isJSXIdentifier(opts?: object): this is NodePath<t.JSXIdentifier>;
isJSXMemberExpression(opts?: object): this is NodePath<t.JSXMemberExpression>;
isJSXNamespacedName(opts?: object): this is NodePath<t.JSXNamespacedName>;
isJSXOpeningElement(opts?: object): this is NodePath<t.JSXOpeningElement>;
isJSXSpreadAttribute(opts?: object): this is NodePath<t.JSXSpreadAttribute>;
isJSXText(opts?: object): this is NodePath<t.JSXText>;
isNoop(opts?: object): this is NodePath<t.Noop>;
isParenthesizedExpression(opts?: object): this is NodePath<t.ParenthesizedExpression>;
isAwaitExpression(opts?: object): this is NodePath<t.AwaitExpression>;
isBindExpression(opts?: object): this is NodePath<t.BindExpression>;
isDecorator(opts?: object): this is NodePath<t.Decorator>;
isDoExpression(opts?: object): this is NodePath<t.DoExpression>;
isExportDefaultSpecifier(opts?: object): this is NodePath<t.ExportDefaultSpecifier>;
isExportNamespaceSpecifier(opts?: object): this is NodePath<t.ExportNamespaceSpecifier>;
isRestProperty(opts?: object): this is NodePath<t.RestProperty>;
isSpreadProperty(opts?: object): this is NodePath<t.SpreadProperty>;
isExpression(opts?: object): this is NodePath<t.Expression>;
isBinary(opts?: object): this is NodePath<t.Binary>;
isScopable(opts?: object): this is NodePath<t.Scopable>;
isBlockParent(opts?: object): this is NodePath<t.BlockParent>;
isBlock(opts?: object): this is NodePath<t.Block>;
isStatement(opts?: object): this is NodePath<t.Statement>;
isTerminatorless(opts?: object): this is NodePath<t.Terminatorless>;
isCompletionStatement(opts?: object): this is NodePath<t.CompletionStatement>;
isConditional(opts?: object): this is NodePath<t.Conditional>;
isLoop(opts?: object): this is NodePath<t.Loop>;
isWhile(opts?: object): this is NodePath<t.While>;
isExpressionWrapper(opts?: object): this is NodePath<t.ExpressionWrapper>;
isFor(opts?: object): this is NodePath<t.For>;
isForXStatement(opts?: object): this is NodePath<t.ForXStatement>;
isFunction(opts?: object): this is NodePath<t.Function>;
isFunctionParent(opts?: object): this is NodePath<t.FunctionParent>;
isPureish(opts?: object): this is NodePath<t.Pureish>;
isDeclaration(opts?: object): this is NodePath<t.Declaration>;
isLVal(opts?: object): this is NodePath<t.LVal>;
isLiteral(opts?: object): this is NodePath<t.Literal>;
isImmutable(opts?: object): this is NodePath<t.Immutable>;
isUserWhitespacable(opts?: object): this is NodePath<t.UserWhitespacable>;
isMethod(opts?: object): this is NodePath<t.Method>;
isObjectMember(opts?: object): this is NodePath<t.ObjectMember>;
isProperty(opts?: object): this is NodePath<t.Property>;
isUnaryLike(opts?: object): this is NodePath<t.UnaryLike>;
isPattern(opts?: object): this is NodePath<t.Pattern>;
isClass(opts?: object): this is NodePath<t.Class>;
isModuleDeclaration(opts?: object): this is NodePath<t.ModuleDeclaration>;
isExportDeclaration(opts?: object): this is NodePath<t.ExportDeclaration>;
isModuleSpecifier(opts?: object): this is NodePath<t.ModuleSpecifier>;
isFlow(opts?: object): this is NodePath<t.Flow>;
isFlowBaseAnnotation(opts?: object): this is NodePath<t.FlowBaseAnnotation>;
isFlowDeclaration(opts?: object): this is NodePath<t.FlowDeclaration>;
isJSX(opts?: object): this is NodePath<t.JSX>;
isNumberLiteral(opts?: object): this is NodePath<t.NumericLiteral>;
isRegexLiteral(opts?: object): this is NodePath<t.RegExpLiteral>;
isReferencedIdentifier(opts?: object): this is NodePath<t.Identifier|t.JSXIdentifier>;
isReferencedMemberExpression(opts?: object): this is NodePath<t.MemberExpression>;
isBindingIdentifier(opts?: object): this is NodePath<t.Identifier>;
isScope(opts?: object): this is NodePath<t.Scopable>;
isReferenced(opts?: object): boolean;
isBlockScoped(opts?: object):
this is NodePath<t.FunctionDeclaration|t.ClassDeclaration|t.VariableDeclaration>;
isVar(opts?: object): this is NodePath<t.VariableDeclaration>;
isUser(opts?: object): boolean;
isGenerated(opts?: object): boolean;
isPure(opts?: object): boolean;
// ------------------------- assertXXX -------------------------
assertArrayExpression(opts?: object): void;
assertAssignmentExpression(opts?: object): void;
assertBinaryExpression(opts?: object): void;
assertDirective(opts?: object): void;
assertDirectiveLiteral(opts?: object): void;
assertBlockStatement(opts?: object): void;
assertBreakStatement(opts?: object): void;
assertCallExpression(opts?: object): void;
assertCatchClause(opts?: object): void;
assertConditionalExpression(opts?: object): void;
assertContinueStatement(opts?: object): void;
assertDebuggerStatement(opts?: object): void;
assertDoWhileStatement(opts?: object): void;
assertEmptyStatement(opts?: object): void;
assertExpressionStatement(opts?: object): void;
assertFile(opts?: object): void;
assertForInStatement(opts?: object): void;
assertForStatement(opts?: object): void;
assertFunctionDeclaration(opts?: object): void;
assertFunctionExpression(opts?: object): void;
assertIdentifier(opts?: object): void;
assertIfStatement(opts?: object): void;
assertLabeledStatement(opts?: object): void;
assertStringLiteral(opts?: object): void;
assertNumericLiteral(opts?: object): void;
assertNullLiteral(opts?: object): void;
assertBooleanLiteral(opts?: object): void;
assertRegExpLiteral(opts?: object): void;
assertLogicalExpression(opts?: object): void;
assertMemberExpression(opts?: object): void;
assertNewExpression(opts?: object): void;
assertProgram(opts?: object): void;
assertObjectExpression(opts?: object): void;
assertObjectMethod(opts?: object): void;
assertObjectProperty(opts?: object): void;
assertRestElement(opts?: object): void;
assertReturnStatement(opts?: object): void;
assertSequenceExpression(opts?: object): void;
assertSwitchCase(opts?: object): void;
assertSwitchStatement(opts?: object): void;
assertThisExpression(opts?: object): void;
assertThrowStatement(opts?: object): void;
assertTryStatement(opts?: object): void;
assertUnaryExpression(opts?: object): void;
assertUpdateExpression(opts?: object): void;
assertVariableDeclaration(opts?: object): void;
assertVariableDeclarator(opts?: object): void;
assertWhileStatement(opts?: object): void;
assertWithStatement(opts?: object): void;
assertAssignmentPattern(opts?: object): void;
assertArrayPattern(opts?: object): void;
assertArrowFunctionExpression(opts?: object): void;
assertClassBody(opts?: object): void;
assertClassDeclaration(opts?: object): void;
assertClassExpression(opts?: object): void;
assertExportAllDeclaration(opts?: object): void;
assertExportDefaultDeclaration(opts?: object): void;
assertExportNamedDeclaration(opts?: object): void;
assertExportSpecifier(opts?: object): void;
assertForOfStatement(opts?: object): void;
assertImportDeclaration(opts?: object): void;
assertImportDefaultSpecifier(opts?: object): void;
assertImportNamespaceSpecifier(opts?: object): void;
assertImportSpecifier(opts?: object): void;
assertMetaProperty(opts?: object): void;
assertClassMethod(opts?: object): void;
assertObjectPattern(opts?: object): void;
assertSpreadElement(opts?: object): void;
assertSuper(opts?: object): void;
assertTaggedTemplateExpression(opts?: object): void;
assertTemplateElement(opts?: object): void;
assertTemplateLiteral(opts?: object): void;
assertYieldExpression(opts?: object): void;
assertAnyTypeAnnotation(opts?: object): void;
assertArrayTypeAnnotation(opts?: object): void;
assertBooleanTypeAnnotation(opts?: object): void;
assertBooleanLiteralTypeAnnotation(opts?: object): void;
assertNullLiteralTypeAnnotation(opts?: object): void;
assertClassImplements(opts?: object): void;
assertClassProperty(opts?: object): void;
assertDeclareClass(opts?: object): void;
assertDeclareFunction(opts?: object): void;
assertDeclareInterface(opts?: object): void;
assertDeclareModule(opts?: object): void;
assertDeclareTypeAlias(opts?: object): void;
assertDeclareVariable(opts?: object): void;
assertExistentialTypeParam(opts?: object): void;
assertFunctionTypeAnnotation(opts?: object): void;
assertFunctionTypeParam(opts?: object): void;
assertGenericTypeAnnotation(opts?: object): void;
assertInterfaceExtends(opts?: object): void;
assertInterfaceDeclaration(opts?: object): void;
assertIntersectionTypeAnnotation(opts?: object): void;
assertMixedTypeAnnotation(opts?: object): void;
assertNullableTypeAnnotation(opts?: object): void;
assertNumericLiteralTypeAnnotation(opts?: object): void;
assertNumberTypeAnnotation(opts?: object): void;
assertStringLiteralTypeAnnotation(opts?: object): void;
assertStringTypeAnnotation(opts?: object): void;
assertThisTypeAnnotation(opts?: object): void;
assertTupleTypeAnnotation(opts?: object): void;
assertTypeofTypeAnnotation(opts?: object): void;
assertTypeAlias(opts?: object): void;
assertTypeAnnotation(opts?: object): void;
assertTypeCastExpression(opts?: object): void;
assertTypeParameterDeclaration(opts?: object): void;
assertTypeParameterInstantiation(opts?: object): void;
assertObjectTypeAnnotation(opts?: object): void;
assertObjectTypeCallProperty(opts?: object): void;
assertObjectTypeIndexer(opts?: object): void;
assertObjectTypeProperty(opts?: object): void;
assertQualifiedTypeIdentifier(opts?: object): void;
assertUnionTypeAnnotation(opts?: object): void;
assertVoidTypeAnnotation(opts?: object): void;
assertJSXAttribute(opts?: object): void;
assertJSXClosingElement(opts?: object): void;
assertJSXElement(opts?: object): void;
assertJSXEmptyExpression(opts?: object): void;
assertJSXExpressionContainer(opts?: object): void;
assertJSXIdentifier(opts?: object): void;
assertJSXMemberExpression(opts?: object): void;
assertJSXNamespacedName(opts?: object): void;
assertJSXOpeningElement(opts?: object): void;
assertJSXSpreadAttribute(opts?: object): void;
assertJSXText(opts?: object): void;
assertNoop(opts?: object): void;
assertParenthesizedExpression(opts?: object): void;
assertAwaitExpression(opts?: object): void;
assertBindExpression(opts?: object): void;
assertDecorator(opts?: object): void;
assertDoExpression(opts?: object): void;
assertExportDefaultSpecifier(opts?: object): void;
assertExportNamespaceSpecifier(opts?: object): void;
assertRestProperty(opts?: object): void;
assertSpreadProperty(opts?: object): void;
assertExpression(opts?: object): void;
assertBinary(opts?: object): void;
assertScopable(opts?: object): void;
assertBlockParent(opts?: object): void;
assertBlock(opts?: object): void;
assertStatement(opts?: object): void;
assertTerminatorless(opts?: object): void;
assertCompletionStatement(opts?: object): void;
assertConditional(opts?: object): void;
assertLoop(opts?: object): void;
assertWhile(opts?: object): void;
assertExpressionWrapper(opts?: object): void;
assertFor(opts?: object): void;
assertForXStatement(opts?: object): void;
assertFunction(opts?: object): void;
assertFunctionParent(opts?: object): void;
assertPureish(opts?: object): void;
assertDeclaration(opts?: object): void;
assertLVal(opts?: object): void;
assertLiteral(opts?: object): void;
assertImmutable(opts?: object): void;
assertUserWhitespacable(opts?: object): void;
assertMethod(opts?: object): void;
assertObjectMember(opts?: object): void;
assertProperty(opts?: object): void;
assertUnaryLike(opts?: object): void;
assertPattern(opts?: object): void;
assertClass(opts?: object): void;
assertModuleDeclaration(opts?: object): void;
assertExportDeclaration(opts?: object): void;
assertModuleSpecifier(opts?: object): void;
assertFlow(opts?: object): void;
assertFlowBaseAnnotation(opts?: object): void;
assertFlowDeclaration(opts?: object): void;
assertJSX(opts?: object): void;
assertNumberLiteral(opts?: object): void;
assertRegexLiteral(opts?: object): void;
}
export class Hub {
constructor(file: any, options: any);
file: any;
options: any;
}
export interface TraversalContext {
parentPath: NodePath;
scope: Scope;
state: any;
opts: any;
}
}

View File

@ -15,6 +15,7 @@
"test": "test" "test": "test"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^10.9.4",
"domino": "2.1.2", "domino": "2.1.2",
"mocha": "^3.1.2", "mocha": "^3.1.2",
"mock-require": "3.0.3", "mock-require": "3.0.3",

View File

@ -16,7 +16,8 @@
"es2015.promise", "es2015.promise",
"es2015.symbol", "es2015.symbol",
"es2015.symbol.wellknown" "es2015.symbol.wellknown"
] ],
"typeRoots": ["node_modules/@types"],
}, },
"exclude": [ "exclude": [
"node_modules", "node_modules",

View File

@ -20,7 +20,8 @@ try {
process.exit(0); process.exit(0);
} }
const {set, cd, sed, rm} = require('shelljs'); const {set, cd, sed, echo, ls} = require('shelljs');
const {readFileSync} = require('fs');
const path = require('path'); const path = require('path');
const log = console.log; const log = console.log;
@ -51,4 +52,20 @@ sed('-i', 'process.platform !== \'linux\'',
'process.platform !== \'linux\' && process.platform !== \'darwin\'', 'process.platform !== \'linux\' && process.platform !== \'darwin\'',
'node_modules/@bazel/karma/karma.conf.js'); 'node_modules/@bazel/karma/karma.conf.js');
// Workaround https://github.com/bazelbuild/rules_nodejs/issues/1033
// TypeScript doesn't understand typings without "declare module" unless
// they are actually resolved by the @types default mechanism
log('\n# patch: @types/babel__* adding declare module wrappers');
ls('node_modules/@types').filter(f => f.startsWith('babel__')).forEach(pkg => {
const modName = '@' + pkg.replace('__', '/');
const typingsFile = `node_modules/@types/${pkg}/index.d.ts`;
// Only add the patch if it is not already there.
if (readFileSync(typingsFile, 'utf8').indexOf('/*added by tools/postinstall_patches.js*/') ===
-1) {
const insertPrefix = `/*added by tools/postinstall_patches.js*/ declare module "${modName}" { `;
sed('-i', `(// Type definitions for ${modName})`, insertPrefix + '$1', typingsFile);
echo('}').toEnd(typingsFile);
}
});
log('===== finished running the postinstall-patches.js script ====='); log('===== finished running the postinstall-patches.js script =====');

137
yarn.lock
View File

@ -88,15 +88,15 @@
dependencies: dependencies:
"@babel/highlight" "^7.0.0" "@babel/highlight" "^7.0.0"
"@babel/core@^7.5.5": "@babel/core@^7.6.4":
version "7.6.3" version "7.6.4"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.6.3.tgz#44de824e89eaa089bb12da7337bc9bdff2ab68f9" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.6.4.tgz#6ebd9fe00925f6c3e177bb726a188b5f578088ff"
integrity sha512-QfQ5jTBgXLzJuo7Mo8bZK/ePywmgNRgk/UQykiKwEtZPiFIn8ZqE6jB+AnD1hbB1S2xQyL4//it5vuAUOVAMTw== integrity sha512-Rm0HGw101GY8FTzpWSyRbki/jzq+/PkNQJ+nSulrdY6gFGOsNseCqD6KHRYe2E+EdzuBdr2pxCp6s4Uk6eJ+XQ==
dependencies: dependencies:
"@babel/code-frame" "^7.5.5" "@babel/code-frame" "^7.5.5"
"@babel/generator" "^7.6.3" "@babel/generator" "^7.6.4"
"@babel/helpers" "^7.6.2" "@babel/helpers" "^7.6.2"
"@babel/parser" "^7.6.3" "@babel/parser" "^7.6.4"
"@babel/template" "^7.6.0" "@babel/template" "^7.6.0"
"@babel/traverse" "^7.6.3" "@babel/traverse" "^7.6.3"
"@babel/types" "^7.6.3" "@babel/types" "^7.6.3"
@ -106,27 +106,17 @@
lodash "^4.17.13" lodash "^4.17.13"
resolve "^1.3.2" resolve "^1.3.2"
semver "^5.4.1" semver "^5.4.1"
source-map "^0.6.1"
"@babel/generator@^7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.6.2.tgz#dac8a3c2df118334c2a29ff3446da1636a8f8c03"
integrity sha512-j8iHaIW4gGPnViaIHI7e9t/Hl8qLjERI6DcV9kEpAIDJsAOrcnXqRS7t+QbhL76pwbtqP+QCQLL0z1CyVmtjjQ==
dependencies:
"@babel/types" "^7.6.0"
jsesc "^2.5.1"
lodash "^4.17.13"
source-map "^0.5.0" source-map "^0.5.0"
"@babel/generator@^7.6.3": "@babel/generator@^7.6.3", "@babel/generator@^7.6.4":
version "7.6.3" version "7.6.4"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.6.3.tgz#71d5375264f93ec7bac7d9f35a67067733f5578e" resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.6.4.tgz#a4f8437287bf9671b07f483b76e3bb731bc97671"
integrity sha512-hLhYbAb3pHwxjlijC4AQ7mqZdcoujiNaW7izCT04CIowHK8psN0IN8QjDv0iyFtycF5FowUOTwDloIheI25aMw== integrity sha512-jsBuXkFoZxk0yWLyGI9llT9oiQ2FeTASmRFE32U+aaDTfoE92t78eroO7PTpU/OrYq38hlcDM6vbfLDaOLy+7w==
dependencies: dependencies:
"@babel/types" "^7.6.3" "@babel/types" "^7.6.3"
jsesc "^2.5.1" jsesc "^2.5.1"
lodash "^4.17.13" lodash "^4.17.13"
source-map "^0.6.1" source-map "^0.5.0"
"@babel/helper-function-name@^7.1.0": "@babel/helper-function-name@^7.1.0":
version "7.1.0" version "7.1.0"
@ -169,31 +159,12 @@
esutils "^2.0.2" esutils "^2.0.2"
js-tokens "^4.0.0" js-tokens "^4.0.0"
"@babel/parser@^7.4.4": "@babel/parser@^7.1.0", "@babel/parser@^7.6.0", "@babel/parser@^7.6.3", "@babel/parser@^7.6.4":
version "7.5.5" version "7.6.4"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.5.5.tgz#02f077ac8817d3df4a832ef59de67565e71cca4b" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.4.tgz#cb9b36a7482110282d5cb6dd424ec9262b473d81"
integrity sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g== integrity sha512-D8RHPW5qd0Vbyo3qb+YjO5nvUVRTXFLQ/FsDxJU2Nqz4uB5EnUN0ZQSEYpvTIbRuttig1XbHWU5oMeQwQSAA+A==
"@babel/parser@^7.6.0", "@babel/parser@^7.6.2": "@babel/template@^7.1.0", "@babel/template@^7.6.0":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.2.tgz#205e9c95e16ba3b8b96090677a67c9d6075b70a1"
integrity sha512-mdFqWrSPCmikBoaBYMuBulzTIKuXVPtEISFbRRVNwMWpCms/hmE2kRq0bblUHaNRKrjRlmVbx1sDHmjmRgD2Xg==
"@babel/parser@^7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.3.tgz#9eff8b9c3eeae16a74d8d4ff30da2bd0d6f0487e"
integrity sha512-sUZdXlva1dt2Vw2RqbMkmfoImubO0D0gaCrNngV6Hi0DA4x3o4mlrq0tbfY0dZEUIccH8I6wQ4qgEtwcpOR6Qg==
"@babel/template@^7.1.0":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.4.4.tgz#f4b88d1225689a08f5bc3a17483545be9e4ed237"
integrity sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==
dependencies:
"@babel/code-frame" "^7.0.0"
"@babel/parser" "^7.4.4"
"@babel/types" "^7.4.4"
"@babel/template@^7.6.0":
version "7.6.0" version "7.6.0"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.6.0.tgz#7f0159c7f5012230dad64cca42ec9bdb5c9536e6" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.6.0.tgz#7f0159c7f5012230dad64cca42ec9bdb5c9536e6"
integrity sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ== integrity sha512-5AEH2EXD8euCk446b7edmgFdub/qfH1SN6Nii3+fyXP807QRx9Q73A2N5hNwRRslC2H9sNzaFhsPubkS4L8oNQ==
@ -202,22 +173,7 @@
"@babel/parser" "^7.6.0" "@babel/parser" "^7.6.0"
"@babel/types" "^7.6.0" "@babel/types" "^7.6.0"
"@babel/traverse@^7.6.2": "@babel/traverse@^7.6.2", "@babel/traverse@^7.6.3":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.6.2.tgz#b0e2bfd401d339ce0e6c05690206d1e11502ce2c"
integrity sha512-8fRE76xNwNttVEF2TwxJDGBLWthUkHWSldmfuBzVRmEDWOtu4XdINTgN7TDWzuLg4bbeIMLvfMFD9we5YcWkRQ==
dependencies:
"@babel/code-frame" "^7.5.5"
"@babel/generator" "^7.6.2"
"@babel/helper-function-name" "^7.1.0"
"@babel/helper-split-export-declaration" "^7.4.4"
"@babel/parser" "^7.6.2"
"@babel/types" "^7.6.0"
debug "^4.1.0"
globals "^11.1.0"
lodash "^4.17.13"
"@babel/traverse@^7.6.3":
version "7.6.3" version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.6.3.tgz#66d7dba146b086703c0fb10dd588b7364cec47f9" resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.6.3.tgz#66d7dba146b086703c0fb10dd588b7364cec47f9"
integrity sha512-unn7P4LGsijIxaAJo/wpoU11zN+2IaClkQAxcJWBNCMS6cmVh802IyLHNkAjQ0iYnRS3nnxk5O3fuXW28IMxTw== integrity sha512-unn7P4LGsijIxaAJo/wpoU11zN+2IaClkQAxcJWBNCMS6cmVh802IyLHNkAjQ0iYnRS3nnxk5O3fuXW28IMxTw==
@ -232,25 +188,7 @@
globals "^11.1.0" globals "^11.1.0"
lodash "^4.17.13" lodash "^4.17.13"
"@babel/types@^7.0.0", "@babel/types@^7.4.4": "@babel/types@^7.0.0", "@babel/types@^7.3.0", "@babel/types@^7.4.4", "@babel/types@^7.6.0", "@babel/types@^7.6.3":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.5.5.tgz#97b9f728e182785909aa4ab56264f090a028d18a"
integrity sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==
dependencies:
esutils "^2.0.2"
lodash "^4.17.13"
to-fast-properties "^2.0.0"
"@babel/types@^7.6.0":
version "7.6.1"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.1.tgz#53abf3308add3ac2a2884d539151c57c4b3ac648"
integrity sha512-X7gdiuaCmA0uRjCmRtYJNAVCc/q+5xSgsfKJHqMN4iNLILX39677fJE1O40arPMh0TTtS9ItH67yre6c7k6t0g==
dependencies:
esutils "^2.0.2"
lodash "^4.17.13"
to-fast-properties "^2.0.0"
"@babel/types@^7.6.3":
version "7.6.3" version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.3.tgz#3f07d96f854f98e2fbd45c64b0cb942d11e8ba09" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.3.tgz#3f07d96f854f98e2fbd45c64b0cb942d11e8ba09"
integrity sha512-CqbcpTxMcpuQTMhjI37ZHVgjBkysg5icREQIEZ0eG1yCNwg3oy+5AaLiOKmjsCj6nqOsa6Hf0ObjRVwokb7srA== integrity sha512-CqbcpTxMcpuQTMhjI37ZHVgjBkysg5icREQIEZ0eG1yCNwg3oy+5AaLiOKmjsCj6nqOsa6Hf0ObjRVwokb7srA==
@ -613,6 +551,39 @@
resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.33.tgz#2728669427cdd74a99e53c9f457ca2866a37c52d" resolved "https://registry.yarnpkg.com/@types/argparse/-/argparse-1.0.33.tgz#2728669427cdd74a99e53c9f457ca2866a37c52d"
integrity sha512-VQgHxyPMTj3hIlq9SY1mctqx+Jj8kpQfoLvDlVSDNOyuYs8JYfkuY3OW/4+dO657yPmNhHpePRx0/Tje5ImNVQ== integrity sha512-VQgHxyPMTj3hIlq9SY1mctqx+Jj8kpQfoLvDlVSDNOyuYs8JYfkuY3OW/4+dO657yPmNhHpePRx0/Tje5ImNVQ==
"@types/babel__core@^7.1.3":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.3.tgz#e441ea7df63cd080dfcd02ab199e6d16a735fc30"
integrity sha512-8fBo0UR2CcwWxeX7WIIgJ7lXjasFxoYgRnFHUj+hRvKkpiBJbxhdAPTCY6/ZKM0uxANFVzt4yObSLuTiTnazDA==
dependencies:
"@babel/parser" "^7.1.0"
"@babel/types" "^7.0.0"
"@types/babel__generator" "*"
"@types/babel__template" "*"
"@types/babel__traverse" "*"
"@types/babel__generator@*":
version "7.6.0"
resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.6.0.tgz#f1ec1c104d1bb463556ecb724018ab788d0c172a"
integrity sha512-c1mZUu4up5cp9KROs/QAw0gTeHrw/x7m52LcnvMxxOZ03DmLwPV0MlGmlgzV3cnSdjhJOZsj7E7FHeioai+egw==
dependencies:
"@babel/types" "^7.0.0"
"@types/babel__template@*":
version "7.0.2"
resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.0.2.tgz#4ff63d6b52eddac1de7b975a5223ed32ecea9307"
integrity sha512-/K6zCpeW7Imzgab2bLkLEbz0+1JlFSrUMdw7KoIIu+IUdu51GWaBZpd3y1VXGVXzynvGa4DaIaxNZHiON3GXUg==
dependencies:
"@babel/parser" "^7.1.0"
"@babel/types" "^7.0.0"
"@types/babel__traverse@*":
version "7.0.7"
resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.0.7.tgz#2496e9ff56196cc1429c72034e07eab6121b6f3f"
integrity sha512-CeBpmX1J8kWLcDEnI3Cl2Eo6RfbGvzUctA+CjZUhOKDFbLfcr7fc4usEqLNWetrlJd7RhAkyYe2czXop4fICpw==
dependencies:
"@babel/types" "^7.3.0"
"@types/base64-js@1.2.5": "@types/base64-js@1.2.5":
version "1.2.5" version "1.2.5"
resolved "https://registry.yarnpkg.com/@types/base64-js/-/base64-js-1.2.5.tgz#582b2476169a6cba460a214d476c744441d873d5" resolved "https://registry.yarnpkg.com/@types/base64-js/-/base64-js-1.2.5.tgz#582b2476169a6cba460a214d476c744441d873d5"
@ -6578,9 +6549,9 @@ json5@^1.0.1:
minimist "^1.2.0" minimist "^1.2.0"
json5@^2.1.0: json5@^2.1.0:
version "2.1.0" version "2.1.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.0.tgz#e7a0c62c48285c628d20a10b85c89bb807c32850" resolved "https://registry.yarnpkg.com/json5/-/json5-2.1.1.tgz#81b6cb04e9ba496f1c7005d07b4368a2638f90b6"
integrity sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ== integrity sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==
dependencies: dependencies:
minimist "^1.2.0" minimist "^1.2.0"