microsoft / dts-gen

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

Unexpected crash dts-gen -m @react-native-community/datetimepicker #143

Open SaeedZhiany opened 5 years ago

SaeedZhiany commented 5 years ago
C:\Users\SAEED\AppData\Roaming\npm\node_modules\@react-native-community\datetimepicker\src\index.js:1
import RNDateTimePicker from './datetimepicker';
       ^^^^^^^^^^^^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:718:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (C:\Users\SAEED\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:58:67)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
orta commented 5 years ago

This looks like it's loading a JS file into node which doesn't support import/export syntax here

SaeedZhiany commented 5 years ago

@orta I took a look at structure of the repository, there is no identical file with 'datetimepicker.js'. instead, there are two files with the name datetimepicker.ios.js and datetimepicker.android.js. it seems it can not deal with such a situation.

So are you think this is a bug? if no, how can I manage to produce the TS files?

orta commented 5 years ago

Ah yeah, I don't think that's going to work at all - this dependency needs to run inside react native and not node. They have different runtime semantics (like handling the .platform.js) - I don't think you can use dts-gen for this module.

SaeedZhiany commented 5 years ago

Alright then, thank you for your response. I close this issue.

SaeedZhiany commented 4 years ago

Hi @orta

I wanted to generate an initial definition file for react-native-charts-wrapper. it gives the same error, but in this case, there is no platform base file and all the files are .js

the commands I'm using to generate the file

npm install -g dts-gen
npm install -g react-native-charts-wrapper
dts-gen -m react-native-charts-wrapper
Unexpected crash! Please log a bug with the commandline you specified.
C:\Users\SAEED\AppData\Roaming\npm\node_modules\react-native-charts-wrapper\index.js:1
import BarChart from './lib/BarChart';
       ^^^^^^^^

SyntaxError: Unexpected identifier
    at Module._compile (internal/modules/cjs/loader.js:718:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:681:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (C:\Users\SAEED\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:58:67)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)

Can you please check it yourself too. I think I'm missing something due to I don't know how exactly I should use this library to generate the definition file.