typescript TS1005 error when importing types from type definition

Viewed 17

One of the libraries (parse5) used by my project is exposing typing information (in .d.ts files) using the following syntax to import types:

import { type CharacterToken, type DoctypeToken, type TagToken, type EOFToken, type CommentToken } from '../common/token.js';

This is causing a bunch of typescript errors when running the application, since it looks like typescript doesn't recognise this why of importing types.

If I change the syntax to

import type { CharacterToken, DoctypeToken, TagToken, EOFToken, CommentToken } from '../common/token.js';

I don't get any error.

might it be that I'm using a wrong tsc version?

1 Answers

In TypeScript(3.8) you should use import type { SomeThing } from "./some-module.js";, not import { type SomeThing } from "./some-module.js";

More info

Related