At runtime, for the browser, I need
import * as d3 from '../lib/d3.js';
to correctly fetch d3
. I verified that this does work indeed. But the file containing the above, call it main.js
, is generated from a typescript file main.ts
which currently starts with the very same line above.
The typescript compiler complains that it cannot find the module or its declarations. I thought to fix this with something along the lines of
"paths": {
"../lib/d3.js": ["node_modules/@types/d3"]
},
but from the Typescript handbook I cannot see how to write this correctly: shall the key be the full file path or just a module name? What about the value array: file paths, directories?
Can this be done with path mapping in tsconfig.json at all? (I know how to get this going with webpack, but I am now interested to know how to do without.)
Related: https://github.com/microsoft/TypeScript/issues/37971, but does not help me.