Ensure that the options object always exists.

This commit is contained in:
Logan Smyth 2017-10-05 22:03:39 -04:00
parent ca4460c0b8
commit b3331c0217
2 changed files with 4 additions and 4 deletions

View File

@ -222,7 +222,7 @@ type BasicDescriptor = {
type LoadedDescriptor = {
value: {},
options: {} | void,
options: {},
dirname: string,
alias: string,
loc: string,
@ -292,7 +292,7 @@ const loadConfig = makeWeakCache((config): {
*/
const loadDescriptor = makeWeakCache(
(descriptor: BasicDescriptor, cache): LoadedDescriptor => {
const { value, options, dirname, alias, loc } = descriptor;
const { value, options = {}, dirname, alias, loc } = descriptor;
let item = value;
if (typeof value === "function") {

View File

@ -7,9 +7,9 @@ export default class Plugin {
pre: ?Function;
visitor: ?{};
options: {} | void;
options: {};
constructor(plugin: {}, options: {} | void, key?: string) {
constructor(plugin: {}, options: {}, key?: string) {
if (plugin.name != null && typeof plugin.name !== "string") {
throw new Error("Plugin .name must be a string, null, or undefined");
}