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

Component Template errors after running #8786

Closed
MrAmericanMike opened this issue Oct 9, 2023 · 6 comments · Fixed by #9602
Closed

Component Template errors after running #8786

MrAmericanMike opened this issue Oct 9, 2023 · 6 comments · Fixed by #9602
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: typescript Related to TypeScript (scope)

Comments

@MrAmericanMike
Copy link

MrAmericanMike commented Oct 9, 2023

So I was following the guide here as to how to create a component to publish to NPMJS: https://docs.astro.build/en/reference/publish-to-npm/

(Apart from the guide been a bit confusing) one of the first steps mentions to run:

pnpm create astro@latest my-new-component-directory -- --template component

After doing this and opening the index.ts file an error shows in './src/MyComponent.astro' that says:

Cannot find module './src/MyComponent.astro' or its corresponding type declarations.(2307)

Here is an stackblitz illustrating the problem: https://stackblitz.com/edit/github-gg5qiw?file=my-new-component-directory%2Findex.ts



### If this issue only occurs in one browser, which browser is a problem?

_No response_

### Describe the Bug

Errors out of the box when using provided template.

### What's the expected result?

To not see any error.

### Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-gg5qiw?file=my-new-component-directory%2Findex.ts

### Participation

- [ ] I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Oct 9, 2023
@Princesseuh
Copy link
Member

Princesseuh commented Oct 10, 2023

The error in your message isn't a runtime error, it's because Stackblitz does not run our tooling and so cannot get the types from .astro files. Are you encountering the same error (or another error) outside Stackblitz?

@Princesseuh Princesseuh added needs response Issue needs response from OP and removed needs triage Issue needs to be triaged labels Oct 10, 2023
@MrAmericanMike
Copy link
Author

The error in your message isn't a runtime error, it's because Stackblitz does not run our tooling and so cannot get the types from .astro files. Are you encountering the same error (or another error) outside Stackblitz?

Yes, exact same error when working locally inside Visual Studio Code

@lilnasy
Copy link
Contributor

lilnasy commented Oct 25, 2023

I am getting a different error.
image

Fixed by setting jsx: preserve in tsconfig.json.

@lilnasy lilnasy added - P2: nice to have Not breaking anything but nice to have (priority) feat: typescript Related to TypeScript (scope) and removed needs response Issue needs response from OP labels Oct 25, 2023
@bluwy
Copy link
Member

bluwy commented Jan 3, 2024

It seems to also be the case for starlight:
image

@Princesseuh would the fix for this be on the language tools side, or is there a jsx misconfiguration, or is it an expected behaviour for now?

@Princesseuh
Copy link
Member

Hmm, the best way would be to add jsx: 'preserve' to our tsconfig.json templates, but I'm not sure if this could potentially cause issues with compilation? If it doesn't cause issues, then that would be my suggestion.

@bluwy
Copy link
Member

bluwy commented Jan 4, 2024

jsx: 'preserve' seems to work fine after a few tests that also mixes React stuff. I could try adding that to the templates then as the solution for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority) feat: typescript Related to TypeScript (scope)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants