score:0
this mvce:
// main.ts
import file from './file.json';
console.log(file);
// file.json
{ "hello": "world" }
// index.d.ts
declare module '*.json' {
const value: any;
export default value;
}
// tsconfig.json
{
"compileroptions": {
"target": "es5",
"module": "commonjs",
"esmoduleinterop": true,
"resolvejsonmodule": true
}
}
can do this:
> tsc
> node main.ts
{ hello: 'world' }
perhaps you should add the json declaration file.
i'd also suggest another way: adding the webpack json-loader, and including 'json' to module.exports.resolve.extensions
in webpack.config.json
.
note that every json is a valid js file - if this file is not use by other entities, you can replace its extension by .js and add export default { "nodes": ...
at the beginning of the file.
Source: stackoverflow.com
Related Query
- How to import a json file using angular and typescript
- How to change json file in d3.js and update chart using select options
- How to load a CSV and a JSON file and combine both datsets to one dataset using d3.json, d3.csv and d3.zip
- How to divide a map into zipcodes using d3, javascript, and a json file?
- Bundle layout using d3.js and given json file structure
- Typings Error when using D3 V4 on Angular 2 and Typescript V2
- How to loop through JSON file using jQuery
- How would I import a single column CSV file into a pie chart using Javascript D3?
- How to implement D3 lasso plugin with Angular 2 and Typescript
- how to update data form file json using d3.js (zoomable circle pack)
- How to fetch data from json file to draw a dynamic graph by using d3.js
- How to iterate over data in JSON file using D3 javascript
- In Angular app, how do I import d3 and use d3.js scripts?
- How to add tooltip to line chart written in typescript and angular
- How to draw a multi line series graph using d3.js with json data using angular directives
- How can I navigate JSON nested file using d3.js?
- How to import d3.js in a node and typescript project? [ERR_REQUIRE_ESM]
- Is this JSON I made using jsonify with flask and python 3 formatted correctly for making a D3 graph? And if not, how should I format it?
- How can I load a local json file using d3?
- D3.js Heatmap: How to read from a nested json and create a Heatmap using D3
- How to read specific attribute from external json file using d3.js?
- Can we add images in json data file and call it on page using D3.js
- How can I put a json object into a test file ("file.json") and then read that file in a d3.json("file.json", function(error, root))?
- Compilation errors when drawing a piechart using D3.js, TypeScript and Angular
- How to access object properties in a JSON file using literals obtained from the same file
- How to import JSON file to hold within a javascript variable
- How to create histogram using D3.js and reading data from JSON
- How to build a simple Donut Chart using D3js and Angular 7
- how to load json file using the latest d3?
- How to make a Scatter plot with D3 using a JSON file as input
More Query from same tag
- JSON summing multiple objects where values contain a string
- Relationship Graph with D3
- d3.js line chart instead of area
- Highlighting individual rings in ring chart
- Call function when d3 add method will finish execution
- SVG elements overlapping issue
- D3.js - Nested Data Works But Selection Does NOT Follow
- how to display month in sequence wise in dc.js
- d3 - Position of text on a map
- Update options in a drop-down menu based on another drop-down
- Where is d3.svg.diagonal()?
- d3 dynamic bubble chart - adding text to bubbles
- Insert space before tick with d3 format
- D3 drag & click in v6 for grouped objects
- How to zoom around an svg
- D3 same ticks being showed twice on y axis
- How can I make straight line instead of curve line in d3 force layout?
- How to change the tick value in d3, javascript from "1900" to "January"?
- Angular - how do I get data to load with ngOnChanges
- D3: Order grouped column chart
- Does it make sense to convert dc.js to React?
- How to render/ format axes each 6 month with d3.scaleTime?
- Working with Vuex with Vue and displaying data
- ZingChart not supporting utf characters at wordcloud chart( tag chart)
- d3.js fit scale to rgb() range of blue
- Dynamically updating datamaps fill color not working using variable as country key
- Save d3js dynamically generated svg chart to png directly on server side
- Combining stacked area chart and brushing in D3
- More modular D3.js coding
- Update a grouped bar chart (transition or removal of groups of elements)