Code Monkey home page Code Monkey logo

Comments (3)

surfjedi avatar surfjedi commented on August 26, 2024

+1 same here

from ts-json.

nfantone avatar nfantone commented on August 26, 2024

@daslicht and @surfjedi This solution is not working any more, unfortunately.

What you need to do is keep the declaration the same in your typings.d.ts (personally, I always create a separate json.d.ts file for this):

declare module '*.json' {
  const value: any;
  export default value;
}

And import your JSON data with:

import config from '../config/config.json'; // not * as config

from ts-json.

nfantone avatar nfantone commented on August 26, 2024

Ok, after playing around with this repo for a while I came back just to say that I couldn't make my approach work, sadly.

The way this project is set up seems to make the import statement work just fine. Oddly enough, it didn't in any of my Angular code bases. Conversely, I failed to apply what I was doing in my personal projects here.

🤷‍♂️

Also, since we are using export default, it'd make sense for the imported symbol to be able to compile and be interpreted as:

import data from './example.json';

rather than

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

from ts-json.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.