Skip to content

Module imports are problematic in TypeScript #19

@morungos

Description

@morungos

I think it's deeply hidden inside: https://www.typescriptlang.org/tsconfig/#esModuleInterop

When you use:

import removeMarkdown from 'markdown-to-text';

The value removeMarkdown is actually { default: [Function: removeMarkdown] } (not matching the types), It's not easy to work around this, because import { default as.... also doesn't work, oddly still getting the value { default: [Function: removeMarkdown] }. I'm using TypeScript 5.0.0.

I'm way out of my depth here, because I though since both my package and yours are both using esModuleInterop: true we'd be home free, but then I did read: microsoft/TypeScript#27293 (comment), which kind of suggests that targeting CJS might be the issue, maybe.

In any event, a huge win might simply be to also export as a named removeMarkdown, so:

import { removeMarkdown } from 'markdown-to-text';

also works. This is not at all uncommon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions