Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TS2551: Property toSpliced does not exist on type Array

According to:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSpliced

the method .toSpliced() is now available in all major JS platforms. But as you can see here:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

https://www.typescriptlang.org/play?ts=5.3.0-beta#code/MYewdgzgLgBAhgJwTAvDA2gcgB6YDQyYCe+hAXpgLoCwAUKJLIggEyrxIB0UIAygA4AbAJbAApgBMAFAEYCMgJQwA9Mow5SmCjVpA

Even with TS 5.3.0-beta its type is not defined in TypeScript.

enter image description here

>Solution :

To use toSpliced, you need to set target to ESNext (for now, until there’s an ES2023 setting). Your playground targets ES2017, which wouldn’t support toSpliced or anything else from ES2018 onward. You also need to be using a fairly recent version of TypeScript (for instance, 5.1.6 doesn’t support it, but 5.2.2 does; I don’t know precisely where in there it was added).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading