Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Type Fixes (for *.d.ts files) #1949

Closed
joshxyzhimself opened this issue Feb 21, 2023 · 1 comment
Closed

TypeScript Type Fixes (for *.d.ts files) #1949

joshxyzhimself opened this issue Feb 21, 2023 · 1 comment
Labels
bug Something isn't working Types Changes related to the TypeScript definitions

Comments

@joshxyzhimself
Copy link
Contributor

Hi, thought of submitting a couple type fixes for the *.d.types to improve some VSCode IntelliSense.

For example, Client.Options.socketPath type is missing when the following lines use it:

socketPath,

dest.socketPath = path.join(os.tmpdir(), 'undici.sock')

A question before I proceed, am I correct that the types below:

undici/types/client.d.ts

Lines 20 to 52 in d04ec2b

declare namespace Client {
export interface Options {
/** the timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. Default: `4e3` milliseconds (4s). */
keepAliveTimeout?: number | null;
/** the maximum allowed `idleTimeout` when overridden by *keep-alive* hints from the server. Default: `600e3` milliseconds (10min). */
keepAliveMaxTimeout?: number | null;
/** A number subtracted from server *keep-alive* hints when overriding `idleTimeout` to account for timing inaccuracies caused by e.g. transport latency. Default: `1e3` milliseconds (1s). */
keepAliveTimeoutThreshold?: number | null;
/** The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Default: `1`. */
pipelining?: number | null;
/** **/
connect?: buildConnector.BuildOptions | buildConnector.connector | null;
/** The maximum length of request headers in bytes. Default: `16384` (16KiB). */
maxHeaderSize?: number | null;
/** The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Default: `300e3` milliseconds (300s). */
bodyTimeout?: number | null;
/** The amount of time the parser will wait to receive the complete HTTP headers (Node 14 and above only). Default: `300e3` milliseconds (300s). */
headersTimeout?: number | null;
/** If `true`, an error is thrown when the request content-length header doesn't match the length of the request body. Default: `true`. */
strictContentLength?: boolean;
/** @deprecated use the connect option instead */
tls?: TlsOptions | null;
/** */
maxRequestsPerClient?: number;
/** Max response body size in bytes, -1 is disabled */
maxResponseSize?: number | null;
/** Enables a family autodetection algorithm that loosely implements section 5 of RFC 8305. */
autoSelectFamily?: boolean;
/** The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. */
autoSelectFamilyAttemptTimeout?: number;
interceptors?: {Client: readonly DispatchInterceptor[] | undefined}
}

..are intended for the constructor below?

undici/lib/client.js

Lines 88 to 115 in d04ec2b

class Client extends DispatcherBase {
constructor (url, {
interceptors,
maxHeaderSize,
headersTimeout,
socketTimeout,
requestTimeout,
connectTimeout,
bodyTimeout,
idleTimeout,
keepAlive,
keepAliveTimeout,
maxKeepAliveTimeout,
keepAliveMaxTimeout,
keepAliveTimeoutThreshold,
socketPath,
pipelining,
tls,
strictContentLength,
maxCachedSessions,
maxRedirections,
connect,
maxRequestsPerClient,
localAddress,
maxResponseSize,
autoSelectFamily,
autoSelectFamilyAttemptTimeout
} = {}) {

I'm thinking of adding types for options.socketPath, but also noticed missing types for other parameters like options.socketTimeout, is it alright to include those?

Thanks.

@joshxyzhimself joshxyzhimself added the bug Something isn't working label Feb 21, 2023
@mcollina
Copy link
Member

Go ahead!

@mcollina mcollina added the Types Changes related to the TypeScript definitions label Feb 21, 2023
mcollina pushed a commit that referenced this issue Feb 24, 2023
* update types for client

* update types for client.js

* revert some changes made in client.js

* update client.js

* use never for all @deprecated properties

* add tests

* revert since it's false anyways lol
metcoder95 pushed a commit to metcoder95/undici that referenced this issue Jul 21, 2023
* update types for client

* update types for client.js

* revert some changes made in client.js

* update client.js

* use never for all @deprecated properties

* add tests

* revert since it's false anyways lol
crysmags pushed a commit to crysmags/undici that referenced this issue Feb 27, 2024
* update types for client

* update types for client.js

* revert some changes made in client.js

* update client.js

* use never for all @deprecated properties

* add tests

* revert since it's false anyways lol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Types Changes related to the TypeScript definitions
Projects
None yet
Development

No branches or pull requests

3 participants