We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
My function
export async function getAccount(provider: Provider): Promise<string | null> { try { const accounts: string[] = await provider.send('eth_accounts'); // 1. provider.send returns undefined return accounts[0] || null; // 2. throw error 'Cannot read property '0' of undefined' } catch { warning('Some text'); // 3. log warning } return 'fallback account'; // 4. return 'fallback account' }
compiled to
var getAccount = function getAccount(provider) { try { var _exit2 = false; var _temp2 = _catch(function () { return Promise.resolve(provider.send('eth_accounts')).then(function (accounts) { // 1. accounts === undefined _exit2 = true; return accounts[0] || null; // 2. throw error 'Cannot read property '0' of undefined' }); }, function () { process.env.NODE_ENV !== "production" ? warning('Some text') : void 0; // 3. log warning }); return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function (_result) { return _exit2 ? _result : 'fallback account'; // 4. return undefined because _exit2 === true and _result === undefined }) : _exit2 ? _temp2 : 'fallback account'); } catch (e) { return Promise.reject(e); } };
var getAccount = function getAccount(provider) { try { var _exit2 = false; var _temp2 = _catch(function () { return Promise.resolve(provider.send('eth_accounts')).then(function (accounts) { // 1. accounts === undefined - _exit2 = true; return accounts[0] || null; // 2. throw error 'Cannot read property '0' of undefined' + }).then(function () { + _exit2 = true; }); }, function () { process.env.NODE_ENV !== "production" ? warning('Some text') : void 0; // 3. log warning }); return Promise.resolve(_temp2 && _temp2.then ? _temp2.then(function (_result) { - return _exit2 ? _result : 'fallback account'; // 4. return undefined because _exit2 === true and _result === undefined + return _exit2 ? _result : 'fallback account'; // 4. return 'fallback account' because _exit2 === false }) : _exit2 ? _temp2 : 'fallback account'); } catch (e) { return Promise.reject(e); } };
The text was updated successfully, but these errors were encountered:
65791b9
No branches or pull requests
Current Behavior
My function
compiled to
Expected behavior
compiled to
My environment
The text was updated successfully, but these errors were encountered: