In working with JSONs in Typescripts

As you know Typescript has native support for JSON as a data entry point.

But it comes with its own quirks. Like everything else in typescript

import * as data from './data.json'

This results in

{
  default: { name: "Kayvan", age: 99 },
  name: "Kayvan",
  age: 99
}

That extra default costs us.


Header image credit goes to Fer Troulik on Unsplash

View Comments (1)

Leave a Comment

Your email address will not be published. Required fields are marked *