The Titan SDK is built in JavaScript and delivered via a CDN, meaning it’s not a standard npm module. As a result, your modern TypeScript project won’t automatically have access to its type definitions. To get the benefits of autocompletion and type-checking, you’ll need to manually integrate the type declaration file (.d.ts) we provide.

Integrating the TitanSDK types

Here is a suggestion on how to integrate our type declarations into your project. 1. Download the .d.ts File First, get the declaration file and save it locally. You can do this by opening the CDN URL in your browser and saving the content or by using a command-line tool like curl. Note: The interface should not change, but sometimes we might add new properties to the SDK. The declaration file (d.ts) is updated automatically once we add something new to the interface. Example URL: https://sdk.titanos.tv/sdk/sdk.d.ts Recommended Location: Create a new folder, src/types, and save the file there. This keeps your project organized and separate from your main code. Your project structure should look like this after this step:
├ /your-project
├─└─ /src
├────└── /types
├────└───└── /sdk.d.ts  <-- The downloaded file
├────└── /App.tsx
├─└── /tsconfig.json
2. Declare the Global Variable The library’s main variable (TitanSDK) is available on the global window object when the script is loaded via the CDN. However, TypeScript needs to be told about this to avoid errors. You must declare that this global variable exists and what its type is. Create a new file, src/types/globals.d.ts, and add the following code. This file is a special declaration file that tells TypeScript to “merge” your new type definitions with the built-in window object. If you already have a declaration file, just post this code there.

// src/types/globals.d.ts

// Import the type definition from the sdk.d.ts file you just saved.
import { TitanSDK } from './sdk.d.ts';

// Use declaration merging to add the TitanSDK property to the global Window interface.
declare global {
  interface Window {
    TitanSDK: TitanSDK;
  }
}

// This empty export is necessary to make this file a module
// and prevent it from being treated as a global script.
export {};
3. Use the Types in Your Code Once the global variable is declared, you can use window.TitanSDK directly in your TypeScript or JavaScript files. Your code editor will now provide IntelliSense, autocompletion, and type-checking for all the functions and properties defined in the .d.ts file. You no longer need to import the types or variables; TypeScript automatically links them based on their names. TypeScript in action in a React Component:

Real-World Examples & Resources

To see these it in action and understand more about the integration on our GitHub examples repository: We are committed to receiving feedback and continuously improving our documentation and examples.

Next steps