Create type with two possible variants in Typescript -


is there way in typescript declare variable can int16array or uint16array , nothing more?

typescript 1.4 has support type unions, notation is:

var arr: int16array|uint16array; 

common methods both of these have available on arr. if use instanceof or typeof checks on arr in conditional/branched code, infer type of arr in branches.

typescript 1.4. has support type aliases:

type my16array = int16array | uint16array; 

you can use:

var arr: my16array; 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -