Skip to content

Change source of truth for types to umd/index.d.ts to resolve issue with typescript import in 5.x (Resolves #109)#130

Merged
dcodeIO merged 1 commit into
dcodeIO:mainfrom
SimplyLinn:main
Jan 9, 2025
Merged

Change source of truth for types to umd/index.d.ts to resolve issue with typescript import in 5.x (Resolves #109)#130
dcodeIO merged 1 commit into
dcodeIO:mainfrom
SimplyLinn:main

Conversation

@SimplyLinn

@SimplyLinn SimplyLinn commented Nov 22, 2023

Copy link
Copy Markdown
Contributor

The previous PR to resolve this issue (#124) ended up duplicating the types to the umd module.

Moving the source-of-truth to the ./umd/index.d.ts file enables the ./index.d.ts file to import the class from the umd subdirectory with no issues. The other way around, however, seems to be the cause of the issues.

My suggestion is to move the source of truth to the umd declaration file, and import it from the root index.d.ts, as to avoid duplicated code, while still keeping the types functional.

This would resolve #109

@SimplyLinn SimplyLinn changed the title Change source of truth for types to umd/index.d.ts to resolve issue with typescript import in 5.x Change source of truth for types to umd/index.d.ts to resolve issue with typescript import in 5.x (Resolves #109) Nov 22, 2023
@arnidan

arnidan commented Jan 18, 2024

Copy link
Copy Markdown

@dcodeIO hello! Could you review the PR?

@dcodeIO

dcodeIO commented Jan 18, 2024

Copy link
Copy Markdown
Owner

Have ya'll verified that the proposed change indeed works for both ESM and CJS/UMD?

@alecgibson

Copy link
Copy Markdown

@dcodeIO we're trying to move a project from CJS to ESM, and it looks like if we swap the imports like in this PR, it works in both CJS and ESM.

@TangrisJones

Copy link
Copy Markdown

Would love to get this merged! 🙏

@yinzara

yinzara commented Feb 6, 2024

Copy link
Copy Markdown

Also would love to get this merged. Requires we enable skipLibCheck which we don't love

@aakasheoran

Copy link
Copy Markdown

@dcodeIO Were you able to review this? We need this fix. I have tested it as well and it works fine.

@gillg

gillg commented Jun 5, 2024

Copy link
Copy Markdown

Any news ?

tec27 added a commit to ShieldBattery/ShieldBattery that referenced this pull request Sep 17, 2024
tec27 added a commit to ShieldBattery/ShieldBattery that referenced this pull request Oct 3, 2024
@nhuethmayr

Copy link
Copy Markdown

Can we merge this one @dcodeIO?

@Sam-Spencer

Copy link
Copy Markdown

@dcodeIO Can we please get this merged?

@manoelcamillo

Copy link
Copy Markdown

@dcodeIO Can we please get this merged? I had to use skipLibCheck im my project too

@zachrussell12

Copy link
Copy Markdown

Also still having this issue. Don't want to have to set skipLibCheck in my project.

@smaye81

smaye81 commented Feb 3, 2025

Copy link
Copy Markdown

I think this change may still require skipLibCheck in some instances. If you are using moduleResolution of node16 or nodenext, you will start seeing:

Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Did you mean './umd/index.js'?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable import in TypeScript since v5+