Skip to content

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

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

Merged
merged 5 commits into from
Jun 4, 2024
Merged

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

merged 5 commits into from
Jun 4, 2024

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

@@ -314,12 +314,15 @@ export const createTypeScriptSandbox = (
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
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
9 checks passed
@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