When using an async IIFE to await a promise eslint is hinting me to add void to mark the function as unhandled w/ this rule: @typescript-eslint/no-floating-promises.
If I do so, the compiler will toss up a call stack:
TypeError: Cannot read property 'text' of undefined
at Object.getTokenPosOfNode (/Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript/lib/typescript.js:14120:72)
at NodeObject.getStart (/Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript/lib/typescript.js:152666:23)
at /Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript-to-lua/dist/transformation/utils/diagnostics.js:9:17
at Object.assign.code.code [as unsupportedNodeKind] (/Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript-to-lua/dist/utils.js:24:8)
at TransformationContext.transformNode (/Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript-to-lua/dist/transformation/context/context.js:38:49)
at TransformationContext.transformExpression (/Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript-to-lua/dist/transformation/context/context.js:56:31)
at Object.transformExpressionStatement [as transform] (/Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript-to-lua/dist/transformation/visitors/expression-statement.js:25:28)
at TransformationContext.transformNode (/Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript-to-lua/dist/transformation/context/context.js:44:62)
at /Users/thejustinwalsh/Projects/gui-tests/node_modules/typescript-to-lua/dist/transformation/context/context.js:70:58
at Array.flatMap (<anonymous>)
Offending code:
async function doLater(): Promise<void> {
return new Promise<void>((resolve) => {
resolve();
});
}
void (async () => {
await doLater();
})();
Compiles without issue:
// eslint-disable-next-line @typescript-eslint/no-floating-promises
(async () => {
await doLater();
})();
.eslintrc
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.json"
},
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking"
],
"rules": {
"@typescript-eslint/no-unused-vars": ["error", {"args": "all", "argsIgnorePattern": "^_"}],
"@typescript-eslint/strict-boolean-expressions": ["error", {"allowString": false, "allowNumber": false}],
"@typescript-eslint/restrict-plus-operands": "off",
"@typescript-eslint/semi": "error"
}
}
When using an async IIFE to await a promise eslint is hinting me to add
voidto mark the function as unhandled w/ this rule: @typescript-eslint/no-floating-promises.If I do so, the compiler will toss up a call stack:
Offending code:
Compiles without issue:
.eslintrc
{ "root": true, "parser": "@typescript-eslint/parser", "parserOptions": { "project": "tsconfig.json" }, "plugins": [ "@typescript-eslint" ], "extends": [ "eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended-requiring-type-checking" ], "rules": { "@typescript-eslint/no-unused-vars": ["error", {"args": "all", "argsIgnorePattern": "^_"}], "@typescript-eslint/strict-boolean-expressions": ["error", {"allowString": false, "allowNumber": false}], "@typescript-eslint/restrict-plus-operands": "off", "@typescript-eslint/semi": "error" } }