Repository navigation
[v22.x backport] module: unflag --experimental-strip-types - #57298
marco-ippolito wants to merge 11 commits into
Conversation
commented
Mar 3, 2025
|
Review requested:
|
37874fb to
3e34c66
Compare
commented
Mar 4, 2025
|
Issue with test runner #56546 |
commented
Mar 6, 2025
|
I still haven't had the time to create an isolated repro, but the type stripping feature broke things for us, executing compiled code via |
please open an issue with a minimal repro, it's very hard to tell whats going on |
commented
Mar 6, 2025
Enabling the new |
commented
Mar 6, 2025
My issue is running a compiled code (via I already found the part that breaks, it is an optional symbol property, it's not about decorators. const OptionalProps = Symbol('OptionalProps');
abstract class BaseEntity<Optional = never> {
[OptionalProps]?: 'createdAt' | 'updatedAt' | Optional;
}This gets compiled (by const OptionalProps = Symbol('OptionalProps');
class BaseEntity {
[OptionalProps]; // still here and breaks when running via `node` 23, works if type stripping is disabled
}This is happening when dynamically importing this compiled JS file. The code is clearly valid JS, I can run it in node as well as browsers. I will try to wrap this up in the evening and create the issue. Sorry for the noise here, but this will affect pretty much all of our users, so enabling this flag is quite a BC for us. |
|
I found your error: // node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js
// PATH: /Users/marcoippolito/Documents/projects/test/guide/src/modules/common/base.entity.ts NAME: Base
const targets = await this.getEntityClassOrSchema(path, name);You are doing a dynamic import of ts with decorators. All files you are matching: Without experimental-strip-types you are matching: I think your issue is static detectTsNode() {
/* istanbul ignore next */
return process.argv[0].endsWith('ts-node') // running via ts-node directly
// @ts-ignore
|| !!process[Symbol.for('ts-node.register.instance')] // check if internal ts-node symbol exists
|| !!process.env.TS_JEST // check if ts-jest is used (works only with v27.0.4+)
|| !!process.env.VITEST // check if vitest is used
|| !!process.versions.bun // check if bun is used
|| process.argv.slice(1).some(arg => arg.includes('ts-node')) // registering ts-node runner
|| process.execArgv.some(arg => arg === 'ts-node/esm') // check for ts-node/esm module loader
|| (require.extensions && !!require.extensions['.ts']); // check if the extension is registered
}|| (require.extensions && !!require.extensions['.ts']); // check if the extension is registeredThere we go, this is your bug, |
commented
Mar 20, 2025
|
This breaks some of the workflows with v23, based on mocha + ts-node: open-telemetry/opentelemetry-js#5415 Existing ts projects can be written in module syntax for static analysis and transpiled to CJS. These workflows assume that these TS files are treated as CJS. However, in this case, mocha will try to |
left a comment
There was a problem hiding this comment.
I'd prefer to hold on release on v22 to address #57298 (comment).
|
I'm not sure I understand, what are the actionable items to do in Node.js? |
commented
Mar 20, 2025
Re this assumption in the OP: should this be considered a breakage in existing workflows in v23? |
commented
Mar 20, 2025
Yeah, that area of Mocha has had some discussions recently (mochajs/mocha#5235, mochajs/mocha#5294). It predates all of the current maintenance team -myself included- as well as Node.js type stripping / What would you like us to change in Mocha? 🙂 (do you want to file an issue on Mocha?) |
commented
Jul 3, 2025
commented
Jul 4, 2025
commented
Jul 4, 2025
commented
Jul 4, 2025
|
Landed in d649e9a...4af5915 |
PR-URL: #56350
Fixes: nodejs/typescript#17
Reviewed-By: Matteo Collina matteo.collina@gmail.com
Reviewed-By: Mohammed Keyvanzadeh mohammadkeyvanzade94@gmail.com
Reviewed-By: Paolo Insogna paolo@cowtech.it
Reviewed-By: Pietro Marchini pietro.marchini94@gmail.com