Skip to content

Commit 929673d

Browse files
committed
address review comments
1 parent 6d3aecc commit 929673d

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

docs/docs/how-to/custom-configuration/typescript.md

+1
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ exports.createPages = () => {}
253253

254254
Gatsby natively supports JavaScript and TypeScript, you can change files from `.js`/`.jsx` to `.ts`/ `tsx` at any point to start adding types and gaining the benefits of a type system. But you'll need to do a bit more to be able use Typescipt in `gatsby-*` files:
255255

256+
- Run `gatsby clean` to remove any old artifacts
256257
- Convert your `.js`/`.jsx` files to `.ts/.tsx`
257258
- Install `@types/node`, `@types/react`, `@types/react-dom`, `typescript` as `devDependencies`
258259
- Add a `tsconfig.json` file using `npx tsc init` or use the one from [gatsby-minimal-starter-ts](https://github.com/gatsbyjs/gatsby/blob/master/starters/gatsby-starter-minimal-ts/tsconfig.json)

packages/gatsby-cli/src/structured-errors/error-map.ts

+7
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,13 @@ const errors = {
698698
type: Type.COMPILATION,
699699
category: ErrorCategory.USER,
700700
},
701+
"11903": {
702+
text: (context): string =>
703+
`There was an unhandled error during compilation for ${context.siteRoot}. Please run the command with the --verbose flag again.`,
704+
level: Level.ERROR,
705+
type: Type.COMPILATION,
706+
category: ErrorCategory.USER,
707+
},
701708
}
702709

703710
export type ErrorId = string | keyof typeof errors

packages/gatsby/src/services/initialize.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ export async function initialize({
330330
`${program.directory}/gatsby-node.js`,
331331
`${program.directory}/gatsby-config.ts`,
332332
`${program.directory}/gatsby-node.ts`,
333-
].filter(Boolean) as Array<string>
333+
] as Array<string>
334334

335335
const state = store.getState()
336336

packages/gatsby/src/utils/parcel/compile-gatsby-files.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,17 @@ export async function compileGatsbyFiles(siteRoot: string): Promise<void> {
4848
await emptyDir(distDir)
4949
await parcel.run()
5050
} catch (error) {
51-
handleErrors(error.diagnostics)
51+
if (error.diagnostics) {
52+
handleErrors(error.diagnostics)
53+
} else {
54+
reporter.panic({
55+
id: `11903`,
56+
error,
57+
context: {
58+
siteRoot,
59+
},
60+
})
61+
}
5262
}
5363
}
5464

0 commit comments

Comments
 (0)