#javascript #typescript
When there’s a variable or an argument in a function or method call, you can annotate your code with types. To annotate, follow the variable or argument with a colon and followed by it’s type.
var myName: string = "Andrew"; function printName(name: string) { console.log(name);
}
If you want to change selection, open document below and click on "Move attachment"
Unknown titles created since running the tsc command won’t get compiled, you need to stop the watcher and start again.
Syntax
Now on to the good stuff – the stuff that makes you less error prone and more productive – it’s syntax.
Optional Typing
<span>When there’s a variable or an argument in a function or method call, you can annotate your code with types. To annotate, follow the variable or argument with a colon and followed by it’s type.
var myName: string = "Andrew";
function printName(name: string) {
console.log(name);
}
When you try and call the function with the missing or wrong types of parameter it warns us. Also it helps with autocompletion since every variable’s type is known and it suggests an Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details