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

update deno 1-2 migration guide with useUnknownInCatchVariables change #1154

Open
thisisjofrank opened this issue Nov 19, 2024 · 0 comments
Open
Labels
deno 2 Doc changes for Deno 2 documentation Improvements or additions to documentation

Comments

@thisisjofrank
Copy link
Collaborator

in Deno 2 we enabled useUnknownInCatchVariables by default. Previously the caught value would be any, now it is unknown.

try {} catch (error) {
  console.log(error.message);
}

with Deno 1.x:

% deno --version
deno 1.44.0 (release, aarch64-apple-darwin)
v8 12.6.228.3
typescript 5.4.5

% deno check index.ts
Check file:///Users/eduardoboucas/Sites/tests/deno-20-test/index.ts

with Deno 2.x:

% deno --version
deno 2.0.6 (stable, release, aarch64-apple-darwin)
v8 12.9.202.13-rusty
typescript 5.6.2

% deno check index.ts                         
Check file:///Users/eduardoboucas/Sites/tests/deno-20-test/index.ts
error: TS18046 [ERROR]: 'error' is of type 'unknown'.
  console.log(error.message);
              ~~~~~
    at file:///Users/eduardoboucas/Sites/tests/deno-20-test/index.ts:3:15
@thisisjofrank thisisjofrank added documentation Improvements or additions to documentation deno 2 Doc changes for Deno 2 labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deno 2 Doc changes for Deno 2 documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant