-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Block scoped declarations (let, const, function,class) not yet supported outside strict mode #275
Comments
What |
@preco21 node version 4.4.3 |
@CrazyAbdul I guess some of features are not supported in Could you upgrade your node to version 6 or 7? |
Would be better to target a 4.x Node.js version. |
node-telegram-bot-api/index.js Lines 7 to 11 in 2a782fd
Seems fallbacks in Still have no idea for about TravisCI.. |
Maybe this opts file is causing the problem? It is requiring |
@preco21 Thanks for looking into this issue. It seems Node v4 does not support the syntax fully. We can have the fallback work also for Node v4.x. However, I was hoping to only deprecate Node v0.x! Do we deprecate v4.x too? Also, we should check if it runs on v5.x, v6.x, v7.x! |
@preco21 It seems the quickest solution for me is to upgrade node to version 6. I'll update this thread on how it turns within the next few hours. |
If you can use the latest version of Node, I would suggest you go with that. However, since we are promising our users that we support Node v4.x, we need to fix this. |
@GochoMugo I could look into adding support for node v4 upwards |
@CrazyAbdul We could really do with some help! Thanks in advance! |
@CrazyAbdul But we should discuss how to achieve that, to avoid having you do so much work only to be discarded! |
What about simply do: const majorVersion = process.versions.node.split('.')[0];
if (majorVersion === '0') {
const deprecate = require('depd')('node-telegram-bot-api');
deprecate('Node.js v0.12 and below will no longer be supported in the future');
module.exports = require('./lib/telegram');
} else if (majorVersion === '4') {
module.exports = require('./lib/telegram');
} else {
module.exports = require('./src/telegram');
} or even: const majorVersion = process.versions.node.split('.')[0];
if (majorVersion === '0') {
const deprecate = require('depd')('node-telegram-bot-api');
deprecate('Node.js v0.12 and below will no longer be supported in the future');
}
module.exports = require(majorVersion === '0' || majorVersion === '4' ? './lib/telegram' : './src/telegram'); Also, you may need to fix |
@GochoMugo you earlier mentioned something about a fallback. What versions of node are those fallbacks for and how were they implemented. I'd want to learn from what the team has done so far before coming with a plan |
I guess you guys could consider about using babel-preset-env over static |
@preco21 then i can put the 2 js files I made node v4 compatible in |
@CrazyAbdul I guess it should be on |
@preco21 yeah. I see that now |
My major issue is whether we should deprecate node v4.x, or fix the syntax to support node v4.x ? We really want to move away from babel! |
@GochoMugo I came across this pdf showing stats on the various node versions On page 18, it shows that majority of people use v4 |
@GochoMugo what alternative to babel are you considering? |
@CrazyAbdul we are hoping to use the source as is i.e. no transpiling!!! |
According with https://nodesource.com/node-by-numbers v6 is more popular |
But supporting v4 without transpiling would be the best IMO |
@yagop checked your link out and it is clearly more up to date than the pdf i talked about. |
So, I think we should push our community to using newer versions of Node.js. So we could deprecate older versions continuously. So it seems we will continue transpiling until the moment we will deprecate Node v4.x! |
@GochoMugo should i go ahead and make a pull request? |
@CrazyAbdul Good to go. IMO, transpiles are needed. I don't think it makes sense to simply change the codebase to the old grammar to support older version of the node. Newer grammar gives us readability, maintainable code, such advantages. |
@CrazyAbdul Everything seems okay. We are waiting for a PR to fallback Node v4.x to use transpiled code. (@preco21's comment above is helpful.) @preco21 I agree. At the rate at which Node releases newer versions, it seems unwise to downgrade our syntax to support older versions, which will be surpassed in quite a short time I presume. |
@GochoMugo Pull request (#280) sent |
Great job guys! |
Bug: Node.js v4 does not support the ES6 syntax fully, thus we get the error: Block scoped declarations (let, const, function,class) not yet supported outside strict mode Fix: * Load transpiled code * Deprecate support for Node.js v4.x References: * Bug report: #275 * PR: #280 * Reported-by: @CrazyAbdul * PR-by: @CrazyAbdul
PR #280 merged into master in commit d4a469df6b6eeae4c045faf7b6e63bdc765b0a15. Please try out the fix and report your results. |
@GochoMugo @preco21 @yagop it's working now. I was able to run Thanks for letting me help out. Deeply appreciated |
Added: 1. Add constructor options: * (#243) `options.polling.params` (by @GochoMugo, requested-by @sidelux) 1. Add methods: * (#74) *TelegramBot#removeReplyListener()* (by @githugger) 1. (#283) Add proper error handling (by @GochoMugo) 1. (#272) Add health-check endpoint (by @mironov) * `options.webHook.healthEndpoint` 1. (#152) Add test for TelegramBot#sendDocument() using 'fileOpts' param (by @evolun) 1. Document `options.webHook.host` (by @GochoMugo) 1. (#264) Add Bot API version to README (by @kamikazechaser) 1. Add examples: - (#271) WebHook on Heroku (by @TheBeastOfCaerbannog) - (#274) WebHook on Zeit Now (by @ferrari) Changed: 1. (#147) Use *String#indexOf()*, instead of *RegExp#test()*, to find token in webhook request (by @AVVS) Fixed: * Fix bug: - (#275, #280) fix es6 syntax error on Node.js v4.x (by @CrazyAbdul) - (#276) promise.warning from `request-promise` (by @GochoMugo, reported-by @preco21) - (#281) fix handling error during polling (by @GochoMugo, reported-by @dimawebmaker) - (#284) fix error during deletion of already-set webhook, during polling (by @GochoMugo, reported-by @dcparga) 1. Fix links in documentation (by @Ni2c2k)
Fixed in v0.27.0. |
Bug: Node.js v4 does not support the ES6 syntax fully, thus we get the error: Block scoped declarations (let, const, function,class) not yet supported outside strict mode Fix: * Load transpiled code * Deprecate support for Node.js v4.x References: * Bug report: yagop/node-telegram-bot-api#275 * PR: yagop/node-telegram-bot-api#280 * Reported-by: @CrazyAbdul * PR-by: @CrazyAbdul
Bug: Node.js v4 does not support the ES6 syntax fully, thus we get the error: Block scoped declarations (let, const, function,class) not yet supported outside strict mode Fix: * Load transpiled code * Deprecate support for Node.js v4.x References: * Bug report: yagop/node-telegram-bot-api#275 * PR: yagop/node-telegram-bot-api#280 * Reported-by: @CrazyAbdul * PR-by: @CrazyAbdul
I have read:
I am using the latest version of the library.
v 0.26.0
Expected Behavior
I was trying to run the bot after writing some lines of code. I expected that after running
node index.js
,there will be no errors and when i send a request from telegram, get the desired result.
Actual Behavior
what happened instead was this error in the console
So i run this instead
node --use_strict index.js
and got different set of errorsSo after a while, I went through
telegram.js
andtelegramPolling.js
and changed the following function parametersand in some cases, initialized the variable to an empty object within the function. For example
It was after taking these steps that it finally worked
Steps to reproduce the Behavior
node index.js
My project, as at now, only tests sending messages but I could test other features If given approval
The text was updated successfully, but these errors were encountered: