Comments (14)
@ziimakc I think the issue still exists:
index.ts(6,7): error TS2322: Type 'FastifyInstance<Http2SecureServer, Http2ServerRequest, Http2ServerResponse, FastifyBaseLogger, FastifyTypeProviderDefault> & PromiseLike<...>' is not assignable to type 'FastifyInstance<Server, IncomingMessage, ServerResponse, FastifyBaseLogger, FastifyTypeProviderDefault>'.
Types of property 'server' are incompatible.
Type 'Http2SecureServer' is missing the following properties from type 'Server': maxHeadersCount, maxRequestsPerSocket, timeout, headersTimeout, and 4 more.
from fastify-static.
Gotcha, looks like following the plugin structure style from those other packages will help! Nice work on the PR, I see Ethan is reviewing so it'll be all good 👍
from fastify-static.
please open a fresh issue with a reproduction
from fastify-static.
no reason. Making really dynamic code with typescript is hard. PRs are welcome!
from fastify-static.
I'm new to typescript, so i will pass it for now to anyone who is more knowledgeable of typescript generics and declaration files, as i don't see a clear way to make it work for different interfaces.
Temporally i changed index.d.ts of fastify-static to:
import { Http2SecureServer, Http2ServerRequest, Http2ServerResponse } from "http2"
declare const fastifyStatic: fastify.Plugin<Http2SecureServer, Http2ServerRequest, Http2ServerResponse, {//options }>;
Upd:
You can also use // @ts-ignore comment before registering module to solve it
from fastify-static.
@ReTWi, do you have a more complete example? What's your tsconfig
, what other code is in your file?
The following code compiles and runs if I use npx tsc index.ts --target es6 --module commonjs
:
import * as fastify from 'fastify'
import { resolve } from 'path'
import { Http2SecureServer, Http2ServerRequest, Http2ServerResponse } from 'http2'
const https: fastify.FastifyInstance<Http2SecureServer, Http2ServerRequest, Http2ServerResponse> = fastify({
logger: true,
ignoreTrailingSlash: true,
http2: true,
https: { allowHTTP1: true }
})
https.register(require('fastify-static'), {
root: resolve(__dirname, 'public',),
prefix: '/public/', // optional: default '/'
})
https.listen(8080)
from fastify-static.
@evanshortiss i will make a PR in a few minutes to fix this.
My code runs and works too, but there is always a warning from typescript.
I don't think you need something more to get a warning.
Config is:
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"esModuleInterop": true,
"sourceMap": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"removeComments": true,
"noImplicitThis": true,
"alwaysStrict": true,
"strictBindCallApply": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"allowJs": true,
"strictPropertyInitialization": true
},
"exclude": [
"../../node_modules"
]
}
"target": "es2019"
from fastify-static.
@evanshortiss i found that i have no warning if i use
require('fastify-static')
instead of
import fastifyStatic from 'fastify-static'
from fastify-static.
@ReTWi you included a compiler error, not warning in the original issue though. Have I misunderstood? A compiler error means the code doesn't compile and therefore does not run.
from fastify-static.
@evanshortiss it's error, but it's compiles and works so i sad "warning". Sorry if i misguided you
from fastify-static.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from fastify-static.
No overload matches this call.
The last overload gave the following error.
Argument of type '{ logger: { level: string; transport: { target: string; }; serializers: { res(reply: FastifyReply<Server, IncomingMessage, ServerResponse, RouteGenericInterface, unknown, FastifySchema, FastifyTypeProviderDefault, unknown>): { ...; }; req(request: FastifyRequest<...>): { ...; }; }; }; bodyLimit: number; requestTimeo...' is not assignable to parameter of type 'FastifyServerOptions<Server, FastifyBaseLogger>'.
Object literal may only specify known properties, and 'http2' does not exist in type 'FastifyServerOptions<Server, FastifyBaseLogger>'.ts(2769)
fastify.d.ts(56, 18): The last overload is declared here.
from fastify-static.
The issue is still there
from fastify-static.
this issue should be re-opened @mcollina?
from fastify-static.
Related Issues (20)
- Forking send to @fastify/send to avoid CVE warning
- setNotFoundHandler and @fastify/static context issue HOT 2
- Parameter in route and serving files HOT 2
- Support URL for root parameter (and `file:` protocol) HOT 9
- Serve the same html for all get routes HOT 1
- Regression on isUtf8MimeType HOT 5
- Investigate path-scurry by @isaacs HOT 2
- Why @[email protected] bind [email protected] rather than 4.x HOT 1
- 我正在使用 nestjs,并通过 fastify-static 使用 public static,但我无法在打包时自动让目录 public 在目录 dist 内生成。 HOT 1
- . HOT 1
- inflight - transient dependency introduced memory leak HOT 8
- Correct module exports? HOT 2
- abstract the plugin to provide support of virtual file system HOT 1
- `FST_ERR_REP_ALREADY_SENT` when wrapping route handler HOT 5
- 404 when using wildcard HOT 3
- setting content-length HOT 5
- Is there a way to reduce the size of importing @fastify/static? HOT 1
- HTTP HEAD can not get the content-length(always 0) HOT 3
- Watch on file changes and reload HOT 2
- 400 Bad Request for files containing a `%` character
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastify-static.