Giter VIP home page Giter VIP logo

Comments (3)

ranaalisaeed avatar ranaalisaeed commented on July 1, 2024

Another way to import that works is:

import { csv } from 'd3-fetch'
csv('/data/output.csv').then(function(data) { 
	console.log('csv', data)
})

from d3-webpack-babel-typescript.

ranaalisaeed avatar ranaalisaeed commented on July 1, 2024

Two options in tsconfig.json deal with default imports:

"allowSyntheticDefaultImports": true,     /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true                   /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */

from d3-webpack-babel-typescript.

ranaalisaeed avatar ranaalisaeed commented on July 1, 2024

Following are the ways to deal with default imports

  1. import * as d3Fetch from 'd3-fetch' --> all exports in d3-fetch will be made available under d3Fetch
  2. import { csv } from 'd3-fetch --> only export function csv(){} will be imported and can be used directly without any prefix
  3. enable allowSyntheticDefaultImports and esModuleInterop flags in tsconfig.json and then import d3Fetch from 'd3-fetch' will work.

from d3-webpack-babel-typescript.

Related Issues (10)

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.