tsconfig.json top level options Flashcards

1
Q

What does files top level option do?

A

Specifies an allowlist of files to include in the program. An error occurs if any of the files can’t be found.

Example:
~~~
{
“compilerOptions”: {},
“files”: [
“core.ts”,
“sys.ts”,
“types.ts”,
“scanner.ts”,
“parser.ts”,
“utilities.ts”,
“binder.ts”,
“checker.ts”,
“tsc.ts”
]
}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does include top level option do?

A

Specifies an array of filenames or patterns to include in the program. These filenames are resolved relative to the directory containing the tsconfig.json file.

Example:

{
  "include": ["src/**/*", "tests/**/*"]
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does exclude top level option do?

A

Specifies an array of filenames or patterns that should be skipped when resolving include.

Important: exclude only changes which files are included as a result of the include setting. A file specified by exclude can still become part of your codebase due to an import statement in your code, a types inclusion, a /// <reference directive, or being specified in the files list.

It is not a mechanism that prevents a file from being included in the codebase - it simply changes what the include setting finds.

Example:
~~~
{
“include”: [“src//”, “tests/**/”],
“exclude”: [“src/
/*.spec.ts”]
}
~~~

Source typelang

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does references top level option do?

A

Project references are a way to structure your TypeScript programs into smaller pieces. Using Project References can greatly improve build and editor interaction times, enforce logical separation between components, and organize your code in new and improved ways.

Example:

{
    "compilerOptions": {
        // The usual
    },
    "references": [
        { "path": "../src" }
    ]
}

Source typelang

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does extends top level option do?

A

The value of extends is a string which contains a path to another configuration file to inherit from.

The configuration from the base file are loaded first, then overridden by those in the inheriting config file. All relative paths found in the configuration file will be resolved relative to the configuration file they originated in.

Beware that files, include and exclude from the inheriting config file overwrite those from the base config file.

Currently, the only top-level property that is excluded from inheritance is references.

Example:
~~~
{
“extends”: “./tsconfig”,
“compilerOptions”: {
“strictNullChecks”: false
}
}
~~~

How well did you know this?
1
Not at all
2
3
4
5
Perfectly