Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
Repro
{"rules": {"@typescript-eslint/promise-function-async": ["error", {"allowedPromiseNames": [],"checkArrowFunctions":false,"checkFunctionDeclarations":true,"checkFunctionExpressions":false,"checkMethodDeclarations":false } ] }}
code 1:
exportfunctionvalid(n:number){returnn;}
code 2
exportdefaultfunctioninvalid(n:number){returnn;}
Expected Result
code 1 - no error
code 2 - lint error
Actual Result
TypeError: Cannot read property 'resolvedReturnType' of undefined at Object.getReturnTypeOfSignature (/path/to/repo/node_modules/typescript/lib/typescript.js:38106:28) at validateNode (/path/to/repo/node_modules/@typescript-eslint/eslint-plugin/lib/rules/promise-function-async.js:91:34) at FunctionDeclaration (/path/to/repo/node_modules/@typescript-eslint/eslint-plugin/lib/rules/promise-function-async.js:111:11) at listeners.(anonymous function).forEach.listener (/path/to/repo/node_modules/eslint/lib/util/safe-emitter.js:45:58) at Array.forEach (<anonymous>) at Object.emit (/path/to/repo/node_modules/eslint/lib/util/safe-emitter.js:45:38) at NodeEventGenerator.applySelector (/path/to/repo/node_modules/eslint/lib/util/node-event-generator.js:251:26) at NodeEventGenerator.applySelectors (/path/to/repo/node_modules/eslint/lib/util/node-event-generator.js:280:22) at NodeEventGenerator.enterNode (/path/to/repo/node_modules/eslint/lib/util/node-event-generator.js:294:14) at CodePathAnalyzer.enterNode (/path/to/repo/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:632:23)
Additional Info
No problem with non-exported function declarations:
functionvalid(n:number){returnn;}functioninvalid(p:Promise<void>){returnp;}// lint error
and also with arrow functions (checkArrowFunctions: true
):
exportconstvalid=(n:number)=>n;exportconstinvalid=(p:Promise<void>)=>p;// lint error
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin | 1.2.0 |
@typescript-eslint/parser | 1.2.0 |
TypeScript | 3.2.4 ,3.3.0 |
ESLint | 5.13.0 |
node | 11.8.0 |
npm | 6.7.0 |