-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
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
Es6 const #485
Es6 const #485
Conversation
es6 constants seem to work in --harmony on 0.12 too
I'd be careful with |
@targos In the context of Koa, I'd personally prefer the removal of side-effects of hoisting and |
I've PR"d (but not merge- will wait on discussion here first) the usage of
Since Would love to hear thoughts on this PR (and the PR to my branch adding // tagging participants from #484 |
One issue I'm facing- when an error occurs
✓ should emit "error" on the app
✓ should respond with 500
1) should be catchable
47 passing (142ms)
1 failing
1) app.respond when an error occurs should be catchable:
Error: expected 200 "OK", got 500 "Internal Server Error" The reason for this is - it('should be catchable', function(done){
const app = koa();
app.use(function *(next){
try {
yield next;
this.body = 'Hello';
} catch (err) {
error = err;
this.body = 'Got error';
}
});
app.use(function *(next){
throw new Error('boom!');
this.body = 'Oh no';
});
const server = app.listen();
request(server)
.get('/')
.expect(200, 'Got error')
.end(done);
}) not sure why this is... any ideas? @jonathanong |
Maybe this is one of the unnoticed bugs block-scoped variables help you to prevent ;) |
@felixfbecker I don't quite see how this could be an issue of block-scope. |
Ok so I only looked at the snippet you posted but the only thing I see being passed into the catch block is |
Oh that is it man. I double guessed myself. mixed up |
@jonathanong @felixfbecker That issue is now fixed. tejasmanohar@26a10e7. This is the PR adding
|
What is that line even doing? It doesnt seem to have any purpose... Maybe it should be removed if all tests still pass? |
@felixfbecker Tbh, I wondered the same thing. Tests still pass. I don't see how it could make the tests fail. For example, if I'm all for removing it if it's purposeless- simple change, but that's something the original authors / maintainers must comment on first. |
Who is to |
@felixfbecker Not great w/ that... but
so seems like @tj. there may be a reason behind this, i just don't know it- that's why i've refrained from removing. |
hmm haha I think that's just an accident from an older version of the test |
@tejasmanohar can you rebase? |
@jonathanong merged changes from upstream/master. tests still pass, no conflicts. PS: closed my |
@tejasmanohar i'm going to merge these into an "es2016" branch |
@jonathanong perfect. thanks- i will submit a |
PR in response to discussion w/ @jonathanong in issue #484.
I've done large replacements here, all tests pass (before and after using
const
in tests too). I'm looking through as well to make sure I haven't missed anything... but it's ready for review. This ONLY uses ES6 const and depends on either Node 4.x.x or harmony of our base version 0.12.x.Question- Should we use
let
in place ofvar
? We have to be in strict mode if we want to uselet
w/ Node 4.x.x. There are a couple instances where block-scope and the lack of hoisting is especially useful like w/ for loops (and variations).