Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ yarn-error.log
# IDE
*.swp
.tags
.idea

# Now
now.json
35 changes: 35 additions & 0 deletions src/mdx-pages/guides/typescript.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Typescript
category: advanced
description: Using Video.js with Typescript.
---

Starting with Video.js 8.0, types are included in the npm package. This documentation are for the included types. If you are using 7.0 or below you can use the [DefinitelyTyped](https://www.npmjs.com/package/@types/video.js) package and see their documentation.

## Usage

In general, you should be able to use Video.js with Typescript without any extra steps. If you are using advanced features of video.js you might need to pull in some internal types. You can find them in the `video.js/dist/types` package.

```ts
// A few examples

import type Player from 'video.js/dist/types/player';
import type Plugin from 'video.js/dist/types/plugin';
import type Component, {ComponentOptions} from 'video.js/dist/types/component';
```

## Plugins

If you are writing a plugin, you can use module augmentation to add types to the `videojs` namespace.

```ts
declare module 'video.js/dist/types/player' {
interface Player {
// videojs-contrib-quality-levels
qualityLevels: {
VERSION: string;
(): QualityLevelList;
};
}
}
```