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

Properly include and export TypeScript types #248

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Properly include and export TypeScript types #248

merged 1 commit into from
Sep 18, 2023

Conversation

nex3
Copy link
Contributor

@nex3 nex3 commented Sep 15, 2023

We need to copy the entrypoing typings file, as described in the
TypeScript docs
:

It’s important to note that the CommonJS entrypoint and the ES
module entrypoint each needs its own declaration file, even if the
contents are the same between them. Every declaration file is
interpreted either as a CommonJS module or as an ES module, based on
its file extension and the "type" field of the package.json, and
this detected module kind must match the module kind that Node will
detect for the corresponding JavaScript file for type checking to be
correct. Attempting to use a single .d.ts file to type both an ES
module entrypoint and a CommonJS entrypoint will cause TypeScript to
think only one of those entrypoints exists, causing compiler errors
for users of the package.

Closes #247

@nex3 nex3 requested a review from Goodwine September 15, 2023 23:49
nex3 added a commit to sass/dart-sass that referenced this pull request Sep 15, 2023
We need to copy the entrypoing typings file, as described in [the
TypeScript docs]:

> It’s important to note that the CommonJS entrypoint and the ES
> module entrypoint each needs its own declaration file, even if the
> contents are the same between them. Every declaration file is
> interpreted either as a CommonJS module or as an ES module, based on
> its file extension and the `"type"` field of the `package.json`, and
> this detected module kind must match the module kind that Node will
> detect for the corresponding JavaScript file for type checking to be
> correct. Attempting to use a single `.d.ts` file to type both an ES
> module entrypoint and a CommonJS entrypoint will cause TypeScript to
> think only one of those entrypoints exists, causing compiler errors
> for users of the package.

[the TypeScript docs]: https://www.typescriptlang.org/docs/handbook/esm-node.html

Closes #247
@nex3 nex3 merged commit ffa9947 into main Sep 18, 2023
16 checks passed
@nex3 nex3 deleted the typescript branch September 18, 2023 20:50
nex3 added a commit to sass/dart-sass that referenced this pull request Sep 18, 2023
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.

package.json should be updated to support TypeScripts bundler module resolution
2 participants