Skip to content

Typechecking fails with "moduleResolution": "node16" or "nodenext" #6

Closed
@jameshfisher

Description

@jameshfisher

Initial checklist

Affected packages and versions

mdast-util-directive@2.2.2

Link to runnable example

https://github.com/jameshfisher/bug-report-remark-node16

Steps to reproduce

Set "moduleResolution" to "node16" or "nodenext" in tsconfig.json.

Run tsc.

Expected behavior

No typechecking errors.

Actual behavior

$ npm run build

> test-remark-node16@1.0.0 build
> tsc

example.ts:10:10 - error TS2367: This comparison appears to be unintentional because the types '"link" | "html" | "strong" | "image" | "text" | "linkReference" | "emphasis" | "delete" | "break" | "footnote" | "inlineCode" | "imageReference" | "footnoteReference"' and '"textDirective"' have no overlap.

10   return p.type === "textDirective";
            ~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/mdast-util-directive/index.d.ts:14:69 - error TS2694: Namespace '"/Users/jim/dev/tmp/test-remark-node16/node_modules/mdast-util-to-markdown/lib/types"' has no exported member 'Context'.

14 export type Context = import('mdast-util-to-markdown/lib/types.js').Context
                                                                       ~~~~~~~

node_modules/mdast-util-directive/index.d.ts:17:41 - error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

17 export type ContainerDirective = import('./complex-types').ContainerDirective
                                           ~~~~~~~~~~~~~~~~~

node_modules/mdast-util-directive/index.d.ts:18:36 - error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

18 export type LeafDirective = import('./complex-types').LeafDirective
                                      ~~~~~~~~~~~~~~~~~

node_modules/mdast-util-directive/index.d.ts:19:36 - error TS2834: Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

19 export type TextDirective = import('./complex-types').TextDirective
                                      ~~~~~~~~~~~~~~~~~


Found 5 errors in 2 files.

Errors  Files
     1  example.ts:10
     4  node_modules/mdast-util-directive/index.d.ts:14

Affected runtime and version

Node 16

Affected package manager and version

npm 8

Affected OS and version

macOS

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions