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

Enable "useUnknownInCatchVariables" for TypeScript by default #11826

Closed
Tracked by #25162
kitsonk opened this issue Aug 24, 2021 · 5 comments · Fixed by #12547 or #25465
Closed
Tracked by #25162

Enable "useUnknownInCatchVariables" for TypeScript by default #11826

kitsonk opened this issue Aug 24, 2021 · 5 comments · Fixed by #12547 or #25465
Labels
breaking change a change or feature that breaks existing semantics cli related to cli/ dir feat new feature (which has been agreed to/accepted)
Milestone

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Aug 24, 2021

In TypeScript 4.4, the option "useUnknownInCatchVariables" was introduced and was default enabled under "strict" which is the default for Deno. It is a good change, as it helps ensure code properly guards against non-errors being thrown, which if not properly guarded can cause their own runtime errors. The problem is that there is a lot of unsafe code out there, which isn't validating that the value is actually an instance of Error including quite a lot in std, so for 1.14 we are doing to disable it, and then enable it for 1.15 to minimise the impact on code.

A reminder about our position on breaking changes in TypeScript: https://deno.land/[email protected]/typescript/faqs#there-was-a-breaking-change-in-the-version-of-typescript-that-deno-uses-why-did-you-break-my-program

More on the change in TypeScript: https://devblogs.microsoft.com/typescript/announcing-typescript-4-4-rc/#use-unknown-catch-variables

Ref #11678

@kitsonk kitsonk added feat new feature (which has been agreed to/accepted) cli related to cli/ dir breaking change a change or feature that breaks existing semantics labels Aug 24, 2021
@kitsonk kitsonk added this to the 1.15.0 milestone Aug 24, 2021
@kitsonk kitsonk self-assigned this Aug 24, 2021
@kitsonk kitsonk mentioned this issue Sep 17, 2021
17 tasks
@kitsonk kitsonk modified the milestones: 1.15.0, 2.0.0 Sep 17, 2021
@kitsonk kitsonk modified the milestones: 2.0.0, 1.16.0 Oct 18, 2021
kitsonk added a commit to kitsonk/deno that referenced this issue Oct 26, 2021
kitsonk added a commit to kitsonk/deno that referenced this issue Oct 26, 2021
kitsonk added a commit that referenced this issue Oct 27, 2021
Closes #11826

**BREAKING CHANGE** this behaviour was disable when introduced in Deno 1.14/TypeScript 4.4. It will highlight code that unsafely handles variables that are caught, and will cause type errors in unsafe code.
@kitsonk kitsonk reopened this Nov 9, 2021
@kitsonk
Copy link
Contributor Author

kitsonk commented Nov 9, 2021

This was reverted.

@frou
Copy link

frou commented May 29, 2023

@dsherret Should this issue be moved to the Deno 2.0 Milestone? It's currently hanging around on the old 1.16 Milestone.

@dsherret dsherret modified the milestones: 1.16.0, 2.0 May 29, 2023
@bartlomieju bartlomieju removed this from the 2.0 milestone Mar 21, 2024
@jsejcksn
Copy link
Contributor

Hi @bartlomieju: I see this was closed as completed, but I don't see a linked reference to any related commit or merged PR after the original one was reverted. Can you share a link here for context? Thanks!

@bartlomieju
Copy link
Member

@jsejcksn I closed it with a wrong option :( We actually don't plan to implement it after all due to being a huge breaking change for most users. You are encouraged to enable it on a per-project basis in compilerOptions.

@jsejcksn
Copy link
Contributor

@jsejcksn I closed it with a wrong option :( We actually don't plan to implement it after all due to being a huge breaking change for most users. You are encouraged to enable it on a per-project basis in compilerOptions.

@bartlomieju I see. In that case, please consider re-opening it and closing again as not planned so that it can be indexed with other declined issues. (The same with this one if it's the same scenario.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change a change or feature that breaks existing semantics cli related to cli/ dir feat new feature (which has been agreed to/accepted)
Projects
None yet
5 participants