Fix type definitions for CommonJS and ESM#7377
Merged
ybiquitous merged 3 commits intostylelint:mainfrom Dec 8, 2023
remcohaszing:fix-types
Merged
Fix type definitions for CommonJS and ESM#7377ybiquitous merged 3 commits intostylelint:mainfrom remcohaszing:fix-types
ybiquitous merged 3 commits intostylelint:mainfrom
remcohaszing:fix-types
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.Refs 7309
https://arethetypeswrong.github.io/?p=stylelint@16.0.0 before this PR:
After uploading the result of
npm packafter this PR:This is best reviewed with whitespace changes disabled.