Skip to content

Explicit file extensions required for nodenext for type declaration files #78

@nickdnk

Description

@nickdnk

Hello

I'm trying to use this project with react-email, and I compile it with tsc using:
tsc index.ts --target esnext --moduleResolution nodenext --module nodenext --jsx react-jsx

Importing this project like this in index.ts:

import {createMimeMessage, Mailbox, MailboxAddrObject} from "mimetext";

But it complains that file extensions are missing in this configuration:

node_modules/mimetext/dist/MIMEMessageContent.d.ts:1:41 - error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

1 import type { EnvironmentContext } from './MIMEMessage';
                                          ~~~~~~~~~~~~~~~

node_modules/mimetext/dist/MIMEMessageContent.d.ts:2:30 - error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

2 import type { Mailbox } from './Mailbox';
                               ~~~~~~~~~~~

node_modules/mimetext/dist/MIMEMessageHeader.d.ts:1:41 - error TS2834: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Consider adding an extension to the import path.

1 import type { EnvironmentContext } from "./MIMEMessage";
                                          ~~~~~~~~~~~~~~~

It is fixed by simply adding .d.ts to these types, i.e:

import type { EnvironmentContext } from './MIMEMessage.d.ts';

nodenext is required in order to compile react-email, so I cannot omit this. It seems you can also just add .js, but I'm unsure in which places this would cause a problem. It just needs any of the valid file extensions, it seems.

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