1#  Use ``class`` instead of a type with call signature
2
3Rule ``arkts-no-call-signatures``
4
5**Severity: error**
6
7ArkTS does not support call signatures in object types. Use classes instead.
8
9
10## TypeScript
11
12
13```
14
15    type DescribableFunction = {
16        description: string
17        (someArg: number): string // call signature
18    }
19
20    function doSomething(fn: DescribableFunction): void {
21        console.log(fn.description + " returned " + fn(6))
22    }
23
24```
25
26## ArkTS
27
28
29```
30
31    class DescribableFunction {
32        description: string
33        public invoke(someArg: number): string {
34            return someArg.toString()
35        }
36        constructor() {
37            this.description = "desc"
38        }
39    }
40
41    function doSomething(fn: DescribableFunction): void {
42        console.log(fn.description + " returned " + fn.invoke(6))
43    }
44
45    doSomething(new DescribableFunction())
46
47```
48
49## See also
50
51- Recipe 015:  Use ``class`` instead of a type with constructor signature (``arkts-no-ctor-signatures-type``)
52
53
54