Skip to content

ESM types are described incorrectly #443

Description

@dsherret

https://arethetypeswrong.github.io/?p=preact-render-to-string%406.6.5

I started working on this a bit, but the repo needs a bit of a larger overhaul that would be better for a maintainer to do.

// package.json
{
  "dependencies": {
    "preact": "^10.28.2",
    "preact-render-to-string": "^6.6.5",
    "typescript": "^5.9.3"
  }
}
// tsconfig.json
{
  "compilerOptions": {
    "module": "nodenext",
    "target": "esnext",
    "types": [],
    "noEmit": true,
    "noUncheckedIndexedAccess": true,
    "exactOptionalPropertyTypes": true,
    "strict": true,
    "jsx": "react-jsx",
    "verbatimModuleSyntax": true,
    "isolatedModules": true,
    "noUncheckedSideEffectImports": true,
    "moduleDetection": "force",
    "skipLibCheck": true,
  }
}
// main.mts
import renderToString, { shallowRender, render } from "preact-render-to-string/jsx";
import { h } from "preact";

console.log(shallowRender);
console.log(render);
console.log(renderToString(h("div", {})))
> npx tsc --noEmit
main.mts:6:13 - error TS2349: This expression is not callable.
  Type 'typeof import("V:/scratch/node_modules/preact-render-to-string/dist/jsx")' has no call signatures.

6 console.log(renderToString(h("div", {})))
              ~~~~~~~~~~~~~~


Found 1 error in main.mts:6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions