• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#  Use ``class`` instead of a type with constructor signature
2
3Rule ``arkts-no-ctor-signatures-type``
4
5**Severity: error**
6
7ArkTS does not support constructor signatures in object types. Use classes
8instead.
9
10
11## TypeScript
12
13
14```
15
16    class SomeObject {}
17
18    type SomeConstructor = {
19        new (s: string): SomeObject
20    }
21
22    function fn(ctor: SomeConstructor) {
23        return new ctor("hello")
24    }
25
26```
27
28## ArkTS
29
30
31```
32
33    class SomeObject {
34        public f: string
35        constructor (s: string) {
36            this.f = s
37        }
38    }
39
40    function fn(s: string): SomeObject {
41        return new SomeObject(s)
42    }
43
44```
45
46## See also
47
48- Recipe 014:  Use ``class`` instead of a type with call signature (``arkts-no-call-signatures``)
49
50
51