Skip to content

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

Open
@thisisjofrank

Description

@thisisjofrank

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    deno 2Doc changes for Deno 2documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions