Comments (4)
idk about x == undefined
, but x == null
is a common pattern that e.g. has a eslint rule preference (deprecated only because a more general preference can be used to emulate it)
i much rather use x == null
than the cumbersome and typo-prone x === null || typeof x === 'undefined'
.
from js2coffee.
yep, it allows for that! I have no time to do it at the moment though
:(
On Nov 6 2016, at 12:36 pm, QwertyZW [email protected] wrote:
@rstacruz Yea that came up to me after giving it a bit more thought. I use x == null as a shorthand for
x === null || typeof x === 'undefined'
. I think what you can do in this case a temporary hack would be to create a transformation pass that transforms the jsexpression == null
to the js
expression === null || typeof expression === 'undefined'
before transpiling it coffee script
Of course that's just a suggestion under the assumption that the current architecture allows something like this
(JFTR I'm by no means a compiler person)
from js2coffee.
This is weird territory... Typeof x == 'undefined'
is not a direct
translation because it's possible to redefine undefined
. Also, x == undefined
will be true if x is null, so the more accurate translation is
more like x is undefined or x is null
I guess.
With that said, try === instead to get rid of the ambiguities :)
On Sat, Nov 5, 2016, 11:01 AM QwertyZW [email protected] wrote:
The javascript:
var x;
if (x == undefined){}
transpiles to:
x = undefined
if x == undefined
elseand emits a "Operator '==' is not supported in coffescript"
expected transpilation:
x = undefined
if typeof x is 'undefined'
else—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#460, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEikciTeERuQYoXF0LDQQ0GwrrhrLJMks5q6_GdgaJpZM4KqJVr
.
from js2coffee.
@rstacruz Yea that came up to me after giving it a bit more thought. I use x == null as a shorthand for x === null || typeof x === 'undefined'
. I think what you can do in this case a temporary hack would be to create a transformation pass that transforms the js
expression == null
to the js
expression === null || typeof expression === 'undefined'
before transpiling it coffee script
Of course that's just a suggestion under the assumption that the current architecture allows something like this
(JFTR I'm by no means a compiler person)
from js2coffee.
Related Issues (20)
- remove arrow function from logo HOT 2
- Support CoffeeScript 1.11
- website doesnt seem to work, neither the npm installation script HOT 3
- Support CoffeeScript 1.12 HOT 1
- Alt+2 character can't be typed
- ECMA 6 to CoffeeScript 2.0 compatible version HOT 17
- Incorrect compilation of comparison operators
- Treble-equals should compile to `is`, not double-equals
- How to Add/Modify CoffeeScript AST and write the result to a CoffeeScript file HOT 4
- Cannot find module 'minimist'
- Can't use web version for code with 3rd party dependency
- Web page not functioning ? HOT 1
- Unknown node type RestElement. HOT 1
- [error] ArrayPattern is not supported
- Error: Unknown node type RestElement.
- Incorrect translation of return clause
- Add ClassDeclaration and TemplateLiteral and all those ES6 goodies that are super useful
- Support for `?.` please?
- Support for async/await
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js2coffee.