I hope my question doesn't seem silly, but I'm facing some issues when importing Shaka player in a typescript module like this:
import shaka from 'shaka-player/dist/shaka-player.ui';
In this case the compiler tells me this:
TS2306: File '~/dist/shaka-player.ui.d.ts' is not a module.
When looking at module architecture, you can obviously see in the dist folder contains currently the types declaration file and the js build for the module
And this is my tsconfig compiler options:
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"allowJs": true,
"checkJs": false,
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}

Shaka is not a Typescript-native project, and the tools they are using to generate the definitions are clearly not able to do everything we need. But there is a solution, it depends on shaka-player version.
For v3: Create a
global.d.tsfile and declareFor v4 and higher:
and then add to
global.d.ts:and make import:
Maybe they will add better support in future versions. But now, seems this is the only way...