将 TypeScript 与 IMA SDK 搭配使用
TypeScript 是一种强类型的面向对象编程语言,可编译为 JavaScript。TypeScript 是 JavaScript 的超集,支持 JavaScript 的所有功能,以及可选的静态类型。TypeScript 工具有助于检测和防范您在纯 JavaScript 中可能不会注意到的问题。
开始使用
DefinitelyTyped 是一个开源项目,用于维护许多软件包(包括 IMA SDK 库)的类型声明文件的代码库。您可以使用 npm 从 @types/google-interactive-media-ads 软件包安装 IMA 类型。
npm install --save-dev @types/google-interactive-media-ads
安装完成后,您就可以在自己的代码中使用 google.ima
对象公开的所有类型。您还可以在具有这些功能的源代码编辑器(例如 Visual Studio Code)中,针对 IMA 方法和属性使用代码补全和内容协助功能。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-01-14。
[null,null,["最后更新时间 (UTC):2025-01-14。"],[[["TypeScript is a strongly typed, object-oriented programming language that compiles to JavaScript and supports all of JavaScript's features plus optional static typing."],["TypeScript tooling helps in detecting and preventing bugs that might go unnoticed in plain JavaScript."],["DefinitelyTyped is an open-source project containing type declaration files for various packages, including the IMA SDK library."],["Installing the IMA types using npm from the @types/google-interactive-media-ads package gives you access to all types exposed by the google.ima object."],["After installation, source code editors with features like code completion and content assist can be used to take full advantage of IMA methods and properties."]]],[]]