videogular2: Cannot find type definition file for 'core-js'

Description

Running Videogular 2 in Ionic 2

Expected Behavior

I’m expecting it to run without these errors

Actual Behavior

When following the getting started guide and attempting to run the app, I get the following errors:

node_modules/videogular2/src/core/services/vg-api.d.ts(1,1): error TS2688: Cannot find type definition file for 'core-js'.
node_modules/videogular2/src/core/vg-media/i-playable.d.ts(1,1): error TS2688: Cannot find type definition file for 'core-js'. 

Steps to Reproduce

  1. Initialize Ionic v2 project
  2. Follow getting started guide to import Videogular
  3. Run app

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 17 (3 by maintainers)

Most upvoted comments

npm install @types/core-js --save-dev

will solve your problem.

In the end I solved this for me with: npm install --save @types/core-js

In package.json:

"dependencies": {
   ...
    "@types/core-js": "^0.9.35"  _(my Visual Studio stated: no version available)_
    ...
    "videogular2": "4.0.0",
   ...
   }

and in tsconfig.json

 "compilerOptions": {
    ...
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ],
    "lib": [ "es5", "dom" ],
    ...
  },

Cheers

@Elecash Hmm… Thanks, but that didn’t help. Actually, I just went into the vg-api.d and i-playable.d typings and deleted : /// <reference types="core-js" /> which fixed it. Seems like a hack, but I’m not sure what else to do

Installing core-js breaks when using a lib definition bigger than es2015 cause of duplicate symbols:

ERROR in /Users/xxx/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts
(94,5): error TS2300: Duplicate identifier '[Symbol.unscopables]'.

ERROR in /Users/xxx/node_modules/typescript/lib/lib.es2015.core.d.ts
(21,14): error TS2300: Duplicate identifier 'PropertyKey'.

ERROR in /Users/xxx/node_modules/@types/core-js/index.d.ts
(21,14): error TS2300: Duplicate identifier 'PropertyKey'.

ERROR in /Users/xxx/node_modules/@types/core-js/index.d.ts
(145,5): error TS2300: Duplicate identifier '[Symbol.unscopables]'.

I think as long as this project depends on core-js the best solution is to patch the type definitions after installation. We use the following postinstall script to strip out the core-js definition.

#!/bin/sh

set -e

sed -i.bak "/core-js/d" "./node_modules/videogular2/src/core/vg-media/i-playable.d.ts"
sed -i.bak "/core-js/d" "./node_modules/videogular2/src/core/services/vg-api.d.ts"

This script simply removes the first line from the .d.ts files.