More flow updates, and lots of fixes!
We've added 4 new collaborators to Babel since the last release!
All of the hard work goes to them and our new contributors!
- Moti Zilberman: 🐙 @motiz88, 🐦 @motiz88
- Dan Harper: 🐙 @danharper, 🐦 @DanHarper7
- Kai Cataldo: 🐙 @kaicataldo, 🐦 @kai_cataldo
- Andrew Levine: 🐙 @DrewML, 🐦 @drewml
They've been helping keep this project afloat with @loganfsmyth, @danez, and me!
v6.18.0 Summary (2016-10-24)
Again if you haven't checked recently, we've moved back to Github Issues! This is all thanks to @danez
🚀 New Feature
#4697 Add variance node type and generate property variance annotations. (@samwgoldman)
Check out the blog post and flow docs for more info:
type T = { +p: T };
interface T { -p: T };
declare class T { +[k:K]: V };
class T { -[k:K]: V };
class C2 { +p: T = e };
#4746 Support ObjectExpression
in static path evaluation. (@motiz88)
Useful for babel/babili and other plugins.
// in
{['a' + 'b']: 10 * 20, 'z': [1, 2, 3]}
// out
{ab: 200, z: [1, 2, 3]}
#4699 import()
: Initial support for dynamic-import
. (@kesne)
Parser support was added in babel/babylon#v6.12.0.
Just the plugin to enable it in babel.
// install
$ npm install babel-plugin-syntax-dynamic-import --save-dev
or use the new parserOpts
// .babelrc
{
"parserOpts": {
"plugins": ['dynamicImport']
}
}
#4655 Add useBuiltIns
option to helper-builder-react-jsx. (@existentialism)
Previously we added a useBuiltIns
for object-rest-spread so that it use the native/built in version if you use a polyfill or have it supported natively.
This change just uses the same option from the plugin to be applied with spread inside of jsx.
// in
var div = <Component {...props} foo="bar" />
// out
var div = React.createElement(Component, Object.assign({}, props, { foo: "bar" }));
#4724 Add EmptyTypeAnnotation
. (@samwgoldman)
Added in flow here and in babylon here.
function f<T>(x: empty): T {
return x;
}
f(); // nothing to pass...
#4758 Make getBinding ignore labels; add Scope#getLabel, Scope#hasLabel, Scope#registerLabel. (@kangax)
Track LabeledStatement
separately (not part of bindings).
💅 Polish
#4690 Consolidate contiguous var declarations in destructuring transform. (@motiz88)
// in
const [a, b] = [1, 2];
// out
var a = 1,
b = 2;
#4685 Better error messaging when preset options are given without a corresponding preset. (@kaicataldo)
We've had a few reports of users not wrapping a preset in
[]
when passing in options so we added an extra error message for this.
// incorrect, and current gives a unexpected error message
{
"presets": [
"preset",
{ "presetOptions": 'hi' } // gets parsed as another preset instead of being part of the "preset"
]
}
// correct
{
"presets": [
["preset",
{
"presetOptions": 'hi'
}
]
]
}
ReferenceError: [BABEL] /test.js: Unknown option: base.loose2. Check out http://babeljs.io/docs/usage/options/ for more information about options.
A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:
Invalid:
`{ presets: [{option: value}] }`
Valid:
`{ presets: [["presetName", {option: value}]] }`
For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options.
#4646 Change babel-generator to output boolean
instead of bool
for the BooleanTypeAnnotation
AST node. (@existentialism)
var a: Promise<boolean>[];
// instead of
var a: Promise<bool>[];
📝 Documentation
#4653 Tweak license for GitHub display. (@existentialism)
So that our MIT License shows up.
🐛 Bug Fixes
#4765 Don't treat JSXIdentifier
in JSXMemberExpression
as HTML tag. Closes #4027. (@DrewML)
// transform-react-inline-elements
// issue with imported components that were JSXMemberExpression
import { form } from "./export";
function ParentComponent() {
return <form.TestComponent />;
}
#4763 Handle remapping of JSXIdentifier to MemberExpression in CommonJS transform. Closes #3728. (@DrewML)
// transform-react-inline-elements
import { Modal } from "react-bootstrap";
export default CustomModal = () => <Modal.Header>foobar</Modal.Header>;