async arrow functions fail on target es2018
See original GitHub issueHey there I cannot seem to get async arrow functions of a class to work
class LogClass {
public error = async (_: string) => null;
public warn = async (_: string) => null;
}
const fakeLogger = mock(LogClass);
when(fakeLogger.error(anything())).thenResolve(null) // fakeLogger.error is not a function
// nor does
when(fakeLogger.warn(anything())).thenReturn(Promise.resolve(null)); //fakeLogger.warn is not a function
However
class LogClass {
public error = (_: string) => null;
public async warn (_: string) { return null };
}
const fakeLogger = mock(LogClass);
when(fakeLogger.error(anything())).thenReturn(null);
when(fakeLogger.warn(anything())).thenResolve();
works. I would like it if I could use async arrow functions
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Syntax for an async arrow function - javascript - Stack Overflow
Async arrow functions look like this: const foo = async () => { // do something }. Async arrow functions look like this...
Read more >async arrow function expected a return value - You.com
The resulting return of .then() is a promise. Ie, its a "promise" that something will happen or fail. Theres no "real value" being...
Read more >JavaScript (ES2015+) Enlightenment - Frontend Masters
"An Arrow Function does not define local bindings for arguments, super, this, or new.target. Any reference to arguments, super, this, or new.target within...
Read more >babel/plugin-transform-arrow-functions
@babel/plugin-transform-arrow-functions. NOTE: This plugin is included in @babel/preset-env. Example.
Read more >Node.js ES2015/ES6, ES2016 and ES2017 support
Yes. Yes Yes. Yes Error. Error Error. Error Error. Error Error. Error
function() function() function() function() function() function()
function() function() function() function() function() function()
function() function()...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Figured out the difference in my tsconfig.json
works
fails
@NagRock ^ ?