Here is a sample javascript file named test.js:
const someType = {
val1: "myvalue",
val2: "myothervalue"
};
function sampleFunction(param) {
return 1;
}
function sampleFunction2(param) {
return 2;
}
export {someType, sampleFunction, sampleFunction2};
Alongside it, we have a definitions file called test.d.ts:
declare module "test" {
// defining an enum-like object within the module
export type someType = {
val1: 'myvalue',
val2: 'myothervalue',
}
export function sampleFunction(param1: someType): number;
export function sampleFUnction2(param1: someType): number;
}
The question arises on how to correctly define the object enum in the definitions file.
import sampleFunction, someType from 'test';
console.log(sampleFunction(someType.val1)); /// encountered issue here with someType
The above code snippet faces issues as someType is not recognized as a valid value. Using { someType }
while importing results in an error as it's a type being treated as a value.