Skip to content

Commit

Permalink
Fix file stream type (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
kibertoad authored Jun 29, 2021
1 parent f31b175 commit 6437f4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export type Multipart<T = true> = T extends true ? MultipartFile : MultipartValu

export interface MultipartFile {
toBuffer: () => Promise<Buffer>,
file: NodeJS.ReadableStream,
file: Readable,
filepath: string,
fieldname: string,
filename: string,
Expand Down
8 changes: 4 additions & 4 deletions test/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fastify from 'fastify'
import fastifyMultipart from '..'
import { Multipart, MultipartFields, MultipartFile } from '..'
import * as util from 'util'
import { pipeline } from 'stream'
import { pipeline, Readable } from 'stream'
import * as fs from 'fs'
import { expectError, expectType } from 'tsd'
import { FastifyErrorConstructor } from "fastify-error"
Expand Down Expand Up @@ -55,7 +55,7 @@ const runServer = async () => {
app.post('/', async (req, reply) => {
const data = await req.file()

expectType<NodeJS.ReadableStream>(data.file)
expectType<Readable>(data.file)
expectType<MultipartFields>(data.fields)
expectType<string>(data.fieldname)
expectType<string>(data.filename)
Expand All @@ -72,7 +72,7 @@ const runServer = async () => {
expectError(req.body.foo.file);
expectType<string>(req.body.foo.value);

expectType<NodeJS.ReadableStream>(req.body.file.file)
expectType<Readable>(req.body.file.file)
expectError(req.body.file.value);
reply.send();
})
Expand All @@ -82,7 +82,7 @@ const runServer = async () => {
reply.send();

// file is a file
expectType<NodeJS.ReadableStream>(req.body.file.file)
expectType<Readable>(req.body.file.file)
expectError(req.body.file.value);
})

Expand Down

0 comments on commit 6437f4e

Please sign in to comment.