I'm working with file A.js
(non-TypeScript) which has the following structure:
module({
}, function (imports) {
return {
foo: function () {
// ...
}
};
});
This file follows a module format similar to AMD, with an implementation resembling requirejs but in a slightly different format.
Now, file B.ts
(TypeScript) is trying to import it:
import A from '../old-code/A'
console.log(A)
However, attempting this import results in an error:
ERROR in ./src/app.ts
(9,17): error TS2306: File '/path/to/B.js' is not a module.
Is there a solution to this issue? How can TypeScript properly import the non-TypeScript file?
As someone new to TypeScript, I wonder if creating a type definition for it could solve the problem?
EDIT: I came across information about declaration files, but it doesn't address importing non-TypeScript files.
I am hopeful that there is a way to define the imports and exports of the file. If not, it would be great to have this feature added in the future.