Friday, 20 September 2019

Angular 8 Native Typescript crash-free, accessor shorthand

Angular 8 :

I used to use as a short hack on typescript side :

object['accessor']['accessor']['accessor']

to get

object.accessor.accessor.accessor

without running the risk of throwing an error if one of the children was empty.

What is the best way to do this by today's ECMA Script standards inside the typescript file?

EDIT :

I found this https://medium.com/inside-rimeto/optional-chaining-in-typescript-622c3121f99b

the b/ Nested Ternary Expressions seems the best but it seems convoluted

EDIT 2 :

nevermind, this crashes the application irrecuperably (at the component level, though) just as much.

it seem newer anguar rules are more strict. they just haven't provided an alternative.



from Angular 8 Native Typescript crash-free, accessor shorthand

No comments:

Post a Comment