-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Error: Using declaration is not enabled. Set jsc.parser.usingDecl to true #15464
Comments
Start a new pull request in StackBlitz Codeflow. |
Rollup doesn't support export default defineConfig({
esbuild: {
target: 'es2020',
include: /\.(m?[jt]s|[jt]sx)$/,
exclude: []
}
}) Note that this configuration will make all files to be transpiled by esbuild, to make it more performant, only run the transpile on the files using If you just need to enable it in related: #13756 |
@sapphi-red, I'm having the same issue with |
This seems only works in built mode. Found out that vite has emulated rollup build hooks in development mode, so it's possible to call esbuild to transform code. import { transform } from 'esbuild'
// ...
plugins: [
vue(),
vueJsx(),
{
name: 'esbuild-transform',
async transform(code, id, options) {
if (id.endsWith('.ts') || id.endsWith('.vue')) {
code = (
await transform(code, {
target: 'es2022'
})
).code
}
return code
}
}
], |
Closing as this is now supported by rollup since v4.14.0. |
Describe the bug
I am using a stock, default vite build, and trying to adopt the
using
statement supported by Typescript 5.2: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-2.html#using-declarations-and-explicit-resource-managementThis results in an error:
Note that the error advises:
I tried putting this in
vite.config.js
, but it didn't typecheck and had no effect on the error. I think it's an SWC option, and I don't see a way to pass options to SWC.Reproduction
https://stackblitz.com/edit/vitejs-vite-94zdjw?file=main.js
Steps to reproduce
Add a using statement to a new vite project, like
using _x = 1
.System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: