Angular: Add versioned @types/node to packages installed during storybook init#34192
Angular: Add versioned @types/node to packages installed during storybook init#34192Copilot wants to merge 3 commits into
@types/node to packages installed during storybook init#34192Conversation
Co-authored-by: valentinpalkovic <5889929+valentinpalkovic@users.noreply.github.com>
@types/node to packages installed during storybook init
| return { | ||
| extraPackages: [ | ||
| ...extraAngularDeps, | ||
| '@types/node', |
There was a problem hiding this comment.
@copilot . I think this is too simple. We need to detect the user's Node.js version and install @types/node based on the user's major Node.js version.
There was a problem hiding this comment.
Updated in f4810a1 — we now read process.versions.node at init time, extract the major version, and install @types/node@^{majorVersion} (e.g. @types/node@^22 on Node.js 22).
There was a problem hiding this comment.
Do we support other runtimes like deno or bun ? I'm not sure that process.versions.node would always be populated.
This can result in NaN
There was a problem hiding this comment.
I know that bun sets process.versions.node for sure! Deno as well: https://docs.deno.com/api/node/process/~/Process.versions. Officially, we don't have Deno support, and our bun runtime support is experimental
…rsion Co-authored-by: valentinpalkovic <5889929+valentinpalkovic@users.noreply.github.com>
@types/node to packages installed during storybook init@types/node to packages installed during storybook init
@types/node to packages installed during storybook init@types/node to packages installed during storybook init
|
View your CI Pipeline Execution ↗ for commit f4810a1
☁️ Nx Cloud last updated this comment at |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change introduces a runtime calculation of the Node.js major version extracted from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
✨ Finishing Touches📝 Generate docstrings
📝 Coding Plan
Comment |
Sidnioulz
left a comment
There was a problem hiding this comment.
The currently running node version has nothing to do with the type declarations consumed by Storybook or Angular. We should install the right version. As far as we're concerned, it's the minimal supported version we consume.
@Sidnioulz The runtime doesn't distinguish between node_modules and user code. One Node.js runtime is processing both. Installing |
My point was that a user setting up SB might be running Node 25, but their colleagues might be on 22.22.1. Suddenly they have types that might not match their runtime because some breaking changes happened because the person running the init has a more recent version. In contrast, if we always installed 22.19, we'd know we're not using any Node 25 exclusive APIs because that's our minimal required version. And we'd still run into issues if the project needs lower versions than us. But I'm now suspecting what you want to ensure is that users with a lower runtime version than our minimal version don't get forced into an upgrade? Would we then want to
|
Fresh Angular projects initialized with pnpm miss
@types/node(due to pnpm's strict dependency isolation), causing a Webpack/TypeScript error at startup:Cannot find type definition file for 'node'.Changes
generators/ANGULAR/index.ts: Detect the user's Node.js major version at init time and add the matching@types/node@^{majorVersion}(e.g.@types/node@^22on Node.js 22) toextraPackagesreturned from the Angular generator'sconfigurefunction, ensuring it is installed as a dev dependency duringstorybook initFor npm/yarn users where
@types/nodeis already present transitively, the explicit versioned install is a no-op. For pnpm users it resolves the missing type definition with types that match their actual Node.js runtime.View original Slack conversation
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.
Summary by CodeRabbit