Open austinlogo opened 1 year ago
Same with function f<const T>() {}
generics not working.
@nandorojo Please open a different issue after verifying that nobody hasn’t already reported the issue.
Fair suggestion, however, I think it’s under the same umbrella issue: TS 5 features not being supported. My guess is all syntax gets supported together by upgrading the TS version Next (or SWC) uses.
This is SWC-only issue. Fortunately, NextJS allows to switch back to the original TSC instead of SWC. I tried It, and It IS working right now. My advice: use TSC. This is the only fully-functional TS compiler right now.
Oh, good to know. What did you do exactly?
Oh, good to know. What did you do exactly?
ts-loader
Configure your next.config.js like this:
module.exports = {
webpack: (config) => {
config.module.rules.push({
test: /\.tsx?$/,
use: [
{
loader: "ts-loader",
options: { transpileOnly: true },
},
],
});
return config;
},
};
npm start dev
You may notice there will be some errors in the console (ts-loader
cannot handle some imports located in the newly created app). Remove them or try to solve those errors by yourself.
Another way to quickly fix this issue, without waiting for NextJS to update, is to use patch-package or pnpm patch to directly enable SWC's stage 3 decorator support.
An example of how to use pnpm patch
to enable this can be found at https://github.com/orch-js/orch-js/commit/47b28ee29fad3ebf688fd56cfe5c96aaac3e1c28. Just simply mark decorators
as true
and specify the decoratorVersion
to 2022-03
.
I have a library using TypeScript 5, nothing special with the tsconfig.json
. This library is built, imported in the Next application, and it fails.
If the above solution works, it should be added to Next's configuration; opt-in to enable TS decorators.
Next.js is now at version 14.1.0, and this issue has not yet been officially resolved (though thanks to @runjuu for the solution).
Next.js is now at version 14.2.3, and this issue has not yet been officially resolved. Give us the ability to use decorators.
Hello @kdy1, I see you self-assigned this almost half a year ago. Please share, is there any news or ETA?
Status? 👀
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
SWC transpilation
Link to the code that reproduces this issue
https://github.com/austinlogo/nextjs-typescript-5
To Reproduce
Install and build as normal you should see an error in building types.
When you use the experimental flags in the tsconfig.json
Describe the Bug
This build Error
Expected Behavior
I would expect it to build.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1559