I have split my code into several projects. And now trying to import the modules, located in node_modules.
import Ticker from "ticker" // Typescript not complaining
But the transpiled JS "import Ticker from "ticker;" does, module spec missing ‘./’, ‘../’ of ‘/’.
But adding "./" leads to: "Cannot find module '.ticker' or its corresponding type declarations."
import {Ticker} from "./node_modules/ticker/dist/ticker.js", results in a working application.
But Typescript complains "Could not find a declaration file for module './node_modules/ticker/dist/ticker.js'. "
Even if I use ///< reference path='node_modules/ticker/typings/ticker.d.ts' / >
The ticker project package contains
"main": "dist/ticker.js",
"module": "dist/ticker.js",
"typings": "typings/ticker.d.ts",
ticker.d.ts
declare module 'ticker' {
class Ticker {
constructor (container:HTMLElement);
add (htmlElem:HTMLElement):number;
}
export default Ticker;
}
The main project tsconfig.json contains:
"moduleResolution": "node",
"baseUrl": "./",
"paths": {
"Ticker":["/node_modules/ticker/dist/ticker.js"]
},
I'm using only tsc and getting confused by all provided options and possibilities.
Why does VCode recognize the path "import {Ticker} from "./node_modules/ticker/ticker", pointing to the location of ticker.ts. But not "./node_modules/ticker/dist/", pointing to the ticker.js?