-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4354a1d
commit 13ad74f
Showing
6 changed files
with
131 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { spawnPromisified } from '../common/index.mjs'; | ||
import * as fixtures from '../common/fixtures.mjs'; | ||
import { strictEqual, match, throws, deepStrictEqual } from 'node:assert'; | ||
import { test } from 'node:test'; | ||
import { mapCallSite } from 'node:module'; | ||
import { getCallSite } from 'node:util'; | ||
|
||
test('module.mapCallSite', async () => { | ||
throws(() => mapCallSite('not an object'), { code: 'ERR_INVALID_ARG_TYPE' }); | ||
deepStrictEqual(mapCallSite([]), []); | ||
throws(() => mapCallSite({}), { code: 'ERR_INVALID_ARG_TYPE' }); | ||
|
||
const callSite = getCallSite(); | ||
deepStrictEqual(callSite, mapCallSite(callSite)); | ||
deepStrictEqual(callSite[0], mapCallSite(callSite[0])); | ||
}); | ||
|
||
|
||
test('module.mapCallSite should reconstruct ts callsite', async () => { | ||
const result = await spawnPromisified(process.execPath, [ | ||
'--no-warnings', | ||
'--experimental-transform-types', | ||
fixtures.path('typescript/ts/test-callsite.ts'), | ||
]); | ||
const output = result.stdout.toString().trim(); | ||
strictEqual(result.stderr, ''); | ||
match(output, /lineNumber: 9/); | ||
match(output, /column: 25/); | ||
strictEqual(result.code, 0); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const { getCallSite } = require('node:util'); | ||
const { mapCallSite } = require('node:module'); | ||
|
||
interface CallSite { | ||
A; | ||
B; | ||
} | ||
|
||
console.log(mapCallSite(getCallSite()[0])); |