-
Notifications
You must be signed in to change notification settings - Fork 2
add boolean, null, number, string, and undefined #1
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
base: master
Are you sure you want to change the base?
Conversation
|
What’s the use case for these though? |
|
The use case is when aliasing something that would have or could have returned that type instead of an object |
|
I am sorry but I still can’t quite get it. Can you provide some code as an example? |
|
Say you have a library which does some calculations and returns a string. You could use webpack or another build step to re-alias that library to easily point to the empty string. |
|
When using Flow and the |
| exports.functionThatReturnsNull = require('./functionThatReturnsNull'); | ||
| exports.functionThatReturnsThis = require('./functionThatReturnsThis'); | ||
| exports.functionThatReturnsArgument = require('./functionThatReturnsArgument'); | ||
| exports['boolean'] = require('./boolean'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you use bracket notation for these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean is probably a reserved word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but reserved words can still be used as key in ES5 and up.
Also, importing/requiring these will cause a bit of a nuisance since you can’t do import {null} from 'empty'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import {null as nullValue} from 'empty'
This comes out of my desire to just import an empty string, but decided to fill out the other primitive types as well (except for Symbol).
Since primitive in JS are immutable, the
Object.freezethat takes place in other modules does not need to occur.