-
Notifications
You must be signed in to change notification settings - Fork 11
fix(): add jsx.d.ts #4817
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
fix(): add jsx.d.ts #4817
Conversation
|
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. Walkthrough为砖块生成器添加对 JSX 类型声明的支持:在生成流程中新增更新 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge base: Disabled due to data retention organization setting 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
next-core
|
||||||||||||||||||||||||||||
| Project |
next-core
|
| Branch Review |
steve/v3-jsx
|
| Run status |
|
| Run duration | 00m 26s |
| Commit |
|
| Committer | Shenwei Wang |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
0
|
|
|
17
|
| View all changes introduced in this branch ↗︎ | |
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 adds JSX TypeScript declaration support for brick components by introducing a jsx.d.ts file that extends JSX intrinsic elements. When a new brick is created, the file is automatically updated with type definitions for the brick.
- Introduces a new
jsx.d.ts.hbstemplate file with JSX type declaration boilerplate - Updates the
build:typesscript to copyjsx.d.tsto the output directory - Adds an
updateJsxDtsfunction in plopfile.js to automatically update JSX type definitions when creating new bricks
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/yo/src/templates/bricks/src/jsx.d.ts.hbs | New template file providing JSX type declaration structure for brick components |
| packages/yo/src/templates/bricks/package.json.hbs | Updated build:types script to include jsx.d.ts in the build output |
| packages/yo/src/plopfile.js | Added updateJsxDts action to automatically generate and update JSX type definitions when creating bricks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/yo/src/plopfile.js
Outdated
|
|
||
| let newJsxDts = jsxDtsContent; | ||
| for (const [pattern, replacement] of replacementPatterns) { | ||
| newJsxDts = jsxDtsContent.replace(pattern, replacement); |
Copilot
AI
Nov 10, 2025
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.
The regex replacement uses jsxDtsContent instead of newJsxDts on line 362. This causes the second pattern replacement to always fail because it's applying to the original content instead of the result of the first replacement. Change jsxDtsContent.replace to newJsxDts.replace.
| newJsxDts = jsxDtsContent.replace(pattern, replacement); | |
| newJsxDts = newJsxDts.replace(pattern, replacement); |
| "build": "npm run build:main && npm run build:types", | ||
| "build:main": "cross-env NODE_ENV=production build-next-bricks", | ||
| "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json", | ||
| "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json && cp src/jsx.d.ts dist-types/jsx.d.ts", |
Copilot
AI
Nov 10, 2025
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.
The cp command will fail on Windows systems. Consider using cross-env (which is already a dependency) with a cross-platform copy command, or use a Node.js-based copy solution. For example, you could use cpy-cli or create a small Node script to handle the copy operation.
| "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json && cp src/jsx.d.ts dist-types/jsx.d.ts", | |
| "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir dist-types --project tsconfig.json && cpy-cli src/jsx.d.ts dist-types/jsx.d.ts", |
| ], | ||
| [ | ||
| // eslint-disable-next-line no-regex-spaces | ||
| /(\r?\n)( \}\r?\n \}\r?\n\}\r?\n)$/, |
Copilot
AI
Nov 10, 2025
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.
The regex pattern uses hard-coded spaces (4 spaces, 2 spaces) which is fragile and will break if the template's indentation changes. Consider using \s* for flexible whitespace matching or extracting the expected structure as a constant with documentation explaining the pattern.
| /(\r?\n)( \}\r?\n \}\r?\n\}\r?\n)$/, | |
| /(\r?\n)(\s*\}\r?\n\s*\}\r?\n\}\r?\n)$/, |
packages/yo/src/plopfile.js
Outdated
| ], | ||
| ]; | ||
|
|
||
| let newJsxDts = jsxDtsContent; |
Copilot
AI
Nov 10, 2025
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.
The initial value of newJsxDts is unused, since it is always overwritten.
| let newJsxDts = jsxDtsContent; | |
| let newJsxDts; |
769bcb9 to
7bce8ad
Compare
7bce8ad to
38d794b
Compare
依赖检查
组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。
请勾选以下两组选项其中之一:
或者:
提交信息检查
Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。
破坏性变更:
feat作为提交类型。BREAKING CHANGE: 你的变更说明。新特性:
feat作为提交类型。问题修复:
fix作为提交类型。杂项工作:
即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:
chore,docs,test等作为提交类型。Summary by CodeRabbit