No More any! We FINALLY Have Proper Types for JSON.parse & JSON.stringify in TypeScript

No More any! We FINALLY Have Proper Types for JSON.parse & JSON.stringify in TypeScript

10.296 Lượt nghe
No More any! We FINALLY Have Proper Types for JSON.parse & JSON.stringify in TypeScript
Code: https://github.com/typed-rocks/typescript/blob/main/json-typed.ts TypeScript Worksheet: https://www.youtube.com/watch?v=GqWaXfuoUYM Branded Types: https://www.youtube.com/watch?v=Yz8ySbaeCf8 Infer: https://www.youtube.com/watch?v=vjsmv7M1iBE Mapped Types: https://www.youtube.com/watch?v=iCEJY9XpfG8 Currently, when we are using JSON.stringify to create a JSON string from an object, we lose all the type information. This means that when you use functions like JSON.parse you are left with the „any“ type. In this video we will fix that. We will create a properly typed JSON.stringify function declaration which will store the type information of the object the string was created from. 0:00 Intro 0:29 The issue 3:10 Fix it the easy way 8:10 Improve our Typings 14:45 Outro