type fixes

This commit is contained in:
Tobias Koppers 2019-10-15 13:56:06 +02:00
parent 33a1bf8f84
commit e2e6789d2a
2 changed files with 13 additions and 10 deletions

View File

@ -31,17 +31,17 @@ class BannerPlugin {
* @param {BannerPluginArgument} options options object
*/
constructor(options) {
validateOptions(schema, options, {
name: "Banner Plugin",
baseDataPath: "options"
});
if (typeof options === "string" || typeof options === "function") {
options = {
banner: options
};
}
validateOptions(schema, options, {
name: "Banner Plugin",
baseDataPath: "options"
});
this.options = options;
const bannerOption = options.banner;

View File

@ -11,9 +11,10 @@ const validateSchema = (schema, options) => {
validate(schema, options, {
name: "Webpack",
postFormatter: (formattedError, error) => {
const children = /** @type {TODO} */ (error).children;
if (
error.children &&
error.children.some(
children &&
children.some(
child =>
child.keyword === "absolutePath" &&
child.dataPath === ".output.filename"
@ -23,7 +24,9 @@ const validateSchema = (schema, options) => {
}
if (error.keyword === "additionalProperties" && !error.dataPath) {
if (error.params.additionalProperty === "debug") {
const params =
/** @type {import("ajv").AdditionalPropertiesParams} */ (error.params);
if (params.additionalProperty === "debug") {
return (
`${formattedError}\n` +
"The 'debug' property was removed in webpack 2.0.0.\n" +
@ -37,7 +40,7 @@ const validateSchema = (schema, options) => {
);
}
if (error.params.additionalProperty) {
if (params.additionalProperty) {
return (
`${formattedError}\n` +
"For typos: please correct them.\n" +
@ -48,7 +51,7 @@ const validateSchema = (schema, options) => {
" new webpack.LoaderOptionsPlugin({\n" +
" // test: /\\.xxx$/, // may apply this only for some modules\n" +
" options: {\n" +
` ${error.params.additionalProperty}: …\n` +
` ${params.additionalProperty}: …\n` +
" }\n" +
" })\n" +
" ]"