Cara menggunakan nodejs readfile utf8 bom

Starting up are the root options in the TSConfig - these options relate to how your TypeScript or JavaScript project is set up.

Show

Files - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}60

Menentukan daftar berkas yang diijinkan untuk disertakan dalam program. Kesalahan terjadi jika salah satu berkas tidak dapat ditemukan.

{

"compilerOptions": {},

"files": [

"core.ts",

"sys.ts",

"types.ts",

"scanner.ts",

"parser.ts",

"utilities.ts",

"binder.ts",

"checker.ts",

"tsc.ts"

]

}

Ini berguna ketika Anda hanya memiliki sejumlah berkas kecil dan tidak perlu menggunakan glob untuk mereferensikan banyak berkas. Jika Anda membutuhkannya, gunakan .

Extends - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}65

Nilai

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

65 adalah string yang berisi jalur ke berkas konfigurasi lain untuk mewarisi. Jalur tersebut mungkin menggunakan resolusi gaya Node.js.

Konfigurasi dari berkas dasar dimuat terlebih dahulu, kemudian diganti dengan yang ada di berkas konfigurasi pewarisan. Semua jalur relatif yang ditemukan di berkas konfigurasi akan diselesaikan secara relatif terhadap berkas konfigurasi tempat asalnya.

Perlu diperhatikan bahwa

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

60,

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

61 dan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

64 dari berkas konfigurasi pewaris menimpa konfigurasi yang berasal dari berkas konfigurasi asal, dan sirkularitas antara berkas konfigurasi tidak diperbolehkan.

Saat ini, satu-satunya properti tingkat atas yang dikecualikan dari pewarisan adalah .

Contoh

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

71:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72:

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

73:

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

Properti dengan jalur relatif yang ditemukan di berkas konfigurasi, yang tidak dikecualikan dari pewarisan, akan diresolusikan secara relatif terhadap berkas konfigurasi tempat asalnya.

Disertakan (_Include_) - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}61

Menentukan sebuah susunan nama berkas atau contoh berkas untuk dimasukkan ke dalam program. Nama berkas ini diselesaikan dengan direktori yang berisi berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72.

json

{

"include": ["src/**/*", "tests/**/*"]

}

Yang akan mencakup:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

61 dan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

64 mendukung karakter untuk membuat pola global:

Jika contoh umum tidak menyertakan ekstensi berkas, maka hanya berkas dengan ekstensi yang didukung yang disertakan (misalnya

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

82,

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

83, dan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84 secara default, dengan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

85 dan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

86 jika

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

87 disetel ke true).

Exclude - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}64

Menentukan array nama berkas atau pola yang harus dilewati saat menyelesaikan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

61.

Penting:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

64 hanya mengubah berkas mana yang disertakan sebagai hasil dari pengaturan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

61. Berkas yang ditentukan oleh

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

64 masih bisa menjadi bagian dari basis kode Anda karena pernyataan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98 dalam kode Anda, penyertaan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

99, perintah

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

00, atau ditentukan dalam daftar

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

60.

Ini bukan mekanisme yang mencegah berkas untuk disertakan dalam basis kode - ini hanya mengubah apa yang ditemukan oleh setelan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

61.

  • Default:

    node_modules,bower_components,jspm_packages,

  • Related:

Referensi - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}06

Referensi proyek adalah cara untuk menyusun program TypeScript Anda menjadi bagian-bagian yang lebih kecil. Menggunakan Referensi Proyek dapat sangat meningkatkan waktu interaksi build dan editor, menerapkan pemisahan logika antar komponen, dan mengatur kode Anda dengan cara yang baru dan lebih baik.

Anda dapat membaca lebih lanjut tentang bagaimana cara kerja referensi di bagian Referensi Proyek dari buku pegangan

Pilihan - Pilihan Kompiler

Banyak pilihan yang membuat jumlah besar di pengaturan Typescript’s dan itu juga meliputi bagaimana bahasa seharusnya bekerja.

Type Checking

Izinkan Kode Tak Terjangkau - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}08

Kapan:

  • {

    "extends": "./configs/base",

    "files": ["main.ts", "supplemental.ts"]

    }

    09 default memberikan saran sebagai peringatan kepada editor
  • {

    "extends": "./configs/base",

    "files": ["main.ts", "supplemental.ts"]

    }

    10 kode yang tidak dapat dijangkau diabaikan
  • {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    62 menimbulkan galat kompiler tentang kode yang tidak dapat dijangkau

Peringatan ini hanya tentang kode yang terbukti tidak dapat dijangkau karena penggunaan sintaks JavaScript, misalnya:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

Dengan

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

12:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

Ini tidak mempengaruhi galat atas dasar kode yang muncul menjadi tidak dapat dijangkau karena menggolongkan uraian.

  • Released:

    1.8

Izinkan Label yang Tidak Digunakan - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}13

Setel ke false untuk menonaktifkan peringatan tentang label yang tidak digunakan.

Label sangat jarang di JavaScript dan biasanya menunjukkan upaya untuk menulis objek dengan tepat:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

  • Released:

    1.8

Selalu Tepat - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}14

Pastikan bahwa berkas Anda diurai di Mode strict EcmaScript, dan mengeluarkan “use strict” untuk setiap berkas asal.

ECMAScript strict mode strict diperkenalkan di ES5 dan memberikan perubahan perilaku pada waktu proses mesin JavaScript untuk meningkatkan kinerja dan membuat kesalahan muncul agar diabaikan.

exactOptionalPropertyTypes - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}19

With exactOptionalPropertyTypes enabled, TypeScript applies stricter rules around how it handles properties on

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

20 or

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

21 which have a

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

80 prefix.

For example, this interface declares that there is a property which can be one of two strings: ‘dark’ or ‘light’ or it should not be in the object.

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

Without this flag enabled, there are three values which you can set

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

23 to be: “dark”, “light” and

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

09.

Setting the value to

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

09 will allow most JavaScript runtime checks for the existence to fail, which is effectively falsy. However, this isn’t quite accurate

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

26 is not the same as

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

23 not being defined. For example

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

28 would have different behavior with

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

09 as the key compared to not being defined.

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

19 makes TypeScript truly enforce the definition provided as an optional property:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

0

  • Recommended
  • Released:

    4.4

No Fallthrough Cases In Switch - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}31

Report errors for fallthrough cases in switch statements. Ensures that any non-empty case inside a switch statement includes either

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

32 or

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

33. This means you won’t accidentally ship a case fallthrough bug.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

1

  • Released:

    1.8

No Implicit Any - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}34

Di beberapa kasus, dimana tidak ada anotasi tipe yang ada, TypeScript akan kembali ke suatu tipe dari

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

35 untuk suatu variabel yang saat itu tidakbisa simpulkan tipenya.

Ini dapat menyebabkan beberapa kesalahan untuk dilewatkan, sebagai contoh:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

2

Menyalakan opsi

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

34 namun TypeScript akan mengeluarkan kesalahan setiap kali

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

35 yang ia simpulkan:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

3

noImplicitOverride - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}42

When working with classes which use inheritance, it’s possible for a sub-class to get “out of sync” with the functions it overloads when they are renamed in the base class.

For example, imagine you are modeling a music album syncing system:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

4

Then when you add support for machine-learning generated playlists, you refactor the

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

43 class to have a ‘setup’ function instead:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

5

In this case, TypeScript has provided no warning that

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

44 on

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

45 expected to override a function in the base class.

Using

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

42 you can ensure that the sub-classes never go out of sync, by ensuring that functions which override include the keyword

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

47.

The following example has

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

42 enabled, and you can see the error received when

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

47 is missing:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

6

  • Released:

    4.3

No Implicit Returns - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}50

Saat diaktifkaan, TypeScript akan melakukan pengecekan semua jalur kode di suatu fungsi untuk memastikan mereka mengembalikan suatu nilai.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

7

  • Released:

    1.8

No Implicit This - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}51

Menimbulkan kesalahan kepada pernyataan ‘this’ dengan tersiratnya tipe ‘any’.

Sebagai contoh, class dibawah ini mengembalikan suatu fungsi yang mencoba mengakses

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

52 dan

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

53 – tapi konteksnya untuk

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

54 didalam fungsi yang didalam

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

55 ini, bukanlah instansi dari class Rectangle.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

8

noPropertyAccessFromIndexSignature - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}60

This setting ensures consistency between accessing a field via the “dot” (

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

61) syntax, and “indexed” (

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

62) and the way which the property is declared in the type.

Without this flag, TypeScript will allow you to use the dot syntax to access fields which are not defined:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

9

Turning the flag on will raise an error because the unknown field uses dot syntax instead of indexed syntax.

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

0

The goal of this flag is to signal intent in your calling syntax about how certain you are this property exists.

  • Released:

    4.2

noUncheckedIndexedAccess - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}63

TypeScript has a way to describe objects which have unknown keys but known values on an object, via index signatures.

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

1

Turning on

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

63 will add

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

09 to any un-declared field in the type.

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

2

  • Released:

    4.1

No Unused Locals - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}66

Report errors on unused local variables.

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

3

  • Released:

    2.0

No Unused Parameters - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}67

Report errors on unused parameters in functions.

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

4

  • Released:

    2.0

Strict - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}16

The

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

16 flag enables a wide range of type checking behavior that results in stronger guarantees of program correctness. Turning this on is equivalent to enabling all of the strict mode family options, which are outlined below. You can then turn off individual strict mode family checks as needed.

Future versions of TypeScript may introduce additional stricter checking under this flag, so upgrades of TypeScript might result in new type errors in your program. When appropriate and possible, a corresponding flag will be added to disable that behavior.

  • Recommended
  • Related:
  • Released:

    2.3

Strict Bind Call Apply - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}72

When set, TypeScript will check that the built-in methods of functions

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

79,

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

80, and

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

81 are invoked with correct argument for the underlying function:

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

5

Otherwise, these functions accept any arguments and will return

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

35:

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

6

Strict Function Types - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}73

When enabled, this flag causes functions parameters to be checked more correctly.

Here’s a basic example with

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

73 off:

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

7

With

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

73 on, the error is correctly detected:

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

8

During development of this feature, we discovered a large number of inherently unsafe class hierarchies, including some in the DOM. Because of this, the setting only applies to functions written in function syntax, not to those in method syntax:

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

9

Strict Null Checks - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}71

When

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

71 is

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

62,

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

97 and

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

09 are effectively ignored by the language. This can lead to unexpected errors at runtime.

When

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

71 is

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10,

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

97 and

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

09 have their own distinct types and you’ll get a type error if you try to use them where a concrete value is expected.

For example with this TypeScript code,

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

03 has no guarantee that it will actually find a user, but you can write code as though it will:

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

0

Setting

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

71 to

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10 will raise an error that you have not made a guarantee that the

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

06 exists before trying to use it.

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

1

The second example failed because the array’s

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

07 function looks a bit like this simplification:

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

2

Strict Property Initialization - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}74

When set to true, TypeScript will raise an error when a class property was declared but not set in the constructor.

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

3

In the above case:

useUnknownInCatchVariables - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}77

In TypeScript 4.0, support was added to allow changing the type of the variable in a catch clause from

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

35 to

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

24. Allowing for code like:

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

4

This pattern ensures that error handling code becomes more comprehensive because you cannot guarantee that the object being thrown is a Error subclass ahead of time. With the flag

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

77 enabled, then you do not need the additional syntax (

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

26) nor a linter rule to try enforce this behavior.

Modules

Izinkan Akses Global Umd - { "extends": "./tsconfig", "compilerOptions": { "strictNullChecks": false }}31

Jika disetel ke true,

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

31 memungkinkan Anda mengakses ekspor UMD sebagai global dari dalam berkas modul. Berkas modul adalah berkas yang telah diimpor dan/atau diekspor. Tanpa opsi ini, menggunakan ekspor dari modul UMD memerlukan deklarasi impor.

Contoh kasus penggunaan untuk opsi ini adalah proyek web yang anda tahu bahwa pustaka tertentu (seperti jQuery atau Lodash) akan selalu tersedia saat runtime, tetapi Anda tidak dapat mengaksesnya dengan impor.

  • Released:

    3.5

Base Url - { "extends": "./tsconfig", "compilerOptions": { "strictNullChecks": false }}33

Memungkinkan Anda menyetel direktori dasar untuk menyelesaikan nama modul dengan benar.

Anda dapat menentukan folder root di mana Anda dapat melakukan keputusan berkas yang sesungguhnya, misalnya :

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

5

Dengan

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

34 di dalam proyek ini TypeScript akan mencari berkas yang dimulai dari folder yang sama dengan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72.

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

6

Jika Anda lelah cara impor selalu seperti

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

36 atau

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

37. Atau harus untuk merubah saat Anda memindahkan berkas, ini adalah cara terbaik untuk memperbaikinya.

Module - { "extends": "./tsconfig", "compilerOptions": { "strictNullChecks": false }}38

Sets the module system for the program. See the Modules reference page for more information. You very likely want

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

39 for node projects.

Changing

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

38 affects which also has a reference page.

Here’s some example output for this file:

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

7

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

42

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

8

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

43

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

9

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

44

json

{

"include": ["src/**/*", "tests/**/*"]

}

0

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

45

json

{

"include": ["src/**/*", "tests/**/*"]

}

1

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

46

json

{

"include": ["src/**/*", "tests/**/*"]

}

2

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

47

json

{

"include": ["src/**/*", "tests/**/*"]

}

3

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

48/

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

49

json

{

"include": ["src/**/*", "tests/**/*"]

}

4

If you are wondering about the difference between

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

48 (aka

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

49) and

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

47,

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

47 adds support for dynamic

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98s, and

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

55.

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

56/

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

57 (nightly builds)

Available from 4.7+, the

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

56 and

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

57 modes integrate with Node’s native ECMAScript Module support. The emitted JavaScript uses either

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

42 or

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

47 output depending on the file extension and the value of the

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

20 setting in the nearest

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

63. Module resolution also works differently. You can learn more in the handbook.

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

64

json

{

"include": ["src/**/*", "tests/**/*"]

}

5

Module Resolution - { "extends": "./tsconfig", "compilerOptions": { "strictNullChecks": false }}41

Specify the module resolution strategy:

There is a handbook reference page on Module Resolution

moduleSuffixes - json{ "include": ["src/**/*", "tests/**/*"]}06

Provides a way to override the default list of file name suffixes to search when resolving a module.

json

{

"include": ["src/**/*", "tests/**/*"]

}

6

Given the above configuration, an import like the following:

json

{

"include": ["src/**/*", "tests/**/*"]

}

7

TypeScript will look for the relative files

json

{

"include": ["src/**/*", "tests/**/*"]

}

07,

json

{

"include": ["src/**/*", "tests/**/*"]

}

08, and finally

json

{

"include": ["src/**/*", "tests/**/*"]

}

09.

Note the empty string

json

{

"include": ["src/**/*", "tests/**/*"]

}

10 in which is necessary for TypeScript to also look-up

json

{

"include": ["src/**/*", "tests/**/*"]

}

09.

This feature can be useful for React Native projects where each target platform can use a separate tsconfig.json with differing

json

{

"include": ["src/**/*", "tests/**/*"]

}

06.

  • Released:

    4.7

No Resolve - json{ "include": ["src/**/*", "tests/**/*"]}14

By default, TypeScript will examine the initial set of files for

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98 and

json

{

"include": ["src/**/*", "tests/**/*"]

}

16 directives and add these resolved files to your program.

If

json

{

"include": ["src/**/*", "tests/**/*"]

}

14 is set, this process doesn’t happen. However,

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98 statements are still checked to see if they resolve to a valid module, so you’ll need to make sure this is satisfied by some other means.

Paths - json{ "include": ["src/**/*", "tests/**/*"]}19

A series of entries which re-map imports to lookup locations relative to the . There is a larger coverage of

json

{

"include": ["src/**/*", "tests/**/*"]

}

19 in .

json

{

"include": ["src/**/*", "tests/**/*"]

}

19 lets you declare how TypeScript should resolve an import in your

json

{

"include": ["src/**/*", "tests/**/*"]

}

23/

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98s.

json

{

"include": ["src/**/*", "tests/**/*"]

}

8

This would allow you to be able to write

json

{

"include": ["src/**/*", "tests/**/*"]

}

25, and get all of the correct typing locally.

json

{

"include": ["src/**/*", "tests/**/*"]

}

9

In this case, you can tell the TypeScript file resolver to support a number of custom prefixes to find code. This pattern can be used to avoid long relative paths within your codebase.

Menyelesaikan Module JSON - json{ "include": ["src/**/*", "tests/**/*"]}26

Memperbolehkan mengimpor modul dengan ekstensi ‘.json’ merupakan praktik umum pada proyek node. Ini termasuk membuat jenis untuk

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98 berdasarkan bentuk JSON statis.

TypeScript tidak mendukung penyelesaian berkas JSON secara bawaan:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

0

Mengaktifkan opsi memungkinkan impor JSON, dan memvalidasi jenis dalam berkas JSON tersebut.

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

1

Root Dir - json{ "include": ["src/**/*", "tests/**/*"]}28

Bawaan: Jalur umum terpanjang dari semua berkas masukan non-deklarasi. Jika

json

{

"include": ["src/**/*", "tests/**/*"]

}

29 disetel, bawaannya adalah direktori yang berisi berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72.

Ketika TypeScript mengkompilasi berkas, ia mempertahankan struktur direktori yang sama pada direktori keluaran seperti struktur di direktori masukan.

Misalnya, Anda memiliki beberapa berkas masukan:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

2

Kesimpulan untuk

json

{

"include": ["src/**/*", "tests/**/*"]

}

28 adalah jalur umum terpanjang dari semua berkas masukan non-deklarasi, yang dalam hal ini adalah

json

{

"include": ["src/**/*", "tests/**/*"]

}

32.

Jika nilai

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

03 anda adalah

json

{

"include": ["src/**/*", "tests/**/*"]

}

34, maka TypeScript akan membuat struktur direktori seperti ini:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

3

Namun, anda mungkin mengharapkan

json

{

"include": ["src/**/*", "tests/**/*"]

}

35 menjadi bagian dari struktur direktori keluaran. Dengan menyetel

json

{

"include": ["src/**/*", "tests/**/*"]

}

36 pada

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72, TypeScript akan menghasilkan struktur direktori seperti ini:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

4

Yang terpenting,

json

{

"include": ["src/**/*", "tests/**/*"]

}

28 tidak memengaruhi berkas mana yang menjadi bagian dari kompilasi.

json

{

"include": ["src/**/*", "tests/**/*"]

}

28 tidak memiliki hubungan dengan pengaturan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

61,

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

64, atau

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

60 pada

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72

Perhatikan bahwa TypeScript tidak akan pernah menulis berkas keluaran (file output) ke direktori di luar dari

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

03, dan tidak akan pernah melewatkan pengeluaran berkas. Karena alasan ini,

json

{

"include": ["src/**/*", "tests/**/*"]

}

28 mengharuskan semua berkas yang perlu dikeluarkan berada dibawah jalur

json

{

"include": ["src/**/*", "tests/**/*"]

}

28.

Misalnya, Anda memiliki struktur direktori seperti ini:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

5

Ini akan menimbulkan galat ketika menentukan

json

{

"include": ["src/**/*", "tests/**/*"]

}

28 sebagai

json

{

"include": ["src/**/*", "tests/**/*"]

}

35 dan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

61 sebagai

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

79 karena ini membuat berkas (

json

{

"include": ["src/**/*", "tests/**/*"]

}

51) yang perlu diletakkan di luar dari

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

03 (yaitu

json

{

"include": ["src/**/*", "tests/**/*"]

}

53)

  • Default:

    Computed from the list of input files.

  • Released:

    1.5

Root Dirs - json{ "include": ["src/**/*", "tests/**/*"]}54

Dengan menggunakan

json

{

"include": ["src/**/*", "tests/**/*"]

}

54, Anda dapat memberi tahu kompilator bahwa ada banyak direktori “virtual” yang bertindak sebagai salah satu akar (root). Hal ini memungkinkan kompilator untuk menyelesaikan impor pada modul relatif dalam direktori “virtual”, seolah-olah digabungkan menjadi satu direktori.

Sebagai contoh:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

6

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

7

Ini tidak memengaruhi bagaimana Typescript menghasilkan Javascript, ini hanya mengemulasi asumsi bahwa mereka akan mampu melakukan perkerjaan melalui Jalur relatif tersebut saat runtime.

  • Default:

    Computed from the list of input files.

  • Released:

    2.0

Type Roots - json{ "include": ["src/**/*", "tests/**/*"]}56

By default all visible ”

json

{

"include": ["src/**/*", "tests/**/*"]

}

57” packages are included in your compilation. Packages in

json

{

"include": ["src/**/*", "tests/**/*"]

}

58 of any enclosing folder are considered visible. For example, that means packages within

json

{

"include": ["src/**/*", "tests/**/*"]

}

59,

json

{

"include": ["src/**/*", "tests/**/*"]

}

60,

json

{

"include": ["src/**/*", "tests/**/*"]

}

61, and so on.

If

json

{

"include": ["src/**/*", "tests/**/*"]

}

56 is specified, only packages under

json

{

"include": ["src/**/*", "tests/**/*"]

}

56 will be included. For example:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

8

This config file will include all packages under

json

{

"include": ["src/**/*", "tests/**/*"]

}

64 and

json

{

"include": ["src/**/*", "tests/**/*"]

}

65, and no packages from

json

{

"include": ["src/**/*", "tests/**/*"]

}

66. All paths are relative to the

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72.

  • Related:

Types - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}99

Secara default, semua visible package ”

json

{

"include": ["src/**/*", "tests/**/*"]

}

57” diikutsertakan dalam kompilasi Anda. Package dalam

json

{

"include": ["src/**/*", "tests/**/*"]

}

58 yang terletak dalam folder lain dianggap sebagai visible. Sebagai contoh, package yang berada di

json

{

"include": ["src/**/*", "tests/**/*"]

}

59,

json

{

"include": ["src/**/*", "tests/**/*"]

}

60,

json

{

"include": ["src/**/*", "tests/**/*"]

}

61, dan seterusnya dianggap sebagai visible.

Jika

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

99 telah ditentukan, hanya package yang didaftarkan yang akan disertakan pada lingkup global, misalnya:

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

9

Berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72 ini hanya akan menyertakan

json

{

"include": ["src/**/*", "tests/**/*"]

}

77,

json

{

"include": ["src/**/*", "tests/**/*"]

}

78 dan

json

{

"include": ["src/**/*", "tests/**/*"]

}

79. Package lainnya di bawah direktori

json

{

"include": ["src/**/*", "tests/**/*"]

}

80 tidak akan diikutsertakan.

Apa dampaknya?

Opsi ini tidak memengaruhi bagaimana

json

{

"include": ["src/**/*", "tests/**/*"]

}

81 diikutsertakan dalam kode aplikasi Anda, Sebagai contoh, apabila Anda memiliki

json

{

"include": ["src/**/*", "tests/**/*"]

}

82 seperti di pada contoh di atas dan kode seperti berikut:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

0

Import

json

{

"include": ["src/**/*", "tests/**/*"]

}

83 akan sepenuhnya diketik.

Ketika Anda memiliki opsi ini pada pengaturan tanpa menyertakan sebuah modul dalam array

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

99, maka:

  • globals tidak akan ditambahkan ke dalam proyek Anda (contoh:

    json

    {

    "include": ["src/**/*", "tests/**/*"]

    }

    85 pada node atau

    json

    {

    "include": ["src/**/*", "tests/**/*"]

    }

    86 pada Jest)
  • Ekspor tidak akan muncul sebagai rekomendasi auto-import

Pengaturan pada fitur ini hanya tentang menentukan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

99 yang ingin Anda sertakan, sedangkan mendukung apabila Anda hanya menginginkan folder-folder tertentu saja.

  • Related:

Emit

Declaration - json{ "include": ["src/**/*", "tests/**/*"]}90

Buat berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84 untuk setiap berkas TypeScript atau JavaScript di dalam proyek Anda. Berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84 ini adalah berkas definisi tipe yang menjelaskan API eksternal modul Anda. Dengan berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84, alat seperti TypeScript dapat menyediakan tipe yang masuk akal di dalam sumber kode tanpa definisi tipe data.

Jika

json

{

"include": ["src/**/*", "tests/**/*"]

}

90 disetel ke

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10, jalankan compiler dengan kode TypeScript:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

1

Akan menghasilkan berkas

json

{

"include": ["src/**/*", "tests/**/*"]

}

96 seperti ini:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

2

Dengan

json

{

"include": ["src/**/*", "tests/**/*"]

}

97 yang sesuai:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

3

Saat bekerja dengan berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84 untuk file JavaScript, Anda mungkin ingin menggunakan atau menggunakan untuk memastikan bahwa berkas JavaScript tidak ditimpa.

Declaration Dir - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock04

Menawarkan cara untuk mengonfigurasi direktori root tempat berkas deklarasi dihasilkan.

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

4

dengan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72;

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

5

Akan menempatkan d.ts untuk

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

08 di direktori

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

99:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

6

  • Related:
  • Released:

    2.0

_Declaration Map_ - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock11

Menghasilkan peta sumber untuk berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84 yang mengarahkan kembali ke berkas sumber

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

82 asli. Ini akan memungkinkan editor seperti VS Code untuk pergi ke file

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

82 asli saat menggunakan fitur seperti Go to Definition.

Anda harus mempertimbangkan untuk mengaktifkan ini jika Anda menggunakan referensi proyek.

  • Released:

    2.9

Iterasi tingkat bawah - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock15

Downleveling adalah istilah TypeScript untuk mentranspilasi ke versi JavaScript yang lebih lama. Saran ini untuk mengaktifkan dukungan implementasi yang lebih akurat tentang bagaimana JavaScript modern melakukan iterasi melalui konsep baru di runtime JavaScript yang lebih lama.

ECMAScript 6 menambahkan beberapa iterasi primitif baru: loop

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

16 (

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

17), Array spread (

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

18), penyebaran argumen (

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

19), dan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

20.

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

21 memungkinkan iterasi primitif ini digunakan secara lebih akurat dalam lingkungan ES5 jika ada implementasi

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

20.

Contoh: Efek pada

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

16

Tanpa

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

15 aktif, loop

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

16 pada objek apa pun diturunkan levelnya menjadi loop

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

26 tradisional:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

7

Hal ini sering kali diharapkan orang, tetapi tidak 100% sesuai dengan perilaku ECMAScript 6. String tertentu, seperti emoji (😜), memiliki

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

27 2 (atau bahkan lebih!), Tetapi harus diiterasi sebagai 1 unit dalam loop

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

28. Lihat postingan blog oleh Jonathan New untuk penjelasan yang lebih lengkap.

Jika

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

15 diaktifkan, TypeScript akan menggunakan fungsi bantuan yang memeriksa implementasi

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

20 (baik native maupun polyfill). Jika implementasi ini hilang, Anda akan kembali ke iterasi berbasis indeks.

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

8

Catatan: memungkinkan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

15 tidak meningkatkan kepatuhan jika

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

20 tidak ada saat runtime.

Contoh: Efek pada Array Spreads

ini adalah array spread:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

9

Berdasarkan uraian tersebut, sepertinya mudah untuk menurunkan ke ES5:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

0

Namun, ini sangat berbeda dalam kasus tertentu yang jarang terjadi. Misalnya, jika sebuah array memiliki “lubang” di dalamnya, indeks yang hilang akan membuat properti own jika disebarkan, tetapi tidak akan jika dibuat menggunakan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

33:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

1

Seperti halnya dengan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

16,

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

15 akan menggunakan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

20 (jika ada) untuk meniru perilaku ES 6 dengan lebih akurat.

  • Related:
  • Released:

    2.3

_Emit BOM_ - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock38

Mengontrol apakah TypeScript akan menghasilkan tanda urutan byte (byte order mark - BOM) saat menulis berkas output. Beberapa lingkungan runtime memerlukan BOM untuk menafsirkan berkas JavaScript dengan benar; yang lain mengharuskan itu tidak ada. Nilai bawaan dari

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

62 umumnya paling baik kecuali Anda memiliki alasan untuk mengubahnya.

Menghasilkan Deklarasi Saja - json{ "include": ["src/**/*", "tests/**/*"]}99

Hanya menghasilkan berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84; jangan mengirimkan berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

85.

Pengaturan ini berguna dalam dua kasus:

  • Anda menggunakan transpiler selain TypeScript untuk membuat JavaScript Anda.
  • Anda menggunakan TypeScript hanya untuk menghasilkan berkas

    . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

    43 untuk konsumen Anda.

  • Related:
  • Released:

    2.8

Import Helpers - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock37

Untuk operasi penurunan tingkat tertentu, TypeScript menggunakan beberapa kode penunjang untuk operasi seperti memperluas kelas, himpunan(spread) susunan atau objek, dan menyambungkan operasi. Secara umum, penunjang ini dimasukkan ke dalam berkas yang menggunakannya. Ini dapat mengakibatkan duplikasi kode jika penunjang yang sama digunakan di banyak berkas yang berbeda.

Jika

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

37 kode ini aktif, fungsi penunjang ini diimpor dari tslib modul. Anda perlu memastikan bahwa berkas

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

47 modul dapat diimpor saat dijalankan. Ini hanya mempengaruhi modul, berkas kode tidak akan mencoba mengimpor modul.

Misalnya, dengan TypeScript:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

2

Memasang dan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

37 masih salah:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

3

Lalu aktifkan keduanya dan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

37:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

4

Anda bisa menggunakan saat menyediakan implementasi untuk fungsi-fungsi ini.

  • Related:

Impor Tidak Digunakan Sebagai Nilai - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock55

Kode ini mengontrol cara kerja

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98, ada 3 opsi berbeda:

  • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

    57: Perilaku umum untuk menghapus pernyataan

    {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    98 yang hanya merupakan acuan dari kata.

  • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

    59: Mempertahankan semua pernyataan

    {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    98 yang nilai atau katanya tidak pernah digunakan. Hal ini dapat menyebabkan impor/efek samping yang tetap dipertahankan.

  • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

    61: Ini mempertahankan semua impor (sama seperti pilihan), tetapi akan mengalami galat jika impor nilai hanya digunakan sebagai tipe data. Ini mungkin berguna jika Anda ingin memastikan tidak ada nilai yang diimpor secara tidak sengaja, tetapi tetap membuat impor dengan jelas.

Kode ini berfungsi karena Anda dapat menggunakan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

62 secara jelas dengan pernyataan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98 yang tidak boleh dimasukkan ke JavaScript.

  • Default:

    . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

    57

  • Allowed:
    • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

      57

    • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

      59

    • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

      61

  • Released:

    3.8

Peta Sumber Sebaris - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock68

Jika disetel, ketika menulis berkas

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

69 untuk menyediakan peta sumber, TypeScript akan menyematkan konten peta sumber di berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

85. Meskipun ini menghasilkan berkas JS yang lebih besar, tapi dapat memudahkan dalam beberapa tahap. Misalnya anda mungkin ingin mencoba berkas JS pada server web, tapi tidak mengizinkan berkas

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

71 untuk ditampilkan.

Saling terpisah dengan .

Misalnya, dengan TypeScript:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

5

Di ubah menjadi JavaScript:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

6

Kemudian aktifkan pembuatannya dengan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

68, ada komentar di bagian bawah berkas yang menyertakan peta sumber untuk berkas tersebut.

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

7

  • Released:

    1.5

Sumber Sebaris - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock74

Jika dilihat, TypeScript akan menyertakan konten asli dari berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

82 sebagai string yang disematkan di peta sumber. Ini sering kali berguna dalam kasus yang sama seperti

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

68.

Membutuhkan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

72 atau

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

68 untuk disetel.

Misalnya, dengan TypeScript:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

8

Di ubah menjadi JavaScript:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

6

Kemudian dengan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

74 dan

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

68 diaktifkan, ada komentar di bagian bawah berkas yang menyertakan peta sumber untuk berkas tersebut. Perhatikan bahwa ada yang berbeda di akhir [

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

68] (# inlineSourceMap) karena peta sumber sekarang berisi kode sumber asli.

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

0

  • Released:

    1.5

Map Root - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock82

Specify the location where debugger should locate map files instead of generated locations. This string is treated verbatim inside the source-map, for example:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

1

Would declare that

json

{

"include": ["src/**/*", "tests/**/*"]

}

96 will have sourcemaps at

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

84.

New Line - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock85

Specify the end of line sequence to be used when emitting files: ‘CRLF’ (dos) or ‘LF’ (unix).

  • Default:

    Platform specific.

  • Allowed:
    • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

      86

    • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

      87

  • Released:

    1.5

No Emit - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock88

Do not emit compiler output files like JavaScript source code, source-maps or declarations.

This makes room for another tool like Babel, or swc to handle converting the TypeScript file to a file which can run inside a JavaScript environment.

You can then use TypeScript as a tool for providing editor integration, and as a source code type-checker.

No Emit Helpers - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock52

Instead of importing helpers with , you can provide implementations in the global scope for the helpers you use and completely turn off emitting of helper functions.

For example, using this

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

91 function in ES5 requires a

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

92-like function and

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

93-like function to run:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

2

Which creates quite a lot of JavaScript:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

3

Which can be switched out with your own globals via this flag:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

4

  • Related:
  • Released:

    1.5

No Emit On Error - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock95

Do not emit compiler output files like JavaScript source code, source-maps or declarations if any errors were reported.

This defaults to

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

62, making it easier to work with TypeScript in a watch-like environment where you may want to see results of changes to your code in another environment before making sure all errors are resolved.

  • Released:

    1.4

Out Dir - { "extends": "./configs/base", "files": ["main.ts", "supplemental.ts"]}03

Jika ditentukan, berkas-berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

85 (maupun

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84,

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

69, dsb.) akan disertakan ke dalam direktori ini. Struktur direktori dari sumber awal berkas-berkas juga dipertahankan; lihat jika akar yang di perhitungkan bukan yang anda inginkan.

Jika tidak ditentukan, berkas-berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

85 akan disertakan di direktori yang sama dengan berkas-berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

82 dari mana mereka di hasilkan:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

5

Dengan suatu

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72 seperti ini:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

6

Menjalankan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

04 dengan pengaturan ini dapat memindahkan berkas-berkas ke direktori

json

{

"include": ["src/**/*", "tests/**/*"]

}

34:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

7

  • Related:

Out File - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}07

Jika ditentukan, semua berkas global (non-module) akan digabung menjadi satu berkas keluaran tertentu.

Jika

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

38 adalah

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

75 atau

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

73, semua berkas modul juga akan digabungkan menjadi berkas ini setelah semua konten global.

Catatan:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

07 tidak dapat digunakan kecuali

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

38 adalah

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

64,

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

45, atau

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

44. Opsi ini tidak bisa digunakan untuk membundel modul CommonJS atau ES6.

  • Related:
  • Released:

    1.0

Preserve Const Enums - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}19

Do not erase

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

20 declarations in generated code.

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

20s provide a way to reduce the overall memory footprint of your application at runtime by emitting the enum value instead of a reference.

For example with this TypeScript:

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

8

The default

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

20 behavior is to convert any

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

23 to the corresponding number literal, and to remove a reference to the enum from the JavaScript completely.

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

9

With

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

19 set to

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10, the

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

26 exists at runtime and the numbers are still emitted.

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

0

This essentially makes such

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

27 a source-code feature only, with no runtime traces.

preserveValueImports - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}31

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

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

1

or code using ‘Compiles to HTML’ languages like Svelte or Vue.

When combined with : 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.

For example, in the following code

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

33 is a function and

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

34 is a type with

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

29 and

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

31 are enabled:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

2

Which can be fixed by prefixing

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

34 with

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

20 to mark it as a type-only import:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

3

  • Related:
  • Released:

    4.5

Menghapus Komentar - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}41

Menghapus semua komentar pada berkas Typescript pada saat mengonversi ke berkas Javascript. Pengaturan bawaannya adalah

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

62

Sebagai contoh, ini adalah berkas TypeScript yang memiliki komentar JSDoc:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

4

Ketika

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

41 disetel ke

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

5

Tanpa menyetel

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

41 atau menjadikannya sebagai

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

62:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

6

Artinya, komentar anda akan muncul di kode Javascript

Source Map - . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock72

Enables the generation of sourcemap files. These files allow debuggers and other tools to display the original TypeScript source code when actually working with the emitted JavaScript files. Source map files are emitted as

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

69 (or

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

49) files next to the corresponding

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

85 output file.

The

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

85 files will in turn contain a sourcemap comment to indicate where the files are to external tools, for example:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

7

Compiling with

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

72 set to

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10 creates the following JavaScript file:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

8

And this also generates this json map:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

9

Source Root - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}54

Specify the location where a debugger should locate TypeScript files instead of relative source locations. This string is treated verbatim inside the source-map where you can use a path or a URL:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

00

Would declare that

json

{

"include": ["src/**/*", "tests/**/*"]

}

96 will have a source file at

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

56.

Strip Internal - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}57

Do not emit declarations for code that has an

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

58 annotation in its JSDoc comment. This is an internal compiler option; use at your own risk, because the compiler does not check that the result is valid. If you are searching for a tool to handle additional levels of visibility within your

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

43 files, look at api-extractor.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

01

With the flag set to

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

62 (default):

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

02

With

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

57 set to

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10 the

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

43 emitted will be redacted.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

03

The JavaScript output is still the same.

  • Internal

JavaScript Support

Allow JS - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}87

Izinkan berkas JavaScript diimpor ke dalam proyek Anda, bukan hanya berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

82 dan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

83. Contoh, berkas JS ini:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

04

Ketika diimpor ke berkas TypeScript akan menimbulkan galat seperti berikut:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

05

Impor berkas akan baik-baik saja saat

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

87 diaktifkan:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

06

Opsi ini dapat digunakan sebagai cara untuk menambahkan berkas TypeScript secara bertahap ke dalam proyek JS dengan mengizinkan berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

82 dan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

83 untuk hidup berdampingan dengan berkas JavaScript yang ada.

  • Related:
  • Released:

    1.8

Check JS - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}70

Bekerja sama dengan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

87. Kapan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

70 diaktifkan kemudian kesalahan dilaporkan dalam berkas JavaScript. Ini termasuk

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

75 di bagian atas semua berkas JavaScript yang disertakan dalam proyek Anda.

Misalnya, ini adalah JavaScript yang salah menurut definisi jenis

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

76 yang disertakan dengan TypeScript:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

07

Saat diimpor ke modul TypeScript:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

08

Anda tidak akan mendapatkan kesalahan apapun. Namun, jika Anda mengaktifkan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

70 maka Anda akan mendapatkan pesan kesalahan dari berkas JavaScript.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

09

  • Related:
  • Released:

    2.3

Max Node Module JS Depth - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}80

The maximum dependency depth to search under

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

81 and load JavaScript files.

This flag is can only be used when is enabled, and is used if you want to have TypeScript infer types for all of the JavaScript inside your

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

81.

Ideally this should stay at 0 (the default), and

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

43 files should be used to explicitly define the shape of modules. However, there are cases where you may want to turn this on at the expense of speed and potential accuracy.

Editor Support

Nonaktifkan Batas Ukuran - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}85

Untuk menghindari kemungkinan masalah pembengkakan memori saat bekerja dengan proyek JavaScript yang sangat besar, ada batas atas jumlah memori yang akan dialokasikan TypeScript. Mengaktifkan saran ini akan menghapus batas.

Plugins - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}86

List of language service plugins to run inside the editor.

Language service plugins are a way to provide additional information to a user based on existing TypeScript files. They can enhance existing messages between TypeScript and an editor, or to provide their own error messages.

For example:

  • — Adds SQL linting with a template strings SQL builder.
  • typescript-styled-plugin — Provides CSS linting inside template strings .
  • typescript-eslint-language-service — Provides eslint error messaging and fix-its inside the compiler’s output.
  • ts-graphql-plugin — Provides validation and auto-completion inside GraphQL query template strings.

VS Code has the ability for a extension to , and so you may have some running in your editor without needing to define them in your

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72.

Interop Constraints

Izinkan Setelan Standar Impor Sintetis - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}88

Jika disetel ke true

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

88 memungkinkan Anda untuk menulis impor seperti:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

10

daripada:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

11

Jika modul tidak secara eksplisit menentukan ekspor default.

Misalnya, tanpa

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

88 disetel ke true:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

12

Kode ini menimbulkan galat karena tidak ada objek

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

91 yang dapat Anda impor. Meski rasanya seperti itu seharusnya. Untuk kenyamanan, transpiler seperti Babel akan secara otomatis membuat setelan standar jika tidak dibuat. Membuat modul terlihat lebih seperti:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

13

Opsi ini tidak memengaruhi JavaScript yang dihasilkan oleh TypeScript, ini hanya untuk type checking. Opsi ini membuat perilaku TypeScript sejalan dengan Babel, di mana kode ekstra akan ditambahkan kedalam setelan standar ekspor untuk membuat sebuah modul lebih ergonomis.

Interop Modul ES - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}95

Secara bawaan (dengan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

95 false atau tidak disetel) TypeScript memperlakukan modul CommonJS/AMD/UMD mirip dengan modul ES6. Dalam melakukan ini, ada dua bagian tertentu yang ternyata merupakan asumsi yang salah:

  • Impor namespace seperti

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    04 bertindak sama seperti

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    05

  • Impor bawaan seperti

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    06 berfungsi sama seperti

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    07

Ketidakcocokan ini menyebabkan dua masalah berikut:

  • Spesifikasi modul ES6 menyatakan bahwa impor namespace (

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    08) hanya dapat menjadi objek, dengan memiliki TypeScript memperlakukannya sama dengan

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    09 maka TypeScript diizinkan untuk impor diperlakukan sebagai fungsi dan dapat dipanggil. Ini melanggar rekomendasi spesifikasi.

  • Meskipun akurat untuk spesifikasi modul ES6, sebagian besar pustaka dengan modul CommonJS/AMD/UMD tidak seketat implementasi TypeScript.

Mengaktifkan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

95 akan memperbaiki kedua masalah ini dalam kode yang ditranspilasi oleh TypeScript. Perubahan pertama perilaku di kompilator, yang kedua diperbaiki oleh dua fungsi pembantu baru yang menyediakan shim untuk memastikan kompatibilitas dalam JavaScript yang dihasilkan:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

14

Dengan menonaktifkan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

95:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

15

Dengan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

95 disetel ke

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

16

Catatan: Anda dapat meminimalisir ukuran keluaran dengan mengaktifkan :

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

17

Mengaktifkan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

95 juga akan mengaktifkan .

  • Recommended
  • Related:
  • Released:

    2.7

Paksa Jenis Huruf Konsisten Dalam Nama berkas - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try18

TypeScript mengikuti aturan sensitifitas huruf besar dari sistem berkas yang menjalankannya. Ini bisa menjadi masalah jika beberapa pengembang bekerja dalam sistem berkas sensitifitas huruf besar dan kecil dan yang lainnya tidak. Jika sebuah berkas mencoba mengimpor

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

19 dengan menetapkan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

20, berkas tersebut akan ditemukan dalam sistem berkas yang tidak peka huruf besar/kecil, tetapi tidak pada sistem berkas yang peka huruf besar kecil.

Ketika opsi ini disetel, TypeScript akan mengeluarkan galat jika program mencoba memasukkan berkas dengan jenis huruf yang berbeda dari jenis huruf pada disk.

  • Recommended

Modul Terisolasi (_Isolated Modules_) - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}29

Meskipun Anda dapat menggunakan TypeScript untuk menghasilkan ke kode JavaScript, penggunaan transpiler lain seperti Babel juga umum untuk dilakukan. Namun, transpiler lain hanya beroperasi di satu berkas pada satu waktu, yang berarti mereka tidak dapat menerapkan transformasi kode yang bergantung pada pemahaman sistem tipe penuh. Pembatasan ini juga berlaku untuk API

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

22 TypeScript yang digunakan oleh beberapa alat pengembang.

Batasan ini dapat menyebabkan masalah waktu proses dengan beberapa fitur TypeScript seperti

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

20s dan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

24s. Pilihan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

29 memberi tahu TypeScript untuk memperingatkan Anda jika menulis kode tertentu yang tidak dapat diartikan dengan benar oleh proses transpilasi berkas tunggal.

Itu tidak mengubah kode Anda atau mengubah perilaku proses pemeriksaan dan pengecekan kode TypeScript.

Beberapa contoh kode yang tidak berfungsi saat

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

29 diaktifkan.

Ekspor Pengenal Non-Nilai

Di TypeScript, Anda dapat mengimpor type dan kemudian mengekspornya:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

18

Karena tidak ada nilai untuk

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

27,

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

28 yang ditampilkan tidak akan mencoba mengekspornya (ini akan menjadi galat waktu proses di JavaScript):

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

19

Transpiler satu berkas tidak tahu apakah

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

27 menghasilkan nilai atau tidak, jadi itu adalah galat untuk mengekspor nama yang hanya mengacu pada sebuah tipe.

Non-Module Files

Jika

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

29 dipilih, semua berkas implementasi harus dalam modules (yang berarti memiliki beberapa bentuk

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98 /

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

28). galat terjadi jika berkas:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

20

Pembatasan ini tidak berlaku untuk berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

84

Referensi ke anggota

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

20

Di TypeScript, saat mereferensikan anggota

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

20, referensi tersebut diganti dengan nilai sebenarnya di JavaScript yang ditampilkan.

Mengubah TypeScript:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

21

Ini untuk JavaScript:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

22

Tanpa pengetahuan tentang nilai anggota ini, transpiler lain tidak dapat menggantikan referensi ke

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

36, yang akan menjadi galat dijalankan jika dibiarkan (karena tidak ada objek

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

37 pada waktu proses). Karena itu, ketika

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

29 dipilih, akan terjadi galat yang mereferensikan anggota

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

20 di sekelilingnya.

This is to reflect the same flag in Node.js; which does not resolve the real path of symlinks.

This flag also exhibits the opposite behavior to Webpack’s

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

41 option (i.e. setting TypeScript’s

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

40 to true parallels setting Webpack’s

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

41 to false, and vice-versa).

With this enabled, references to modules and packages (e.g.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98s and

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

45 directives) are all resolved relative to the location of the symbolic link file, rather than relative to the path that the symbolic link resolves to.

Backwards Compatibility

Charset - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try46

Di TypeScript versi sebelumnya, ini mengontrol pengkodean yang digunakan saat membaca berkas teks dari memori. Saat ini, TypeScript mengasumsikan pengkodean UTF-8, tetapi akan mendeteksi dengan benar UTF-16 (BE dan LE) atau UTF-8 BOMs.

  • Deprecated
  • Default:

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    47

Keyof Strings Only - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try48

This flag changes the

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

49 type operator to return

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

50 instead of

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

51 when applied to a type with a string index signature.

This flag is used to help people keep this behavior from .

  • Deprecated
  • Released:

    2.9

No Implicit Use Strict - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try52

Anda seharusnya tidak memerlukan ini. Secara bawaan, saat memancarkan sebuah berkas modul kepada sebuah target non-ES6, TypeScript memancarkan sebuah kata pengantar

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

53 di bagian atas berkas. Ini dapat menonaktifkan setelan kata pengantar itu.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

23

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

24

No Strict Generic Checks - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try54

TypeScript will unify type parameters when comparing two generic functions.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

25

This flag can be used to remove that check.

  • Released:

    2.4

Out - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;}06

Gunakan sebagai gantinya.

Opsi

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

06 memproses lokasi akhir dengan dengan cara yang tidak dapat diprediksi atau konsisten. Opsi ini dipertahankan hanya untuk kompatibilitas dengan versi lama dan sudah usang.

  • Deprecated
  • Related:

Suppress Excess Property Errors - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try59

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

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

26

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

We don’t recommend using this flag in a modern codebase, you can suppress one-off cases where you need it using

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

60.

Suppress Implicit Any Index Errors - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try61

Turning

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

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

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

27

Using

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

61 is quite a drastic approach. It is recommended to use a

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

64 comment instead:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

28

  • Related:

Language and Environment

Menghasilkan Dekorator Metadata - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try66

Mengaktifkan dukungan eksperimental untuk menghasilkan tipe data metadata untuk dekorator yang bekerja dengan modul

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

67.

Sebagai contoh, berikut adalah JavaScript

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

29

Dengan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

66 tidak disetel ke true (bawaan):

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

30

Dengan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

69 di setel ke true:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

31

  • Related:

Decorators Eksperimental - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try70

Menyalakan dukungan eksperimental untuk decorator, yang terdapat pada tahap ke 2 proses standarisasi TC39.

Decorator adalah fitur bahasa pemrograman yang belum diadaptasi secara penuh ke dalam spesifikasi JavaScript. Hal ini berarti bahwa versi implementasi di TypeScript mungkin berbeda dengan implementasi pada JavaScript ketika fitur tersebut telah diputuskan oleh TC39.

Anda dapat mencari tahu lebih lanjut mengenai dukungan decorator di TypeScript pada buku petunjuk.

  • Related:

JSX - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try73

Mengatur bagaimana konstruksi JSX dihasilkan di dalam file Javascript. Ini hanya akan berpengaruh pada keluaran file JS yang dimulai di file

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

83.

  • ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    75: Menghasilkan file

    {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    85 dengan JSX yang diubah seperti pemanggilan

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    77
  • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

    59: Menghasilkan file

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    79 tanpa mengubah JSX
  • ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    80: Menghasilkan file

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    79 tanpa mengubah JSX

  • Allowed:
    • . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

      59

    • ts

      function fn(n: number) {

      if (n > 5) {

      return true;

      } else {

      return false;

      }

      return true;

      Unreachable code detected.7027Unreachable code detected.

      }

      Try

      75

    • ts

      function fn(n: number) {

      if (n > 5) {

      return true;

      } else {

      return false;

      }

      return true;

      Unreachable code detected.7027Unreachable code detected.

      }

      Try

      80

    • ts

      function fn(n: number) {

      if (n > 5) {

      return true;

      } else {

      return false;

      }

      return true;

      Unreachable code detected.7027Unreachable code detected.

      }

      Try

      85

    • ts

      function fn(n: number) {

      if (n > 5) {

      return true;

      } else {

      return false;

      }

      return true;

      Unreachable code detected.7027Unreachable code detected.

      }

      Try

      86

  • Related:
  • Released:

    2.2

JSX Factory - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try87

Mengubah fungsi yang dipanggil pada file

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

85 ketika melakukan kompilasi elemen-elemen JSX. Perubahan yang paling umum adalah dengan menggunakan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

92 atau

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

93 dibandingkan penggunaan bawaan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

94 jika menggunakan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

95.

Opsi ini dapat digunakan pada basis per file juga seperti halnya .

  • Default:

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    77

  • Allowed:
    • Any identifier or dotted identifier.

  • Related:

jsxFragmentFactory - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try88

Menentukan fungsi penghasil fragmen JSX yang akan digunakan ketika menargetkan kompiler react JSX

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

87 sudah ditentukan, misalnya seperti

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

03.

Opsi ini dapat digunakan pada basis per file juga seperti halnya .

Contoh dengan menggunakan TSConfig berikut ini:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

32

TSX file berikut:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

33

Akan terlihat seperti:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

34

  • Default:

    ts

    function verifikasiUmur(umur: number) {

    // Lupa menulis pernyataan 'return'

    if (umur > 18) {

    terverifikasi: true;

    Unused label.7028Unused label.

    }

    }

    Try

    05

  • Related:
  • Released:

    4.0

jsxImportSource - tsfunction fn(n: number) { if (n > 5) { return true; } else { return false; } return true;Unreachable code detected.7027Unreachable code detected.}Try89

Declares the module specifier to be used for importing the

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

73 and

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

11 factory functions when using as

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

13 or

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

14 which were introduced in TypeScript 4.1.

With React 17 the library supports a new form of JSX transformation via a separate import.

For example with this code:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

35

Using this TSConfig:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

36

The emitted JavaScript from TypeScript is:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

37

For example if you wanted to use

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

15, you need a tsconfig like:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

38

Which generates code like:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

39

Alternatively, you can use a per-file pragma to set this option, for example:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

40

Would add

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

16 as an import for the

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

17 factory.

Note: In order for this to work like you would expect, your

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

18 file must include an

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

28 or

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

98 so that it is considered a module.

  • Default:

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    75

  • Related:
  • Released:

    4.1

Lib - tsfunction verifikasiUmur(umur: number) { // Lupa menulis pernyataan 'return' if (umur > 18) { terverifikasi: true;Unused label.7028Unused label. }}Try24

TypeScript includes a default set of type definitions for built-in JS APIs (like

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

25), as well as type definitions for things found in browser environments (like

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

26). TypeScript also includes APIs for newer JS features matching the you specify; for example the definition for

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

28 is available if is

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

49 or newer.

You may want to change these for a few reasons:

  • Your program doesn’t run in a browser, so you don’t want the

    ts

    function verifikasiUmur(umur: number) {

    // Lupa menulis pernyataan 'return'

    if (umur > 18) {

    terverifikasi: true;

    Unused label.7028Unused label.

    }

    }

    Try

    31 type definitions
  • Your runtime platform provides certain JavaScript API objects (maybe through polyfills), but doesn’t yet support the full syntax of a given ECMAScript version
  • You have polyfills or native implementations for some, but not all, of a higher level ECMAScript version

In TypeScript 4.5, lib files can be overriden by npm modules, find out more .

High Level libraries

NameContents

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

68Core definitions for all ES3 and ES5 functionality

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

48Additional APIs available in ES2015 (also known as ES6) -

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

34,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

35,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

36,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

37,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

28,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

39,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

40, etc.

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

49Alias for “ES2015”

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

42Additional APIs available in ES2016 -

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

43, etc.

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

44Alias for “ES2016”

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

45Additional APIs available in ES2017 -

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

46,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

47,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

48,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

49,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

50, typed arrays, etc.

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

51Additional APIs available in ES2018 -

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

91 iterables,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

53,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

54,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

55, etc.

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

56Additional APIs available in ES2019 -

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

57,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

58,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

59,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

60,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

61, etc.

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

47Additional APIs available in ES2020 -

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

63, etc.

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

64Additional APIs available in ES2021 -

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

65,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

66 etc.

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

46Additional APIs available in ESNext - This changes as the JavaScript specification evolves

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

68DOM definitions -

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

69,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

26, etc.

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

71APIs available in WebWorker contexts

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

72APIs for the Windows Script Hosting System

Individual library components

Name

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

73

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

74

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

75

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

76

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

77

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

78

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

79

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

80

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

81

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

82

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

83

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

84

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

85

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

86

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

87

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

88

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

89

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

90

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

91

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

92

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

93

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

94

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

95

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

96

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

97

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

98

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

99

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

00

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

01

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

02

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

03

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

04

This list may be out of date, you can see the full list in the TypeScript source code.

  • Related:
  • Released:

    2.0

moduleDetection - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}06

There are three choices:

  • ts

    interface UserDefaults {

    // The absence of a value represents 'system'

    colorThemeOverride?: "dark" | "light";

    }

    07 (default) - TypeScript will not only look for import and export statements, but it will also check whether the

    ts

    interface UserDefaults {

    // The absence of a value represents 'system'

    colorThemeOverride?: "dark" | "light";

    }

    08 field in a

    {

    "extends": "./tsconfig",

    "compilerOptions": {

    "strictNullChecks": false

    }

    }

    63 is set to

    ts

    interface UserDefaults {

    // The absence of a value represents 'system'

    colorThemeOverride?: "dark" | "light";

    }

    10 when running with :

    {

    "extends": "./tsconfig",

    "compilerOptions": {

    "strictNullChecks": false

    }

    }

    57 or

    {

    "extends": "./tsconfig",

    "compilerOptions": {

    "strictNullChecks": false

    }

    }

    56, and check whether the current file is a JSX file when running under :

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    Unreachable code detected.7027Unreachable code detected.

    }

    Try

    85.

  • ts

    interface UserDefaults {

    // The absence of a value represents 'system'

    colorThemeOverride?: "dark" | "light";

    }

    16 - The same behavior as 4.6 and prior, usings import and export statements to determine whether a file is a module.

  • ts

    interface UserDefaults {

    // The absence of a value represents 'system'

    colorThemeOverride?: "dark" | "light";

    }

    17 - Ensures that every non-declaration file is treated as a module.

  • Default:

    "auto": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node16+) as modules.

  • Allowed:
    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      18

    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      19

    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      20

  • Released:

    4.7

No Lib - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}05

Disables the automatic inclusion of any library files. If this option is set,

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

24 is ignored.

TypeScript cannot compile anything without a set of interfaces for key primitives like:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

23,

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

24,

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

25,

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

26,

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

36,

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

28,

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

29, and

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

30. It is expected that if you use

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

05 you will be including your own type definitions for these.

  • Related:

React Namespace - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}33

Gunakan sebagai gantinya. Tentukan objek yang dipanggil oleh

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

35 ketika menargetkan

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

Unreachable code detected.7027Unreachable code detected.

}

Try

75 pada berkas TSX.

  • Default:

    ts

    interface UserDefaults {

    // The absence of a value represents 'system'

    colorThemeOverride?: "dark" | "light";

    }

    37

Target - { "extends": "./tsconfig", "compilerOptions": { "strictNullChecks": false }}66

Beberapa browser modern mendukung semua fitur ES6, jadi

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

49 merupakan pilihan yang baik. Anda dapat memilih untuk menyetel sasaran yang lebih rendah apabila kode Anda diluncurkan untuk lingkungan yang lebih lama, atau sebuah sasaran yang lebih tinggi apabila kode Anda dijamin untuk dapat berjalan di lingkungan yang lebih baru.

Pengaturan

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

66 mengubah fitur JS mana yang diturunkan levelnya dan mana yang dibiarkan utuh. Sebagai contoh, sebuah arrow_function

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

41 akan berubah menjadi sebuah ekspresi yang ekuivalen dengan

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

42 apabila

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

66 merupakan ES5 atau versi yang lebih rendah.

Mengubah

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

66 berarti juga mengubah nilai default dari . Anda dapat mengatur

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

66 dan

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

24 sesuai keinginan, tetapi Anda dapat menyetel

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

66 untuk alasan kenyamanan.

Jika Anda hanya bekerja dengan Node.js, berikut adalah beberapa

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

66 yang direkomendasikan berdasarkan versi Node:

NamaTarget yang didukungNode 8

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

45Node 10

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

51Node 12

ts

function verifikasiUmur(umur: number) {

// Lupa menulis pernyataan 'return'

if (umur > 18) {

terverifikasi: true;

Unused label.7028Unused label.

}

}

Try

56

Ini didasarkan pada database dukungan node.green.

Nilai khusus

{

"extends": "./tsconfig",

"compilerOptions": {

"strictNullChecks": false

}

}

46 merujuk pada versi tertinggi yang didukung oleh versi TypeScript Anda. Pengaturan ini harus dilakukan secara hati-hati, karena ini tidak berarti hal yang sama pada versi TypeScript yang berbeda dan dapat membuat peningkatan kurang dapat diprediksi.

  • Default:

    {

    "extends": "./tsconfig",

    "compilerOptions": {

    "strictNullChecks": false

    }

    }

    67

  • Allowed:
    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      55

    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      56

    • {

      "extends": "./tsconfig",

      "compilerOptions": {

      "strictNullChecks": false

      }

      }

      76/

      {

      "extends": "./tsconfig",

      "compilerOptions": {

      "strictNullChecks": false

      }

      }

      77

    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      59

    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      60

    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      61

    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      62

    • {

      "extends": "./tsconfig",

      "compilerOptions": {

      "strictNullChecks": false

      }

      }

      78

    • ts

      interface UserDefaults {

      // The absence of a value represents 'system'

      colorThemeOverride?: "dark" | "light";

      }

      64

    • {

      "extends": "./tsconfig",

      "compilerOptions": {

      "strictNullChecks": false

      }

      }

      79

    • {

      "extends": "./tsconfig",

      "compilerOptions": {

      "strictNullChecks": false

      }

      }

      80

  • Released:

    1.0

Use Define For Class Fields - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}67

This flag is used as part of migrating to the upcoming standard version of class fields. TypeScript introduced class fields many years before it was ratified in TC39. The latest version of the upcoming specification has a different runtime behavior to TypeScript’s implementation but the same syntax.

This flag switches to the upcoming ECMA runtime behavior.

You can read more about the transition in .

Compiler Diagnostics

Diagnostics - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}73

Digunakan untuk mengeluarkan informasi diagnostik untuk debugging. Perintah ini adalah subset dari yang lebih merupakan hasil yang dilihat pengguna, dan lebih mudah ditafsirkan.

Jika Anda telah diminta oleh kompilator engineer TypeScript untuk memberikan hasil menggunakan tanda ini dalam sebuah kompilasi, di mana tidak ada salahnya menggunakan sebagai gantinya.

  • Deprecated
  • Related:

explainFiles - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}77

Print names of files which TypeScript sees as a part of your project and the reason they are part of the compilation.

For example, with this project of just a single

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

08 file

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

41

Using a

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

72 which has

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

77 set to true:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

42

Running TypeScript against this folder would have output like this:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

43

The output above show:

  • The initial lib.d.ts lookup based on , and the chain of

    {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    84 files which are referenced
  • The

    . ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

    08 file located via the default pattern of

This option is intended for debugging how a file has become a part of your compile.

  • Released:

    4.2

Diagnosa yang Diperpanjang - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}74

Anda dapat menggunakan opsi ini untuk menemukan dimana TypeScript menghabiskan waktunya selama proses kompilasi. Peralatan ini digunakan untuk memahami karakteristik peforma basis kode Anda secara keseluruhan.

Anda dapat mempelajari lebih lanjut bagaimana mengukur dan memahami hasil keluaran pada bagian wiki peforma.

  • Related:

Hasilkan Profil CPU - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}87

Opsi ini memberi Anda kesempatan untuk meminta TypeScript mengeluarkan profil CPU v8 selama penyusun dijalankan. Profil CPU dapat memberikan wawasan tentang mengapa proyek Anda bisa lambat.

Opsi ini hanya dapat digunakan dari CLI melalui:

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

88.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

44

Berkas ini dapat dibuka di peramban berbasis chromium seperti Chrome atau Edge Developer di bagian Riwayat CPU. Anda dapat mempelajari lebih lanjut tentang memahami kinerja penyusun di Bagian wiki TypeScript tentang kinerja.

  • Default:

    ts

    interface UserDefaults {

    // The absence of a value represents 'system'

    colorThemeOverride?: "dark" | "light";

    }

    89

  • Released:

    3.7

List Emitted Files - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}90

Print names of generated files part of the compilation to the terminal.

This flag is useful in two cases:

  • You want to transpile TypeScript as a part of a build chain in the terminal where the filenames are processed in the next command.
  • You are not sure that TypeScript has included a file you expected, as a part of debugging the .

For example:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

4

With:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

46

Would echo paths like:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

47

Normally, TypeScript would return silently on success.

List Files - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}91

Print names of files part of the compilation. This is useful when you are not sure that TypeScript has included a file you expected.

For example:

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

4

With:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

49

Would echo paths like:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

50

Note if using TypeScript 4.2, prefer which offers an explanation of why a file was added too.

  • Related:

Trace Resolution - tsinterface UserDefaults { // The absence of a value represents 'system' colorThemeOverride?: "dark" | "light";}94

When you are trying to debug why a module isn’t being included. You can set

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

94 to

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10 to have TypeScript print information about its resolution process for each processed file.

You can read more about this in .

  • Released:

    2.0

Projects

Composite - json{ "include": ["src/**/*", "tests/**/*"]}29

Opsi

json

{

"include": ["src/**/*", "tests/**/*"]

}

29 memberlakukan batasan tertentu yang memungkinkan untuk membangun (termasuk TypeScript sendiri, di bawah mode

ts

interface UserDefaults {

// The absence of a value represents 'system'

colorThemeOverride?: "dark" | "light";

}

99) untuk menentukan dengan cepat apakah proyek telah dibangun.

Saat pengaturan ini aktif:

  • Setelan

    json

    {

    "include": ["src/**/*", "tests/**/*"]

    }

    28, jika tidak disetel secara eksplisit, lokasi penyimpanan akan berisi berkas

    {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    72.

  • Semua berkas implementasi harus cocok dengan sebuah

    {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    61 contoh atau terdaftar dalam aturan

    {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    60. Jika batasan ini dilanggar,

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    }

    04 akan memberi tahu Anda berkas mana yang tidak ditentukan.

  • json

    {

    "include": ["src/**/*", "tests/**/*"]

    }

    90 defaults ke

    {

    "extends": "./configs/base",

    "files": ["main.ts", "supplemental.ts"]

    }

    10

Anda dapat menemukan dokumentasi tentang proyek TypeScript di the handbook.

  • Related:
  • Released:

    3.0

disableReferencedProjectLoad - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}009

Dalam program TypeScript multi-proyek, TypeScript akan memuat semua proyek yang tersedia ke dalam memori untuk memberikan hasil yang akurat untuk tanggapan editor yang memerlukan grafik pengetahuan lengkap seperti ‘Temukan Semua Referensi’.

Jika proyek Anda besar, Anda dapat menggunakan saran

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

009 untuk menonaktifkan pemuatan otomatis semua proyek. Sebaliknya, proyek dimuat secara dinamis saat Anda membuka file melalui editor Anda.

  • Released:

    4.0

Nonaktifkan Pencarian Solusi - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}011

Saat bekerja dengan proyek TypeScript komposit, opsi ini menyediakan cara untuk menyatakan bahwa Anda tidak ingin proyek disertakan saat menggunakan fitur seperti find all reference atau jump to definition di editor.

Saran ini untuk sesuatu yang dapat Anda gunakan untuk meningkatkan daya tanggap dalam proyek komposit besar.

  • Released:

    3.8

Nonaktifkan Pengalihan Referensi Proyek Sumber - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}012

Saat bekerja dengan proyek TypeScript komposit, opsi ini menyediakan cara untuk menuju perilaku di mana berkas d.ts digunakan sebagai batas antar modul. Di 3.7, sumber kebenaran sekarang adalah berkas TypeScript Anda.

  • Released:

    3.7

Incremental - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}007

Memberi tahu TypeScript untuk menyimpan informasi tentang grafik proyek dari kompilasi terakhir ke berkas yang disimpan di penyimpanan. Ini membuat serangkaian berkas

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

014 di folder yang sama dengan keluaran kompilasi Anda. Mereka tidak menggunakan JavaScript saat runtime dan dapat dihapus dengan aman. Anda dapat membaca lebih lanjut di .

Anda dapat mengontrol nama folder dengan menggunakan pilihan .

TS Build Info File - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}008

This setting lets you specify a file for storing incremental compilation information as a part of composite projects which enables faster building of larger TypeScript codebases. You can read more about composite projects in the handbook.

This option offers a way to configure the place where TypeScript keeps track of the files it stores on the disk to indicate a project’s build state — by default, they are in the same folder as your emitted JavaScript.

Output Formatting

No Error Truncation - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}025

Do not truncate error messages.

With

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

62, the default.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

51

With

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

10

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

52

Preserve Watch Output - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}028

Whether to keep outdated console output in watch mode instead of clearing the screen every time a change happened.

  • Internal

Pretty - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}029

Stylize errors and messages using color and context, this is on by default — offers you a chance to have less terse, single colored messages from the compiler.

  • Default:

    {

    "extends": "./configs/base",

    "files": ["main.ts", "supplemental.ts"]

    }

    10

Completeness

Melewati pemeriksaan pustaka bawaan - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}031

Gunakan [

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

032](# skipLibCheck) sebagai gantinya. Lewati pemeriksaan jenis file deklarasi pustaka bawaan.

Melewati pengecekan pustaka - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}033

Melewati pemeriksaan jenis berkas deklarasi.

Ini dapat menghemat waktu selama kompilasi dengan mengorbankan akurasi dari sistem type. Misalnya, dua pustaka bisa mendefinisikan dua salinan dari

{

"extends": "./configs/base",

"files": ["main.ts", "supplemental.ts"]

}

20 (tipe) yang sama dengan cara yang tidak konsisten. Dibandingkan melakukan pengecekan menyeluruh pada semua berkas

. ├── scripts ⨯ │ ├── lint.ts ⨯ │ ├── update_deps.ts ⨯ │ └── utils.ts ⨯ ├── src ✓ │ ├── client ✓ │ │ ├── index.ts ✓ │ │ └── utils.ts ✓ │ ├── server ✓ │ │ └── index.ts ✓ ├── tests ✓ │ ├── app.test.ts ✓ │ ├── utils.ts ✓ │ └── tests.d.ts ✓ ├── package.json ├── tsconfig.json └── yarn.lock

43, TypeScript akan mengecek tipe data dari kode yang Anda acu secara spesifik di dalam kode sumber aplikasi.

Kasus umum dimana Anda mungkin berpikir untuk menggunakan

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

033 adalah ketika ada dua salinan pustaka di

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

81 Anda. Dalam kasus ini, Anda harus mempertimbangkan untuk menggunakan fitur seperti yarn’s resolutions untuk memastikan hanya ada satu salinan dependency di root Anda atau menyelidiki bagaimana cara memastikan hanya ada satu resolusi dependency untuk memperbaiki masalah tanpa ada alat tambahan.

  • Recommended
  • Released:

    2.0

Baris Perintah

Opsi Pengawasan

TypeScript 3.8 dilengkapi dengan strategi baru untuk mengawasi direktori, yang krusial menentukan perubahan secara efisien terhadap

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

81.

Pada sistem operasi seperti Linux, TypeScript memasang direktori pengawas (daripada pengawas berkas) pada

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

81 dan banyak direktori di dalamnya untuk mendeteksi perubahan pada dependensi. Hal ini dikarenakan banyaknya pengawas berkas sering melebihi berkas-berkas yang terdapat pada

ts

function fn(n: number) {

if (n > 5) {

return true;

} else {

return false;

}

return true;

}

81, sedangkan ada lebih sedikit direktori untuk diawasi.

Karena setiap proyek mungkin bekerja dengan strategi yang berbeda, dan pendekatan baru ini mungkin tidak bekerja dengan baik dengan alur kerja anda, TypeScript 3.8 memperkenalkan opsi

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

041 yang memungkinkan pengguna untuk memberitahu kompiler/layanan bahasa strategi pengawasan yang mana yang harus digunakan untuk mengawasi berkas dan direktori.

Menganggap Perubahan Hanya Mempengaruhi Dependensi Langsung - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}042

Ketika opsi ini diaktifkan, TypeScript akan menghindari pemeriksaan ulang/membangun kembali semua berkas yang benar-benar mungkin terpengaruh dan hanya memeriksa ulang/membangun kembali berkas yang telah berubah serta berkas yang langsung mengimpornya.

Ini dapat dianggap sebagai implementasi ‘fast & loose’ dari algoritma pengawas, yang mana bisa secara drastis dapat mengurangi waktu rebuild dengan sesekali harus menjalankan build lengkap untuk mendapatkan semua pesan penyusun kesalahan.

  • Released:

    3.8

watchFile - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}043

Strategi bagaimana setiap berkas diamati.

watchDirectory - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}055

Strategi untuk bagaimana seluruh direktori diperhatikan dalam sistem yang tidak memiliki fungsi pengawasan berkas secara rekursif.

fallbackPolling - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}063

Saat menggunakan peristiwa sistem berkas, opsi ini menetapkan strategi polling yang akan digunakan saat sistem kehabisan pengamat berkas asli dan / atau tidak mendukung pengamat berkas asli.

  • {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    044: Periksa setiap berkas apakah ada perubahan beberapa kali dalam satu detik pada interval tetap.
  • {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    045: Periksa setiap berkas apakah ada perubahan beberapa kali dalam satu detik, tetapi gunakan heuristik untuk memeriksa jenis berkas tertentu lebih jarang daripada yang lain.
  • {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    046: Gunakan antrian dinamis di mana berkas yang lebih jarang diubah akan lebih jarang diperiksa.
  • {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    067: Menonaktifkan pengawas yang ditunda pada direktori. Menonton yang ditunda berguna ketika banyak perubahan berkas mungkin terjadi sekaligus (misal. Perubahan dalam

    ts

    function fn(n: number) {

    if (n > 5) {

    return true;

    } else {

    return false;

    }

    return true;

    }

    81 dari menjalankan

    {

    "compilerOptions": {

    "noImplicitAny": true,

    "strictNullChecks": true

    }

    }

    069), tetapi Anda mungkin ingin menonaktifkannya dengan tanda ini untuk beberapa penyiapan yang kurang umum.

synchronousWatchDirectory - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}067

Synchronously call callbacks and update the state of directory watchers on platforms that don`t support recursive watching natively. Instead of giving a small timeout to allow for potentially multiple edits to occur on a file.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

53

excludeDirectories - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}075

You can use to drastically reduce the number of files which are watched during

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

077. This can be a useful way to reduce the number of open file which TypeScript tracks on Linux.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

54

excludeFiles - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}076

You can use

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

076 to remove a set of specific files from the files which are watched.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

55

Type Acquisition

Type Acquisition is only important for JavaScript projects. In TypeScript projects you need to include the types in your projects explicitly. However, for JavaScript projects, the TypeScript tooling will download types for your modules in the background and outside of your node_modules folder.

enable - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}080

Disables automatic type acquisition in JavaScript projects:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

56

Include - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}61

If you have a JavaScript project where TypeScript needs additional guidance to understand global dependencies, or have disabled the built-in inference via .

You can use

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

61 to specify which types should be used from DefinitelyTyped:

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

57

Exclude - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}64

Offers a config for disabling the type-acquisition for a certain module in JavaScript projects. This can be useful for projects which include other libraries in testing infrastructure which aren’t needed in the main application.

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

58

disableFilenameBasedTypeAcquisition - { "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true }}082

TypeScript’s type acquisition can infer what types should be added based on filenames in a project. This means that having a file like

{

"compilerOptions": {

"noImplicitAny": true,

"strictNullChecks": true

}

}

086 in your project would automatically download the types for JQuery from DefinitelyTyped.