Skip to content

Commit a876ac6

Browse files
authored
Merge pull request #291 from opentok/fix-typescript-definitions
Fix TypeScript definitions
2 parents d99de94 + 2d76ecb commit a876ac6

File tree

9 files changed

+1777
-1248
lines changed

9 files changed

+1777
-1248
lines changed

package-lock.json

Lines changed: 1254 additions & 1056 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opentok-network-test-js",
3-
"version": "3.1.4",
3+
"version": "3.1.5",
44
"description": "Precall network test for applications using the OpenTok platform.",
55
"main": "dist/NetworkTest/index.js",
66
"types": "dist/NetworkTest/index.d.ts",
@@ -84,6 +84,9 @@
8484
},
8585
"find-versions": {
8686
"semver-regex": "^4.0.5"
87+
},
88+
"bin-check": {
89+
"execa": "1.0.0"
8790
}
8891
}
8992
}

sample/package-lock.json

Lines changed: 477 additions & 183 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sample/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"license": "MIT",
1414
"homepage": "https://github.com/opentok/opentok-network-connectivity",
1515
"devDependencies": {
16+
"ts-loader": "^9.5.2",
17+
"typescript": "^5.7.3",
1618
"webpack": "^5.88.1"
1719
},
1820
"dependencies": {

sample/src/js/index.js renamed to sample/src/js/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import NetworkTest from 'opentok-network-test-js';
22
import createChart from './chart.js';
33
import * as ConnectivityUI from './connectivity-ui.js';
44
import config from './config.js';
5+
declare const OT: any;
56
let sessionInfo = config;
6-
let otNetworkTest;
7+
let otNetworkTest : NetworkTest;
78
let audioOnly;
89

910
const precallDiv = document.getElementById('precall');
@@ -14,12 +15,12 @@ precallDiv.querySelector('#precall button').addEventListener('click', function (
1415
});
1516

1617
function startTest() {
17-
const audioOnly = precallDiv.querySelector('#audioOnlyCheckbox').checked;
18-
const scalableVideo = precallDiv.querySelector('#scalableCheckbox').checked;
19-
const fullHd = precallDiv.querySelector('#fullHdCheckbox').checked;
18+
const audioOnly = (precallDiv.querySelector('#audioOnlyCheckbox') as HTMLInputElement).checked;
19+
const scalableVideo = (precallDiv.querySelector('#scalableCheckbox') as HTMLInputElement).checked;
20+
const fullHd = (precallDiv.querySelector('#fullHdCheckbox') as HTMLInputElement).checked;
2021

2122
const timeoutSelect = precallDiv.querySelector('select');
22-
const timeout = timeoutSelect.options[timeoutSelect.selectedIndex].text * 1000;
23+
const timeout = Number(timeoutSelect.options[timeoutSelect.selectedIndex].text) * 1000;
2324

2425
const options = {
2526
audioOnly: audioOnly,
@@ -48,4 +49,4 @@ function testQuality() {
4849
ConnectivityUI.graphIntermediateStats('video', stats);
4950
}).then(results => ConnectivityUI.displayTestQualityResults(null, results))
5051
.catch(error => ConnectivityUI.displayTestQualityResults(error));
51-
}
52+
}

sample/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "./dist/",
4+
"noImplicitAny": true,
5+
"module": "es6",
6+
"target": "es5",
7+
"jsx": "react",
8+
"allowJs": true,
9+
"allowSyntheticDefaultImports": true,
10+
"moduleResolution": "node"
11+
}
12+
}

sample/webpack.config.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
module.exports = {
2-
entry: ['./src/js/index.js'],
2+
entry: ['./src/js/index.ts'],
33
mode: "none",
4+
module: {
5+
rules: [
6+
{
7+
test: /\.tsx?$/,
8+
use: 'ts-loader',
9+
exclude: /node_modules/,
10+
},
11+
],
12+
},
13+
resolve: {
14+
extensions: ['.tsx', '.ts', '.js'],
15+
},
416
output: {
517
path: __dirname,
618
filename: "bundle.js"

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
"lib": ["es2018", "es2017.object", "dom"], /* Specify library files to be included in the compilation: */
77
"allowJs": false, /* Allow javascript files to be compiled. */
88
"declaration": true, /* Generates corresponding '.d.ts' file. */
9+
"declarationMap": true,
10+
"declarationDir": "dist",
911
"sourceMap": true, /* Generates corresponding '.map' file. */
1012
"outDir": "../", /* Redirect output structure to the directory. */
1113
"rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */

webpack.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ module.exports = {
1010
rules: [{
1111
test: /\.tsx?$/,
1212
use: [
13-
{ loader: 'ts-loader' },
13+
{
14+
loader: 'ts-loader',
15+
options: {
16+
transpileOnly: false
17+
}
18+
},
1419
],
1520
}],
1621
},

0 commit comments

Comments
 (0)