Skip to content

[core] Avoid node types in the built packages #17533

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

LukasTy
Copy link
Member

@LukasTy LukasTy commented Apr 24, 2025

Fixes #17477.

Removing the usage of node in the tsconfig.compilerOptions.types to avoid NodeJS types in the built packages.

The drawback of this approach is inconclusive JSDoc/IntelliSense.
Hovering over methods shows node JSDoc where available, while the built output will have a different API (i.e. setTimeout).

I don't know how to easily avoid having node types in the project config, since there are numerous usages of path, __dirname and similar things, especially in test files.

@LukasTy LukasTy added core Infrastructure work going on behind the scenes enhancement This is not a bug, nor a new feature scope: code-infra Specific to the core-infra product labels Apr 24, 2025
@LukasTy LukasTy self-assigned this Apr 24, 2025
@@ -8,7 +8,9 @@
"noEmit": false,
"emitDeclarationOnly": true,
"outDir": "build/esm",
"rootDir": "./src"
"rootDir": "./src",
"skipLibCheck": true,
Copy link
Member Author

@LukasTy LukasTy Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this compilation failed due to not finding node types in the exceljs lib.
I don't think it's that important to check this validity twice (typescript step already checks with node types defined).

@mui-bot
Copy link

mui-bot commented Apr 24, 2025

Deploy preview: https://deploy-preview-17533--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against cd15e9f

@@ -14,7 +14,7 @@ export class TimerBasedCleanupTracking implements CleanupTracking {

register(object: any, unsubscribe: UnsubscribeFn, unregisterToken: UnregisterToken): void {
if (!this.timeouts) {
this.timeouts = new Map<number, NodeJS.Timeout>();
this.timeouts = new Map<number, ReturnType<typeof setTimeout>>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we need specificity to have conclusive types, I would vote for reverting mui/mui-public#195 and using window.setTimeout with return type of number instead of relying on terse ReturnType<typeof setTimeout>, which would now return NodeJS.Timeout in IDE/JSDoc and number in built output.

@LukasTy LukasTy marked this pull request as ready for review April 24, 2025 20:58
@LukasTy LukasTy requested review from a team April 24, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes enhancement This is not a bug, nor a new feature scope: code-infra Specific to the core-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[data grid] TS types reference NodeJS
2 participants