Skip to content

Investigate weird stack positions for thrown TSErrors #1784

Open

Description

@cspotcode

An example pulled from the tests:
D:\a\ts-node\ts-node\tests\node_modules\ts-node\src\index.ts:147

That line number does not make sense in either the source ts nor the emitted js.

Is this a trace-mapping bug?

Error (JestAssertionError) {
    message: `␊
    expect(received).toBe(expected) // Object.is equality␊
    ␊
    Expected: null␊
    Received: [Error: Command failed: "D:\\a\\ts-node\\ts-node\\tests\\node_modules\\.bin\\ts-node" --esm ./index.mjs␊
    D:\\a\\ts-node\\ts-node\\tests\\node_modules\\ts-node\\src\\index.ts:147␊
    const shouldDebug = yn(env.TS_NODE_DEBUG);␊
                                              ^␊
    TSError: ⨯ Unable to compile TypeScript:␊
    static_import_from_mts.mts(13,25): error TS2339: Property 'default' does not exist on type 'typeof import("D:/a/ts-node/ts-node/tests/tmp/package-json-type=module_allowJs=false_typecheck_tsconfig-module=Node16/mts", { assert: { "resolution-mode": "import" } })'.·␊
    static_import_from_mts.mts(17,23): error TS2339: Property 'default' does not exist on type 'typeof import("D:/a/ts-node/ts-node/tests/tmp/package-json-type=module_allowJs=false_typecheck_tsconfig-module=Node16/ts", { assert: { "resolution-mode": "import" } })'.·␊
    static_import_from_mts.mts(19,25): error TS2339: Property 'default' does not exist on type 'typeof import("D:/a/ts-node/ts-node/tests/tmp/package-json-type=module_allowJs=false_typecheck_tsconfig-module=Node16/tsx", { assert: { "resolution-mode": "import" } })'.··␊
        at createTSError (D:\\a\\ts-node\\ts-node\\tests\\node_modules\\ts-node\\src\\index.ts:147:43)␊
        at reportTSError (D:\\a\\ts-node\\ts-node\\tests\\node_modules\\ts-node\\src\\index.ts:147:43)␊
        at getOutput (D:\\a\\ts-node\\ts-node\\tests\\node_modules\\ts-node\\dist\\index.js:69:657)␊
        at Object.compile (D:\\a\\ts-node\\ts-node\\tests\\node_modules\\ts-node\\src\\index.ts:453:18)␊
        at transformSource (D:\\a\\ts-node\\ts-node\\tests\\node_modules\\ts-node\\src\\esm.ts:119:2)␊
        at D:\\a\\ts-node\\ts-node\\tests\\node_modules\\ts-node\\src\\esm.ts:114:65␊
        at async addShortCircuitFlag (D:\\a\\ts-node\\ts-node\\tests\\node_modules\\ts-node\\src\\esm.ts:119:2)␊
        at async ESMLoader.load (node:internal/modules/esm/loader:584:20)␊
        at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:435:11)␊
        at async link (node:internal/modules/esm/module_job:70:21) {␊
      diagnosticCodes: [ 2339, 2339, 2339 ]␊
    }␊
    ]␊

Activity

  1. added this to the 10.8.1 milestone on Jun 1, 2022
  2. cspotcode commented on Jun 1, 2022

    @cspotcode
    CollaboratorAuthor

    Doesn't repro locally so might be isolated to the test suite, perhaps a doubly-registered source-map-support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions