Skip to content

编译出错没有报错,直接中断然后结束,没有提示 #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Sheetaa opened this issue Aug 23, 2020 · 1 comment
Closed

编译出错没有报错,直接中断然后结束,没有提示 #128

Sheetaa opened this issue Aug 23, 2020 · 1 comment
Assignees
Labels
bug Something isn't working released

Comments

@Sheetaa
Copy link

Sheetaa commented Aug 23, 2020

编译出错没有报错,直接中断结束,没有提示,也没有编译产出,有点懵逼。排查了很久,debug 发现是 emitter.ts 里 emit 函数执行出问题了

function emit(node: ts.Node | undefined) {
    if (!node) return;
    emitWithHint(ts.EmitHint.Unspecified, node);
}

加上 try...catch 以后错误正常报出来了,如下:

TypeError: Cannot read property 'kind' of undefined
    at getCannotFindNameDiagnosticForName (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:52570:37)
    at getResolvedSymbol (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:52582:105)
    at checkIdentifier (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:54414:26)
    at checkExpressionWorker (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:61624:28)
    at checkExpression (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:61574:38)
    at removeOptionalityFromDeclaredType (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:54371:37)
    at checkIdentifier (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:54539:66)
    at checkExpressionWorker (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:61624:28)
    at checkExpression (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:61574:38)
    at getTypeOfExpression (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:61516:24)
    at getRegularTypeOfExpression (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:67375:48)
    at getTypeOfNode (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:67283:24)
    at Object.getTypeAtLocation (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/typescript/lib/typescript.js:35196:31)
    at isClassLike (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/ts2php/dist/utilities/nodeTest.js:140:34)
    at Object.shouldAddDollar (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/ts2php/dist/utilities/nodeTest.js:46:9)
    at getTextOfNode (~/baidu/ps-se-fe-tpl/aladdin-san/node_modules/ts2php/dist/emitter.js:2880:28)

源代码是这样的:

parseData(tplData: CardTplData, extData?: ResultExtData, queryInfo?: QueryInfo, resData?: ResData): ParsedData | void {
    return formatData(tplData, resData?.lego_id);
}

emitter 中加上 try...catch 以后可以产出编译结果,编译结果如下:

function parseData($tplData, $extData = null, $queryInfo = null, $resData = null) {
    return formatData($tplData, ;
}
@Sheetaa Sheetaa added the bug Something isn't working label Aug 23, 2020
@cxtom cxtom self-assigned this Aug 24, 2020
@cxtom cxtom closed this as completed in d9f28b4 Aug 24, 2020
cxtom pushed a commit that referenced this issue Aug 24, 2020
# [0.30.0](v0.29.0...v0.30.0) (2020-08-24)

### Bug Fixes

* [#128](#128) ([d9f28b4](d9f28b4))
* test case ([2cde59e](2cde59e))

### Features

* update typescript to 3.9 ([303ae02](303ae02))
@cxtom
Copy link
Collaborator

cxtom commented Aug 24, 2020

🎉 This issue has been resolved in version 0.30.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@cxtom cxtom added the released label Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants