Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Esm requires file extension in d.ts files. #1018

Closed
ankoh opened this issue Apr 14, 2024 · 2 comments · Fixed by #1020
Closed

[Bug] Esm requires file extension in d.ts files. #1018

ankoh opened this issue Apr 14, 2024 · 2 comments · Fixed by #1020
Assignees
Labels

Comments

@ankoh
Copy link

ankoh commented Apr 14, 2024

Typescript projects using the moduleResolution NodeNext or node16 cannot consume @primer/octicons-react 19.9.0 (and transitively @primer/react36.13.0, regressing from 36.12.0) since the icons type definition is not imported with a file extension.

The import will just fail and, when peeking into the index.d.mts, you'll find the error:

relative import paths need explicit file extensions in ecmascript imports

Patch that worked for me on dist:

diff --git a/dist/index.d.mts b/dist/index.d.mts
index acfe71a1ce71b4764c3d155334b3bbc2830ea5d0..8539c08534ff1732a8f80c3ba850dfd6cc7f4ac8 100644
--- a/dist/index.d.mts
+++ b/dist/index.d.mts
@@ -2,7 +2,7 @@
 import * as React from 'react'
 
 // eslint-disable-next-line prettier/prettier
-import { Icon } from './icons'
+import { Icon } from './icons.js'
 
 type Size = 'small' | 'medium' | 'large'
 
@@ -20,4 +20,4 @@ export interface OcticonProps {
   verticalAlign?: 'middle' | 'text-bottom' | 'text-top' | 'top' | 'unset'
 }
 
-export * from './icons'
+export * from './icons.js'

I guess it's just https://github.com/primer/octicons/blob/main/lib/octicons_react/src/index.d.ts

@ankoh ankoh added the octicon label Apr 14, 2024
@ankoh
Copy link
Author

ankoh commented Apr 14, 2024

@joshblack since this was introduced with #1008

@joshblack
Copy link
Member

Thanks for taking the time to make this issue @ankoh! Really appreciate it. Opened a PR over at: #1020 to (hopefully) address this 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants