Skip to content

Typescript const enums not compiled correctly #3376

Closed
@jestarray

Description

@jestarray

Version

3.3.0

Reproduction link

https://github.com/jestarray/const-enum-vue

Environment info

   @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.2
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.2
    @vue/babel-preset-app:  3.3.0
    @vue/babel-preset-jsx:  1.0.0-beta.2
    @vue/babel-sugar-functional-vue:  1.0.0-beta.2
    @vue/babel-sugar-inject-h:  1.0.0-beta.2
    @vue/babel-sugar-v-model:  1.0.0-beta.2
    @vue/babel-sugar-v-on:  1.0.0-beta.2
    @vue/cli-overlay:  3.3.0
    @vue/cli-plugin-babel: ^3.3.0 => 3.3.0
    @vue/cli-plugin-typescript: ^3.3.0 => 3.3.0
    @vue/cli-service: ^3.3.0 => 3.3.1
    @vue/cli-shared-utils:  3.3.0
    @vue/component-compiler-utils:  2.5.1
    @vue/preload-webpack-plugin:  1.1.0
    @vue/web-component-wrapper:  1.2.0
    babel-helper-vue-jsx-merge-props:  2.0.3
    babel-plugin-transform-vue-jsx:  4.0.1
    vue: ^2.5.21 => 2.5.22
    vue-class-component: ^6.0.0 => 6.3.2
    vue-hot-reload-api:  2.3.1
    vue-loader:  15.6.2
    vue-property-decorator: ^7.0.0 => 7.3.0
    vue-style-loader:  4.1.2
    vue-template-compiler: ^2.5.21 => 2.5.22
    vue-template-es2015-compiler:  1.8.2
  npmGlobalPackages:
    @vue/cli: 3.3.0

Steps to reproduce

-npm install the dependencies,
-npm run build
-check the output in dist

What is expected?

const enum declarations should be inlined.
example:

const enum TEST{
HELLLO
}

console.log(TEST.HELLO);
//should be transpiled to console.log(0)

What is actually happening?

It's transpiled into console.log(TEST.HELLO) instead.


I have a const enum of keyboard events and event key names that I need inlined correctly. Followed some solutions of ts-loader since vue cli uses it under the hood but no luck.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions