Skip to content

Not resolving to the right export #916

Open
@abstractalgo

Description

@abstractalgo

We are using https://www.npmjs.com/package/markdown-to-jsx in our project. And import a namespace from it via:

import type { MarkdownToJSX } from 'markdown-to-jsx'`

With "typescript": "5.8.3" things work as expected.

With "@typescript/native-preview": "^7.0.0-dev.20250522.2", there's the following error:

Module '"/Users/.../my-repo/node_modules/markdown-to-jsx/dist/index.cjs"' has no exported member 'MarkdownToJSX'. Did you mean to use 'import MarkdownToJSX from "/Users/.../my-repo/node_modules/markdown-to-jsx/dist/index.cjs"' instead?

import type { MarkdownToJSX } from 'markdown-to-jsx';

Checking markdown-to-jsx's "exports", things look reasonable enough:

"exports": {
    ".": {
      "import": {
        "types": "./dist/index.d.ts",
        "node": "./dist/index.module.js",
        "default": "./dist/index.modern.js"
      },
      "require": {
        "types": "./dist/index.cjs.d.ts",
        "default": "./dist/index.cjs"
      }
    }
  },

It looks suspicious that tsgo tries to resolve to CJS files, and not ESM.


For ref, here's our repo's full TSconfig:

TSconfig

{
  "compilerOptions": {
    // type checking
    "strict": true,
    "allowUnusedLabels": false,
    "allowUnreachableCode": false,
    "noUnusedLocals": true,
    "noFallthroughCasesInSwitch": true,
    "noUnusedParameters": true,
    "noImplicitThis": true,
    "useUnknownInCatchVariables": true,
    "noPropertyAccessFromIndexSignature": false,
    "noImplicitReturns": false,
    "noUncheckedIndexedAccess": false,
    "noImplicitAny": false,
    // modules
    "baseUrl": "./",
    "module": "Preserve",
    "moduleResolution": "bundler",
    "paths": {
      "MODULES/*": ["./src/modules/*"],
      "UTILS/*": ["./src/utils/*"],
      "LEGACY/*": ["./src/LEGACY/*"],
      "SRC/*": ["./src/*"]
    },
    "resolveJsonModule": true,
    // emit
    "noEmit": true,
    // JS support
    "allowJs": false,
    // interop
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "isolatedModules": true,
    "verbatimModuleSyntax": false,
    // language and environment
    "target": "es2021",
    "lib": ["dom", "dom.iterable", "esnext"],
    "jsx": "react-jsx",
    // completeness
    "skipLibCheck": true
  },
  "exclude": ["node_modules", "cypress", "coverage", "build"],
  "include": [
    "./@types/**/*.ts",
    "./src/**/*.ts",
    "./src/**/*.tsx",
    "node_modules/vitest/globals.d.ts",
    "./playwright"
  ]
}

Activity

filipsobol

filipsobol commented on May 23, 2025

@filipsobol

This might be the same issue as described here: #895 (comment)

See #904.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Module ResolutionRelated to module resolution and module checker errors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @abstractalgo@filipsobol@jakebailey

        Issue actions

          Not resolving to the right export · Issue #916 · microsoft/typescript-go