When attempting to import a module called index.ts from a directory by only specifying the directory name and not the module name itself, I encountered a TS2307 error stating "Cannot find module".
Here is a snippet from ./src/main.ts:
'use strict';
// Import successful
import {helloWorld as helloWorld1} from '../lib/helloworld/index';
// Import failed
import {helloWorld as helloWorld3} from '../lib/helloworld';
helloWorld1();
And from ./lib/helloworld/index.ts:
'use strict';
export function helloWorld() {
console.log('Hello World');
}
While this method works fine in native JavaScript, it fails in TypeScript. What mistake am I making?