Skip to content

error TS6137: Cannot import type declaration files. Consider importing 'hast' instead of '@types/hast'. #8

@andersk

Description

@andersk

The npm package incorrectly uses

import type * as hast from "@types/hast";

which causes TypeScript errors with "module": "nodenext". This should be

import type * as hast from "hast";

Related:

Minimal reproduction

tsconfig.json

{
  "compilerOptions": {
    "module": "nodenext",
    "noEmit": true,
    "jsx": "react-jsx",
    "jsxImportSource": "hastx",
  }
}

hello.tsx

const hello = <h1>Hello, world!</h1>;
$ npm i hastx typescript
$ npx tsc
node_modules/hastx/script/html.d.ts:1:28 - error TS6137: Cannot import type declaration files. Consider importing 'hast' instead of '@types/hast'.

1 import type * as hast from "@types/hast";
                             ~~~~~~~~~~~~~

node_modules/hastx/script/jsx-runtime.d.ts:1:28 - error TS6137: Cannot import type declaration files. Consider importing 'hast' instead of '@types/hast'.

1 import type * as hast from "@types/hast";
                             ~~~~~~~~~~~~~

node_modules/hastx/script/svg.d.ts:1:28 - error TS6137: Cannot import type declaration files. Consider importing 'hast' instead of '@types/hast'.

1 import type * as hast from "@types/hast";
                             ~~~~~~~~~~~~~


Found 3 errors in 3 files.

Errors  Files
     1  node_modules/hastx/script/html.d.ts:1
     1  node_modules/hastx/script/jsx-runtime.d.ts:1
     1  node_modules/hastx/script/svg.d.ts:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions