-
Notifications
You must be signed in to change notification settings - Fork 158
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!
I, JJ Kasper <[email protected]>, hereby add my Signed-off-by to this commit: aa1dc36 I, JJ Kasper <[email protected]>, hereby add my Signed-off-by to this commit: e25f174 Signed-off-by: JJ Kasper <[email protected]>
|
@technopahadi could you commit the sign-off from here https://github.com/vercel/workflow/pull/757/checks?check_run_id=60157121285 |
I, Rishabh <[email protected]>, hereby add my Signed-off-by to this commit: e2f9304 I, Rishabh <[email protected]>, hereby add my Signed-off-by to this commit: 3faee5d I, Rishabh <[email protected]>, hereby add my Signed-off-by to this commit: 9dbbda6 Signed-off-by: Rishabh <[email protected]>
|
@ijjk Done |
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