Skip to content

Commit

Permalink
fix(typings): fix the type of the "query" option (#1439)
Browse files Browse the repository at this point in the history
Having type `Object` it was not possible to set values, e.g.:

```ts
if (!this.socket.io.opts.query) {
  this.socket.io.opts.query = {};
}
this.socket.io.opts.query.token = 'abc123';
```

Results in error:

> Element implicitly has an 'any' type because expression of type '"token"' can't be used to index type 'Object'.
  • Loading branch information
MickL authored and darrachequesne committed Feb 2, 2021
1 parent be81a2c commit f02ab3b
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function lookup(
io = cache[id];
}
if (parsed.query && !opts.query) {
opts.query = parsed.query;
opts.query = parsed.queryKey;
}
return io.socket(parsed.path, opts);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface EngineOptions {
/**
* Any query parameters in our uri. Set from the URI passed when connecting
*/
query: Object;
query: { [key: string]: string };

/**
* `http.Agent` to use, defaults to `false` (NodeJS only)
Expand Down
2 changes: 1 addition & 1 deletion lib/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ParsedUrl = {
query: string;
anchor: string;
pathNames: Array<string>;
queryKey: Record<string, string>;
queryKey: { [key: string]: string };

// Custom properties (not native to parseuri):
id: string;
Expand Down

0 comments on commit f02ab3b

Please sign in to comment.