Search code examples
javascripttypescriptwindows-runtimewin-universal-appwinjs

Use a Windows-Runtime-Component in a Typescript-Application


I created a WinJS-Application [Windows-10-UWP] converted the code to Typescript.
Now I have a Windows-Runtime-Component, which I want to refer to in my .ts files.
I allready achieved this in the normal javascript by following the instructions given here. But I have no idea to achieve this in Typescript. The main problem here is, that I am not able to create a reference to the Window-Runtime Component. Is this even possible?


Solution

  • The main problem here is, that I am not able to create a reference to the Window-Runtime Component. Is this even possible?

    Yes, it is possible. If you have referenced the Windows Runtime Component in your main project. The namespace will be stored in the global window object. So you can access the Windows Runtime Component like below:

    let variable= window["MyTestComponent"];