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

🐛 BUG: Can't stop typescript errors #706

Closed
cdtut opened this issue Nov 20, 2023 · 19 comments
Closed

🐛 BUG: Can't stop typescript errors #706

cdtut opened this issue Nov 20, 2023 · 19 comments
Labels
- P2: has workaround Bug, but has workaround (priority) ecosystem: upstream Issue is caused by a bug / missing feature upstream

Comments

@cdtut
Copy link

cdtut commented Nov 20, 2023

Describe the Bug

Can't stop typescript errors appearing.

Steps to Reproduce

Front matter

const array = [
  { required: '' },
  { required: '', optional: '' }
]
array[1].optional

optional is underlined in red and hovering explains error Property 'optional' does not exist on type '{ required: string; optional?: undefined; }'.ts(2339)

I tried to disable validation with "checkJs": false in jsconfig.json and "typescript.validate.enable": false in settings but it doesn't stop errors.

No error putting that code in .js file but error still in .astro file.

Using typescript is not requirement for astro so should not be required to write any typescript to stop these errors. They shouldn't appear if typescript checks are disabled.

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Nov 20, 2023
@Princesseuh
Copy link
Member

Princesseuh commented Nov 20, 2023

Astro is TypeScript only at this time, TypeScript cannot be disabled. Nonetheless, yes, I believe that option should be working

@cdtut
Copy link
Author

cdtut commented Nov 20, 2023

Instead of "typescript.validate.enable": false can an extension specific setting be added to settings file disabling typescript errors in astro files? Can be people who don't want disable all typescript validation if they're writing typescript in non astro files but are writing astro as javascript (without type annotations which is valid typescript).

@Princesseuh
Copy link
Member

Princesseuh commented Nov 20, 2023

We'd rather make that option work if that's a possibility

@cdtut
Copy link
Author

cdtut commented Nov 22, 2023

Is there any workaround until fixed? Disruptive for developing and causes to miss important errors because so many things are underlined in red. Even every access under Astro.locals complains with error that property doesn't exist.

@Princesseuh Princesseuh added ecosystem: upstream Issue is caused by a bug / missing feature upstream - P2: nice to have Not breaking anything but nice to have (priority) and removed needs triage Issue needs to be triaged labels Dec 4, 2023
@cdtut
Copy link
Author

cdtut commented Dec 5, 2023

@Princesseuh Can it be P1 bug? There are so many error everywhere. I can give more example. Cannot trust errors in IDE anymore because most of them are because of this extension instead of real problems with code. Trusting errors is more than nice to have I believe, it's very frustrating developer experience.

@Princesseuh
Copy link
Member

Princesseuh commented Dec 5, 2023

@Princesseuh Can it be P1 bug? There are so many error everywhere. I can give more example. Cannot trust errors in IDE anymore because most of them are because of this extension instead of real problems with code. Trusting errors is more than nice to have I believe, it's very frustrating developer experience.

TypeScript errors are real errors.. I'm sorry this is affecting your experience so much, but it's a niche issue, people typically use TypeScript just fine. You can use // @ts-nocheck in the meantime

@Princesseuh Princesseuh added - P2: has workaround Bug, but has workaround (priority) and removed - P2: nice to have Not breaking anything but nice to have (priority) labels Dec 5, 2023
@cdtut
Copy link
Author

cdtut commented Dec 5, 2023

TypeScript errors are real errors..

This is opinion and objectively wrong. There are many example that run and build fine but this extension still complain with error. Rule of thumb is if it runs without error in astro and browser it's not an error.

it's a niche issue, people typically use TypeScript just fine

People typically use javascript just fine. It is allowed to write vanilla javascript in astro and everyone should respect right to choose for own code.

@Princesseuh
Copy link
Member

Fixed by volarjs/services@6f13b47, we'll release an update with it soon-ish

@cdtut
Copy link
Author

cdtut commented Jan 19, 2024

Is it in 2.6.2?

@Princesseuh
Copy link
Member

Nope, not yet sorry. There was an unexpected delay, unfortunately. The holidays period also delayed things a fair amount. Still definitely planned, though!

@cdtut
Copy link
Author

cdtut commented Feb 8, 2024

Is it in 2.7.1?

@Princesseuh
Copy link
Member

Yes, it should work now!

@cdtut
Copy link
Author

cdtut commented Feb 9, 2024

I still have typescript errors like Property 'item' does not exist on type 'Element'. ts(2339). Is enough to set "typescript.validate.enable": false`?

@cdtut
Copy link
Author

cdtut commented Feb 12, 2024

@Princesseuh working for you?

@Princesseuh
Copy link
Member

Ah, it only seems to be working for certain kinds of errors, I'll take a look. Sorry for the inconvenience.

@cdtut
Copy link
Author

cdtut commented Feb 21, 2024

@Princesseuh can you open this issue?

@Princesseuh
Copy link
Member

I'll open an issue on the upstream project instead, since the code for this isn't in this repo

@cdtut
Copy link
Author

cdtut commented Feb 26, 2024

@Princesseuh where to find that issue number?

@Princesseuh
Copy link
Member

Princesseuh commented Feb 27, 2024

The option works as expected for me right now after the latest updates:
image
(removing the option shows a type error in both files)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: has workaround Bug, but has workaround (priority) ecosystem: upstream Issue is caused by a bug / missing feature upstream
Projects
None yet
Development

No branches or pull requests

2 participants