I’m in the process of prepping my code to cut over to TypeScript. To check for incompatibilities, I’ve been running tsc in the project directory and whittling down the places where it didn’t like my code. I’ve resolved most of them, but:
-
That’s currently giving me some errors about “possibly undefined” when I access properties/functions of
this.$alexaSkill
andthis$googleAction
. Is there something I need to replace those with, or is there something I need to do to the code so it knows the app should be inheriting those properties, or should I be compiling the TypeScript another way? -
There are a couple of complaints from inside Jovo. I presume the error isn’t the code, or others would have noticed, so it must be something about my environment or the use of
tsc
. Any advice?
node_modules/jovo-framework/dist/src/index.d.ts:17:16 - error TS2665: Invalid module name in augmentation. Module 'express' resolves to an untyped module at 'C:/myProjectDirector/node_modules/express/index.js', which cannot be augmented. 17 declare module 'express' { ~~~~~~~~~ node_modules/jovo-plugin-debugger/dist/src/JovoDebugger.d.ts:1:23 - error TS2688: Cannot find type definition file for 'socket.io-client'. 1 /// <reference types="socket.io-client" /> ~~~~~~~~~~~~~~~~ node_modules/jovo-plugin-debugger/dist/src/JovoDebugger.d.ts:37:14 - error TS2503: Cannot find namespace 'SocketIOClient'. 37 socket?: SocketIOClient.Socket; ~~~~~~~~~~~~~~
-
The remaining case that’s probably my own fault is that I’m trying to use axios to issue an
HTTP get
, and while the code is working fine in Javascript, TS complains about it. The code isconst axios=require('axios') axios.get(uriString)
and the error is
src/player.js:375:9 - error TS2339: Property 'get' does not exist on type
'typeof import("C:/myProjectDirectory/node_modules/axios/index")'.
375 axios.get(uri)
~~~
(Apologies if the answers are obvious to someone more experienced; as I’ve said I’m trying to learn Javascript, Jovo, and now Typescript simultaneously and that leads to a certain amount of tripping over my own feet.)