feat: add JSDoc type-checking and declaration emission#1312
Merged
Conversation
|
a283064 to
21cd4a9
Compare
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
21cd4a9 to
904ba17
Compare
🦋 Changeset detectedLatest commit: 16611be The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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
904ba17 to
1718324
Compare
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
emitDeclarationOnly) writing to ./types
build:code and build:types in parallel; clean removes types
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