Skip to content

Commit

Permalink
fix(gatsby): infer shape of warning object (#31489)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladimir Razuvaev <[email protected]>
Co-authored-by: gatsbybot <[email protected]>
  • Loading branch information
3 people authored Jun 14, 2021
1 parent c87d1d1 commit 96dc88a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/gatsby/src/utils/webpack-error-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,16 @@ export const reportWebpackWarnings = (
warnings: StatsCompilation["warnings"] = [],
reporter: Reporter
): void => {
const warningMessages = warnings.map(
warning => `${warning.moduleName}\n\n${warning.message}`
)
let warningMessages: Array<string> = []
if (typeof warnings[0] === `string`) {
warningMessages = (warnings as unknown) as Array<string>
} else if (warnings[0]?.message && warnings[0]?.moduleName) {
warningMessages = warnings.map(
warning => `${warning.moduleName}\n\n${warning.message}`
)
} else if (warnings[0]?.message) {
warningMessages = warnings.map(warning => warning.message)
}

formatWebpackMessages({
errors: [],
Expand Down

0 comments on commit 96dc88a

Please sign in to comment.