I am trying to use the Salesforce JavaScript SDK in a Typescript project.
It has a file called canvas-all.js. That has a variable called Sfdc.
We have some javascript that uses this successfully. All it needs to do to use it is add this to the index.html
<script type="text/javascript" src="./plugins/canvas-sdk/js/canvas-all.js"></script>
But Typescript does not know about it from that. (Says Cannot find name Sfdc)
I tried to just import it like this:
import * as canvas from '../plugins/canvas-sdk/js/canvas-all';
But that gives the error:
Cannot find module '../plugins/canvas-sdk/js/canvas-all'.
I am thinking I need a .d.ts for this, but I can't find one, and I am not succeeding in trying to make one.
I have looked at this aricle: https://www.stevefenton.co.uk/2013/01/complex-typescript-definitions-made-easy/ but it does not seem to help.
Step 2 in that article is for those that just want Typescript to be unblocked (my scenario). But all it says is declare var amazingToolkit: any (It does not have any context on where to put it or how to get it recognized by typescript in the file you need to use it.)
I don't need intelisense. I just want Sfdc to be seen as an any so that the Typescript will compile when I do something like this:
Sfdc.canvas.client.refreshSignedRequest( .....
So here is my question:
How can I make the simplest Typescript Definition file (.d.ts) possible for a JavaScript file with a bunch of functions?
And how do I get it "connected" to the JavaScript (canvas-all.js) file (that has no modules) and imported into my Typescript (myApplicationFile.ts) file?