Skip to content

fix: support .d.mts and .d.cts#3000

Merged
jakebailey merged 5 commits intomicrosoft:v2from
antfu:feat/dcmts
Jun 4, 2024
Merged

fix: support .d.mts and .d.cts#3000
jakebailey merged 5 commits intomicrosoft:v2from
antfu:feat/dcmts

Conversation

@antfu
Copy link
Contributor

@antfu antfu commented Dec 16, 2023

https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext

For example, package shikiji is an ESM-only package that only ships .mjs and .d.mts. The ATA failed to work as failed to find .d.ts and start looking for @types/shikiji, which do not exist either:
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgcwKYwBLGQCwDbY4ypRwC+cAZlBCHAOQDOOwA1sAFbD0BQPAxhAB2jeAEM4AXjhiA7mODw0mQgVzEoACgCUQA

return (firstJS && firstJS.text) || ""
}

const isDtsFile = (name: string) => /\.d\.[cm]?ts$/.test(name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, good to know. Updated

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda frustrating that there's no common way to access this one regex, but, oh well.

Not sure how much it matters but it may technically be more performant to store the regexp object off in a var somewhere and reuse it. not sure if V8 performs that optimization or not, though.

Also will require a package release.

@jakebailey jakebailey added the deploy-preview Enables automatic deployments to preview environments on a PR label Jun 4, 2024
@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2024

Azure Static Web Apps: Your stage site is ready! Visit it here: https://victorious-plant-05c166c10-3000.centralus.5.azurestaticapps.net

@jakebailey jakebailey merged commit 71776ae into microsoft:v2 Jun 4, 2024
@typescript-bot typescript-bot mentioned this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy-preview Enables automatic deployments to preview environments on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants