'How to specify type of literal object and comply with TSLint?
TSLint marks both of these as errors:const a = {} as MyClass; // no-object-literal-type-assertionconst a = <MyClass>{}; // no-angle-bracket-type-assertion
And advices to use explicit typing:let a: MyClass
But what should you use when just using literals and not assignments?return { name: 'john' } as MyClassreturn <MyClass> { name: 'john' }
What alternative can be used there without declaring a variable?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
