TypeScript is a typed superset of JavaScript that compile to plain JavaScript. It adds static typing.
See Typescript - tsc (official compiler)
When installing third party libraries (lodash, jQuery, …), it is important to remember to install the typing definition for that library.
yarn add @types/jquery --dev
yarn add jquery --peer
{
"compilerOptions": {
....
"types": [
"jquery"
]
},
...
}
type annotation. See Typescript - Type
export enum choice {
YES = 'Yes',
NO = 'No',
NA = 'Not applicable',
}
interface are type
Classes in TypeScript are just a shorthand for the same prototype-based OO.
The name is not imported you can define it also fully.
Example:
* @param {!Browser} browser
could be replaced with the fully qualified name
* @param {!import('puppeteer').Browser} browser