Add the types output by the TypeScript compiler to the source TS source code

With TypeScript, you can explicitly specify types or let the compiler output them.

Is there a way to add types that are output to the source code?

For example, I would start with:

private posX = 0;
private posY = 0;
private sizeX = 0;
private sizeY = 0;

I would do type inference, and since types can be inferred in this case, I would get:

private posX: number = 0;
private posY: number = 0;
private sizeX: number = 0;
private sizeY: number = 0;

That way, when editing the code, I can check if the output worked as I expect, and I could manually provide more restrictive types if necessary.

+4
source share
1 answer

Someone really realized this!

https://github.com/urish/typewiz

+2
source

Source: https://habr.com/ru/post/1683795/


All Articles