I'm a beginner in TS and I've created a definition file to specify the argument types for a function in another file.
customFunctions.ts
export default ({}) => {
const myCustomFunction = ({ param1 }: { param1: string }) => {
return param1;
};
return {
myCustomFunction
};
};
customFunctions.d.ts
declare var _default: ({}: {}) => {
myCustomfunction: ({ param1 }: {
param1: string;
}) => string;
};
export default _default;
otherfile.ts
export default ({ customFunctions }) => {
customFunctions().myCustomFunction({ param1: 1 });
};
The customFunctions
parameter is defined in customFunctions.ts, but otherfile.ts doesn't know its structure.
How can I utilize customFunctions.d.ts here? Do I really need it?