Type-check options.js and index.js (#490)
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
// @flow
|
||||
|
||||
// A second optional argument can be given to further configure
|
||||
// the parser process. These options are recognized:
|
||||
|
||||
export const defaultOptions: {
|
||||
sourceType: string,
|
||||
sourceFilename: any,
|
||||
startLine: number,
|
||||
allowReturnOutsideFunction: boolean,
|
||||
allowImportExportEverywhere: boolean,
|
||||
allowSuperOutsideMethod: boolean,
|
||||
plugins: Array<string>,
|
||||
strictMode: any,
|
||||
ranges: boolean,
|
||||
} = {
|
||||
export type Options = {
|
||||
sourceType: "script" | "module";
|
||||
sourceFilename?: string;
|
||||
startLine: number;
|
||||
allowReturnOutsideFunction: boolean;
|
||||
allowImportExportEverywhere: boolean;
|
||||
allowSuperOutsideMethod: boolean;
|
||||
plugins: $ReadOnlyArray<string>;
|
||||
strictMode: ?boolean;
|
||||
ranges: boolean;
|
||||
};
|
||||
|
||||
export const defaultOptions: Options = {
|
||||
// Source type ("script" or "module") for different semantics
|
||||
sourceType: "script",
|
||||
// Source filename.
|
||||
@@ -44,8 +48,8 @@ export const defaultOptions: {
|
||||
|
||||
// Interpret and default an options object
|
||||
|
||||
export function getOptions(opts?: Object): Object {
|
||||
const options = {};
|
||||
export function getOptions(opts: ?Options): Options {
|
||||
const options: any = {};
|
||||
for (const key in defaultOptions) {
|
||||
options[key] = opts && key in opts ? opts[key] : defaultOptions[key];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user