Skip to content

Commit

Permalink
Remove usages of any
Browse files Browse the repository at this point in the history
  • Loading branch information
syyyr committed Sep 25, 2024
1 parent 68ad977 commit e95f92e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .xo-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"format": ["PascalCase"],
"selector": "variable",
"modifiers": ["const"],
"filter": "Validation$|Zod$"
"filter": "Ctor$|Validation$|Zod$"
}
],
"@typescript-eslint/prefer-promise-reject-errors": "off",
Expand Down
2 changes: 1 addition & 1 deletion src/chainpack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ class ChainPackWriter {
}

writeMapContent(map: MetaMap | ShvMap | IMap) {
for (const [key, value] of Object.entries(map)) {
for (const [key, value] of Object.entries<RpcValue>(map)) {
if (value === undefined) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,7 +834,7 @@ class CponWriter {
this.increaseIndentIfNotOneLiner(map);
this.doIndentIfNotOneliner(map);
let first = true;
for (const [key, value] of Object.entries(map)) {
for (const [key, value] of Object.entries<RpcValue>(map)) {
if (value === undefined) {
continue;
}
Expand Down
8 changes: 4 additions & 4 deletions src/rpcmessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class RpcMessage {
}

params() {
return this.value[RpcMessageKey.Params];
return this.value[RpcMessageKey.Params] as RpcValue;
}

setParams(params: RpcValue) {
Expand All @@ -152,7 +152,7 @@ class RpcMessage {

const code = errorMap[ERROR_CODE] as unknown;

const errorTypeCtor = (() => {
const ErrorTypeCtor = (() => {
switch (code) {
case ErrorCode.InvalidRequest: return InvalidRequest;
case ErrorCode.MethodNotFound: return MethodNotFound;
Expand All @@ -170,11 +170,11 @@ class RpcMessage {
}
})();

return new errorTypeCtor(this.value[RpcMessageKey.Error] as unknown as ErrorMap);
return new ErrorTypeCtor(this.value[RpcMessageKey.Error] as IMap<ErrorMap>);
}

if (Object.hasOwn(this.value, RpcMessageKey.Result)) {
return this.value[RpcMessageKey.Result];
return this.value[RpcMessageKey.Result] as RpcValue;
}

return new ProtocolError('Response included neither result nor error');
Expand Down
2 changes: 1 addition & 1 deletion src/ws-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class WsClient {
this.onDisconnected();
});

this.websocket.addEventListener('message', evt => {
this.websocket.addEventListener('message', (evt: MessageEvent<ArrayBuffer>) => {
const rpcVal = dataToRpcValue(evt.data);
const rpcMsg = new RpcMessage(rpcVal);
this.logDebug(`message received: ${rpcMsg.toCpon()}`);
Expand Down

0 comments on commit e95f92e

Please sign in to comment.