-
-
Notifications
You must be signed in to change notification settings - Fork 437
script setup + const enum = 💔 #277
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
Comments
Thanks for the report. But we can't change this behavior, otherwise it will be a bug for general users, because users will get runtime error in this case. You can use import type + import type { X } from "./enum";
const map = {
// @ts-ignore
[X.A]: 1
} |
@johnsoncodehk could you please explain what runtime error general (who?) users would get? I am not sure I get it. |
I want to add that I'm having similar error messages when importing types. These can be work-around by using // Error: 'Type' only refers to a type, but is being used as a value here.ts(2693)
import { Type, Value } from "x";
// Work-around: double imports
import { Value } from "x";
import type { Type } from "x"; Also: when you migrate from a regular |
See #209 (comment). |
I went down the linked issues to vuejs/core#3183 which seems to be the open issue for this. |
Even when everything is correct and runs properly, Volar complains about imported const enums.

This problem can be worked around a little by using

import type
, but depending on your code you get another error then:I know the default Vite setup can't properly compile const enums, but we use a custom build with regular TSC that compiles const enums efficiently. This is important for us because we have tons of enums generated from server-side code and it really adds up.
The text was updated successfully, but these errors were encountered: