I am trying to learn https://github.com/TypeStrong/ts-node. I've written two files as a simplistic example. They are both in the same directory, which is currently not in the same folder as package.json
/package.json
/src/build-lib/run-ts.js
/src/build-lib/Test.ts
run-ts.js
require('ts-node').register();
const Test = require('./Test.ts').Test; // Tried with and without .ts extension
const tester = new Test();
tester.log('Message');
Test.ts
export class Test {
log(message: string) {
console.log(`Test ${message}`);
}
}
I'm running the following script:
ts-node src/build-scripts/gen-xml.js
And I'm getting the following compilation error
/Users/jmendes/gitclient/vcd-ui/content/core/node_modules/ts-node/src/index.ts:319
throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset))
^
TSError: ⨯ Unable to compile TypeScript
src/build-scripts/Test.ts (7,36): Parameter 'message' implicitly has an 'any' type. (7006)
at getOutput (/Users/jmendes/gitclient/vcd-ui/content/core/node_modules/ts-node/src/index.ts:319:17)
at /Users/jmendes/gitclient/vcd-ui/content/core/node_modules/ts-node/src/index.ts:350:18
I expected to see "Test Message" on the console.
via Juan Mendes
No comments:
Post a Comment