locked
No Ambient Declaration generated RRS feed

  • Question

  • User1904516115 posted

    I am using Visual Studio TypeScript Html Project Template. For print() method no Ambient declaration code is generated in Type Declaration File. 

    app.ts

    function greet():string{ return "Greeting!"; } 
    function add(a:number,b:number): number { return a+b; } 
    function print(message:number): void{ console.log(message); }

    app.d.ts

    declare function greet(): string;
    declare function add(a: number, b: number): number;
    

    Tuesday, February 19, 2019 5:44 PM

Answers

  • User-1174608757 posted

    Hi vinodkpasi,

    In fact , print is the global method of window in JavaScript. You could notice that print word has different color.When it creates Type Declaration File, the program will filter your print method by default to prevent the cover  of own  print method.

    So, I suggest you to change name "print" to other but not  has defined in Script.

    I hope it could help you.

    Best Regards

    Wei Zhang

      

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 20, 2019 8:51 AM

All replies

  • User-1174608757 posted

    Hi vinodkpasi,

    In fact , print is the global method of window in JavaScript. You could notice that print word has different color.When it creates Type Declaration File, the program will filter your print method by default to prevent the cover  of own  print method.

    So, I suggest you to change name "print" to other but not  has defined in Script.

    I hope it could help you.

    Best Regards

    Wei Zhang

      

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 20, 2019 8:51 AM
  • User1904516115 posted
    I notified earlier but could not update this thread. Thanks for your time.
    Wednesday, February 20, 2019 7:03 PM