-
Notifications
You must be signed in to change notification settings - Fork 160
fix: add TypeScript decorator support to SWC transform #757
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
Enable decorator parsing in SWC configuration to support codebases using TypeScript decorators (TypeORM, NestJS, class-validator, custom decorators). Without this fix, projects importing files with decorators fail with: "Unexpected token `@`. Expected identifier..." syntax errors. Changes: - Add `decorators: true` to parser options for TypeScript and ECMAScript - Add `legacyDecorator: true` for TypeScript's experimentalDecorators - Add `decoratorMetadata: true` for emitDecoratorMetadata support
|
|
@technopahadi is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
Fixes #756 |
Read experimentalDecorators and emitDecoratorMetadata from tsconfig.json to match Next.js behavior. Decorators are now only enabled when explicitly configured in the project's tsconfig. - Add getDecoratorOptionsForDirectory() to read tsconfig settings - Update applySwcTransform and Next.js loader to use tsconfig options - Handle JSONC format (comments, trailing commas) in tsconfig parsing
Replace manual regex-based JSONC parsing with json5 library for more robust handling of comments and trailing commas in tsconfig.json files.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
ijjk
left a 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.
Looks good, thanks for the PR!
|
@technopahadi could you commit the sign-off from here https://github.com/vercel/workflow/pull/757/checks?check_run_id=60157121285 |
I, Rishabh <rishabh.pugalia@gmail.com>, hereby add my Signed-off-by to this commit: e2f9304 I, Rishabh <rishabh.pugalia@gmail.com>, hereby add my Signed-off-by to this commit: 3faee5d I, Rishabh <rishabh.pugalia@gmail.com>, hereby add my Signed-off-by to this commit: 9dbbda6 Signed-off-by: Rishabh <rishabh.pugalia@gmail.com>
|
@ijjk Done |
* fix: add TypeScript decorator support to SWC transform Enable decorator parsing in SWC configuration to support codebases using TypeScript decorators (TypeORM, NestJS, class-validator, custom decorators). Without this fix, projects importing files with decorators fail with: "Unexpected token `@`. Expected identifier..." syntax errors. Changes: - Add `decorators: true` to parser options for TypeScript and ECMAScript - Add `legacyDecorator: true` for TypeScript's experimentalDecorators - Add `decoratorMetadata: true` for emitDecoratorMetadata support * fix: conditionally enable decorators based on tsconfig compilerOptions Read experimentalDecorators and emitDecoratorMetadata from tsconfig.json to match Next.js behavior. Decorators are now only enabled when explicitly configured in the project's tsconfig. - Add getDecoratorOptionsForDirectory() to read tsconfig settings - Update applySwcTransform and Next.js loader to use tsconfig options - Handle JSONC format (comments, trailing commas) in tsconfig parsing * fix: use json5 for parsing tsconfig in decorator options Replace manual regex-based JSONC parsing with json5 library for more robust handling of comments and trailing commas in tsconfig.json files. * bump * apply fix * DCO Remediation Commit for JJ Kasper <jj@jjsweb.site> I, JJ Kasper <jj@jjsweb.site>, hereby add my Signed-off-by to this commit: aa1dc36 I, JJ Kasper <jj@jjsweb.site>, hereby add my Signed-off-by to this commit: e25f174 Signed-off-by: JJ Kasper <jj@jjsweb.site> * DCO Remediation Commit for Rishabh <rishabh.pugalia@gmail.com> I, Rishabh <rishabh.pugalia@gmail.com>, hereby add my Signed-off-by to this commit: e2f9304 I, Rishabh <rishabh.pugalia@gmail.com>, hereby add my Signed-off-by to this commit: 3faee5d I, Rishabh <rishabh.pugalia@gmail.com>, hereby add my Signed-off-by to this commit: 9dbbda6 Signed-off-by: Rishabh <rishabh.pugalia@gmail.com> --------- Signed-off-by: JJ Kasper <jj@jjsweb.site> Signed-off-by: Rishabh <rishabh.pugalia@gmail.com> Co-authored-by: JJ Kasper <jj@jjsweb.site>
Enable decorator parsing in SWC configuration to support codebases using
TypeScript decorators (TypeORM, NestJS, class-validator, custom decorators).
Without this fix, projects importing files with decorators fail with:
"Unexpected token
@. Expected identifier..." syntax errors.Changes:
decorators: trueto parser options for TypeScript and ECMAScriptlegacyDecorator: truefor TypeScript's experimentalDecoratorsdecoratorMetadata: truefor emitDecoratorMetadata support