Ensure that the options object always exists.
This commit is contained in:
parent
ca4460c0b8
commit
b3331c0217
@ -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") {
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user