Typescript Import Problem after updating Deno

Viewed 3711

I recently update deno from v1.3.0 to v1.4.0. Before updating, my code doesn't have any problem, but after that i have this error:

error: TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
  LevelName,
  ~~~~~~~~~
    at https://deno.land/x/branch@0.0.2/deps.ts:8:3

TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
export { LogConfig, setup, prefix } from "./branch.ts";
         ~~~~~~~~~
    at https://deno.land/x/branch@0.0.2/mod.ts:3:10

TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { WatcherConfig } from "./watcher.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/denon@2.3.3/src/config.ts:14:1

TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { RunnerConfig } from "./runner.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/denon@2.3.3/src/config.ts:15:1

TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { Args } from "./args.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/denon@2.3.3/src/config.ts:18:1

TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { Template } from "./templates.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/denon@2.3.3/src/config.ts:19:1

TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { Denon, DenonEvent } from "../denon.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/denon@2.3.3/src/daemon.ts:5:1

TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { CompleteDenonConfig } from "./config.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/denon@2.3.3/src/daemon.ts:6:1

TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { ScriptOptions } from "./scripts.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    at https://deno.land/x/denon@2.3.3/src/daemon.ts:7:1

I found a page that fix this problem, but this error looks like it's coming from third party library. I also use Denon to run the script. Here is my imported package:

import { Application } from "https://deno.land/x/oak/mod.ts";
import { oakCors } from "https://deno.land/x/cors/mod.ts";
import { Router } from "https://deno.land/x/oak/mod.ts";
import { RouterContext } from "https://deno.land/x/oak/mod.ts";
import * as bcrypt from "https://deno.land/x/bcrypt/mod.ts";
import { SmtpClient } from "https://deno.land/x/smtp/mod.ts";
import { MongoClient } from "https://deno.land/x/mongo@v0.11.1/mod.ts";

And this is my denon.json:

{
  "$schema": "https://deno.land/x/denon/schema.json",
  "scripts": {
    "start": {
      "cmd": "deno run --unstable server.ts",
      "allow": [
        "net",
        "write",
        "read",
        "plugin"
      ]
    }
  }
}

Is there a way to fix this? or a way to downgrade Deno?

6 Answers

Setting tsconfig like this will solve the problem

{
  "compilerOptions": {
    "importsNotUsedAsValues": "remove",
    "isolatedModules": false,
  }
}

Or you could just do import type instead of just import where necessary.

As you asked, if you want to downgrade, you can do as

With Shell:

curl -fsSL https://deno.land/x/install/install.sh | sh -s v1.3.0

With Scoop:

scoop install deno@1.3.0

Or you can check for a different environment here.

The DevLoverUmar's solution to downgrade did'nt work for me, but this one did :

deno upgrade --version 1.3.0

The TS1205 "Re-exporting a type..." check is now included in Deno 1.5 by default.

This section of the release notes has more instructions on how to update affected code or turn it off.

Related