13af6ab5fSopenharmony_ci# Usage of ``ESObject`` type is restricted 23af6ab5fSopenharmony_ci 33af6ab5fSopenharmony_ciRule ``arkts-limited-esobj`` 43af6ab5fSopenharmony_ci 53af6ab5fSopenharmony_ci**Severity: warning** 63af6ab5fSopenharmony_ci 73af6ab5fSopenharmony_ciArkTS does not allow using ``ESObject`` type in some cases. The most part of 83af6ab5fSopenharmony_cilimitations are put in place in order to prevent spread of dynamic objects in 93af6ab5fSopenharmony_cithe static codebase. The only scenario where it is permited to use ``ESObject`` 103af6ab5fSopenharmony_cias type specifier is in local variable declaration. Initialization of variables 113af6ab5fSopenharmony_ciwith ``ESObject`` type is also limited. Such variables can only be initialized 123af6ab5fSopenharmony_ciwith values that originate from interop: other ``ESObject`` typed variables, 133af6ab5fSopenharmony_ciany, unknown, variables with anonymous type, etc. It is prohibited to 143af6ab5fSopenharmony_ciinitialize ``ESObject`` typed variable with statically typed value. Varaible 153af6ab5fSopenharmony_ciof type ``ESObject`` can only be passed to interop calls and assigned to other 163af6ab5fSopenharmony_civariables of type ``ESObject``. 173af6ab5fSopenharmony_ci 183af6ab5fSopenharmony_ci 193af6ab5fSopenharmony_ci## ArkTS 203af6ab5fSopenharmony_ci 213af6ab5fSopenharmony_ci 223af6ab5fSopenharmony_ci``` 233af6ab5fSopenharmony_ci // lib.d.ts 243af6ab5fSopenharmony_ci declare function foo(): any; 253af6ab5fSopenharmony_ci declare function bar(a: any): number; 263af6ab5fSopenharmony_ci 273af6ab5fSopenharmony_ci // main.ets 283af6ab5fSopenharmony_ci let e0: ESObject = foo(); // CTE - ``ESObject`` typed variable can only be local 293af6ab5fSopenharmony_ci 303af6ab5fSopenharmony_ci function f() { 313af6ab5fSopenharmony_ci let e1 = foo(); // CTE - type of e1 is `any` 323af6ab5fSopenharmony_ci let e2: ESObject = 1; // CTE - can't initialize ESObject with not dynamic values 333af6ab5fSopenharmony_ci let e3: ESObject = {}; // CTE - can't initialize ESObject with not dynamic values 343af6ab5fSopenharmony_ci let e4: ESObject = []; // CTE - can't initialize ESObject with not dynamic values 353af6ab5fSopenharmony_ci let e5: ESObject = ""; // CTE - can't initialize ESObject with not dynamic values 363af6ab5fSopenharmony_ci e5['prop'] // CTE - can't access dynamic properties of ESObject 373af6ab5fSopenharmony_ci e5[1] // CTE - can't access dynamic properties of ESObject 383af6ab5fSopenharmony_ci e5.prop // CTE - can't access dynamic properties of ESObject 393af6ab5fSopenharmony_ci 403af6ab5fSopenharmony_ci let e6: ESObject = foo(); // OK - explicitly annotaded as ESObject 413af6ab5fSopenharmony_ci let e7 = e6; // OK - initialize ESObject with ESObject 423af6ab5fSopenharmony_ci bar(e7) // OK - ESObject is passed to interop call 433af6ab5fSopenharmony_ci } 443af6ab5fSopenharmony_ci``` 453af6ab5fSopenharmony_ci 463af6ab5fSopenharmony_ci 473af6ab5fSopenharmony_ci## See also 483af6ab5fSopenharmony_ci 493af6ab5fSopenharmony_ci- Recipe 001: Objects with property names that are not identifiers are not supported (``arkts-identifiers-as-prop-names``) 503af6ab5fSopenharmony_ci- Recipe 002: ``Symbol()`` API is not supported (``arkts-no-symbol``) 513af6ab5fSopenharmony_ci- Recipe 029: Indexed access is not supported for fields (``arkts-no-props-by-index``) 523af6ab5fSopenharmony_ci- Recipe 060: ``typeof`` operator is allowed only in expression contexts (``arkts-no-type-query``) 533af6ab5fSopenharmony_ci- Recipe 066: ``in`` operator is not supported (``arkts-no-in``) 543af6ab5fSopenharmony_ci- Recipe 137: ``globalThis`` is not supported (``arkts-no-globalthis``) 553af6ab5fSopenharmony_ci 56