Add missing flow type to babel-cli for consistency (#10692)

This commit is contained in:
ZYSzys 2019-11-14 00:39:19 +08:00 committed by Nicolò Ribaudo
parent 67ea7f4b4d
commit 1d1101eb7c
3 changed files with 8 additions and 5 deletions

View File

@ -145,7 +145,7 @@ export default async function({
if (cliOptions.watch) { if (cliOptions.watch) {
const chokidar = util.requireChokidar(); const chokidar = util.requireChokidar();
filenames.forEach(function(filenameOrDir) { filenames.forEach(function(filenameOrDir: string): void {
const watcher = chokidar.watch(filenameOrDir, { const watcher = chokidar.watch(filenameOrDir, {
persistent: true, persistent: true,
ignoreInitial: true, ignoreInitial: true,
@ -155,8 +155,8 @@ export default async function({
}, },
}); });
["add", "change"].forEach(function(type) { ["add", "change"].forEach(function(type: string): void {
watcher.on(type, function(filename) { watcher.on(type, function(filename: string): void {
handleFile( handleFile(
filename, filename,
filename === filenameOrDir filename === filenameOrDir

View File

@ -223,7 +223,7 @@ export default async function({
pollInterval: 10, pollInterval: 10,
}, },
}) })
.on("all", function(type: string, filename: string) { .on("all", function(type: string, filename: string): void {
if (!util.isCompilableExtension(filename, cliOptions.extensions)) { if (!util.isCompilableExtension(filename, cliOptions.extensions)) {
return; return;
} }

View File

@ -320,7 +320,10 @@ function booleanify(val: any): boolean | any {
return val; return val;
} }
function collect(value, previousValue): Array<string> { function collect(
value: string | any,
previousValue: Array<string>,
): Array<string> {
// If the user passed the option with no value, like "babel file.js --presets", do nothing. // If the user passed the option with no value, like "babel file.js --presets", do nothing.
if (typeof value !== "string") return previousValue; if (typeof value !== "string") return previousValue;