I am having problem importing classes from one .ts file to another .ts file.
This is my project structure:
I am trying to import print.ts to testing.ts.
This is what my tsconfig.json looks like:
Contents of my testing.ts:
import { names } from 'testing';
console.log(names.printFirstName());
Contents of my print.ts:
class nameCollection {
static printFirstName(){
return 'OYEAAAH';
};
}
export {nameCollection as names};
I am running my tests using:
node testing.js
Thanks!
Typescript does path mapping for module resolution, you are mixing directories and files
{
"compilerOptions": {
"paths": {
"testing/*": ["src/nested/*"]
}
}
}
and then in your scripts you can import import {names} from 'testing/print';
check https://www.typescriptlang.org/docs/handbook/module-resolution.html for more details