Typescript: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 40: | Line 40: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
you get a default file. | you get a default file. | ||
You can inherit tsconfigs from parent directories. This compiles all *.ts files in this directory and child directories. | |||
<syntaxhighlight lang="json"> | |||
{ | |||
"extends": "../tsconfig.base", | |||
"compilerOptions": { | |||
"removeComments": true | |||
}, | |||
"include": [ | |||
"./**/*.ts" | |||
] | |||
} | |||
</syntaxhighlight> |
Revision as of 02:46, 10 July 2020
Introduction
TypeScript is a typed language which produces javascript.
e.g.
let myString = "fred";
let myBoolean = true;
function createMessage(name:string) {
}
Typescript supports classes and access modifiers
class Person {
name: string
lastName: string
public Person(name:string) {
this.name = name;
}
public void setLastName(lastName: string) {
this.lastName = lastName;
}
}
tsconfig
You can set the options for the compiler you can specify a tsconfig.json file. By using
tsc --init
you get a default file.
You can inherit tsconfigs from parent directories. This compiles all *.ts files in this directory and child directories.
{
"extends": "../tsconfig.base",
"compilerOptions": {
"removeComments": true
},
"include": [
"./**/*.ts"
]
}