1# Object literals cannot be used as type declarations 2 3Rule ``arkts-no-obj-literals-as-types`` 4 5**Severity: error** 6 7ArkTS does not support the usage of object literals to declare 8types in place. Declare classes and interfaces explicitly instead. 9 10 11## TypeScript 12 13 14``` 15 16 let o: {x: number, y: number} = { 17 x: 2, 18 y: 3 19 } 20 21 type S = Set<{x: number, y: number}> 22 23``` 24 25## ArkTS 26 27 28``` 29 30 class O { 31 x: number = 0 32 y: number = 0 33 } 34 35 let o: O = {x: 2, y: 3} 36 37 type S = Set<O> 38 39``` 40 41## See also 42 43- Recipe 038: Object literal must correspond to some explicitly declared class or interface (``arkts-no-untyped-obj-literals``) 44- Recipe 043: Array literals must contain elements of only inferrable types (``arkts-no-noninferrable-arr-literals``) 45 46 47