Skip to content
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

feat: add emitDecoratorMetadata config #1420

Merged
merged 1 commit into from
Jul 17, 2024
Merged

feat: add emitDecoratorMetadata config #1420

merged 1 commit into from
Jul 17, 2024

Conversation

sorrycc
Copy link
Member

@sorrycc sorrycc commented Jul 17, 2024

Close #1173

用例来自 https://github.com/leonardfactory/babel-plugin-transform-typescript-metadata/blob/master/test/__fixtures__/generics/code.js

参考:
https://www.typescriptlang.org/docs/handbook/decorators.html#metadata
https://github.com/leonardfactory/babel-plugin-transform-typescript-metadata
https://babeljs.io/docs/babel-plugin-transform-typescript#typescript-compiler-options

Summary by CodeRabbit

  • 新功能

    • 引入了 emitDecoratorMetadata 配置选项并默认设置为 true,优化了装饰器的元数据发射功能。
    • 新增了测试脚本以验证 emitDecoratorMetadata 功能。
  • 文档

    • 更新了 config.md 文档,修改了 emitDecoratorMetadatauseDefineForClassFields 选项的默认值说明。
  • 测试

    • 增加了新的端到端测试文件和配置,以验证装饰器元数据的发射功能。

Copy link
Contributor

coderabbitai bot commented Jul 17, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

此次更改主要是在 TypeScript 的配置和转换过程中增加了 emitDecoratorMetadata 配置选项,并调整了编译顺序以确保装饰器在编译为 ES5 时不会被静默移除。这些更改旨在增强对装饰器元数据的支持,并优化 ES5 的兼容性。

Changes

文件路径 更改摘要
crates/mako/src/build/transform.rs 调整装饰器顺序并在 emit_metadata 字段中增加上下文变量,以确保装饰器在编译为 ES5 时被正确处理。
crates/mako/src/config/config.rs Config 结构体中添加了 emit_decorator_metadata 字段,默认值为 false
docs/config.md 更新文档中 emitDecoratorMetadatauseDefineForClassFields 选项的默认值。
e2e/fixtures/javascript.transform.emit_decorator_metadata/expect.js 添加了一个测试脚本,以验证 index.js 文件中是否存在特定字符串。
e2e/fixtures/javascript.transform.emit_decorator_metadata/mako.config.json 新增配置文件,将 emitDecoratorMetadata 设置为 true
e2e/fixtures/javascript.transform.emit_decorator_metadata/src/index.ts 新增文件,包含一个类 MyClass 及其构造函数和方法,展示装饰器元数据的使用。

Assessment against linked issues

Objective Addressed Explanation
支持 TypeScript 的 emitDecoratorMetadata 配置 (#1173)

在代码的森林里,新增的配置如同新芽,
元数据在装饰器的光芒下闪亮,
优化的编译流程如溪流般流畅,
测试脚本的护航,确保万无一失,
代码之树在夏日的阳光下茁壮成长。


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sorrycc sorrycc merged commit aace092 into master Jul 17, 2024
8 checks passed
@sorrycc sorrycc deleted the sorrycc-k54i branch August 9, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: support emitDecoratorMetadata config of TypeScript
1 participant