Comments (3)
+1 same here
from ts-json.
@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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ts-json.