Skip to content

[TypeScript] @mdx-js/rollup doesn't match Vite 3's plugin types #2105

@guoyunhe

Description

@guoyunhe

Initial checklist

Affected packages and versions

@mdx-js/rollup 2.1.2

Link to runnable example

No response

Steps to reproduce

Create a vite.config.ts with:

import mdx from '@mdx-js/rollup';
import react from '@vitejs/plugin-react';
import { UserConfig } from 'vite';

const config: UserConfig = {
    plugins: [
      react({ jsxRuntime: 'classic' }),
      mdx({
        jsxRuntime: 'classic',
        providerImportSource: '@mdx-js/react',
      }) as any,
    ],
}

export default config;

Expected behavior

TypeScript should not show errors

Actual behavior

TypeScript shows errors:

error TS2322: Type 'Plugin' is not assignable to type 'PluginOption'.
  Type 'Plugin' is not assignable to type 'Plugin_2'.
    Types of property 'resolveId' are incompatible.
      Type 'ObjectHook<(this: PluginContext, source: string, importer: string | undefined, options: { custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>, {}> | undefined' is not assignable to type '((this: PluginContext, source: string, importer: string | undefined, options: { custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>) | undefined'.
        Type '{ handler: (this: PluginContext, source: string, importer: string | undefined, options: { custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>; order?: "pre" | ... 2 more ... | undefined; }' is not assignable to type '(this: PluginContext, source: string, importer: string | undefined, options: { custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>'.
          Type '{ handler: (this: PluginContext, source: string, importer: string | undefined, options: { custom?: CustomPluginOptions | undefined; isEntry: boolean; }) => ResolveIdResult | Promise<...>; order?: "pre" | ... 2 more ... | undefined; }' provides no match for the signature '(this: PluginContext, source: string, importer: string | undefined, options: { custom?: CustomPluginOptions | undefined; ssr?: boolean | undefined; isEntry: boolean; }): ResolveIdResult | Promise<...>'.

 38       mdx({
          ~~~~~
 39         jsxRuntime: 'classic',
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 42       }),
    ~~~~~~~~

    at createTSError (/Users/guoyunhe/Git/cratedx/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/guoyunhe/Git/cratedx/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/guoyunhe/Git/cratedx/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/guoyunhe/Git/cratedx/node_modules/ts-node/src/index.ts:1433:41)
    at transformSource (/Users/guoyunhe/Git/cratedx/node_modules/ts-node/src/esm.ts:400:37)
    at /Users/guoyunhe/Git/cratedx/node_modules/ts-node/src/esm.ts:278:53
    at async addShortCircuitFlag (/Users/guoyunhe/Git/cratedx/node_modules/ts-node/src/esm.ts:409:15)
    at async ESMLoader.load (node:internal/modules/esm/loader:359:20)
    at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:280:47) {
  diagnosticCodes: [ 2322 ]
}

Runtime

Node v16

Package manager

npm v8

OS

macOS

Build and bundle tools

Vite

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