Skip to content

tsconfig useDefineForClassFields setting not respected #3227

Closed
@molszews

Description

@molszews

Describe the bug

My project requires use of setting useDefineForClassFields: true in tsconfig.json. For some reason the output presented by npm run dev behaves like that setting was set to false.

Reproduction

Create from React-TypeScript template (npm init @vitejs/app my-app -- --template react-ts) and add following code to App.tsx

class ContactInfoDto {
    firstName; lastName;
}

and inside App():

const contactInfo = new ContactInfoDto();
Object.keys(contactInfo).forEach(k => console.log(k));

It should console.log two lines when useDefineForClassFields set to true in tsconfig.json. (It works that way executed under webpack+babel or webpack+esbuild)

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

npx: installed 1 in 0.738s

  System:
    OS: Linux 5.4 elementary OS 5.1.7 Hera
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 4.45 GB / 31.16 GB
    Container: Yes
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 12.21.0 - ~/.nvm/versions/node/v12.21.0/bin/node
    Yarn: 1.22.10 - /usr/bin/yarn
    npm: 6.14.11 - ~/.nvm/versions/node/v12.21.0/bin/npm
  Browsers:
    Chrome: 90.0.4430.85
    Firefox: 87.0
  npmPackages:
    vite: ^2.2.3 => 2.2.3 

Used package manager: npm

Metadata

Metadata

Assignees

Labels

inconsistencyInconsistency between dev & buildp4-importantViolate documented behavior or significantly improves performance (priority)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions