Cannot import fastify-html using default import in TypeScript: "Module ... has no default export.ts(1192)"
bug
Hello, I’m encountering a TypeScript error when attempting to use a default import with fastify-html.
My code looks like this:
```
import fastifyHtml from 'fastify-html';
import fp from 'fastify-plugin'
export default fp(async (fastify) => {
await fastify.register(fastifyHtml, { async: true });
fastify.addLayout(function (inner, reply) {
return fastify.html`
<!DOCTYPE html>
<html>
<head>
</head>
<body>
!${inner}
</body>
</html>`
}, { skipOnHeader: 'hx-request' })
});
```

But when I compile, I get:
Module '"/path/to/node_modules/fastify-html/types/plugin"' has no default export.ts(1192)
My tsconfig.json is:
`{
"extends": "fastify-tsconfig",
"compilerOptions": {
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"outDir": "dist",
"sourceMap": true
},
"include": [
"src/**/*.ts",
"src/**/*.js"
]
}`
Thanks for looking into this!
关闭于 2025-05-19 2 条评论