-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Unable to use standard decorators in Vanilla template, using TypeScript #18693
Comments
If we modify this code, export
@element('kitchen-sink')
class KitchenSink /*extends HTMLElement*/ {} to this, export {KitchenSink}; // totally separate export statement
@element('kitchen-sink')
class KitchenSink /*extends HTMLElement*/ {} then If we modify that code to @element('kitchen-sink')
export class KitchenSink /*extends HTMLElement*/ {} then we get the same error message. Looks like prod vs dev are using different tools that can and cannot handle the syntax. |
The Vite config is confusing. I was able to fix the issue by not using So instead of this which is not working, /** @import {UserConfig} from 'vite' */
/** @type {UserConfig} */
export default {
build: {
target: 'es2022'
}
} this is working, /** @import {UserConfig} from 'vite' */
/** @type {UserConfig} */
export default {
esbuild: {
target: 'es2022'
}
} but from the docs it is not clear why there are two /** @import {UserConfig} from 'vite' */
/** @type {UserConfig} */
export default {
// Configure both `target`s just in case
build: {
target: 'es2022'
},
esbuild: {
target: 'es2022'
}
} |
For syntax lowering during dev, |
Hmm, maybe the thing vite could do that would be more intuitive is to accept a single I think it is a good idea. If someone wants to test |
Looking at the type definition compared to docs, its a little confusing. To be safe, the following is what I am doing. Is this how we are supposed to configure the target? /** @import {UserConfig} from 'vite' */
// Make sure to put the target in all three locations below.
const target = 'es2022'
/** @type {UserConfig} */
export default {
build: {
target,
},
esbuild: {
target,
},
optimizeDeps: {
esbuildOptions: {
target,
}
}
} Here's a working example in the reproduction repo at this commit: https://github.com/trusktr/vite-issue-18693/tree/72aaaff170d5ec5d325fa8a498420862540af757 It seems like a nice idea to default |
Describe the bug
TypeScript 5 has supported decorators out of the box since version 5, but Vite's default TypeScript setup has syntax errors with decorators.
Reproduction
https://github.com/trusktr/vite-issue-18693
Steps to reproduce
System Info
Used Package Manager
npm
Logs
Click to expand!
Validations
The text was updated successfully, but these errors were encountered: