Используйте TypeScript с IMA SDK
Оптимизируйте свои подборки
Сохраняйте и классифицируйте контент в соответствии со своими настройками.
TypeScript — это строго типизированный объектно-ориентированный язык программирования, который компилируется в JavaScript. TypeScript — это расширенная версия JavaScript, поддерживающая все функции JavaScript, а также дополнительную статическую типизацию . Инструменты TypeScript могут помочь обнаружить и предотвратить ошибки, которые вы могли бы не заметить в простом JavaScript.
Начать
DefinitelyTyped — это проект с открытым исходным кодом, который поддерживает репозиторий файлов объявлений типов для многих пакетов, включая библиотеку IMA SDK. Вы можете установить типы IMA с помощью npm из пакета @types/google_interactive_media_ads_types .
npm install --save-dev @types/google_interactive_media_ads_types
После установки у вас есть доступ ко всем типам, предоставляемым объектом google.ima
в вашем собственном коде. Вы также можете воспользоваться преимуществами автодополнения кода и помощи по содержимому для методов и свойств IMA в редакторах исходного кода, которые имеют эти функции, например Visual Studio Code .
Если не указано иное, контент на этой странице предоставляется по лицензии Creative Commons "С указанием авторства 4.0", а примеры кода – по лицензии Apache 2.0. Подробнее об этом написано в правилах сайта. Java – это зарегистрированный товарный знак корпорации Oracle и ее аффилированных лиц.
Последнее обновление: 2025-08-08 UTC.
[null,null,["Последнее обновление: 2025-08-08 UTC."],[[["\u003cp\u003eTypeScript is a strongly typed, object-oriented programming language that compiles to JavaScript and supports all of JavaScript's features plus optional static typing.\u003c/p\u003e\n"],["\u003cp\u003eTypeScript tooling helps in detecting and preventing bugs that might go unnoticed in plain JavaScript.\u003c/p\u003e\n"],["\u003cp\u003eDefinitelyTyped is an open-source project containing type declaration files for various packages, including the IMA SDK library.\u003c/p\u003e\n"],["\u003cp\u003eInstalling 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.\u003c/p\u003e\n"],["\u003cp\u003eAfter installation, source code editors with features like code completion and content assist can be used to take full advantage of IMA methods and properties.\u003c/p\u003e\n"]]],[],null,["# Use TypeScript with the IMA SDK\n\n[TypeScript](//www.typescriptlang.org/) is a strongly typed, object-oriented\nprogramming language that compiles to JavaScript. TypeScript is a superset of\nJavaScript, and supports all of JavaScript's features plus optional\n[static typing](//en.wikipedia.org/wiki/Type_system#STATIC).\n[TypeScript tooling](http://www.typescriptlang.org/docs/handbook/2/basic-types.html#types-for-tooling)\ncan help detect and prevent bugs that you might not notice in plain JavaScript.\n\nGet started\n-----------\n\n[DefinitelyTyped](//github.com/DefinitelyTyped/DefinitelyTyped) is an open\nsource project that maintains a repository of type\n[declaration files](//www.typescriptlang.org/docs/handbook/declaration-files/introduction.html)\nfor many packages, including the IMA SDK library. You can install the IMA types\nwith [npm](//docs.npmjs.com/about-npm) from the\n[@types/google_interactive_media_ads_types](//www.npmjs.com/package/@types/google_interactive_media_ads_types)\npackage. \n\n npm install --save-dev @types/google_interactive_media_ads_types\n\nAfter installation, you have access to all of the types exposed by the\n[`google.ima`](/interactive-media-ads/docs/sdks/html5/client-side/reference/ts)\nobject in your own code. You can also take advantage of code completion and\ncontent assist for IMA methods and properties in source code editors that have\nthose features, for example, [Visual Studio Code](https://code.visualstudio.com/docs/languages/typescript)."]]