Use Typescript types with Container APIs

OpenFin publishes TypeScript types for its Container APIs in a separate npm package. You can import these types in order to use them from TypeScript code when using OpenFin Container APIs.

If you use untyped JavaScript

If you are writing regular, untyped JavaScript, you do not need to import types. However, you might find it useful to do so, as the type definitions help your IDE to provide you with auto-completion hints.

This package contains a shim for the fin object, so importing it helps you avoid "fin is not defined" errors. However, the shim throws an informative error when used outside an OpenFin context.

Install the package in your environment

npm install --save @openfin/core

Import the package in your code

import OpenFin, { fin, inOpenFin } from "@openfin/core"; 

const showWindow = async (identity: OpenFin.Identity) => { \
   const win = await fin.Window.wrap(identity);

   await win.show(); \
}

The published types apply only to the V2 (promise-based) version of the OpenFin JavaScript API. Type definitions are not available for V1 of the API (callback-based). V2 is available starting in OpenFin Version 9. If you are not sure which version of the API you are using, please contact [email protected] for guidance.


Did this page help you?