-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: typescript-estree should allow using
declaration in ambient context
#11244
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
Comments
Do you have a real world usecase for this? Cos honestly I'm pretty okay with this failing given its pretty nonsensical code... "just use |
using
declaration in ambient context
I don't expect there are real world case, this feature just begins to ship very recently. Given that tsc already accept Of course if tsc decides to forbid |
The complication is that the parser has no way to reliably detect ambient contexts without reproducing a lot of detection logic, so traditionally to allow ambient declaration syntax we must allow them wholesale in the parser, for example uninitialized |
Yeah I'm personally okay with us being incorrect here because having to detect the "ambient declaration context" is a pain and not something we do in the parser right now. Without a real-world usecase I don't personally see the motivation to build that logic in -- I don't think that academic correctness is a good enough reason. cc @typescript-eslint/triage-team thoughts? |
Before You File a Bug Report Please Confirm You Have Done The Following...
Relevant Package
typescript-estree
Playground Link
https://typescript-eslint.io/play/#ts=5.8.3&sourceType=script&fileType=.ts&code=CYUwxgNghgTiAEA7KBbEBnADlMCBuUEAlsAPrJpY4ikEzwDeAUPPAK7pGIDm8AIgG4mAXyZA&eslintrc=N4KABGBEBOCuA2BTAzpAXGYBfEWg&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA&tokens=true
Repro Code
ESLint Config
tsconfig
Expected Result
Pass. The TS Playground is happy about that: https://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEA7KBbEBnADlMCBuUEAlsAPrJpY4ikEzwDeAUPPAK7pGIDm8AIgG4mAXyZA
Actual Result
Error is thrown from
typescript-eslint/packages/typescript-estree/src/convert.ts
Line 1247 in 4ad8a07
Additional Info
No response
Versions
@typescript-eslint/typescript-estree
8.32.1
The text was updated successfully, but these errors were encountered: