Skip to content

Commit 8d42ca8

Browse files
committed
fix: resolve JSR slow-type error and annotate unanalyzable dynamic import
- Add explicit return type to WithDsdHydration mixin (missing-explicit-return-type) - New DsdHydrationMixin interface for public API type contract - Document intentional dynamic import in scanPackageIslands (unanalyzable-dynamic-import warning)
1 parent bdc7032 commit 8d42ca8

3 files changed

Lines changed: 25 additions & 4 deletions

File tree

packages/adapter-lit/src/dsd-hydration.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,20 @@ export interface DsdHydration {
6060
_hydrateEvents(): void;
6161
}
6262

63+
/**
64+
* Instance interface added by the WithDsdHydration mixin beyond DsdHydration.
65+
* Captures the LitElement method overrides the mixin provides.
66+
* Required by JSR slow-types checker for explicit public API return types.
67+
*/
68+
export interface DsdHydrationMixin extends DsdHydration {
69+
/** Override: reuses existing shadow root when DSD-pre-populated */
70+
createRenderRoot(): HTMLElement | DocumentFragment;
71+
/** Override: auto-wires DSD hydration events on connect */
72+
connectedCallback(): void;
73+
/** Override: cleans up hydration listeners on disconnect */
74+
disconnectedCallback(): void;
75+
}
76+
6377
/**
6478
* Mixin that adds DSD hydration support to a LitElement subclass.
6579
*
@@ -73,7 +87,9 @@ export interface DsdHydration {
7387
* - Declare `static hydrateEvents: HydrateEventDescriptor[]`
7488
* - Check `if (this._dsdHydrated) return nothing` at the top of render()
7589
*/
76-
export function WithDsdHydration<T extends Constructor<LitElement>>(superClass: T) {
90+
export function WithDsdHydration<T extends Constructor<LitElement>>(
91+
superClass: T,
92+
): T & Constructor<DsdHydrationMixin> {
7793
class WithDsdHydrationClass extends superClass {
7894
/**
7995
* Declarative event bindings for DSD hydration.
@@ -168,7 +184,7 @@ export function WithDsdHydration<T extends Constructor<LitElement>>(superClass:
168184
}
169185
}
170186

171-
return WithDsdHydrationClass as unknown as T & Constructor<WithDsdHydrationClass>;
187+
return WithDsdHydrationClass as unknown as T & Constructor<DsdHydrationMixin>;
172188
}
173189

174190
/**

packages/adapter-lit/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
export { installLitAdapter, uninstallLitAdapter } from './ssr.js';
2525
export { isLitTemplateResult, renderLitToString } from './ssr.js';
2626
export { DsdLitElement, WithDsdHydration } from './dsd-hydration.js';
27-
export type { DsdHydration } from './dsd-hydration.js';
27+
export type { DsdHydration, DsdHydrationMixin } from './dsd-hydration.js';

packages/core/src/route-scanner.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,12 @@ export async function scanPackageIslands(
255255

256256
for (const pkg of packageNames) {
257257
try {
258-
// Dynamic import the package
258+
// JSR publishes a warning[unanalyzable-dynamic-import] here because
259+
// `pkg` is a variable — JSR cannot resolve it at publish time.
260+
// This is intentional: packageNames are user-configured (e.g. ['@lessjs/ui'])
261+
// and must resolve at runtime via the consumer's import map / package.json.
262+
// The warning does NOT block publishing; the import resolves correctly
263+
// in the consuming project where the target package is a declared dependency.
259264
const mod = await import(pkg);
260265
if (mod.islands && Array.isArray(mod.islands)) {
261266
// Validate each island has required fields

0 commit comments

Comments
 (0)