microsoft / dts-gen

dts-gen creates starter TypeScript definition files for any module or library.
MIT License
2.43k stars 101 forks source link

Unexpected crash with syntax error: Unexpected token import on pouchdb-react-native #93

Closed rodrigoelp closed 5 years ago

rodrigoelp commented 6 years ago

I've been trying to write the typescript definition for a module I want to experiment with called pouchdb-react-native. Making the story short, I got this module installed, when I typed:

dts-gen -m pouchdb-react-native -f src/typedefs/pouchdb-react-native.d.ts

I get the following error:

Unexpected crash! Please log a bug with the commandline you specified.
/path_to_project/node_modules/pouchdb-react-native/index.js:3
import PouchDB from 'pouchdb-core'
^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:152:10)
    at Module._compile (module.js:624:28)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/dts-gen/bin/lib/run.js:57:67)

And this is my package.json file

{
  "name": "project",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "pouchdb-react-native": "^6.3.4",
    "react": "16.0.0",
    "react-native": "0.51.0"
  },
  "devDependencies": {
    "@types/pouchdb-adapter-fruitdown": "^6.1.2",
    "@types/pouchdb-adapter-localstorage": "^6.1.2",
    "@types/pouchdb-adapter-memory": "^6.1.2",
    "@types/pouchdb-adapter-node-websql": "^6.1.2",
    "@types/pouchdb-browser": "^6.1.2",
    "@types/pouchdb-core": "^6.1.10",
    "@types/pouchdb-http": "^6.1.2",
    "@types/pouchdb-node": "^6.1.2",
    "@types/pouchdb-replication": "^6.1.4",
    "@types/react": "^16.0.31",
    "@types/react-native": "^0.51.7",
    "babel-jest": "22.0.4",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.0.4",
    "react-test-renderer": "16.0.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

My dev env is: macos: 10.13.2, node: 8.9.3, tsc: 2.6.2 and dts-gen: 0.5.7