3 ms·
It is a full static checking system, so it will find obvious errors like mistyping something, but it also infers alot of information from the context. I made a
by 0xcoffee 9y ago
It is a full static checking system, so it will find obvious errors like mistyping something, but it also infers alot of information from the context.
I made a small simple demo here: https://www.typescriptlang.org/play/index.html#src=const%20example1%20%3D%20%22Hello%22%3B%0D%0Aexample1.length%3B%0D%0A%0D%0Aconst%20example2%20%3D%20Math.random()%20%3E%200.5%20%3F%20null%20%3A%20%22Hello%22%3B%0D%0A%0D%0A%2F%2F%20Error%20-%3E%20Object%20is%20possibly%20'null'.%0D%0Aexample2.length%3B%0D%0A%0D%0Aif%20(example2%20!%3D%3D%20null)%20%7B%0D%0A%20%20%20%20example2.length%3B%0D%0A%7D%0D%0A%0D%0Aconst%20example3%20%3D%201%3B%0D%0A%0D%0A%2F%2F%20Have%20fun%0D%0Aconst%20example4%20%3D%20Math.random()%20%3E%200.5%20%3F%20example2%20%3A%20example3%3B https://www.typescriptlang.org/play/index.html#src=const%20e...
Note: Click Options and enable all the settings. Typescript works best in strict mode, but it seems options arn't including in sharing via url.
- z3t4 9y agoIt seems it can only find properties if they are defined as foo = {bar: 1}; and not foo={};foo.bar=1;