add some more flow types
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* @noflow */
|
||||
/* @flow */
|
||||
|
||||
import * as t from "babel-types";
|
||||
|
||||
|
||||
@@ -537,7 +537,7 @@ export default class File extends Store {
|
||||
}
|
||||
}
|
||||
|
||||
makeResult({ code, map, ast, ignored } /*: BabelFileResult */): BabelFileResult {
|
||||
makeResult({ code, map, ast, ignored }: BabelFileResult): BabelFileResult {
|
||||
let result = {
|
||||
metadata: null,
|
||||
options: this.opts,
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
/* @noflow */
|
||||
/* @flow */
|
||||
/* global BabelFileResult */
|
||||
/* global BabelFileMetadata */
|
||||
|
||||
import normalizeAst from "../helpers/normalize-ast";
|
||||
import Plugin from "./plugin";
|
||||
import File from "./file";
|
||||
|
||||
export default class Pipeline {
|
||||
lint(code: string, opts?: Object = {}) {
|
||||
lint(code: string, opts?: Object = {}): BabelFileResult {
|
||||
opts.code = false;
|
||||
opts.mode = "lint";
|
||||
return this.transform(code, opts);
|
||||
}
|
||||
|
||||
pretransform(code: string, opts?: Object) {
|
||||
pretransform(code: string, opts?: Object): BabelFileResult {
|
||||
let file = new File(opts, this);
|
||||
return file.wrap(code, function () {
|
||||
file.addCode(code);
|
||||
@@ -20,7 +22,7 @@ export default class Pipeline {
|
||||
});
|
||||
}
|
||||
|
||||
transform(code: string, opts?: Object) {
|
||||
transform(code: string, opts?: Object): BabelFileResult {
|
||||
let file = new File(opts, this);
|
||||
return file.wrap(code, function () {
|
||||
file.addCode(code);
|
||||
@@ -29,7 +31,7 @@ export default class Pipeline {
|
||||
});
|
||||
}
|
||||
|
||||
analyse(code: string, opts: Object = {}, visitor?) {
|
||||
analyse(code: string, opts: Object = {}, visitor?: Object): ?BabelFileMetadata {
|
||||
opts.code = false;
|
||||
if (visitor) {
|
||||
opts.plugins = opts.plugins || [];
|
||||
@@ -38,7 +40,7 @@ export default class Pipeline {
|
||||
return this.transform(code, opts).metadata;
|
||||
}
|
||||
|
||||
transformFromAst(ast, code: string, opts: Object) {
|
||||
transformFromAst(ast: Object, code: string, opts: Object): BabelFileResult {
|
||||
ast = normalizeAst(ast);
|
||||
|
||||
let file = new File(opts, this);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* @noflow */
|
||||
/* @flow */
|
||||
|
||||
import escapeRegExp from "lodash/string/escapeRegExp";
|
||||
import startsWith from "lodash/string/startsWith";
|
||||
@@ -16,7 +16,7 @@ export { inherits, inspect } from "util";
|
||||
* Test if a filename ends with a compilable extension.
|
||||
*/
|
||||
|
||||
export function canCompile(filename: string, altExts?: Array<string>) {
|
||||
export function canCompile(filename: string, altExts?: Array<string>): boolean {
|
||||
let exts = altExts || canCompile.EXTENSIONS;
|
||||
let ext = path.extname(filename);
|
||||
return contains(exts, ext);
|
||||
|
||||
Reference in New Issue
Block a user