Typescript Import Problem after updating Deno
Asked Answered
R

6

9

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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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?

Riant answered 14/9, 2020 at 9:29 Comment(3)
Which OS you are working on?Dabbs
I'm working with WindowsRiant
downgrade deno version to 1.3.3Turn
C
7

Setting tsconfig like this will solve the problem

{
  "compilerOptions": {
    "importsNotUsedAsValues": "remove",
    "isolatedModules": false,
  }
}
Cephalonia answered 10/10, 2020 at 13:44 Comment(0)
W
6

There was an unstable feature added in Deno v1.4.0. https://github.com/denoland/deno/pull/7413. A similar issue was here https://github.com/Jozty/Fae/issues/32 This will be fixed by the library writers or you can raise PR with a fix. A temporary fix is to downgrade Deno to v1.3.0

Wintery answered 14/9, 2020 at 16:4 Comment(0)
K
3

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

Kurr answered 30/12, 2020 at 5:28 Comment(0)
D
2

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 [email protected]

Or you can check for a different environment here.

Dabbs answered 14/9, 2020 at 12:11 Comment(0)
D
2

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

deno upgrade --version 1.3.0

Doordie answered 18/9, 2020 at 8:37 Comment(0)
I
1

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.

Ideal answered 22/11, 2020 at 17:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.