-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
Error: Debug Failure when importing AssertionError
from node:assert/strict
#58534
Comments
It repros in the playground too: TS playground. To repro you need to hover over |
Failing test case: // @strict: true
// @moduleResolution: node
// @noEmit: true
// @filename: node_modules/@types/node/index.d.ts
/// <reference path="assert.d.ts" />
/// <reference path="assert/strict.d.ts" />
// @filename: node_modules/@types/node/assert/strict.d.ts
declare module "node:assert/strict" {
import { strict } from "node:assert";
export = strict;
}
// @filename: node_modules/@types/node/assert.d.ts
declare module "assert" {
function assert(value: unknown, message?: string | Error): asserts value;
namespace assert {
class AssertionError extends Error {
actual: unknown;
expected: unknown;
code: "ERR_ASSERTION";
constructor(options?: {
message?: string | undefined;
actual?: unknown | undefined;
expected?: unknown | undefined;
});
}
namespace strict {
type AssertionError = assert.AssertionError;
}
const strict: Omit<typeof assert, "strict">;
}
export = assert;
}
declare module "node:assert" {
import assert = require("assert");
export = assert;
}
// @filename: index.ts
import { AssertionError } from 'node:assert/strict';
throw new AssertionError({
message: 'Hello',
actual: 3,
expected: 3,
}); |
The above test crashes even in TS 4.5 (and back even in 4.0 though with a slightly different error). So this most definitely is not a recent regression at all. |
This is an interesting one. So the symbol that leads to a crash is a result of We could propagate I need to think more about it but it seems like more stuff should get propagated onto that combined symbol from the mapped symbol. |
Hello there, Here is my temporary fix, it does seem to work at first glance. Before: import assert, { AssertionError } from 'node:assert/strict'; import { AssertionError } from 'node:assert';
import assert from 'node:assert/strict'; It looks like After that, no problem to build with Only minor issue I have now is that ESLint will complain:
Cheers! |
I can reproduce it with latest ts for me it isn't working with
{
"name": "ts-issue",
"scripts": {
"typecheck": "tsc --noEmit -p tsconfig.json"
},
"license": "ISC",
"devDependencies": {
"@types/node": "20.14.9",
"typescript": "5.5.3",
"tslib": "2.6.3"
}
}
{
"compileOnSave": false,
"include": ["./src/issue.ts"],
"compilerOptions": {
"baseUrl": ".",
"rootDir": ".",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"importHelpers": true,
"target": "es2021",
"module": "CommonJS",
"moduleResolution": "Node",
"incremental": true,
"sourceMap": true,
"declaration": false,
"esModuleInterop": true,
"useDefineForClassFields": false,
"allowJs": true,
"resolveJsonModule": true,
"moduleDetection": "force",
"isolatedModules": false,
"lib": ["es2021", "es2022.Error", "ESNext.Disposable"],
"strict": true,
"noUncheckedIndexedAccess": false,
"noImplicitOverride": false,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"pretty": true,
"paths": {}
}
}
import { AssertionError } from "node:assert/strict";
throw new AssertionError({
message: "unreachable assertion",
operator: "unreachable",
});
|
🔎 Search Terms
Error: Debug Failure
🕗 Version & Regression Information
Happened when using tsc v5.4.5 with
@types/node
. Wasn’t an issue before (older tsc and older@types/node
v20.12.12).⏯ Playground Link
https://github.com/rauschma/tsc-debug-failure
💻 Code
Some of my compilerOptions in tsconfig:
🙁 Actual behavior
🙂 Expected behavior
No exception (normal operation)
Additional information about the issue
Possibly helpful:
tsc.js:53005
as follows. That told me that this problem was aboutAssertionError
.The text was updated successfully, but these errors were encountered: