Skip to content

feat: add JSDoc types and TypeScript declaration generation#464

Merged
alexander-akait merged 5 commits into
mainfrom
claude/jsdoc-types-generation-xNIdz
May 25, 2026
Merged

feat: add JSDoc types and TypeScript declaration generation#464
alexander-akait merged 5 commits into
mainfrom
claude/jsdoc-types-generation-xNIdz

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Annotate the source with JSDoc, add a tsconfig.json, and emit TypeScript declarations to types/. The package now exposes types via the exports/types fields, mirroring how sass-loader ships them.

Summary

What kind of change does this PR introduce?

Did you add tests for your changes?

Does this PR introduce a breaking change?

If relevant, what needs to be documented once your changes are merged or what have you already documented?

Use of AI

Annotate the source with JSDoc, add a `tsconfig.json`, and emit
TypeScript declarations to `types/`. The package now exposes types via
the `exports`/`types` fields, mirroring how `sass-loader` ships them.
Copilot AI review requested due to automatic review settings May 22, 2026 10:01
@linux-foundation-easycla

linux-foundation-easycla Bot commented May 22, 2026

Copy link
Copy Markdown

CLA Not Signed

@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.33333% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.21%. Comparing base (8ff6fa6) to head (b2c6a99).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/utils.js 97.92% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #464      +/-   ##
==========================================
+ Coverage   95.28%   96.21%   +0.93%     
==========================================
  Files           2        2              
  Lines         996     1269     +273     
==========================================
+ Hits          949     1221     +272     
- Misses         47       48       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds first-class TypeScript support for stylus-loader by annotating the JS source with JSDoc, introducing a tsconfig.json for declaration emit, and shipping the generated .d.ts files via exports/types in package.json.

Changes:

  • Added JSDoc typedefs throughout src/ (and some helpers) and generated declaration outputs into types/.
  • Introduced tsconfig.json and new build:types / lint:types scripts to emit and typecheck declarations.
  • Updated package metadata (exports, types, files) and lockfile to include the new typing toolchain.

Reviewed changes

Copilot reviewed 12 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
types/utils.d.ts New generated declaration file for utility types and exported helper APIs.
types/index.d.ts New generated declaration file for the loader entry point and re-exported types.
tsconfig.json TypeScript config for allowJs + checkJs and emitting declarations to types/.
src/utils.js Added JSDoc types and casts to satisfy TS checking while keeping runtime behavior.
src/index.js Added JSDoc types for the loader and some casts for strict checking.
package.json Exposes types in exports/types, includes types/ in published files, adds TS scripts/dev deps.
package-lock.json Updates lockfile for newly added dev tooling and dependency graph changes.
test/loader.test.js Adds JSDoc typedefs to satisfy TS checking for inline stylus plugins.
test/helpers/testLoader.cjs Adds JSDoc for TS checking.
test/helpers/readAssets.js Adds JSDoc for TS checking.
test/helpers/normalizeErrors.js Adds JSDoc for TS checking.
test/helpers/getCodeFromStylus.js Adds JSDoc/typedefs for TS checking.
test/helpers/getCodeFromBundle.js Adds JSDoc for TS checking.
bench/index.js Adds JSDoc for TS checking.
bench/fixtures/imports/testLoader.js Adds JSDoc for TS checking.
.changeset/add-jsdoc-types.md Changeset entry documenting the new typings feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
"prebuild": "npm run clean",
"build:esm": "babel src -d dist/esm --env-name esm --copy-files --no-copy-ignored",
"build:cjs": "babel src -d dist/cjs --env-name cjs --copy-files --no-copy-ignored && node -e \"const fs=require('fs');fs.writeFileSync('dist/cjs/package.json','{\\\"type\\\":\\\"commonjs\\\"}\\n');fs.appendFileSync('dist/cjs/index.js','module.exports = exports.default;\\nmodule.exports.default = exports.default;\\n')\"",
"build:types": "tsc && prettier \"types/**/*.ts\" --write",
Copilot AI review requested due to automatic review settings May 25, 2026 17:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 17 changed files in this pull request and generated 4 comments.

Comment thread package.json
"prebuild": "npm run clean",
"build:esm": "babel src -d dist/esm --env-name esm --copy-files --no-copy-ignored",
"build:cjs": "babel src -d dist/cjs --env-name cjs --copy-files --no-copy-ignored && node -e \"const fs=require('fs');fs.writeFileSync('dist/cjs/package.json','{\\\"type\\\":\\\"commonjs\\\"}\\n');fs.appendFileSync('dist/cjs/index.js','module.exports = exports.default;\\nmodule.exports.default = exports.default;\\n')\"",
"build:types": "tsc && prettier \"types/**/*.ts\" --write",
Comment thread src/utils.js

/**
* @typedef {object} StylusResolveUrlOptions
* @property {boolean=} nocheck true when no need to check on disk, otherwise false
Comment thread README.md
Comment on lines 162 to 166
/**
* Resolve relative url()'s inside imported files.
*
* @see https://stylus-lang.com/docs/js.html#stylusresolveroptions
*
* @type {boolean|Object}
* @type {boolean | { nocheck?: boolean }}
* @default { nocheck: true }
Comment thread src/utils.js Outdated
* @param {LoaderContext} loaderContext loader context
* @param {string} code code
* @param {StylusOptions} options stylus options
* @returns {Promise<Evaluator>} custom evaluator class
Copilot AI review requested due to automatic review settings May 25, 2026 17:35
@alexander-akait alexander-akait merged commit 6928e4e into main May 25, 2026
13 of 15 checks passed
@alexander-akait alexander-akait deleted the claude/jsdoc-types-generation-xNIdz branch May 25, 2026 17:40
@alexander-akait alexander-akait removed the request for review from Copilot May 25, 2026 17:59
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.

3 participants