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

Fix TypeScript type definitions #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

remcohaszing
Copy link

There’s no need to use declare module. This is only useful to declare modules that don’t match the package name, e.g. to declare fs in @types/node.

This is a CommonJS module that uses module.exports =. The correct type definition is export =.

Technically the old type definitions work too, because module.exports.default is defined. However, with the new "module": "node16" option this means it should be used as follows in native ESM:

import Concat from 'concat-with-sourcemaps'

new Concat.default(true, 'all.js')

This is typically undesirable.

There’s no need to use `declare module`. This is only useful to declare
modules that don’t match the package name, e.g. to declare `fs` in
`@types/node`.

This is a CommonJS module that uses `module.exports =`. The correct type
definition is `export =`.

Technically the old type definitions work too, because
`module.exports.default` is defined. However, with the new
`"module": "node16"` option this means it should be used as follows in
native ESM:

```ts
import Concat from 'concat-with-sourcemaps'

new Concat.default(true, 'all.js')
```

This is typically undesirable.
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.

1 participant