2017-05-04 59 views

回答

0

您可以通過查找api的definetly類型的版本將它導入到typescript中。 for youtube api:https://github.com/jhdrn/DefinitelyTyped/blob/master/youtube/youtube.d.tshttps://github.com/andrew-w-ross/typings-youtube-api-search/blob/master/youtube-api-search.d.ts

這是否符合您的需求? 如果這兩個都不起作用,只需在文件的源文件中插入一個<script></script>標記,並在您的班級中設置一個declare const變量,但我不建議這樣。正如我認爲打字稿認爲有這個聲明變量,我不需要評估,但程序員說,它將在運行時在那裏,你不會顯示任何錯誤,如拼寫錯誤的功能等。