Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
4 tasks done
danielepolencic opened this issue Jan 20, 2025 · 2 comments
Closed
4 tasks done
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on

Comments

@danielepolencic
Copy link

danielepolencic commented Jan 20, 2025

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

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jan 20, 2025
@wooorm
Copy link
Member

wooorm commented Jan 20, 2025

Hi! The version numbers in your stack are weird: different utilities at different versions, where semver specifies they should not be. Clear your pnpm cache, remove your lockfiles, and do a clean install

Older versions will include bugs, such as this one where null was not supported in the types. Using that with newer versions, with bug fixes, in this case where null is supported in the types, will result in TS doing its job: warning for a mismatch

@wooorm wooorm closed this as not planned Won't fix, can't repro, duplicate, stale Jan 20, 2025
@wooorm wooorm added the 👀 no/external This makes more sense somewhere else label Jan 20, 2025

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👀 no/external This makes more sense somewhere else 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants