• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Type notation using ``this`` is not supported
2
3Rule ``arkts-no-typing-with-this``
4
5**Severity: error**
6
7ArkTS does not support type notation using the ``this`` keyword (for example,
8specifying a method's return type ``this`` is not allowed). Use explicit type
9instead.
10
11
12## TypeScript
13
14
15```
16
17    interface ListItem {
18        getHead(): this
19    }
20
21    class C {
22        n: number = 0
23
24        m(c: this) {
25            console.log(c)
26        }
27    }
28
29```
30
31## ArkTS
32
33
34```
35
36    interface ListItem {
37        getHead(): ListItem
38    }
39
40    class C {
41        n: number = 0
42
43        m(c: C) {
44            console.log(c)
45        }
46    }
47
48```
49
50
51