I wrote a simple function as follows:
export const courseIndustry: any = {
getById: (id: string) => {
return {};
}
};
And I thought I specified that the argument id is of type string, but the mocha test
claims:
mocha -r ts-node/register -r espower-typescript/guess test/**/*.test.ts
Unable to compile TypeScript: courseIndustry.ts(4, 15): error TS7006: Parameter 'id' implicitly has an 'any' type.
Where am I wrong?
Try to use a another transpiler like typescript-compiler or any other and try to complie.
enter link description here
The error seems thrown by espower-typescript/guess. So I checked its document and find the following switch can work around the errors: 'TS_NODE_TRANSPILE_ONLY=1'.
So the final version of the shell command make it work: