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

TypeScript errors when using TS with Project References #1594

Open
1 task
paularmstrong opened this issue Mar 4, 2024 · 1 comment
Open
1 task

TypeScript errors when using TS with Project References #1594

paularmstrong opened this issue Mar 4, 2024 · 1 comment

Comments

@paularmstrong
Copy link
Contributor

What version of starlight are you using?

0.21.0

What version of astro are you using?

4.4.9

What package manager are you using?

yarn

What operating system are you using?

Mac

What browser are you using?

any

Describe the Bug

TypeScript errors appear when Starlight is used within a monorepo and using typescript project references and tsc --build:

 ┌ Typecheck
 │ ERR node_modules/@astrojs/starlight/utils/error-map.ts:6:28 - error TS2307: Cannot find module 'astro/errors' or its corresponding type declarations.
 │ ERR
 │ ERR 6 import { AstroError } from 'astro/errors';
 │ ERR                              ~~~~~~~~~~~~~~
 │ ERR
 │ ERR node_modules/@astrojs/starlight/user-components/rehype-file-tree.ts:1:28 - error TS2307: Cannot find module 'astro/errors' or its corresponding type declarations.
 │ ERR
 │ ERR 1 import { AstroError } from 'astro/errors';
 │ ERR                              ~~~~~~~~~~~~~~
 │ ERR
 │ ERR node_modules/@astrojs/starlight/user-components/rehype-file-tree.ts:173:2 - error TS2322: Type 'string | undefined' is not assignable to type 'string'.
 │ ERR   Type 'undefined' is not assignable to type 'string'.
 │ ERR
 │ ERR 173  icon = getFileIconTypeFromExtension(fileName);
 │ ERR      ~~~~
 │ ERR
 │ ERR
 │ ERR Found 3 errors.
 │ ERR Process exited with code 1
 └ ✘ 1246ms

run npm run typecheck in the terminal

nb: the astro/errors issue appears when using moduleResolution: 'node'

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-2fdfac?file=package.json

Participation

  • I am willing to submit a pull request for this issue.
@Princesseuh
Copy link
Member

You shouldn't use moduleResolution: 'node' with Astro projects, all your Astro code will run inside a modern bundler that does supports the exports field, as such moduleResolution: 'bundler', the default when using the Astro tsconfig templates, is the proper option.

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

No branches or pull requests

2 participants