Skip to content

[2.4.0-beta.0] New typescript errors for css and import.meta.env #4002

@IanVS

Description

@IanVS

Describe the bug

I attempted an upgrade to vite 2.4.0-beta.0, and I've now started to get two types of typescript errors which I did not have before.

CSS imports:

src/screens/login/Login.tsx:11:20 - error TS2307: Cannot find module './Login.module.css' or its corresponding type declarations.

11 import styles from './Login.module.css';

And

src/index.tsx:6:33 - error TS2339: Property 'env' does not exist on type 'ImportMeta'.

6 const environment = import.meta.env.MODE;

I have "types": ["vite/client"], in my tsconfig.json, but the vite client types don't seem to be picked up. I get Cannot find type definition file for 'vite/client'.

Reproduction

https://codesandbox.io/s/frosty-platform-3i81r?file=/src/index.tsx

System Info

System:
    OS: macOS 11.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 66.11 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
    Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.1/bin/yarn
    npm: 7.17.0 - ~/.nvm/versions/node/v14.16.1/bin/npm
  Browsers:
    Brave Browser: 91.1.26.67
    Firefox: 88.0.1
    Safari: 14.1.1
  npmPackages:
    vite: ^2.4.0-beta.0 => 2.4.0-beta.0

Used Package Manager

npm

Logs

No response

Validations

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