Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to add type file for jsx.js #298

Merged
merged 2 commits into from
Apr 14, 2023

Conversation

shinyama-k
Copy link
Contributor

Fixes: #297

When I build the following code with the tsc command, I get an error message.

import { shallowRender } from 'preact-render-to-string/jsx';
import {h} from "preact";

const Sample = () => <div>sample</div>

shallowRender(<Sample />);

The error message is as follows

❯ tsc -p tsconfig.json --strict
src/index.tsx:1:31 - error TS7016: Could not find a declaration file for module 'preact-render-to-string/jsx'. '/Users/shinyama-k/preact-render/node_modules/preact-render-to-string/jsx.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/preact-render-to-string` if it exists or add a new declaration (.d.ts) file containing `declare module 'preact-render-to-string/jsx';`

1 import { shallowRender } from 'preact-render-to-string/jsx';

To fix this problem, added configuration to include the jsx.d.ts file in tarball of the npm package.

@changeset-bot
Copy link

changeset-bot bot commented Apr 14, 2023

🦋 Changeset detected

Latest commit: 6a4b8ed

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

This PR includes changesets to release 1 package
Name Type
preact-render-to-string Patch

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

Copy link
Member

@rschristian rschristian left a comment

Choose a reason for hiding this comment

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

Good catch, thanks!

@rschristian rschristian merged commit ea7f278 into preactjs:master Apr 14, 2023
@github-actions github-actions bot mentioned this pull request Apr 14, 2023
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.

Unable to import shallowRender from preact-render-to-string/jsx due to TypeScript type errors
2 participants