Skip to content

fix: fix compatibility with latest versions of ts-node #4314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 36 additions & 130 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"strip-ansi": "^7.0.0",
"supports-color": "^9.0.0",
"tmp-promise": "^3.0.2",
"ts-node": "10.4.0",
"ts-node": "^10.6.0",
"typescript": "^4.5.4",
"update-notifier": "^5.0.0",
"uuid": "^8.0.0",
Expand Down
10 changes: 9 additions & 1 deletion packages/build/src/error/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ const assignErrorProp = function (error, name, value) {
}

// Inverse of `jsonToError()`.
export const errorToJson = function ({ name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps }) {
export const errorToJson = function (error) {
const { name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps } = error

// diagnosticText is not enumerable in TSError so we need to grab it manually. destructuring won't work.
if (error.diagnosticText) {
// eslint-disable-next-line fp/no-mutation
errorProps.diagnosticText = error.diagnosticText
}

return {
...safeJsonStringify.ensureProperties(errorProps),
...safeJsonStringify.ensureProperties({ name, message, stack, [CUSTOM_ERROR_KEY]: customError }),
Expand Down
8 changes: 7 additions & 1 deletion packages/build/src/plugins/child/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ export const addTsErrorInfo = function (error, tsNodeService) {
config: {
raw: { compilerOptions },
},
options: tsNodeOptions,
options: realTsNodeOptions,
} = tsNodeService

// filter out functions as they cannot be serialized
const tsNodeOptions = Object.fromEntries(
Object.entries(realTsNodeOptions).filter(([, val]) => typeof val !== 'function'),
)

addErrorInfo(error, { tsConfig: { compilerOptions, tsNodeOptions } })
}

Expand Down
4 changes: 2 additions & 2 deletions packages/build/tests/monitor/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -970,9 +970,9 @@ Generated by [AVA](https://avajs.dev).
Error properties␊
{␊
diagnosticCodes: [ 2307, 7031 ],␊
diagnosticText: "plugin.ts(1,28): error TS2307: Cannot find module '@netlify/build' or its corresponding type declarations./n" +␊
"plugin.ts(3,51): error TS7031: Binding element 'constants' implicitly has an 'any' type./n",␊
diagnosticCodes: [ 2307, 7031 ]␊
"plugin.ts(3,51): error TS7031: Binding element 'constants' implicitly has an 'any' type./n"␊
}␊
Resolved config␊
Expand Down
Binary file modified packages/build/tests/monitor/snapshots/tests.js.snap
Binary file not shown.
Loading