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

Specifying directory works differently with TypeScript #199

Closed
sapphi-red opened this issue Oct 8, 2024 · 6 comments · Fixed by #200
Closed

Specifying directory works differently with TypeScript #199

sapphi-red opened this issue Oct 8, 2024 · 6 comments · Fixed by #200

Comments

@sapphi-red
Copy link

Description

When the tsconfig.json has a directory specified in includes option, tsconfck's parse function does not treat that as all files under that directory unlike TypeScript. parseNative function works correctly.

Reproduction

https://stackblitz.com/edit/node-7ykh9n?file=tsconfig.json

Additional Information

  System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 18.24 GB / 31.92 GB
  Binaries:
    Node: 20.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.8.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.8 - C:\Program Files\nodejs\pnpm.CMD
    bun: 1.1.29 - ~\AppData\Local\Microsoft\WinGet\Links\bun.EXE
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527
@dominikg
Copy link
Owner

dominikg commented Oct 8, 2024

so basically tsconfck does not implement this part correctly currently:

If the last path segment in a pattern does not contain a file extension or wildcard character, then it is treated as a directory, and files with supported extensions inside that directory are included (e.g. .ts, .tsx, and .d.ts by default, with .js and .jsx if allowJs is set to true).

https://www.typescriptlang.org/tsconfig/#include

i have to check what to do here, easiest might be to append a /**/* to the pattern if it does not have a glob in the last segment.

@dominikg
Copy link
Owner

dominikg commented Oct 8, 2024

this is related to #195 as well, rereading the include docs, it looks like * matches all extensions, so src/**/* is different from src ? hmpf

@sapphi-red
Copy link
Author

Ah, true. It seems ['src'] means ['src/**/*.ts', 'src/**/*.tsx', 'src/**/*.d.ts'] (if allowJs is false).

@dominikg
Copy link
Owner

dominikg commented Oct 8, 2024

might have to dig into the implementation of ts itself, i am not sure this is intended or just the wording of the docs. would be confusing behavior...

@dominikg
Copy link
Owner

dominikg commented Oct 8, 2024

looks like it is indeed just the docs wording and if the last component of a path does not contain a wildcard they append **/* https://github.com/microsoft/TypeScript/blob/476e9ee201bd19afbc359ffe93b32a0ccd97152a/src/compiler/utilities.ts#L9577

@dominikg
Copy link
Owner

released fix in 3.1.4, vite needs to be updated to use this version as it bundles tsconfck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants