Skip to content

feat: add JSDoc type-checking and declaration emission#1312

Merged
alexander-akait merged 5 commits into
mainfrom
claude/add-jsdoc-types-linting-ldGMv
May 19, 2026
Merged

feat: add JSDoc type-checking and declaration emission#1312
alexander-akait merged 5 commits into
mainfrom
claude/add-jsdoc-types-linting-ldGMv

Conversation

@alexander-akait
Copy link
Copy Markdown
Member

Mirror the JSDoc + tsc pattern used in webpack/webpack-dev-middleware so
sass-loader can be type-checked from JSDoc and ship .d.ts declarations.

  • Add tsconfig.json (allowJs, checkJs, strict, declaration,
    emitDeclarationOnly) writing to ./types
  • Add lint:types (tsc --noEmit) and build:types scripts; build now runs
    build:code and build:types in parallel; clean removes types
  • Add @types/node devDependency and types/index.d.ts entry point
  • Flesh out @typedef blocks (LoaderContext, Importer, ResolveFactory,
    Resolver, ResolutionMap, SassCompileFunction, RawSourceMap, SassError,
    EXPECTED_ANY) and tighten parameter/return types in src/index.js and
    src/utils.js so tsc --strict passes

https://claude.ai/code/session_01UgvxAaf3W9xymtJRAyk7QB

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 9, 2026

CLA Not Signed

@alexander-akait alexander-akait force-pushed the claude/add-jsdoc-types-linting-ldGMv branch from a283064 to 21cd4a9 Compare May 9, 2026 13:32
@codecov
Copy link
Copy Markdown

codecov Bot commented May 9, 2026

Codecov Report

❌ Patch coverage is 95.90909% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.67%. Comparing base (a3db95b) to head (16611be).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/utils.js 95.97% 8 Missing ⚠️
src/index.js 95.23% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1312      +/-   ##
==========================================
- Coverage   96.93%   96.67%   -0.27%     
==========================================
  Files           2        2              
  Lines         848      901      +53     
==========================================
+ Hits          822      871      +49     
- Misses         26       30       +4     

☔ 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.

@alexander-akait alexander-akait force-pushed the claude/add-jsdoc-types-linting-ldGMv branch from 21cd4a9 to 904ba17 Compare May 12, 2026 19:44
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

🦋 Changeset detected

Latest commit: 16611be

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
sass-loader Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Mirror the JSDoc + tsc setup used in webpack/webpack-dev-middleware so
sass-loader can be type-checked from JSDoc and ship .d.ts declarations.

- tsconfig.json (allowJs, checkJs, strict, declaration, emitDeclarationOnly)
  writes to ./types
- lint:types (tsc --noEmit) and build:types scripts; build runs alongside
  build:esm/build:cjs in parallel; clean removes types
- @types/node devDependency; types entry added to package.json `exports`
  and `files`
- Replace the previous Sass / SassEmbedded ambient typedefs with
  structural ones (SourceLocation, SourceSpan, LoggerWarnOptions, Logger,
  CompileResult, ModernImporter, AsyncCompiler, SassImplementation, ApiType)
  so the emitted .d.ts has no `import("sass")` / `import("sass-embedded")`
  references and end users with either peer dep installed get clean types
- SassOptions is parameterised by @template T extends SassImplementation and
  derives the options shape from T's compileStringAsync signature -- no
  manual property enumeration
- getSassOptions, getWebpackResolver, getModernWebpackImporter, getCompileFn
  are generic on T so the implementation type flows through without
  package-specific imports
- Adapt to the new main: async getSassImplementation with `await import()`,
  `apiType` union extended to include "auto"

Verified: all four lint scripts pass, build:types emits clean .d.ts with no
real `import("sass")` references, and the validate-options test suite still
passes against the new node:test runner.

https://claude.ai/code/session_01UgvxAaf3W9xymtJRAyk7QB
@alexander-akait alexander-akait force-pushed the claude/add-jsdoc-types-linting-ldGMv branch from 904ba17 to 1718324 Compare May 18, 2026 15:43
alexander-akait and others added 4 commits May 19, 2026 17:08
The `loaderContext` parameter was removed from `getSassImplementation`
in 0f6dcd5 (it was unused). The implementation-option tests still
called it with the old `({}, undefined)` 2-arg form, which made `{}`
look like a valid implementation, hit the `else` branch of the
type-narrow, and threw "Unknown Sass implementation." before reaching
the actual assertion paths in:

- should try to load using valid order
- should not swallow an error when trying to load a sass implementation

Drop the no-op first argument so both tests exercise the intended
behavior again.

https://claude.ai/code/session_01UgvxAaf3W9xymtJRAyk7QB
@alexander-akait alexander-akait merged commit a4e28f3 into main May 19, 2026
11 of 14 checks passed
@alexander-akait alexander-akait deleted the claude/add-jsdoc-types-linting-ldGMv branch May 19, 2026 16:58
@alexander-akait alexander-akait mentioned this pull request May 19, 2026
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.

2 participants