Click here to Skip to main content
16,016,425 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
Note: ANGULAR 1.5.7 version

I have a javascript function in a demo.js file , i need to call this function inside a class in typescript file.
sample code is

JavaScript
//demo.js
function test(){
alert();
}


in Typescript file
C#
module Data.test {
    export class Controller {
          constructor(){
             // i need to call the javascript function here.
             // i just called test() here like this , it is working but when compiling 
             // in visual studio it shows "Cannot find Name test"
               test();
          }
          TestAlert():void{
             // here also i need to call the javascript function  
             // i just called test() here like this , it is working but when compiling 
             // in visual studio it shows "Cannot find Name test"
               test();
          }

  }
}


What I have tried:

I tried
C#
declare var test:any
in typescript file

but when compile it shows error
Posted
Updated 24-Apr-21 14:34pm
v2

1 solution

Three years later, I was struggling to find an answer to this.

See this blog: Typescript – how to access a global javascript function | tatvog[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900