diff --git a/example.ts b/example.ts index a201bd7..8214378 100644 --- a/example.ts +++ b/example.ts @@ -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; + } +} diff --git a/package.json b/package.json index 4d56496..2bf5396 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "type": "module", "dependencies": { "ts-node": "latest", "typescript": "latest" diff --git a/run.sh b/run.sh index d553b44..7ee6026 100644 --- a/run.sh +++ b/run.sh @@ -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 diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1 @@ +{}