Skip to content

fix: types node16 resolution#117

Merged
rschristian merged 3 commits into
masterfrom
fix/types-node16-resolution
Oct 17, 2025
Merged

fix: types node16 resolution#117
rschristian merged 3 commits into
masterfrom
fix/types-node16-resolution

Conversation

@rschristian

Copy link
Copy Markdown
Member

Are the types wrong?

npm run build && npm pack will show this PR fixes the issue.

Comment thread src/index.d.ts
_vdom: ReturnType<typeof h> | null;
_props: Record<string, unknown>;
};
import { AnyComponent } from 'preact';

@rschristian rschristian Oct 17, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No longer a module file, had to move this out

Comment thread src/index.d.ts
options?: Options
): HTMLElement;

export = register;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actual fix

Comment thread package.json
"prepare": "npx simple-git-hooks",
"build": "microbundle -f cjs,es,umd --no-generateTypes",
"lint": "eslint src/*.{js,jsx}",
"lint": "eslint src/*.js",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

ESLint fails if it can't find a single matching file & we have no .jsx files in src/.

Comment thread src/index.js
Comment on lines -16 to +24
inst._root =
options && options.shadow
? inst.attachShadow({ mode: options.mode || 'open' })
: inst;

if (options && options.adoptedStyleSheets) {
inst._root.adoptedStyleSheets = options.adoptedStyleSheets;
if (options && options.shadow) {
inst._root = inst.attachShadow({ mode: options.mode || 'open' });

if (options.adoptedStyleSheets) {
inst._root.adoptedStyleSheets = options.adoptedStyleSheets;
}
} else {
inst._root = inst;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Drive-by, TS complains that .adoptedStyleSheets might not be set as it'll only exist if options.shadow is enabled. Nesting these initializations corrects the type issue for 1-2b.

@rschristian rschristian force-pushed the fix/types-node16-resolution branch from 53a4399 to 8f41e93 Compare October 17, 2025 06:03
@github-actions

github-actions Bot commented Oct 17, 2025

Copy link
Copy Markdown

Size Change: +3 B (+0.07%)

Total Size: 4.04 kB

Filename Size Change
dist/preact-custom-element.esm.js 1.33 kB +2 B (+0.15%)
dist/preact-custom-element.js 1.32 kB +1 B (+0.08%)
ℹ️ View Unchanged
Filename Size
dist/preact-custom-element.umd.js 1.39 kB

compressed-size-action

@rschristian rschristian force-pushed the fix/types-node16-resolution branch from 9bd5bd0 to 5e6eb49 Compare October 17, 2025 06:22
@rschristian rschristian merged commit 4711c23 into master Oct 17, 2025
2 checks passed
@rschristian rschristian deleted the fix/types-node16-resolution branch October 17, 2025 06:23
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