Improving strict typescript checking

This commit is contained in:
Fabian Stamm 2022-02-14 00:58:05 +00:00
parent 3ececad91b
commit 58e00a9ca3
4 changed files with 8 additions and 2 deletions

View File

@ -10353,6 +10353,7 @@ var TypescriptTarget = class extends CompileTarget {
} }
a(2, ``); a(2, ``);
a(2, `p.push(ctx);`); a(2, `p.push(ctx);`);
a(2, `//@ts-ignore This will cause a typescript error when strict checking, since p is not a tuple`);
a(2, `return this.${fnc.name}.call(this, ...p)` + (fnc.return ? `.then(${((_a = fnc.return) == null ? void 0 : _a.array) ? `res => res.map(e => apply_${fnc.return.type}(e))` : `res => apply_${fnc.return.type}(res)`});` : "")); a(2, `return this.${fnc.name}.call(this, ...p)` + (fnc.return ? `.then(${((_a = fnc.return) == null ? void 0 : _a.array) ? `res => res.map(e => apply_${fnc.return.type}(e))` : `res => apply_${fnc.return.type}(res)`});` : ""));
a(1, `}`); a(1, `}`);
a(0, ``); a(0, ``);
@ -10517,10 +10518,12 @@ var CSharpTarget = class extends CompileTarget {
} }
t.forEach((l) => lines.push(" ".repeat(i) + l.trim())); t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
}; };
a(0, `using System;`);
a(0, `using System.Text.Json;`); a(0, `using System.Text.Json;`);
a(0, `using System.Text.Json.Serialization;`); a(0, `using System.Text.Json.Serialization;`);
a(0, `using System.Text.Json.Nodes;`); a(0, `using System.Text.Json.Nodes;`);
a(0, `using System.Threading.Tasks;`); a(0, `using System.Threading.Tasks;`);
a(0, `using System.Collections.Generic;`);
a(0, ``); a(0, ``);
a(0, `namespace ${this.namespace};`); a(0, `namespace ${this.namespace};`);
a(0, ``); a(0, ``);
@ -10573,10 +10576,12 @@ var CSharpTarget = class extends CompileTarget {
} }
t.forEach((l) => lines.push(" ".repeat(i) + l.trim())); t.forEach((l) => lines.push(" ".repeat(i) + l.trim()));
}; };
a(0, `using System;`);
a(0, `using System.Text.Json;`); a(0, `using System.Text.Json;`);
a(0, `using System.Text.Json.Serialization;`); a(0, `using System.Text.Json.Serialization;`);
a(0, `using System.Text.Json.Nodes;`); a(0, `using System.Text.Json.Nodes;`);
a(0, `using System.Threading.Tasks;`); a(0, `using System.Threading.Tasks;`);
a(0, `using System.Collections.Generic;`);
a(0, ``); a(0, ``);
a(0, `namespace ${this.namespace};`); a(0, `namespace ${this.namespace};`);
a(0, ``); a(0, ``);

View File

@ -1,6 +1,6 @@
{ {
"name": "@hibas123/jrpcgen", "name": "@hibas123/jrpcgen",
"version": "1.0.28", "version": "1.0.29",
"main": "lib/index.js", "main": "lib/index.js",
"license": "MIT", "license": "MIT",
"packageManager": "yarn@3.1.1", "packageManager": "yarn@3.1.1",

View File

@ -383,6 +383,7 @@ export class TypescriptTarget extends CompileTarget {
a(2, ``); a(2, ``);
a(2, `p.push(ctx);`); a(2, `p.push(ctx);`);
a(2, `//@ts-ignore This will cause a typescript error when strict checking, since p is not a tuple`)
a( a(
2, 2,
`return this.${fnc.name}.call(this, ...p)` + //TODO: Refactor. This line is way to compicated for anyone to understand, including me `return this.${fnc.name}.call(this, ...p)` + //TODO: Refactor. This line is way to compicated for anyone to understand, including me

View File

@ -22,7 +22,7 @@ export class Service {
export class ServiceProvider { export class ServiceProvider {
services = new Map<string, Service>(); services = new Map<string, Service>();
requests = new Map<string, ResponseListener>(); requests = new Map<string, ResponseListener |undefined>();
constructor(private sendPacket: IMessageCallback) {} constructor(private sendPacket: IMessageCallback) {}