Skip to content

Clashing types with mdast-util-gfm and micromark-extension-gfm #41

Closed as not planned
@danielepolencic

Description

@danielepolencic

Initial checklist

Affected package

[email protected]

Steps to reproduce

Please note that this works well with [email protected] and the bug was introduced in 2.0.2.

The following code isn't valid anymore:

import { fromMarkdown } from 'mdast-util-from-markdown'
import { gfm } from 'micromark-extension-gfm'
import { gfmFromMarkdown } from 'mdast-util-gfm'

fromMarkdown(text, 'utf8', {
    extensions: [gfm()],
    mdastExtensions: [gfmFromMarkdown()],
  })

Typescript complains with two very long debug messages:

For gfm:

Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Extension' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Extension'.
  Types of property 'contentInitial' are incompatible.
    Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ConstructRecord | undefined' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ConstructRecord | undefined'.
      Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ConstructRecord' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ConstructRecord'.
        'string' index signatures are incompatible.
          Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct | import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", ...' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct | import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", ...'.
            Type 'Construct' is not assignable to type 'Construct | Construct[] | undefined'.
              Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct'.
                Types of property 'exit' are incompatible.
                  Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Exiter | undefined' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Exiter | undefined'.
                    Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Exiter' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Exiter'.
                      The 'this' types of each signature are incompatible.
                        Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext'.
                          Types of property 'currentConstruct' are incompatible.
                            Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct | undefined' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct | undefined'.
                              Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct'.
                                Types of property 'tokenize' are incompatible.
                                  Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Tokenizer' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Tokenizer'.
                                    The 'this' types of each signature are incompatible.
                                      Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext'.
                                        Types of property 'containerState' are incompatible.
                                          Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ContainerState | undefined' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ContainerState | undefined'.
                                            Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ContainerState' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ContainerState'.
                                              Types of property 'type' are incompatible.
                                                Type 'keyof import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenTypeMap | undefined' is not assignable to type 'keyof import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenTypeMap | undefined'.
                                                  Type '"gfmFootnoteCall"' is not assignable to type 'keyof TokenTypeMap | undefined'.ts(2322)

For gfmFromMarkdown:

Type 'Partial<Config>[]' is not assignable to type 'Extension | Extension[]'.
  Type 'Partial<Config>[]' is not assignable to type 'Extension[]'.
    Type 'Partial<Config>' is not assignable to type 'Extension'.
      Types of property 'enter' are incompatible.
        Type 'Handles | undefined' is not assignable to type 'Handles | null | undefined'.
          Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index", { with: { "resolution-mode": "import" } }).Handles' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/types", { with: { "resolution-mode": "import" } }).Handles'.
            'string' index signatures are incompatible.
              Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index", { with: { "resolution-mode": "import" } }).Handle' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/types", { with: { "resolution-mode": "import" } }).Handle'.
                The 'this' types of each signature are incompatible.
                  Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/types", { with: { "resolution-mode": "import" } }).CompileContext' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index", { with: { "resolution-mode": "import" } }).CompileContext'.
                    Types of property 'tokenStack' are incompatible.
                      Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/types", { with: { "resolution-mode": "import" } }).TokenTuple[]' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index", { with: { "resolution-mode": "import" } }).TokenTuple[]'.
                        Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/types", { with: { "resolution-mode": "import" } }).TokenTuple' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index", { with: { "resolution-mode": "import" } }).TokenTuple'.
                          Type at position 0 in source is not compatible with type at position 0 in target.
                            The types of '_tokenizer' are incompatible between these types.
                              Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext | undefined' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext | undefined'.
                                Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext'.
                                  Types of property 'currentConstruct' are incompatible.
                                    Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct | undefined' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct | undefined'.
                                      Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Construct'.
                                        Types of property 'tokenize' are incompatible.
                                          Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Tokenizer' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).Tokenizer'.
                                            The 'this' types of each signature are incompatible.
                                              Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenizeContext'.
                                                Types of property 'containerState' are incompatible.
                                                  Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ContainerState | undefined' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ContainerState | undefined'.
                                                    Type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ContainerState' is not assignable to type 'import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).ContainerState'.
                                                      Types of property 'type' are incompatible.
                                                        Type 'keyof import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenTypeMap | undefined' is not assignable to type 'keyof import("/myproj/node_modules/.pnpm/[email protected]/node_modules/micromark-util-types/index", { with: { "resolution-mode": "import" } }).TokenTypeMap | undefined'.
                                                          Type '"gfmFootnoteCall"' is not assignable to type 'keyof TokenTypeMap | undefined'.ts(2322)

Actual behavior

The types don't work anymore

Expected behavior

The types should match

Runtime

Typescript 5.7.2

Package manager

No response

Operating system

No response

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    👀 no/externalThis makes more sense somewhere else👎 phase/noPost cannot or will not be acted on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions