I need help with the following:
- Importing a js file that defines a class:
./myClass/index.js
- Declaring the public methods of
MyClass
(unsure of where to do this, whether in index.ts or another declaration file) - Creating a typescript file that exposes the class:
index.ts
Here is an example of what I'm trying to achieve:
// index.ts
import MyClass from './myClass' // or require, or any other method that works
export {MyClass}
and
// myClass/index.js
export default class MyClass {
...
}
Unfortunately, this setup is not working as the import of ./myClass/index
is unable to find the module.
I have attempted to create a ./myClass/index.d.ts
file following an example from this resource, but I continue to encounter an Error: Cannot find module './myClass/index.js' at runtime :(
It seems like I may be missing some basic concepts in typescript, and I'm looking for clear resources to help me understand better.
Any suggestions or ideas?