question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Should ES6 global variable "Promise" be changed in examples in the docs?

See original GitHub issue

With ES6 coming and Promise being a reserved keyword in ES6, should we encourage users to use a different variable (other than Promise) when using Bluebird? Bluebird seems like a good replacement candidate.

I’d be willing to do a PR if others think this is a good idea. I would have thought it’d been brought up before, but couldn’t find a ticket. I’m still wondering if there is some other reason it hasn’t been changed, so I wanted to ask before taking the time to do a PR (since it’s not quite as simple as just finding and replacing).

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:21 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
CWSpearcommented, Apr 28, 2017

Man, if I had a dime for everytime I got a message like this (this one is copy and pasted from earlier today):

@cwspear I just spent like 30 mins debugging cus I didn’t import bluebird, and it defaulted to the native Promise… noob mistake.

These kinds of issues will always exist, but can be minimized with the official docs championed const Bluebird = require('bluebird');, etc.

3reactions
berguscommented, Jul 27, 2015

Promise is not a reserved keyword. It’s the name of a built-in object, the identifier for a global variable. Shadowing it is not a problem, it actually is what we aim to do here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Promise - JavaScript - MDN Web Docs
The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value.
Read more >
javascript - Why is my variable unaltered after I modify it inside ...
One word answer: asynchronicity. Forewords. This topic has been iterated at least a couple of thousands of times here in Stack Overflow.
Read more >
Understanding Variables, Scope, and Hoisting in JavaScript
This tutorial will cover what variables are, how to declare and name them, and also take a closer look at the difference between...
Read more >
ECMAScript 6: New Features: Overview and Comparison
Support for constants (also known as "immutable variables"), i.e., variables which cannot be re-assigned new content. Notice: this only makes the variable ......
Read more >
Promise - The Modern JavaScript Tutorial
Later we'll see how “fans” can subscribe to these changes. Here's an example of a promise constructor and a simple executor function with ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found