简体   繁体   English

如何从打字稿中调用JavaScript include中的方法?

[英]How to call a method in a JavaScript include from typescript?

The include I'm using is stacktrace.js 我正在使用的包含是stacktrace.js

This include provides a call to retrieve the stacktrace by calling StaceTrace.get() 这包括通过调用StaceTrace.get()来检索堆栈跟踪的调用

How can I call this method from typescript? 如何从打字稿中调用此方法? I've seen an example where you can declare a variable in ts with the same name as the method but I can't do that because the method is on the StackTrace object. 我看过一个示例,您可以在ts中声明一个与方法同名的变量,但是我不能这样做,因为该方法在StackTrace对象上。

This is killing me. 这真杀了我。 Please help. 请帮忙。

Not everything you reference in your TypeScript code has to be defined in TypeScript itself. 并非必须在TypeScript本身中定义在TypeScript代码中引用的所有内容。 You can reference JavaScript code that is defined in some JS file using the “declare” keyword as seen in the example below. 您可以使用“ declare”关键字引用某些JS文件中定义的JavaScript代码,如以下示例所示。

Code Sample 代码样例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM