• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# TypeScript Compiler Error Codes
2
3Error codes of Typescript Compiler (TSC) start with '105' and serve as error indicators during the TSC compilation process. These error codes and their corresponding descriptions are shown in the editor, console, or log files.
4
5## 10505001 TSC Native Errors
6
7TSC native errors, ending with '001', represent existing native error rules checked by TSC. Common causes of TSC native errors during compilation include: missing keywords or symbols, type mismatches in assignments, and undefined types or variables. These issues typically arise from not adhering to [language specifications](https://developer.huawei.com/consumer/en/doc/harmonyos-guides-V5/introduction-to-arkts-V5) when writing code. Developers can adjust the code based on the error descriptions.
8
9### Missing Keywords Or Symbols
10
11**Error Example Scenario**
12
13```typescript
14declare type AAA = 'BBB;
15```
16
17**Error Message**
18
19Unterminated string literal.
20
21**Description**
22
23The string literal is not correctly terminated at the expected position.
24
25**Possible Causes**
26
27The closing quote is missing.
28
29**Solution**
30
31Based on the error description, add the missing quotes to the code block. The updated code is as follows:
32
33```typescript
34declare type AAA = 'BBB';
35```
36
37### Multiple Default Exports
38
39**Error Example Scenario**
40
41```typescript
42export default A;
43export default B;
44```
45
46**Error Message**
47
48A module cannot have multiple default exports.
49
50**Description**
51
52A module cannot have multiple default exports.
53
54**Possible Causes**
55
56Multiple default exports are defined in the module.
57
58**Solution**
59
60Based on the error description, delete unnecessary default exports. The updated code is as follows:
61
62```typescript
63export default A;
64```
65
66### Type Mismatch in Assignments
67
68**Error Example Scenario**
69
70```typescript
71let a: number = 1;
72let b: string = '2';
73a = b;
74```
75
76**Error Message**
77
78Type 'string' is not assignable to type 'number'.
79
80**Description**
81
82Type 'string' cannot be assigned to type 'number'.
83
84**Possible Causes**
85
86Assigning a value of one type to a variable of a different type results in a type mismatch error.
87
88**Solution**
89
90Based on the error description, ensure type consistency by making appropriate type assignment changes. The updated code is as follows:
91
92```typescript
93let a: number = 1;
94let b: number = 2;
95a = b;
96```
97