doorxp-blog

doorxp.com

dts-gen throw e 不能生成.d.ts,报错

Unexpected crash! Please log a bug with the commandline you specified.
/opt/local/lib/node_modules/dts-gen-v2/bin/lib/run.js:130
        throw e;
        ^
TypeError: Cannot read property 'prototype' of undefined
    at isClasslike (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:114:18)
    at getKeysOfObject.some.k (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:47:41)
    at Array.some (native)
    at hasCloduleProperties (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:47:31)
    at getValueTypes (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:35:37)
    at getResult (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:196:55)
    at getTopLevelDeclarations (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:129:17)
    at getResult (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:201:35)
    at getTopLevelDeclarations (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:129:17)
    at Object.generateModuleDeclarationFile (/opt/local/lib/node_modules/dts-gen-v2/bin/lib/index.js:55:19)


打开 /opt/local/lib/node_modules/dts-gen/bin/lib/index.js

mate /opt/local/lib/node_modules/dts-gen/bin/lib/index.js

定位到114行

function isClasslike(obj) {
    return !!(obj.prototype && Object.getOwnPropertyNames(obj.prototype).length > 1);
}

修改为

function isClasslike(obj) {
    return !!(obj!=null && obj!=undefined && obj.prototype && Object.getOwnPropertyNames(obj.prototype).length > 1);
}


接下来就可以愉快的生成.d.ts 了

发表评论:

Powered By Z-BlogPHP 1.5.1 Zero

Copyright doorxp.com Rights Reserved.