Skip to content
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

Reproduce wrong line numbers in stack traces under Node v20 #34

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion example.ts
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
console.log('Some .ts code reproducing a bug');
type Foo = {
foo: string,
bar: number,
}

function foofn () {
throw new Error('bar');
}

try {
foofn();
}
catch (err) {
const stack = (err as Error).stack || '';
if (/at foofn \(.*\/example\.ts:7:.*\)/.exec(stack)) {
console.log('OK, stack seems to have correct line numbers.');
}
else {
console.error('Grr, stack seems to have wrong line numbers.');
throw err;
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"type": "module",
"dependencies": {
"ts-node": "latest",
"typescript": "latest"
Expand Down
4 changes: 2 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env bash

# Install a specific version of node
n lts
n v18.19.0

# Install package.json dependencies
yarn

# Run ts-node
yarn ts-node ./example.ts
node --loader ts-node/esm/transpile-only ./example.ts

echo "Process exited with code: $?"
echo
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading