Skip to content

importMeta.d.ts file causes TypeScript error due to uppercase character #4541

@macdaddyaz

Description

@macdaddyaz

Describe the bug

There's a long-standing (or maybe recurring) TypeScript bug that filenames with uppercase characters are not handled properly within triple-slash directives on case-sensitive file systems. For Vitest, this means that the importMeta.d.ts file can't be referenced without causing a TypeScript error:

src/main.ts:1:23 - error TS2688: Cannot find type definition file for 'vitest/importmeta'.

1 /// <reference types="vitest/importMeta" />
                        ~~~~~~~~~~~~~~~~~


Found 1 error in src/main.ts:1

error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Note that Vite recently fixed a similar issue: vitejs/vite#13309

Reproduction

See this repository for a small project that shows the issue (only on macOS or Linux, I believe): https://github.com/macdaddyaz/vitest-import-meta-bug

yarn
yarn run tsc --project ./tsconfig.json

System Info

System:
    OS: macOS 13.6.1
    CPU: (8) arm64 Apple M1
    Memory: 58.80 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.8.0 - ~/.asdf/installs/nodejs/20.8.0/bin/node
    Yarn: 1.22.20 - ~/.asdf/installs/nodejs/20.8.0/bin/yarn
    npm: 10.2.1 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 8.10.5 - ~/.asdf/installs/nodejs/20.8.0/bin/pnpm
  Browsers:
    Brave Browser: 119.1.60.118
    Chrome: 119.0.6045.123
    Safari: 17.1
  npmPackages:
    vite: ^5.0.0 => 5.0.0 
    vitest: ^1.0.0-beta.5 => 1.0.0-beta.5 

Used Package Manager

yarn

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions