When the browser runs, I require
import * as d3 from '../lib/d3.js';
for d3
to be fetched correctly. I have confirmed that this does work as intended. However, the file that contains the above code, let's call it main.js
, is generated from a typescript file named main.ts
which also begins with the exact same line.
The typescript compiler raises an error stating that it cannot locate the module or its declarations. I thought of resolving this by adding something like
"paths": {
"../lib/d3.js": ["node_modules/@types/d3"]
},
but after referring to the Typescript handbook, I am unsure about how to format this correctly: should the key be the full file path or just the module name? What should the value array consist of: file paths or directories?
Can this issue be addressed using path mapping in tsconfig.json at all? (I am familiar with implementing this through webpack, but I am curious to learn how to do it without.)
For more information, see: https://github.com/microsoft/TypeScript/issues/37971, although it doesn't provide a solution for my particular situation.