Closed
Description
Repro
{
"rules": {
"@typescript-eslint/promise-function-async": [
"error",
{
"allowedPromiseNames": [],
"checkArrowFunctions": false,
"checkFunctionDeclarations": true,
"checkFunctionExpressions": false,
"checkMethodDeclarations": false
}
]
}
}
code 1:
export function valid(n: number) { return n; }
code 2
export default function invalid(n: number) { return n; }
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:
function valid(n: number) { return n; }
function invalid(p: Promise<void>) { return p; } // lint error
and also with arrow functions ( checkArrowFunctions: true
):
export const valid = (n: number) => n;
export const invalid = (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 |
Metadata
Metadata
Assignees
Labels
Something isn't workingSomething isn't workingIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin