> For the complete documentation index, see [llms.txt](https://kdongs.gitbook.io/kdocs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kdongs.gitbook.io/kdocs/typescript/about.md).

# About

## About

{% embed url="<https://www.typescriptlang.org/docs/handbook/intro.html>" %}

Is a superset of Javascript empowering it by:

* Static typing
* Decorators
* Generic types
* Tuples
* Modules
* Better OO support with abstract classes
* Interfaces
* Visibility modifiers
* And more...

Needs to be `transpiled` to Javascript.

* `Compiler`: Transforms code to low code (machine-code).
* `Transpiler`: Transforms code to other high level languages (source-to-source).

## Interoperability

Run `js` and `ts` in the same environment.

You can allow `js` to apply Typescript by creating a `.d.ts` file for a `js` file.

This file will have definitions typings for the `js`.

<br>

## Exploring the `tsconfig.json`

Centralizes all the code static analysis and transpilation rules.

**Options**

* `incremental`: For incremental transpilation, saving cache that will speedup future transpilations, specially for big projects. Essentialy just transpile the changed files.
* `target`: Defines the version of Javascript that will be utilized as the transpilation target.
  * `es5 | ECMA2009`: Older version from 2009.
  * `es6 | ECMA2015`: Which targets the ECMA from 2015.
  * `ECMA2016`: Is the default one. (Higher compatibility)
    * Adds `**` exponential, ...
  * `ECMA2017`:
    * Adds `async`, ...
  * `ECMA2018`:
    * Adds `rest \ spread`, ...
  * `ECMA2019`:
  * `ECMA2020`:
    * Adds `??`
  * ...
  * Check <https://node.green/> for details of ECMA versions support in Node.js
    * Node 16.x and greater versions, do support up to ECMA2023.
    * ESNext is the versions with `Stage 3`, `Stage 2` and `Stage 1` releases
* `module`: Important to define the type of `module` system to be used. - `CommonJS` - `ES Modules`
* `include`: Defines which are the directories that must be included in the transpilation.
* `exclude`: Defines which directores must be excluded in transpilation.
* `outFile`: Used for projects that run in the browser, defining a file that will concatenate all the transpiled files.
* `outDir`: Defines the directory that the transpiled files will be placed after transpilation.
* `allowJS`: To allow js files to part of the typescript environment.
* `strict`: Turn on several type checkings like:
  * `strictNullChecks`: Allow or not to accept if things return `null | undefined` and what will receive them cannot handle it.
  * `strictFunctionTypes`: Allow or not to scrictly compare functions types to the detail when assigning functions to variables.
  * `strictBindCallApply`: Allow of not to pass to `fn.call()`, parameters to the function that are not of the same type.
  * `strictPropertyInitialization`: Allow or not to have class properties to be declared but not initialized.
  * `noImplicitAny`: Allow or not using variables without typing, that can be automatically impliced typed.
  * `noImplicitThis`: Allow or not, when you have `this` cases, where the `this` is not pointing to where you think it is.
  * `useUnknowInCatchVariables`: Allow or not to use unknown error types in catch.
  * `alwaysStrict`: Will always put `use strict` in the transpiled file.
    * Not used anymore in recent versions of ECMA.
  * `allowUnreachableCode`: Allow or not leaving code that is unreachable.
  * `noUnusedLocals`: Allow or not leaving unused declared variables.
  * `noUncheckedIndexedAccess`: Allow or not to access dynamic properties of objects with `.`.
    * For Ex.: `[prop: string]: string`.
    * The right way to access woulb be with `[]`.
