Skip to content

Fix type definitions for CommonJS and ESM#7377

Merged
ybiquitous merged 3 commits intostylelint:mainfrom
remcohaszing:fix-types
Dec 8, 2023
Merged

Fix type definitions for CommonJS and ESM#7377
ybiquitous merged 3 commits intostylelint:mainfrom
remcohaszing:fix-types

Conversation

@remcohaszing
Copy link
Copy Markdown
Contributor

This fixes the type definitions for CJS by leveraging a namespace. ESM type definitions were added, which export all types from the CJS types, and exports the exported stylelint object as default.

Some tweaks were made to the package.json exports, to resolve the types correctly for both CJS and ESM.

The type test was modified to fix CJS usage. Also a test was added for ESM usage. Stylelint was using tsconfig paths, which is a commonly misunderstood / misused feature that should rarely be used. This was removed, so TypeScript resolves the types based on package exports.

Which issue, if any, is this issue related to?

Refs 7309

Is there anything in the PR that needs further explanation?

https://arethetypeswrong.github.io/?p=stylelint@16.0.0 before this PR:

The result of ATTW showing a lot of errors

After uploading the result of npm pack after this PR:

The result of ATTW showing green checkmarks


This is best reviewed with whitespace changes disabled.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants