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

When deno running typescript, SuppressedError output does not obey spec #23249

Open
loynoir opened this issue Apr 6, 2024 · 3 comments
Open
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling) upstream Changes in upstream are required to solve these issues

Comments

@loynoir
Copy link

loynoir commented Apr 6, 2024

BUG

When deno running typescript, SuppressedError output does not obey spec

version

node v21.7.1

typescript 5.4.4


deno 1.42.1 (release, x86_64-unknown-linux-gnu)

v8 12.3.219.9

typescript 5.4.3

reproduce

src/reproduce.mts

import { deepStrictEqual } from 'node:assert'
import process from 'node:process'

let err: any
try {
  await using _x1 = {
    async [Symbol.asyncDispose]() {
      throw 1
    }
  }

  await using _x2 = {
    async [Symbol.asyncDispose]() {
      throw 2
    }
  }

  await using _x3 = {
    async [Symbol.asyncDispose]() {
      throw 3
    }
  }

  await using _x4 = {
    async [Symbol.asyncDispose]() {
      throw 4
    }
  }

  throw 5
} catch (e) {
  err = e
}

if (process.env['ACCEPT_BUG'] === undefined) {
  deepStrictEqual(err.error, 1)
  deepStrictEqual(err.suppressed.error, 2)
  deepStrictEqual(err.suppressed.suppressed.error, 3)
  deepStrictEqual(err.suppressed.suppressed.suppressed.error, 4)
  deepStrictEqual(err.suppressed.suppressed.suppressed.suppressed, 5)
} else {
  deepStrictEqual(err.suppressed, 1)
  deepStrictEqual(err.error.suppressed, 2)
  deepStrictEqual(err.error.error.suppressed, 3)
  deepStrictEqual(err.error.error.error.suppressed, 4)
  deepStrictEqual(err.error.error.error.error, 5)
}

actual

$ yarn tsc --build && yarn node ./src/reproduce.mjs && deno run -A ./src/reproduce.mjs  && ACCEPT_BUG=1 deno run -A ./src/reproduce.mts && echo OK
OK

expected

$ yarn tsc --build && yarn node ./src/reproduce.mjs && deno run -A ./src/reproduce.mjs  && deno run -A ./src/reproduce.mts && echo OK
OK

additional

https://github.com/tc39/proposal-explicit-resource-management?tab=readme-ov-file#the-suppressederror-error

e.suppressed.suppressed.suppressed

@petamoriken
Copy link
Contributor

In Deno there is no SuppressedError yet because the using syntax is now performed by transpiling TypeScript

@loynoir
Copy link
Author

loynoir commented Apr 6, 2024

In Deno there is no SuppressedError yet because the using syntax is now performed by transpiling TypeScript

I mean, whatever the name is, the result transpiled by tsc, and the result transpiled by deno, are different.

tsc result of using error

  deepStrictEqual(err.error, 1)
  deepStrictEqual(err.suppressed.error, 2)
  deepStrictEqual(err.suppressed.suppressed.error, 3)
  deepStrictEqual(err.suppressed.suppressed.suppressed.error, 4)
  deepStrictEqual(err.suppressed.suppressed.suppressed.suppressed, 5)

deno result of using error

  deepStrictEqual(err.suppressed, 1)
  deepStrictEqual(err.error.suppressed, 2)
  deepStrictEqual(err.error.error.suppressed, 3)
  deepStrictEqual(err.error.error.error.suppressed, 4)
  deepStrictEqual(err.error.error.error.error, 5)

If two names swapped in deno, it should be same result with tsc.

Seems like a mistake.

@petamoriken
Copy link
Contributor

maybe related: #23187

@lucacasonato lucacasonato added bug Something isn't working correctly upstream Changes in upstream are required to solve these issues swc related to swc (bundling/transpiling) labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling) upstream Changes in upstream are required to solve these issues
Projects
None yet
Development

No branches or pull requests

3 participants