import { Dirent } from 'node:fs' import { resolve } from 'node:path' import { Readable } from 'node:stream' import { expectType } from 'tsd' import send, { DirectorySendResult, ErrorSendResult, FileSendResult, SendResult } from '..' send.mime.define({ 'application/x-my-type': ['x-mt', 'x-mtt'] }) expectType<(value: string) => boolean>(send.isUtf8MimeType) expectType(send.isUtf8MimeType('application/json')) const req: any = {} { const result = await send(req, '/test.html', { acceptRanges: true, maxContentRangeChunkSize: 10, immutable: true, maxAge: 0, root: resolve(__dirname, '/wwwroot') }) expectType(result) expectType(result.statusCode) expectType>(result.headers) expectType(result.stream) } { const result = await send(req, '/test.html', { contentType: true, maxAge: 0, root: resolve(__dirname, '/wwwroot') }) expectType(result) expectType(result.statusCode) expectType>(result.headers) expectType(result.stream) } { const result = await send(req, '/test.html', { contentType: false, root: resolve(__dirname, '/wwwroot') }) expectType(result) expectType(result.statusCode) expectType>(result.headers) expectType(result.stream) } const result = await send(req, '/test.html') switch (result.type) { case 'file': { expectType(result) expectType(result.metadata.path) expectType(result.metadata.stat) break } case 'directory': { expectType(result) expectType(result.metadata.path) expectType(result.metadata.requestPath) break } case 'error': { expectType(result) expectType(result.metadata.error) } }