Skip to content

Commit

Permalink
fix(gatsby): infer shape of warning object (#31489) (#31931)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladimir Razuvaev <[email protected]>
Co-authored-by: gatsbybot <[email protected]>
(cherry picked from commit 96dc88a)

Co-authored-by: Kyle Mathews <[email protected]>
  • Loading branch information
GatsbyJS Bot and KyleAMathews authored Jun 15, 2021
1 parent 3e21c9f commit 559c5f2
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 559c5f2

Please sign in to comment.