Skip to content
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

vite 2.4.0: importMeta.d.ts types not exporting ImportMeta and ImportMetaEnv #4134

Closed
6 tasks done
userquin opened this issue Jul 5, 2021 · 12 comments
Closed
6 tasks done
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@userquin
Copy link
Contributor

userquin commented Jul 5, 2021

Describe the bug

Typescript cannot resolve import.meta.globEager:
imagen

Reproduction

not required, just see importMeta.d.ts file

System Info

System:
    OS: Windows 10 10.0.19042
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    Memory: 46.12 GB / 63.95 GB
  Binaries:
    Node: 15.11.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - C:\Program Files\nodejs\yarn.CMD
    npm: 7.6.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 91.0.4472.124
    Edge: Spartan (44.19041.1023.0), Chromium (91.0.864.64)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    @vitejs/plugin-vue: ^1.2.4 => 1.2.4
    vite: ^2.4.0 => 2.4.0

Used Package Manager

pnpm

Logs

No response

Validations

@IanVS
Copy link
Contributor

IanVS commented Jul 5, 2021

globEager is defined at https://github.com/vitejs/vite/blob/main/packages/vite/types/importMeta.d.ts#L54. Was this working for you in a previous version of vite, and broke in an upgrade? Have you added the vite client types as shown in https://vitejs.dev/guide/features.html#client-types?

@userquin
Copy link
Contributor Author

userquin commented Jul 5, 2021

Yes, migrated from 2.3.8 or 2.3.7 and updated vía taze, I'll try tmr, thx.

@userquin
Copy link
Contributor Author

userquin commented Jul 5, 2021

Why are not exported on d.ts file? I'm missing something?? Maybe New ts version??

@userquin
Copy link
Contributor Author

userquin commented Jul 5, 2021

I'm testing with vitesse template and have the second approach of the doc using types on tsconfig.json file:

https://github.com/antfu/vitesse/blob/master/tsconfig.json#L17

@userquin
Copy link
Contributor Author

userquin commented Jul 5, 2021

It is not a problem since build is working, but my intellij ide not resolving this type, while using prevoius versión, the entry on tsconfig.json file just resolves the type.

@IanVS
Copy link
Contributor

IanVS commented Jul 6, 2021

Why are not exported on d.ts file?

It is a property that is being defined on the ImportMeta interface, which is what typescript assigns to import.meta.

I believe this is probably the same problem as #4125, and I think the PR I have opened will solve your issue too.

@avocadowastaken
Copy link
Contributor

avocadowastaken commented Jul 6, 2021

Edit: #4134 (comment)


I fixed it by importing everything manually.

- /// <reference types="vite/client" />
+ import 'vite/client';
+ import 'vite/types/importMeta';

+ declare module 'vite/client' {
  interface ImportMetaEnv {
    LEGACY: boolean;
  }
+ }

@patak-dev
Copy link
Member

Thanks @umidbekk, could you check that #4138 fixes the issue for you? You can check the history of PRs there, looks like import would fail in other cases so triple dashes were introduced

@avocadowastaken
Copy link
Contributor

@patak-js This actually fixed the problem!

So better workaround is:

  /// <reference types="vite/client" />
+ /// <reference types="vite/types/importMeta" />

  interface ImportMetaEnv {
    LEGACY: boolean;
  }

@patak-dev
Copy link
Member

@umidbekk we also tried that, check #4031 to see what was the problem with this one. We just merged #4138 which seems to work across the board, it would be good to check main, as we will release this as 2.4.1 soon

@userquin
Copy link
Contributor Author

userquin commented Jul 6, 2021

cloning main repo working

imagen

@patak-dev patak-dev added bug p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Jul 6, 2021
@patak-dev
Copy link
Member

Closed in #4138

@github-actions github-actions bot locked and limited conversation to collaborators Jul 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

4 participants