-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: use native node typescript #11259
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
4b42f76 to
c2baa37
Compare
packages/create-discord-bot/template/JavaScript/.vscode/settings.json
Outdated
Show resolved
Hide resolved
packages/create-discord-bot/template/TypeScript/.vscode/settings.json
Outdated
Show resolved
Hide resolved
c2baa37 to
37799b4
Compare
37799b4 to
8a726ca
Compare
8a726ca to
056306a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR modernizes the TypeScript templates to leverage Node.js's native TypeScript execution, eliminating the need for a build step. The templates are also integrated into the pnpm workspace for better dependency management, requiring unique package names. Additionally, an unrelated VS Code extension recommendation has been removed, and pnpm-lock.yaml is now excluded from Prettier formatting.
- Removed TypeScript transpilation requirement by using
.tsfile extensions directly and Node.js native TS execution - Added template projects to pnpm workspace with unique scoped package names
- Simplified template file processing logic by removing dynamic file extension replacement
Reviewed changes
Copilot reviewed 31 out of 32 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Added template subdirectories to workspace for unified dependency management |
| pnpm-lock.yaml | Added dependencies for newly workspace-managed template projects |
| packages/create-discord-bot/template/TypeScript/tsconfig.json | Configured for native TS with noEmit, allowImportingTsExtensions, and erasableSyntaxOnly |
| packages/create-discord-bot/template/TypeScript/src/**/*.ts | Updated imports to use explicit .ts extensions for native TS support |
| packages/create-discord-bot/template/TypeScript/package.json | Changed scripts to execute .ts files directly with node --env-file; updated name to scoped package |
| packages/create-discord-bot/template/TypeScript/eslint.config.js | Removed dist from ignored paths since no build output is generated |
| packages/create-discord-bot/template/TypeScript/.vscode/settings.json | Changed placeholder from [REPLACE_ME] to [REPLACE_PACKAGE_MANAGER] for clarity |
| packages/create-discord-bot/template/TypeScript/.vscode/extensions.json | Removed random tamasfe.even-better-toml extension recommendation |
| packages/create-discord-bot/template/TypeScript/.prettierignore | Changed from ignoring dist to pnpm-lock.yaml |
| packages/create-discord-bot/template/JavaScript/package.json | Updated name to scoped package for workspace compatibility |
| packages/create-discord-bot/template/JavaScript/.vscode/settings.json | Changed placeholder to [REPLACE_PACKAGE_MANAGER] |
| packages/create-discord-bot/template/JavaScript/.vscode/extensions.json | Removed tamasfe.even-better-toml extension |
| packages/create-discord-bot/template/JavaScript/.prettierignore | Added to ignore pnpm-lock.yaml |
| packages/create-discord-bot/template/Deno/.vscode/settings.json | Replaced [REPLACE_BOOL] placeholder with actual true value |
| packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json | Configured for native TS support (though with suboptimal module settings for Bun) |
| packages/create-discord-bot/template/Bun/TypeScript/src/index.ts | Added minimal placeholder file |
| packages/create-discord-bot/template/Bun/TypeScript/package.json | Updated with scoped name and scripts for direct .ts execution |
| packages/create-discord-bot/template/Bun/TypeScript/eslint.config.js | Added new ESLint flat config for Bun TypeScript projects |
| packages/create-discord-bot/template/Bun/JavaScript/src/index.js | Added minimal placeholder file |
| packages/create-discord-bot/template/Bun/JavaScript/package.json | Updated with scoped name and .js execution scripts |
| packages/create-discord-bot/template/Bun/JavaScript/eslint.config.js | Added new ESLint flat config for Bun JavaScript projects |
| packages/create-discord-bot/src/util/constants.ts | Removed obsolete NODE_PACKAGE_MANAGERS constant |
| packages/create-discord-bot/src/helpers/packageManager.ts | Changed PackageManager type to derive from array; removed isNodePackageManager helper |
| packages/create-discord-bot/src/create-discord-bot.ts | Simplified file processing by removing glob-based extension replacement and using direct regex replacements |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json
Outdated
Show resolved
Hide resolved
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughRemoved NODE_PACKAGE_MANAGERS and isNodePackageManager, derived PackageManager from PACKAGE_MANAGERS, simplified create-discord-bot file edits (direct read-and-replace), added Bun templates, concretized many template placeholders to .js/.ts/names, and switched loader index-file checks to use basename. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (4)
packages/create-discord-bot/template/Bun/TypeScript/src/index.ts (1)
1-1: Placeholder file still lacks implementation.This file contains only
export {};with no actual bot initialization code. As previously noted, this should either:
- Implement actual bot logic (similar to the Node.js TypeScript template)
- Include a comment explaining it's an intentional placeholder
- Be removed if not needed
packages/create-discord-bot/template/Bun/JavaScript/src/index.js (1)
1-1: Implement the bot entry point or provide meaningful placeholder.This file serves as the main entry point for the Bun JavaScript template but contains only an empty
console.log()statement. Users creating a bot from this template will receive a non-functional starting point with no guidance.Consider either:
- Implementing actual bot initialization code (client setup, event handlers, etc.)
- Providing a meaningful placeholder with clear instructions:
console.log('Bot starting...');- Removing this template variant if it's not ready for release
Apply this diff as a minimal fix:
-console.log(); +console.log('Bun JavaScript template - implement your bot here');packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json (2)
9-10: UseBundlermodule resolution for Bun runtime.
NodeNextmodule resolution is designed for Node.js. Bun has its own module resolution algorithm, and TypeScript's"Bundler"mode is specifically designed for bundlers and alternative runtimes like Bun. This mismatch may lead to incorrect type checking or module resolution issues.Apply this diff:
- "module": "NodeNext", - "moduleResolution": "NodeNext", + "module": "ESNext", + "moduleResolution": "Bundler",
5-8: AdderasableSyntaxOnlyfor native TypeScript execution.The regular TypeScript template includes
"erasableSyntaxOnly": trueto ensure only type-erasable syntax is used when running TypeScript natively. This Bun TypeScript template should have the same option for consistency and to prevent runtime errors from non-erasable syntax.Apply this diff:
"allowImportingTsExtensions": true, + "erasableSyntaxOnly": true, "declaration": false,
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (31)
packages/create-discord-bot/src/create-discord-bot.ts(2 hunks)packages/create-discord-bot/src/helpers/packageManager.ts(1 hunks)packages/create-discord-bot/src/util/constants.ts(0 hunks)packages/create-discord-bot/template/Bun/JavaScript/eslint.config.js(1 hunks)packages/create-discord-bot/template/Bun/JavaScript/package.json(1 hunks)packages/create-discord-bot/template/Bun/JavaScript/src/index.js(1 hunks)packages/create-discord-bot/template/Bun/TypeScript/eslint.config.js(1 hunks)packages/create-discord-bot/template/Bun/TypeScript/package.json(1 hunks)packages/create-discord-bot/template/Bun/TypeScript/src/index.ts(1 hunks)packages/create-discord-bot/template/Bun/TypeScript/tsconfig.json(1 hunks)packages/create-discord-bot/template/Deno/.vscode/settings.json(1 hunks)packages/create-discord-bot/template/JavaScript/.prettierignore(1 hunks)packages/create-discord-bot/template/JavaScript/.vscode/extensions.json(0 hunks)packages/create-discord-bot/template/JavaScript/.vscode/settings.json(1 hunks)packages/create-discord-bot/template/JavaScript/package.json(1 hunks)packages/create-discord-bot/template/TypeScript/.prettierignore(1 hunks)packages/create-discord-bot/template/TypeScript/.vscode/extensions.json(0 hunks)packages/create-discord-bot/template/TypeScript/.vscode/settings.json(1 hunks)packages/create-discord-bot/template/TypeScript/eslint.config.js(1 hunks)packages/create-discord-bot/template/TypeScript/package.json(1 hunks)packages/create-discord-bot/template/TypeScript/src/commands/index.ts(1 hunks)packages/create-discord-bot/template/TypeScript/src/commands/ping.ts(1 hunks)packages/create-discord-bot/template/TypeScript/src/commands/utility/user.ts(1 hunks)packages/create-discord-bot/template/TypeScript/src/events/index.ts(1 hunks)packages/create-discord-bot/template/TypeScript/src/events/interactionCreate.ts(1 hunks)packages/create-discord-bot/template/TypeScript/src/events/ready.ts(1 hunks)packages/create-discord-bot/template/TypeScript/src/index.ts(1 hunks)packages/create-discord-bot/template/TypeScript/src/util/deploy.ts(1 hunks)packages/create-discord-bot/template/TypeScript/src/util/loaders.ts(2 hunks)packages/create-discord-bot/template/TypeScript/tsconfig.json(1 hunks)pnpm-workspace.yaml(1 hunks)
💤 Files with no reviewable changes (3)
- packages/create-discord-bot/template/JavaScript/.vscode/extensions.json
- packages/create-discord-bot/src/util/constants.ts
- packages/create-discord-bot/template/TypeScript/.vscode/extensions.json
🧰 Additional context used
🧬 Code graph analysis (4)
packages/create-discord-bot/template/Bun/JavaScript/eslint.config.js (2)
packages/create-discord-bot/template/Bun/TypeScript/eslint.config.js (1)
config(6-24)packages/create-discord-bot/template/TypeScript/eslint.config.js (1)
config(6-24)
packages/create-discord-bot/template/TypeScript/src/util/loaders.ts (1)
packages/create-discord-bot/template/JavaScript/src/util/loaders.js (2)
basePath(37-37)pattern(38-38)
packages/create-discord-bot/template/Bun/TypeScript/eslint.config.js (2)
packages/create-discord-bot/template/Bun/JavaScript/eslint.config.js (1)
config(5-19)packages/create-discord-bot/template/TypeScript/eslint.config.js (1)
config(6-24)
packages/create-discord-bot/src/helpers/packageManager.ts (1)
packages/create-discord-bot/src/util/constants.ts (1)
PACKAGE_MANAGERS(14-14)
🔇 Additional comments (29)
packages/create-discord-bot/template/Deno/.vscode/settings.json (1)
11-11: ✓ Placeholder correctly replaced with concrete value.The template placeholder
[REPLACE_BOOL]is replaced withtrue, which appropriately enables Deno language support for this template variant. This aligns with the PR objective to remove placeholder configuration values across template files.packages/create-discord-bot/template/JavaScript/.vscode/settings.json (1)
12-12: Clearer placeholder naming—looks good.The change from
[REPLACE_ME]to[REPLACE_PACKAGE_MANAGER]improves clarity on what this placeholder represents during template generation. Thenpm.packageManagerVSCode setting applies universally across all package managers (npm, pnpm, yarn, bun), so this placeholder will be correctly replaced with the user's chosen package manager regardless of which one they select. This directly addresses the earlier concern about clarity.packages/create-discord-bot/template/JavaScript/.prettierignore (1)
1-1: Aligns with PR objectives and follows best practices.Excluding
pnpm-lock.yamlfrom Prettier formatting is appropriate, as lock files should not be formatted by code formatters. This change is consistent with the TypeScript template's.prettierignoreand follows standard practices.pnpm-workspace.yaml (1)
4-4: Workspace pattern is correctly scoped.The pattern
packages/create-discord-bot/template/**/*appropriately includes all template subdirectories in the workspace, enabling proper dependency management as mentioned in the PR objectives. Using just**/*would incorrectly match the entire repository.packages/create-discord-bot/template/TypeScript/.vscode/settings.json (1)
12-12: LGTM! Clearer placeholder naming.The updated placeholder
[REPLACE_PACKAGE_MANAGER]more clearly indicates what value should be substituted, improving the template's usability.packages/create-discord-bot/template/TypeScript/src/commands/index.ts (1)
3-3: LGTM! Correct update for native TypeScript support.The explicit
.tsextension in the import path aligns with Node.js native TypeScript support and theallowImportingTsExtensionscompiler option mentioned in the PR context.packages/create-discord-bot/template/TypeScript/src/events/index.ts (1)
3-3: LGTM! Consistent with template-wide import updates.The explicit
.tsextension correctly supports native TypeScript module resolution, consistent with the changes across other template files.packages/create-discord-bot/template/TypeScript/src/events/ready.ts (1)
2-2: LGTM! Import path correctly updated.The explicit
.tsextension aligns with native TypeScript support and is consistent with the import updates throughout the template.packages/create-discord-bot/template/JavaScript/package.json (1)
3-3: LGTM! Necessary for workspace integration.The scoped package name
@discordjs/template-javascriptis required for the templates to function properly within the pnpm workspace, as mentioned in the PR objectives. This aligns with the naming convention used across other templates in this PR.packages/create-discord-bot/template/TypeScript/.prettierignore (1)
1-1: No action required - the change is correct.The TypeScript template uses
"noEmit": truein tsconfig.json, meaning TypeScript only performs type-checking without emitting any JavaScript output. No build artifacts are generated todist/, so removingdist/*from the ignore list is appropriate. Thebuildscript runstscsolely for validation, not compilation.packages/create-discord-bot/template/TypeScript/eslint.config.js (1)
8-8: LGTM!The empty
ignoresarray is appropriate since native TypeScript execution eliminates thedist/output directory.packages/create-discord-bot/template/Bun/TypeScript/eslint.config.js (1)
1-26: LGTM!The configuration is consistent with the TypeScript template's ESLint setup, which aids maintainability. The empty
ignoresarray aligns with the no-transpilation approach.packages/create-discord-bot/template/TypeScript/src/util/loaders.ts (1)
4-6: LGTM!The explicit
.tsextension imports align with the native TypeScript execution model configured intsconfig.json.packages/create-discord-bot/template/TypeScript/src/index.ts (1)
4-4: LGTM!The explicit
.tsextension import is consistent with the native TypeScript configuration and removes the need for placeholder-based file extension replacement.packages/create-discord-bot/template/TypeScript/tsconfig.json (1)
4-14: Configuration correctly supports Node.js native TypeScript.The tsconfig settings align with Node's
--experimental-strip-typesfeature:
erasableSyntaxOnly(TS 5.8+) restricts syntax to only type constructs that can be stripped at runtimeallowImportingTsExtensions+noEmitenables.tsimports without transpilationincremental: falseand removal ofoutDirare appropriate since no compiled output is generatedTemplate uses TypeScript ~5.9.3, which fully supports all these options.
packages/create-discord-bot/template/TypeScript/src/events/interactionCreate.ts (1)
3-4: LGTM: Import paths updated for native TypeScript support.The explicit
.tsextensions in import paths correctly support native TypeScript execution in Node.js, replacing the previous placeholder-based approach.packages/create-discord-bot/template/TypeScript/src/commands/utility/user.ts (1)
1-1: LGTM: Import path updated consistently.The explicit
.tsextension aligns with the native TypeScript support pattern applied across the template.packages/create-discord-bot/template/TypeScript/src/util/deploy.ts (1)
5-5: LGTM: Import path updated for native TypeScript.The explicit
.tsextension is consistent with the native TypeScript support refactor.packages/create-discord-bot/template/TypeScript/src/commands/ping.ts (1)
1-1: LGTM: Import path updated consistently.The explicit
.tsextension follows the established pattern for native TypeScript support.packages/create-discord-bot/src/create-discord-bot.ts (2)
80-81: Simplified package.json mutation is correct.The direct regex replacement for the package name is cleaner and more maintainable than the previous glob-based approach.
70-77: [rewritten comment]
[classification tag]packages/create-discord-bot/template/Bun/JavaScript/eslint.config.js (1)
1-21: LGTM: ESLint configuration is appropriate for JavaScript template.The configuration correctly combines common, node, and prettier presets without TypeScript-specific options. Disabling JSDoc rules is consistent with other templates in this repository.
packages/create-discord-bot/template/TypeScript/package.json (2)
3-3: Template package name looks consistent and workspace-friendlyUsing
"@discordjs/template-typescript"is clear, scoped, and should satisfy workspace uniqueness and publish constraints.
10-12: Scripts correctly target TypeScript entrypointsPointing
deployandstartatsrc/**/*.tsaligns this template with the native TS setup and removes the previous dist/JS coupling. This should also simplify the mental model for users running the generated bot.packages/create-discord-bot/src/helpers/packageManager.ts (1)
4-9: Good refactor: derivePackageManagerfrom the shared tupleImporting
PACKAGE_MANAGERSas a type and definingPackageManager = (typeof PACKAGE_MANAGERS)[number]removes the manual string union and keeps the type automatically in sync withPACKAGE_MANAGERSinconstants.ts. This reduces the risk of missing cases if new package managers are added.packages/create-discord-bot/template/Bun/TypeScript/package.json (2)
3-3: Bun TypeScript template name is clear and consistent
"@discordjs/template-bun-typescript"matches the naming scheme of the other templates and clearly communicates the runtime + language combo.
8-11: Bun/TS scripts are wired correctly to.tssourcesThe updated
lint,deploy,format, andstartscripts all target.tsfiles undersrc/, which matches the Bun/TypeScript template structure and the broader move to explicit TS entrypoints.packages/create-discord-bot/template/Bun/JavaScript/package.json (2)
3-3: Bun JavaScript template name matches the new convention
"@discordjs/template-bun-javascript"is clear and consistent with the Bun/TypeScript and Node templates.
8-11: Bun/JS scripts correctly target.jsfilesSwitching lint/format/deploy/start to use
.jsextensions and JS entrypoints undersrc/brings this template in line with the new Bun/JavaScript layout and avoids the previous placeholder extension indirection.
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
| "moduleResolution": "NodeNext", | ||
| "incremental": false, | ||
| "module": "ESNext", | ||
| "moduleResolution": "Bundler", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
# Find and display the TypeScript template's package.json
fd -t f 'package\.json' packages/create-discord-bot/template/TypeScript | head -1 | xargs catRepository: discordjs/discord.js
Length of output: 890
🏁 Script executed:
# Also check if there's a tsconfig.json to see all settings in context
cat packages/create-discord-bot/template/TypeScript/tsconfig.jsonRepository: discordjs/discord.js
Length of output: 484
🌐 Web query:
Node.js 22.12.0 native TypeScript support
💡 Result:
Short answer: Node.js v22.12.0 includes experimental TypeScript "run‑time" support, but it is not unconditional native execution — you must enable it with CLI flags. Use --experimental-strip-types to strip erasable TS types, or --experimental-transform-types to also transform TypeScript-only syntax (enums/namespaces). The feature is experimental and has limitations (no tsconfig handling, requires explicit extensions, limited syntax support, disabled in node_modules by default). [1][2][3]
How to run (examples)
- node --experimental-strip-types ./index.ts (type annotations stripped at runtime). [2][3]
- node --experimental-transform-types ./index.ts (transforms TS-only syntax; experimental). [3]
Sources
- Node.js v22.12.0 release notes. [1]
- Node.js v22.6.0 notes (introducing --experimental-strip-types). [2]
- Red Hat / Node.js 22 release notes summarizing strip/transform flags and limitations. [3]
🏁 Script executed:
# Check if there's a loader configuration or setup file that might handle TypeScript
fd -t f -e 'mjs|cjs|json' packages/create-discord-bot/template/TypeScript --max-depth 1Repository: discordjs/discord.js
Length of output: 557
🏁 Script executed:
# Check if there are any other files that might indicate how TS is supposed to run
fd . packages/create-discord-bot/template/TypeScript --type fRepository: discordjs/discord.js
Length of output: 948
🏁 Script executed:
# Look for any mention of experimental-strip-types or tsx in the entire template directory or build setup
rg -i "experimental-strip-types|tsx|ts-node" packages/create-discord-bot/template/TypeScript/Repository: discordjs/discord.js
Length of output: 202
🏁 Script executed:
# Check the git log for this file to see if there's recent context
cd packages/create-discord-bot/template/TypeScript && git log --oneline -10 tsconfig.json 2>/dev/null || echo "No git history available"Repository: discordjs/discord.js
Length of output: 129
🏁 Script executed:
# Check if there's a README or documentation that explains how to use the template
fd -t f 'README|readme|SETUP|setup' packages/create-discord-bot/template/TypeScript/Repository: discordjs/discord.js
Length of output: 46
🏁 Script executed:
# Check actual imports in the source files to see if .ts extensions are used
head -20 packages/create-discord-bot/template/TypeScript/src/index.ts
head -20 packages/create-discord-bot/template/TypeScript/src/util/loaders.tsRepository: discordjs/discord.js
Length of output: 1490
Change moduleResolution: "Bundler" to "node" or "nodeNext".
The "Bundler" strategy is for bundlers (esbuild, webpack, Vite), not Node.js module resolution. Since this template uses Node.js 22.12.0's experimental TypeScript support (indicated by erasableSyntaxOnly: true, allowImportingTsExtensions: true, and .ts extension imports), use "node" or "nodeNext" instead.
Additionally, the scripts in package.json need the --experimental-strip-types flag to execute .ts files:
"start": "node --experimental-strip-types --env-file=.env src/index.ts",
"deploy": "node --experimental-strip-types --env-file=.env src/util/deploy.ts"Without this flag, the template will not work as-is.
🤖 Prompt for AI Agents
In packages/create-discord-bot/template/TypeScript/tsconfig.json around line 11,
moduleResolution is set to "Bundler" which is incorrect for Node.js runtime;
change it to "node" or "nodeNext" to match Node 22.12+ experimental TypeScript
behavior, and update package.json start/deploy scripts to include the Node flag
--experimental-strip-types (e.g., node --experimental-strip-types
--env-file=.env src/index.ts and node --experimental-strip-types --env-file=.env
src/util/deploy.ts) so .ts files run correctly.
Depends on: