Add jsdoc type checking for all of react code#132
Conversation
Make code easier for tsc to prove. Introduce "unreachable" util function that throws an error if reached (it shouldn't).
|
Great work Alan, but what are the benefits of using JSDoc, instead of switching to Typescript? |
|
I agree with @jim3692, we should use Typescript. |
|
I also prefer typescript, it's cleaner for me. I just chose jsdoc because we were already using js, and didn't know if you chose js over ts for a reason. The only benefits are that we can use it in the background and injector without adding a transpilation step (I only edited react though). I will do the change to typescript in this same PR. |
|
There is no need to change everything to TS. The injected code, and other parts that don't have type checking yet, can stay in JS. There is this option in tsconfig: https://www.typescriptlang.org/tsconfig/allowJs.html Also, to answer your question, we opted for JS, because we were too lazy to write TS and we didn't see enough benefits on such a simple UI component to go that route. |
|
Yeah, I was only gonna change the react part to ts. Are you okay with this change to TS then? |
|
@alansartorio Back then, our scope was not that big either 😛 |
Add
yarn lintcommand that runstsctype checking.I think this will be helpful to prevent errors when changing stuff.
Some of the stuff I did:
{isLoading: boolean, data: T | undefined}to{isLoading: true, data: undefined} | {isLoading: false, data: T}so both variables end up being linked.