Skip to content
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here
Your logo here

Backwards Compatibility

charset Deprecated

  • Default: utf8

  • Released: 1.0

In prior versions of TypeScript, this controlled what encoding was used when reading text files from disk. Today, TypeScript assumes UTF-8 encoding, but will correctly detect UTF-16 (BE and LE) or UTF-8 BOMs.

importsNotUsedAsValues

Deprecated in favor of verbatimModuleSyntax.

This flag controls how import works, there are 3 different options:

  • remove: The default behavior of dropping import statements which only reference types.

  • preserve: Preserves all import statements whose values or types are never used. This can cause imports/side-effects to be preserved.

  • error: This preserves all imports (the same as the preserve option), but will error when a value import is only used as a type. This might be useful if you want to ensure no values are being accidentally imported, but still make side-effect imports explicit.

This flag works because you can use import type to explicitly create an import statement which should never be emitted into JavaScript.

keyofStringsOnly Deprecated

This flag changes the keyof type operator to return string instead of string | number when applied to a type with a string index signature.

This flag is used to help people keep this behavior from before TypeScript 2.9's release.

noImplicitUseStrict

You shouldn't need this. By default, when emitting a module file to a non-ES6 target, TypeScript emits a "use strict"; prologue at the top of the file. This setting disables the prologue.

noStrictGenericChecks

TypeScript will unify type parameters when comparing two generic functions.

ts

type 
A
= <
T
,
U
>(
x
:
T
,
y
:
U
) => [
T
,
U
];
type
B
= <
S
>(
x
:
S
,
y
:
S
) => [
S
,
S
];
function
f
(
a
:
A
,
b
:
B
) {
b
=
a
; // Ok
a =
b
; // Error
Type 'B' is not assignable to type 'A'. Types of parameters 'y' and 'y' are incompatible. Type 'U' is not assignable to type 'T'. 'T' could be instantiated with an arbitrary type which could be unrelated to 'U'.
}
Try

This flag can be used to remove that check.

out Deprecated

Use outFile instead.

The out option computes the final file location in a way that is not predictable or consistent. This option is retained for backward compatibility only and is deprecated.

preserveValueImports

Deprecated in favor of verbatimModuleSyntax.

There are some cases where TypeScript can't detect that you're using an import. For example, take the following code:

ts
import { Animal } from "./animal.js";

eval("console.log(new Animal().isDangerous())");

or code using 'Compiles to HTML' languages like Svelte or Vue. preserveValueImports will prevent TypeScript from removing the import, even if it appears unused.

When combined with isolatedModules: imported types must be marked as type-only because compilers that process single files at a time have no way of knowing whether imports are values that appear unused, or a type that must be removed in order to avoid a runtime crash.

suppressExcessPropertyErrors

This disables reporting of excess property errors, such as the one shown in the following example:

ts
type 
Point
= {
x
: number;
y
: number };
const
p
:
Point
= {
x
: 1,
y
: 3, m: 10 };
Object literal may only specify known properties, and 'm' does not exist in type 'Point'.
Try

This flag was added to help people migrate to the stricter checking of new object literals in TypeScript 1.6.

We don't recommend using this flag in a modern codebase, you can suppress one-off cases where you need it using // @ts-ignore.

suppressImplicitAnyIndexErrors

Turning suppressImplicitAnyIndexErrors on suppresses reporting the error about implicit anys when indexing into objects, as shown in the following example:

ts
const 
obj
= {
x
: 10 };
console
.
log
(obj["foo"]);
Element implicitly has an 'any' type because expression of type '"foo"' can't be used to index type '{ x: number; }'. Property 'foo' does not exist on type '{ x: number; }'.
Try

Using suppressImplicitAnyIndexErrors is quite a drastic approach. It is recommended to use a @ts-ignore comment instead:

ts
const 
obj
= {
x
: 10 };
// @ts-ignore
console
.
log
(
obj
["foo"]);
Try