Class extended from built-in Array in Typescript 1.6.2 does not update length while using [] operator

后端 未结 2 1979
长情又很酷
长情又很酷 2021-01-03 10:47

it should be possible to extend build-in types in ts 1.6 as I read here:

TypeScript 1.6 adds support for classes extending arbitrary expression that comp

2条回答
  •  粉色の甜心
    2021-01-03 11:36

    Extending Array is only supported in ES6 environments, so if you've set the compilerSettings.target of your tsconfig.json to ES3 or ES5 this won't work properly. There are workarounds in ES5 but I'd say it isn't worth the trouble - although you can probably use it in TypeScript since it is a superset of ES5. This book on ES6 explains the situation in more detail.

提交回复
热议问题