UNPKG

38.2 kBMarkdownView Raw
1# Changelog
2
3> **Tags:**
4> - :boom: [Breaking Change]
5> - :eyeglasses: [Spec Compliance]
6> - :rocket: [New Feature]
7> - :bug: [Bug Fix]
8> - :memo: [Documentation]
9> - :house: [Internal]
10> - :nail_care: [Polish]
11
12> Semver Policy: https://github.com/babel/babel/tree/main/packages/babel-parser#semver
13
14_Note: Gaps between patch versions are faulty, broken or test releases._
15
16See the [Babel Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md) for the pre-6.8.0 version Changelog.
17
18## 6.17.1 (2017-05-10)
19
20### :bug: Bug Fix
21 * Fix typo in flow spread operator error (Brian Ng)
22 * Fixed invalid number literal parsing ([#473](https://github.com/babel/babylon/pull/473)) (Alex Kuzmenko)
23 * Fix number parser ([#433](https://github.com/babel/babylon/pull/433)) (Alex Kuzmenko)
24 * Ensure non pattern shorthand props are checked for reserved words ([#479](https://github.com/babel/babylon/pull/479)) (Brian Ng)
25 * Remove jsx context when parsing arrow functions ([#475](https://github.com/babel/babylon/pull/475)) (Brian Ng)
26 * Allow super in class properties ([#499](https://github.com/babel/babylon/pull/499)) (Brian Ng)
27 * Allow flow class field to be named constructor ([#510](https://github.com/babel/babylon/pull/510)) (Brian Ng)
28
29## 6.17.0 (2017-04-20)
30
31### :bug: Bug Fix
32 * Cherry-pick #418 to 6.x ([#476](https://github.com/babel/babylon/pull/476)) (Sebastian McKenzie)
33 * Add support for invalid escapes in tagged templates ([#274](https://github.com/babel/babylon/pull/274)) (Kevin Gibbons)
34 * Throw error if new.target is used outside of a function ([#402](https://github.com/babel/babylon/pull/402)) (Brian Ng)
35 * Fix parsing of class properties ([#351](https://github.com/babel/babylon/pull/351)) (Kevin Gibbons)
36 * Fix parsing yield with dynamicImport ([#383](https://github.com/babel/babylon/pull/383)) (Brian Ng)
37 * Ensure consistent start args for parseParenItem ([#386](https://github.com/babel/babylon/pull/386)) (Brian Ng)
38
39## 7.0.0-beta.8 (2017-04-04)
40
41### New Feature
42* Add support for flow type spread (#418) (Conrad Buck)
43* Allow statics in flow interfaces (#427) (Brian Ng)
44
45### Bug Fix
46* Fix predicate attachment to match flow parser (#428) (Brian Ng)
47* Add extra.raw back to JSXText and JSXAttribute (#344) (Alex Rattray)
48* Fix rest parameters with array and objects (#424) (Brian Ng)
49* Fix number parser (#433) (Alex Kuzmenko)
50
51### Docs
52* Fix CONTRIBUTING.md [skip ci] (#432) (Alex Kuzmenko)
53
54### Internal
55* Use babel-register script when running babel smoke tests (#442) (Brian Ng)
56
57## 7.0.0-beta.7 (2017-03-22)
58
59### Spec Compliance
60* Remove babylon plugin for template revision since it's stage-4 (#426) (Henry Zhu)
61
62### Bug Fix
63
64* Fix push-pop logic in flow (#405) (Daniel Tschinder)
65
66## 7.0.0-beta.6 (2017-03-21)
67
68### New Feature
69* Add support for invalid escapes in tagged templates (#274) (Kevin Gibbons)
70
71### Polish
72* Improves error message when super is called outside of constructor (#408) (Arshabh Kumar Agarwal)
73
74### Docs
75
76* [7.0] Moved value field in spec from ObjectMember to ObjectProperty as ObjectMethod's don't have it (#415) [skip ci] (James Browning)
77
78## 7.0.0-beta.5 (2017-03-21)
79
80### Bug Fix
81* Throw error if new.target is used outside of a function (#402) (Brian Ng)
82* Fix parsing of class properties (#351) (Kevin Gibbons)
83
84### Other
85 * Test runner: Detect extra property in 'actual' but not in 'expected'. (#407) (Andy)
86 * Optimize travis builds (#419) (Daniel Tschinder)
87 * Update codecov to 2.0 (#412) (Daniel Tschinder)
88 * Fix spec for ClassMethod: It doesn't have a function, it *is* a function. (#406) [skip ci] (Andy)
89 * Changed Non-existent RestPattern to RestElement which is what is actually parsed (#409) [skip ci] (James Browning)
90 * Upgrade flow to 0.41 (Daniel Tschinder)
91 * Fix watch command (#403) (Brian Ng)
92 * Update yarn lock (Daniel Tschinder)
93 * Fix watch command (#403) (Brian Ng)
94 * chore(package): update flow-bin to version 0.41.0 (#395) (greenkeeper[bot])
95 * Add estree test for correct order of directives (Daniel Tschinder)
96 * Add DoExpression to spec (#364) (Alex Kuzmenko)
97 * Mention cloning of repository in CONTRIBUTING.md (#391) [skip ci] (Sumedh Nimkarde)
98 * Explain how to run only one test (#389) [skip ci] (Aaron Ang)
99
100 ## 7.0.0-beta.4 (2017-03-01)
101
102* Don't consume async when checking for async func decl (#377) (Brian Ng)
103* add `ranges` option [skip ci] (Henry Zhu)
104* Don't parse class properties without initializers when classProperties is disabled and Flow is enabled (#300) (Andrew Levine)
105
106## 7.0.0-beta.3 (2017-02-28)
107
108- [7.0] Change RestProperty/SpreadProperty to RestElement/SpreadElement (#384)
109- Merge changes from 6.x
110
111## 7.0.0-beta.2 (2017-02-20)
112
113- estree: correctly change literals in all cases (#368) (Daniel Tschinder)
114
115## 7.0.0-beta.1 (2017-02-20)
116
117- Fix negative number literal typeannotations (#366) (Daniel Tschinder)
118- Update contributing with more test info [skip ci] (#355) (Brian Ng)
119
120## 7.0.0-beta.0 (2017-02-15)
121
122- Reintroduce Variance node (#333) (Daniel Tschinder)
123- Rename NumericLiteralTypeAnnotation to NumberLiteralTypeAnnotation (#332) (Charles Pick)
124- [7.0] Remove ForAwaitStatement, add await flag to ForOfStatement (#349) (Brandon Dail)
125- chore(package): update ava to version 0.18.0 (#345) (greenkeeper[bot])
126- chore(package): update babel-plugin-istanbul to version 4.0.0 (#350) (greenkeeper[bot])
127- Change location of ObjectTypeIndexer to match flow (#228) (Daniel Tschinder)
128- Rename flow AST Type ExistentialTypeParam to ExistsTypeAnnotation (#322) (Toru Kobayashi)
129- Revert "Temporary rollback for erroring on trailing comma with spread (#154)" (#290) (Daniel Tschinder)
130- Remove classConstructorCall plugin (#291) (Brian Ng)
131- Update yarn.lock (Daniel Tschinder)
132- Update cross-env to 3.x (Daniel Tschinder)
133- [7.0] Remove node 0.10, 0.12 and 5 from Travis (#284) (Sergey Rubanov)
134- Remove `String.fromCodePoint` shim (#279) (Mathias Bynens)
135
136## 6.16.1 (2017-02-23)
137
138### :bug: Regression
139
140- Revert "Fix export default async function to be FunctionDeclaration" ([#375](https://github.com/babel/babylon/pull/375))
141
142Need to modify Babel for this AST node change, so moving to 7.0.
143
144- Revert "Don't parse class properties without initializers when classProperties plugin is disabled, and Flow is enabled" ([#376](https://github.com/babel/babylon/pull/376))
145
146[react-native](https://github.com/facebook/react-native/issues/12542) broke with this so we reverted.
147
148## 6.16.0 (2017-02-23)
149
150### :rocket: New Feature
151
152***ESTree*** compatibility as plugin ([#277](https://github.com/babel/babylon/pull/277)) (Daniel Tschinder)
153
154We finally introduce a new compatibility layer for ESTree. To put babylon into ESTree-compatible mode the new plugin `estree` can be enabled. In this mode the parser will output an AST that is compliant to the specs of [ESTree](https://github.com/estree/estree/)
155
156We highly recommend everyone who uses babylon outside of babel to use this plugin. This will make it much easier for users to switch between different ESTree-compatible parsers. We so far tested several projects with different parsers and exchanged their parser to babylon and in nearly all cases it worked out of the box. Some other estree-compatible parsers include `acorn`, `esprima`, `espree`, `flow-parser`, etc.
157
158To enable `estree` mode simply add the plugin in the config:
159```json
160{
161 "plugins": [ "estree" ]
162}
163```
164
165If you want to migrate your project from non-ESTree mode to ESTree, have a look at our [Readme](https://github.com/babel/babylon/#output), where all deviations are mentioned.
166
167Add a parseExpression public method ([#213](https://github.com/babel/babylon/pull/213)) (jeromew)
168
169Babylon exports a new function to parse a single expression
170
171```js
172import { parseExpression } from 'babylon';
173
174const ast = parseExpression('x || y && z', options);
175```
176
177The returned AST will only consist of the expression. The options are the same as for `parse()`
178
179Add startLine option ([#346](https://github.com/babel/babylon/pull/346)) (Raphael Mu)
180
181A new option was added to babylon allowing to change the initial linenumber for the first line which is usually `1`.
182Changing this for example to `100` will make line `1` of the input source to be marked as line `100`, line `2` as `101`, line `3` as `102`, ...
183
184Function predicate declaration ([#103](https://github.com/babel/babylon/pull/103)) (Panagiotis Vekris)
185
186Added support for function predicates which flow introduced in version 0.33.0
187
188```js
189declare function is_number(x: mixed): boolean %checks(typeof x === "number");
190```
191
192Allow imports in declare module ([#315](https://github.com/babel/babylon/pull/315)) (Daniel Tschinder)
193
194Added support for imports within module declarations which flow introduced in version 0.37.0
195
196```js
197declare module "C" {
198 import type { DT } from "D";
199 declare export type CT = { D: DT };
200}
201```
202
203### :eyeglasses: Spec Compliance
204
205Forbid semicolons after decorators in classes ([#352](https://github.com/babel/babylon/pull/352)) (Kevin Gibbons)
206
207This example now correctly throws an error when there is a semicolon after the decorator:
208
209```js
210class A {
211@a;
212foo(){}
213}
214```
215
216Keywords are not allowed as local specifier ([#307](https://github.com/babel/babylon/pull/307)) (Daniel Tschinder)
217
218Using keywords in imports is not allowed anymore:
219
220```js
221import { default } from "foo";
222import { a as debugger } from "foo";
223```
224
225Do not allow overwritting of primitive types ([#314](https://github.com/babel/babylon/pull/314)) (Daniel Tschinder)
226
227In flow it is now forbidden to overwrite the primitive types `"any"`, `"mixed"`, `"empty"`, `"bool"`, `"boolean"`, `"number"`, `"string"`, `"void"` and `"null"` with your own type declaration.
228
229Disallow import type { type a } from … ([#305](https://github.com/babel/babylon/pull/305)) (Daniel Tschinder)
230
231The following code now correctly throws an error
232
233```js
234import type { type a } from "foo";
235```
236
237Don't parse class properties without initializers when classProperties is disabled and Flow is enabled ([#300](https://github.com/babel/babylon/pull/300)) (Andrew Levine)
238
239Ensure that you enable the `classProperties` plugin in order to enable correct parsing of class properties. Prior to this version it was possible to parse them by enabling the `flow` plugin but this was not intended the behaviour.
240
241If you enable the flow plugin you can only define the type of the class properties, but not initialize them.
242
243Fix export default async function to be FunctionDeclaration ([#324](https://github.com/babel/babylon/pull/324)) (Daniel Tschinder)
244
245Parsing the following code now returns a `FunctionDeclaration` AST node instead of `FunctionExpression`.
246
247```js
248export default async function bar() {};
249```
250
251### :nail_care: Polish
252
253Improve error message on attempt to destructure named import ([#288](https://github.com/babel/babylon/pull/288)) (Brian Ng)
254
255### :bug: Bug Fix
256
257Fix negative number literal typeannotations ([#366](https://github.com/babel/babylon/pull/366)) (Daniel Tschinder)
258
259Ensure takeDecorators is called on exported class ([#358](https://github.com/babel/babylon/pull/358)) (Brian Ng)
260
261ESTree: correctly change literals in all cases ([#368](https://github.com/babel/babylon/pull/368)) (Daniel Tschinder)
262
263Correctly convert RestProperty to Assignable ([#339](https://github.com/babel/babylon/pull/339)) (Daniel Tschinder)
264
265Fix #321 by allowing question marks in type params ([#338](https://github.com/babel/babylon/pull/338)) (Daniel Tschinder)
266
267Fix #336 by correctly setting arrow-param ([#337](https://github.com/babel/babylon/pull/337)) (Daniel Tschinder)
268
269Fix parse error when destructuring `set` with default value ([#317](https://github.com/babel/babylon/pull/317)) (Brian Ng)
270
271Fix ObjectTypeCallProperty static ([#298](https://github.com/babel/babylon/pull/298)) (Dan Harper)
272
273
274### :house: Internal
275
276Fix generator-method-with-computed-name spec ([#360](https://github.com/babel/babylon/pull/360)) (Alex Rattray)
277
278Fix flow type-parameter-declaration test with unintended semantic ([#361](https://github.com/babel/babylon/pull/361)) (Alex Rattray)
279
280Cleanup and splitup parser functions ([#295](https://github.com/babel/babylon/pull/295)) (Daniel Tschinder)
281
282chore(package): update flow-bin to version 0.38.0 ([#313](https://github.com/babel/babylon/pull/313)) (greenkeeper[bot])
283
284Call inner function instead of 1:1 copy to plugin ([#294](https://github.com/babel/babylon/pull/294)) (Daniel Tschinder)
285
286Update eslint-config-babel to the latest version 🚀 ([#299](https://github.com/babel/babylon/pull/299)) (greenkeeper[bot])
287
288Update eslint-config-babel to the latest version 🚀 ([#293](https://github.com/babel/babylon/pull/293)) (greenkeeper[bot])
289
290devDeps: remove eslint-plugin-babel ([#292](https://github.com/babel/babylon/pull/292)) (Kai Cataldo)
291
292Correct indent eslint rule config ([#276](https://github.com/babel/babylon/pull/276)) (Daniel Tschinder)
293
294Fail tests that have expected.json and throws-option ([#285](https://github.com/babel/babylon/pull/285)) (Daniel Tschinder)
295
296### :memo: Documentation
297
298Update contributing with more test info [skip ci] ([#355](https://github.com/babel/babylon/pull/355)) (Brian Ng)
299
300Update API documentation ([#330](https://github.com/babel/babylon/pull/330)) (Timothy Gu)
301
302Added keywords to package.json ([#323](https://github.com/babel/babylon/pull/323)) (Dmytro)
303
304AST spec: fix casing of `RegExpLiteral` ([#318](https://github.com/babel/babylon/pull/318)) (Mathias Bynens)
305
306## 6.15.0 (2017-01-10)
307
308### :eyeglasses: Spec Compliance
309
310Add support for Flow shorthand import type ([#267](https://github.com/babel/babylon/pull/267)) (Jeff Morrison)
311
312This change implements flows new shorthand import syntax
313and where previously you had to write this code:
314
315```js
316import {someValue} from "blah";
317import type {someType} from "blah";
318import typeof {someOtherValue} from "blah";
319```
320
321you can now write it like this:
322
323```js
324import {
325 someValue,
326 type someType,
327 typeof someOtherValue,
328} from "blah";
329```
330
331For more information look at [this](https://github.com/facebook/flow/pull/2890) pull request.
332
333flow: allow leading pipes in all positions ([#256](https://github.com/babel/babylon/pull/256)) (Vladimir Kurchatkin)
334
335This change now allows a leading pipe everywhere types can be used:
336```js
337var f = (x): | 1 | 2 => 1;
338```
339
340Throw error when exporting non-declaration ([#241](https://github.com/babel/babylon/pull/241)) (Kai Cataldo)
341
342Previously babylon parsed the following exports, although they are not valid:
343```js
344export typeof foo;
345export new Foo();
346export function() {};
347export for (;;);
348export while(foo);
349```
350
351### :bug: Bug Fix
352
353Don't set inType flag when parsing property names ([#266](https://github.com/babel/babylon/pull/266)) (Vladimir Kurchatkin)
354
355This fixes parsing of this case:
356
357```js
358const map = {
359 [age <= 17] : 'Too young'
360};
361```
362
363Fix source location for JSXEmptyExpression nodes (fixes #248) ([#249](https://github.com/babel/babylon/pull/249)) (James Long)
364
365The following case produced an invalid AST
366```js
367<div>{/* foo */}</div>
368```
369
370Use fromCodePoint to convert high value unicode entities ([#243](https://github.com/babel/babylon/pull/243)) (Ryan Duffy)
371
372When high value unicode entities (e.g. 💩) were used in the input source code they are now correctly encoded in the resulting AST.
373
374Rename folder to avoid Windows-illegal characters ([#281](https://github.com/babel/babylon/pull/281)) (Ryan Plant)
375
376Allow this.state.clone() when parsing decorators ([#262](https://github.com/babel/babylon/pull/262)) (Alex Rattray)
377
378### :house: Internal
379
380User external-helpers ([#254](https://github.com/babel/babylon/pull/254)) (Daniel Tschinder)
381
382Add watch script for dev ([#234](https://github.com/babel/babylon/pull/234)) (Kai Cataldo)
383
384Freeze current plugins list for "*" option, and remove from README.md ([#245](https://github.com/babel/babylon/pull/245)) (Andrew Levine)
385
386Prepare tests for multiple fixture runners. ([#240](https://github.com/babel/babylon/pull/240)) (Daniel Tschinder)
387
388Add some test coverage for decorators stage-0 plugin ([#250](https://github.com/babel/babylon/pull/250)) (Andrew Levine)
389
390Refactor tokenizer types file ([#263](https://github.com/babel/babylon/pull/263)) (Sven SAULEAU)
391
392Update eslint-config-babel to the latest version 🚀 ([#273](https://github.com/babel/babylon/pull/273)) (greenkeeper[bot])
393
394chore(package): update rollup to version 0.41.0 ([#272](https://github.com/babel/babylon/pull/272)) (greenkeeper[bot])
395
396chore(package): update flow-bin to version 0.37.0 ([#255](https://github.com/babel/babylon/pull/255)) (greenkeeper[bot])
397
398## 6.14.1 (2016-11-17)
399
400### :bug: Bug Fix
401
402Allow `"plugins": ["*"]` ([#229](https://github.com/babel/babylon/pull/229)) (Daniel Tschinder)
403
404```js
405{
406 "plugins": ["*"]
407}
408```
409
410Will include all parser plugins instead of specifying each one individually. Useful for tools like babel-eslint, jscodeshift, and ast-explorer.
411
412## 6.14.0 (2016-11-16)
413
414### :eyeglasses: Spec Compliance
415
416Throw error for reserved words `enum` and `await` ([#195](https://github.com/babel/babylon/pull/195)) (Kai Cataldo)
417
418[11.6.2.2 Future Reserved Words](http://www.ecma-international.org/ecma-262/6.0/#sec-future-reserved-words)
419
420Babylon will throw for more reserved words such as `enum` or `await` (in strict mode).
421
422```
423class enum {} // throws
424class await {} // throws in strict mode (module)
425```
426
427Optional names for function types and object type indexers ([#197](https://github.com/babel/babylon/pull/197)) (Gabe Levi)
428
429So where you used to have to write
430
431```js
432type A = (x: string, y: boolean) => number;
433type B = (z: string) => number;
434type C = { [key: string]: number };
435```
436
437you can now write (with flow 0.34.0)
438
439```js
440type A = (string, boolean) => number;
441type B = string => number;
442type C = { [string]: number };
443```
444
445Parse flow nested array type annotations like `number[][]` ([#219](https://github.com/babel/babylon/pull/219)) (Bernhard Häussner)
446
447Supports these form now of specifying array types:
448
449```js
450var a: number[][][][];
451var b: string[][];
452```
453
454### :bug: Bug Fix
455
456Correctly eat semicolon at the end of `DelcareModuleExports` ([#223](https://github.com/babel/babylon/pull/223)) (Daniel Tschinder)
457
458```
459declare module "foo" { declare module.exports: number }
460declare module "foo" { declare module.exports: number; } // also allowed now
461```
462
463### :house: Internal
464
465 * Count Babel tests towards Babylon code coverage ([#182](https://github.com/babel/babylon/pull/182)) (Moti Zilberman)
466 * Fix strange line endings ([#214](https://github.com/babel/babylon/pull/214)) (Thomas Grainger)
467 * Add node 7 (Daniel Tschinder)
468 * chore(package): update flow-bin to version 0.34.0 ([#204](https://github.com/babel/babylon/pull/204)) (Greenkeeper)
469
470## v6.13.1 (2016-10-26)
471
472### :nail_care: Polish
473
474- Use rollup for bundling to speed up startup time ([#190](https://github.com/babel/babylon/pull/190)) ([@drewml](https://github.com/DrewML))
475
476```js
477const babylon = require('babylon');
478const ast = babylon.parse('var foo = "lol";');
479```
480
481With that test case, there was a ~95ms savings by removing the need for node to build/traverse the dependency graph.
482
483**Without bundling**
484![image](https://cloud.githubusercontent.com/assets/5233399/19420264/3133497e-93ad-11e6-9a6a-2da59c4f5c13.png)
485
486**With bundling**
487![image](https://cloud.githubusercontent.com/assets/5233399/19420267/388f556e-93ad-11e6-813e-7c5c396be322.png)
488
489- add clean command [skip ci] ([#201](https://github.com/babel/babylon/pull/201)) (Henry Zhu)
490- add ForAwaitStatement (async generator already added) [skip ci] ([#196](https://github.com/babel/babylon/pull/196)) (Henry Zhu)
491
492## v6.13.0 (2016-10-21)
493
494### :eyeglasses: Spec Compliance
495
496Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman)
497
498> See https://flowtype.org/docs/variance.html for more information
499
500```js
501type T = { +p: T };
502interface T { -p: T };
503declare class T { +[k:K]: V };
504class T { -[k:K]: V };
505class C2 { +p: T = e };
506```
507
508Raise error on duplicate definition of __proto__ ([#183](https://github.com/babel/babylon/pull/183)) (Moti Zilberman)
509
510```js
511({ __proto__: 1, __proto__: 2 }) // Throws an error now
512```
513
514### :bug: Bug Fix
515
516Flow: Allow class properties to be named `static` ([#184](https://github.com/babel/babylon/pull/184)) (Moti Zilberman)
517
518```js
519declare class A {
520 static: T;
521}
522```
523
524Allow "async" as identifier for object literal property shorthand ([#187](https://github.com/babel/babylon/pull/187)) (Andrew Levine)
525
526```js
527var foo = { async, bar };
528```
529
530### :nail_care: Polish
531
532Fix flowtype and add inType to state ([#189](https://github.com/babel/babylon/pull/189)) (Daniel Tschinder)
533
534> This improves the performance slightly (because of hidden classes)
535
536### :house: Internal
537
538Fix .gitattributes line ending setting ([#191](https://github.com/babel/babylon/pull/191)) (Moti Zilberman)
539
540Increase test coverage ([#175](https://github.com/babel/babylon/pull/175) (Moti Zilberman)
541
542Readd missin .eslinignore for IDEs (Daniel Tschinder)
543
544Error on missing expected.json fixture in CI ([#188](https://github.com/babel/babylon/pull/188)) (Moti Zilberman)
545
546Add .gitattributes and .editorconfig for LF line endings ([#179](https://github.com/babel/babylon/pull/179)) (Moti Zilberman)
547
548Fixes two tests that are failing after the merge of #172 ([#177](https://github.com/babel/babylon/pull/177)) (Moti Zilberman)
549
550## v6.12.0 (2016-10-14)
551
552### :eyeglasses: Spec Compliance
553
554Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler)
555
556#### Dynamic Import
557
558- Proposal Repo: https://github.com/domenic/proposal-dynamic-import
559- Championed by [@domenic](https://github.com/domenic)
560- stage-2
561- [sept-28 tc39 notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-09/sept-28.md#113a-import)
562
563> This repository contains a proposal for adding a "function-like" import() module loading syntactic form to JavaScript
564
565```js
566import(`./section-modules/${link.dataset.entryModule}.js`)
567.then(module => {
568 module.loadPageInto(main);
569})
570```
571
572Add EmptyTypeAnnotation ([#171](https://github.com/babel/babylon/pull/171)) (Sam Goldman)
573
574#### EmptyTypeAnnotation
575
576Just wasn't covered before.
577
578```js
579type T = empty;
580```
581
582### :bug: Bug Fix
583
584Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels)
585
586```js
587// was failing due to sparse array
588export const { foo: [ ,, qux7 ] } = bar;
589```
590
591Allow keyword in Flow object declaration property names with type parameters ([#146](https://github.com/babel/babylon/pull/146)) (Dan Harper)
592
593```js
594declare class X {
595 foobar<T>(): void;
596 static foobar<T>(): void;
597}
598```
599
600Allow keyword in object/class property names with Flow type parameters ([#145](https://github.com/babel/babylon/pull/145)) (Dan Harper)
601
602```js
603class Foo {
604 delete<T>(item: T): T {
605 return item;
606 }
607}
608```
609
610Allow typeAnnotations for yield expressions ([#174](https://github.com/babel/babylon/pull/174))) (Daniel Tschinder)
611
612```js
613function *foo() {
614 const x = (yield 5: any);
615}
616```
617
618### :nail_care: Polish
619
620Annotate more errors with expected token ([#172](https://github.com/babel/babylon/pull/172))) (Moti Zilberman)
621
622```js
623// Unexpected token, expected ; (1:6)
624{ set 1 }
625```
626
627### :house: Internal
628
629Remove kcheck ([#173](https://github.com/babel/babylon/pull/173))) (Daniel Tschinder)
630
631Also run flow, linting, babel tests on separate instances (add back node 0.10)
632
633## v6.11.6 (2016-10-12)
634
635### :bug: Bug Fix/Regression
636
637Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels)
638
639```js
640// was failing with `Cannot read property 'type' of null` because of null identifiers
641export const { foo: [ ,, qux7 ] } = bar;
642```
643
644## v6.11.5 (2016-10-12)
645
646### :eyeglasses: Spec Compliance
647
648Fix: Check for duplicate named exports in exported destructuring assignments ([#144](https://github.com/babel/babylon/pull/144)) (Kai Cataldo)
649
650```js
651// `foo` has already been exported. Exported identifiers must be unique. (2:20)
652export function foo() {};
653export const { a: [{foo}] } = bar;
654```
655
656Fix: Check for duplicate named exports in exported rest elements/properties ([#164](https://github.com/babel/babylon/pull/164)) (Kai Cataldo)
657
658```js
659// `foo` has already been exported. Exported identifiers must be unique. (2:22)
660export const foo = 1;
661export const [bar, ...foo] = baz;
662```
663
664### :bug: Bug Fix
665
666Fix: Allow identifier `async` for default param in arrow expression ([#165](https://github.com/babel/babylon/pull/165)) (Kai Cataldo)
667
668```js
669// this is ok now
670const test = ({async = true}) => {};
671```
672
673### :nail_care: Polish
674
675Babylon will now print out the token it's expecting if there's a `SyntaxError` ([#150](https://github.com/babel/babylon/pull/150)) (Daniel Tschinder)
676
677```bash
678# So in the case of a missing ending curly (`}`)
679Module build failed: SyntaxError: Unexpected token, expected } (30:0)
680 28 | }
681 29 |
682> 30 |
683 | ^
684```
685
686## v6.11.4 (2016-10-03)
687
688Temporary rollback for erroring on trailing comma with spread (#154) (Henry Zhu)
689
690## v6.11.3 (2016-10-01)
691
692### :eyeglasses: Spec Compliance
693
694Add static errors for object rest (#149) ([@danez](https://github.com/danez))
695
696> https://github.com/sebmarkbage/ecmascript-rest-spread
697
698Object rest copies the *rest* of properties from the right hand side `obj` starting from the left to right.
699
700```js
701let { x, y, ...z } = { x: 1, y: 2, z: 3 };
702// x = 1
703// y = 2
704// z = { z: 3 }
705```
706
707#### New Syntax Errors:
708
709**SyntaxError**: The rest element has to be the last element when destructuring (1:10)
710```bash
711> 1 | let { ...x, y, z } = { x: 1, y: 2, z: 3};
712 | ^
713# Previous behavior:
714# x = { x: 1, y: 2, z: 3 }
715# y = 2
716# z = 3
717```
718
719Before, this was just a more verbose way of shallow copying `obj` since it doesn't actually do what you think.
720
721**SyntaxError**: Cannot have multiple rest elements when destructuring (1:13)
722
723```bash
724> 1 | let { x, ...y, ...z } = { x: 1, y: 2, z: 3};
725 | ^
726# Previous behavior:
727# x = 1
728# y = { y: 2, z: 3 }
729# z = { y: 2, z: 3 }
730```
731
732Before y and z would just be the same value anyway so there is no reason to need to have both.
733
734**SyntaxError**: A trailing comma is not permitted after the rest element (1:16)
735
736```js
737let { x, y, ...z, } = obj;
738```
739
740The rationale for this is that the use case for trailing comma is that you can add something at the end without affecting the line above. Since a RestProperty always has to be the last property it doesn't make sense.
741
742---
743
744get / set are valid property names in default assignment (#142) ([@jezell](https://github.com/jezell))
745
746```js
747// valid
748function something({ set = null, get = null }) {}
749```
750
751## v6.11.2 (2016-09-23)
752
753### Bug Fix
754
755- [#139](https://github.com/babel/babylon/issues/139) Don't do the duplicate check if not an identifier (#140) @hzoo
756
757```js
758// regression with duplicate export check
759SyntaxError: ./typography.js: `undefined` has already been exported. Exported identifiers must be unique. (22:13)
760 20 |
761 21 | export const { rhythm } = typography;
762> 22 | export const { TypographyStyle } = typography
763```
764
765Bail out for now, and make a change to account for destructuring in the next release.
766
767## 6.11.1 (2016-09-22)
768
769### Bug Fix
770- [#137](https://github.com/babel/babylon/pull/137) - Fix a regression with duplicate exports - it was erroring on all keys in `Object.prototype`. @danez
771
772```javascript
773export toString from './toString';
774```
775
776```bash
777`toString` has already been exported. Exported identifiers must be unique. (1:7)
778> 1 | export toString from './toString';
779 | ^
780 2 |
781```
782
783## 6.11.0 (2016-09-22)
784
785### Spec Compliance (will break CI)
786
787- Disallow duplicate named exports ([#107](https://github.com/babel/babylon/pull/107)) @kaicataldo
788
789```js
790// Only one default export allowed per module. (2:9)
791export default function() {};
792export { foo as default };
793
794// Only one default export allowed per module. (2:0)
795export default {};
796export default function() {};
797
798// `Foo` has already been exported. Exported identifiers must be unique. (2:0)
799export { Foo };
800export class Foo {};
801```
802
803### New Feature (Syntax)
804
805- Add support for computed class property names ([#121](https://github.com/babel/babylon/pull/121)) @motiz88
806
807```js
808// AST
809interface ClassProperty <: Node {
810 type: "ClassProperty";
811 key: Identifier;
812 value: Expression;
813 computed: boolean; // added
814}
815```
816
817```js
818// with "plugins": ["classProperties"]
819class Foo {
820 [x]
821 ['y']
822}
823
824class Bar {
825 [p]
826 [m] () {}
827}
828 ```
829
830### Bug Fix
831
832- Fix `static` property falling through in the declare class Flow AST ([#135](https://github.com/babel/babylon/pull/135)) @danharper
833
834```js
835declare class X {
836 a: number;
837 static b: number; // static
838 c: number; // this was being marked as static in the AST as well
839}
840```
841
842### Polish
843
844- Rephrase "assigning/binding to rvalue" errors to include context ([#119](https://github.com/babel/babylon/pull/119)) @motiz88
845
846```js
847// Used to error with:
848// SyntaxError: Assigning to rvalue (1:0)
849
850// Now:
851// Invalid left-hand side in assignment expression (1:0)
8523 = 4
853
854// Invalid left-hand side in for-in statement (1:5)
855for (+i in {});
856```
857
858### Internal
859
860- Fix call to `this.parseMaybeAssign` with correct arguments ([#133](https://github.com/babel/babylon/pull/133)) @danez
861- Add semver note to changelog ([#131](https://github.com/babel/babylon/pull/131)) @hzoo
862
863## 6.10.0 (2016-09-19)
864
865> We plan to include some spec compliance bugs in patch versions. An example was the multiple default exports issue.
866
867### Spec Compliance
868
869* Implement ES2016 check for simple parameter list in strict mode ([#106](https://github.com/babel/babylon/pull/106)) (Timothy Gu)
870
871> It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of FormalParameters is false. https://tc39.github.io/ecma262/2016/#sec-function-definitions-static-semantics-early-errors
872
873More Context: [tc39-notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2015-07/july-29.md#611-the-scope-of-use-strict-with-respect-to-destructuring-in-parameter-lists)
874
875For example:
876
877```js
878// this errors because it uses destructuring and default parameters
879// in a function with a "use strict" directive
880function a([ option1, option2 ] = []) {
881 "use strict";
882}
883 ```
884
885The solution would be to use a top level "use strict" or to remove the destructuring or default parameters when using a function + "use strict" or to.
886
887### New Feature
888
889* Exact object type annotations for Flow plugin ([#104](https://github.com/babel/babylon/pull/104)) (Basil Hosmer)
890
891Added to flow in https://github.com/facebook/flow/commit/c710c40aa2a115435098d6c0dfeaadb023cd39b8
892
893Looks like:
894
895```js
896var a : {| x: number, y: string |} = { x: 0, y: 'foo' };
897```
898
899### Bug Fixes
900
901* Include `typeParameter` location in `ArrowFunctionExpression` ([#126](https://github.com/babel/babylon/pull/126)) (Daniel Tschinder)
902* Error on invalid flow type annotation with default assignment ([#122](https://github.com/babel/babylon/pull/122)) (Dan Harper)
903* Fix Flow return types on arrow functions ([#124](https://github.com/babel/babylon/pull/124)) (Dan Harper)
904
905### Misc
906
907* Add tests for export extensions ([#127](https://github.com/babel/babylon/pull/127)) (Daniel Tschinder)
908* Fix Contributing guidelines [skip ci] (Daniel Tschinder)
909
910## 6.9.2 (2016-09-09)
911
912The only change is to remove the `babel-runtime` dependency by compiling with Babel's ES2015 loose mode. So using babylon standalone should be smaller.
913
914## 6.9.1 (2016-08-23)
915
916This release contains mainly small bugfixes but also updates babylons default mode to es2017. The features for `exponentiationOperator`, `asyncFunctions` and `trailingFunctionCommas` which previously needed to be activated via plugin are now enabled by default and the plugins are now no-ops.
917
918### Bug Fixes
919
920- Fix issues with default object params in async functions ([#96](https://github.com/babel/babylon/pull/96)) @danez
921- Fix issues with flow-types and async function ([#95](https://github.com/babel/babylon/pull/95)) @danez
922- Fix arrow functions with destructuring, types & default value ([#94](https://github.com/babel/babylon/pull/94)) @danharper
923- Fix declare class with qualified type identifier ([#97](https://github.com/babel/babylon/pull/97)) @danez
924- Remove exponentiationOperator, asyncFunctions, trailingFunctionCommas plugins and enable them by default ([#98](https://github.com/babel/babylon/pull/98)) @danez
925
926## 6.9.0 (2016-08-16)
927
928### New syntax support
929
930- Add JSX spread children ([#42](https://github.com/babel/babylon/pull/42)) @calebmer
931
932(Be aware that React is not going to support this syntax)
933
934```js
935<div>
936 {...todos.map(todo => <Todo key={todo.id} todo={todo}/>)}
937</div>
938```
939
940- Add support for declare module.exports ([#72](https://github.com/babel/babylon/pull/72)) @danez
941
942```js
943declare module "foo" {
944 declare module.exports: {}
945}
946```
947
948### New Features
949
950- If supplied, attach filename property to comment node loc. ([#80](https://github.com/babel/babylon/pull/80)) @divmain
951- Add identifier name to node loc field ([#90](https://github.com/babel/babylon/pull/90)) @kittens
952
953### Bug Fixes
954
955- Fix exponential operator to behave according to spec ([#75](https://github.com/babel/babylon/pull/75)) @danez
956- Fix lookahead to not add comments to arrays which are not cloned ([#76](https://github.com/babel/babylon/pull/76)) @danez
957- Fix accidental fall-through in Flow type parsing. ([#82](https://github.com/babel/babylon/pull/82)) @xiemaisi
958- Only allow declares inside declare module ([#73](https://github.com/babel/babylon/pull/73)) @danez
959- Small fix for parsing type parameter declarations ([#83](https://github.com/babel/babylon/pull/83)) @gabelevi
960- Fix arrow param locations with flow types ([#57](https://github.com/babel/babylon/pull/57)) @danez
961- Fixes SyntaxError position with flow optional type ([#65](https://github.com/babel/babylon/pull/65)) @danez
962
963### Internal
964
965- Add codecoverage to tests @danez
966- Fix tests to not save expected output if we expect the test to fail @danez
967- Make a shallow clone of babel for testing @danez
968- chore(package): update cross-env to version 2.0.0 ([#77](https://github.com/babel/babylon/pull/77)) @greenkeeperio-bot
969- chore(package): update ava to version 0.16.0 ([#86](https://github.com/babel/babylon/pull/86)) @greenkeeperio-bot
970- chore(package): update babel-plugin-istanbul to version 2.0.0 ([#89](https://github.com/babel/babylon/pull/89)) @greenkeeperio-bot
971- chore(package): update nyc to version 8.0.0 ([#88](https://github.com/babel/babylon/pull/88)) @greenkeeperio-bot
972
973## 6.8.4 (2016-07-06)
974
975### Bug Fixes
976
977- Fix the location of params, when flow and default value used ([#68](https://github.com/babel/babylon/pull/68)) @danez
978
979## 6.8.3 (2016-07-02)
980
981### Bug Fixes
982
983- Fix performance regression introduced in 6.8.2 with conditionals ([#63](https://github.com/babel/babylon/pull/63)) @danez
984
985## 6.8.2 (2016-06-24)
986
987### Bug Fixes
988
989- Fix parse error with yielding jsx elements in generators `function* it() { yield <a></a>; }` ([#31](https://github.com/babel/babylon/pull/31)) @eldereal
990- When cloning nodes do not clone its comments ([#24](https://github.com/babel/babylon/pull/24)) @danez
991- Fix parse errors when using arrow functions with an spread element and return type `(...props): void => {}` ([#10](https://github.com/babel/babylon/pull/10)) @danez
992- Fix leading comments added from previous node ([#23](https://github.com/babel/babylon/pull/23)) @danez
993- Fix parse errors with flow's optional arguments `(arg?) => {}` ([#19](https://github.com/babel/babylon/pull/19)) @danez
994- Support negative numeric type literals @kittens
995- Remove line terminator restriction after await keyword @kittens
996- Remove grouped type arrow restriction as it seems flow no longer has it @kittens
997- Fix parse error with generic methods that have the name `get` or `set` `class foo { get() {} }` ([#55](https://github.com/babel/babylon/pull/55)) @vkurchatkin
998- Fix parse error with arrow functions that have flow type parameter declarations `<T>(x: T): T => x;` ([#54](https://github.com/babel/babylon/pull/54)) @gabelevi
999
1000### Documentation
1001
1002- Document AST differences from ESTree ([#41](https://github.com/babel/babylon/pull/41)) @nene
1003- Move ast spec from babel/babel ([#46](https://github.com/babel/babylon/pull/46)) @hzoo
1004
1005### Internal
1006
1007- Enable skipped tests ([#16](https://github.com/babel/babylon/pull/16)) @danez
1008- Add script to test latest version of babylon with babel ([#21](https://github.com/babel/babylon/pull/21)) @danez
1009- Upgrade test runner ava @kittens
1010- Add missing generate-identifier-regex script @kittens
1011- Rename parser context types @kittens
1012- Add node v6 to travis testing @hzoo
1013- Update to Unicode v9 ([#45](https://github.com/babel/babylon/pull/45)) @mathiasbynens
1014
1015## 6.8.1 (2016-06-06)
1016
1017### New Feature
1018
1019- Parse type parameter declarations with defaults like `type Foo<T = string> = T`
1020
1021### Bug Fixes
1022- Type parameter declarations need 1 or more type parameters.
1023- The existential type `*` is not a valid type parameter.
1024- The existential type `*` is a primary type
1025
1026### Spec Compliance
1027- The param list for type parameter declarations now consists of `TypeParameter` nodes
1028- New `TypeParameter` AST Node (replaces using the `Identifier` node before)
1029
1030```
1031interface TypeParameter <: Node {
1032 bound: TypeAnnotation;
1033 default: TypeAnnotation;
1034 name: string;
1035 variance: "plus" | "minus";
1036}
1037```
1038
1039## 6.8.0 (2016-05-02)
1040
1041#### New Feature
1042
1043##### Parse Method Parameter Decorators ([#12](https://github.com/babel/babylon/pull/12))
1044
1045> [Method Parameter Decorators](https://goo.gl/8MmCMG) is now a TC39 [stage 0 proposal](https://github.com/tc39/ecma262/blob/master/stage0.md).
1046
1047Examples:
1048
1049```js
1050class Foo {
1051 constructor(@foo() x, @bar({ a: 123 }) @baz() y) {}
1052}
1053
1054export default function func(@foo() x, @bar({ a: 123 }) @baz() y) {}
1055
1056var obj = {
1057 method(@foo() x, @bar({ a: 123 }) @baz() y) {}
1058};
1059```
1060
1061##### Parse for-await statements (w/ `asyncGenerators` plugin) ([#17](https://github.com/babel/babylon/pull/17))
1062
1063There is also a new node type, `ForAwaitStatement`.
1064
1065> [Async generators and for-await](https://github.com/tc39/proposal-async-iteration) are now a [stage 2 proposal](https://github.com/tc39/ecma262#current-proposals).
1066
1067Example:
1068
1069```js
1070async function f() {
1071 for await (let x of y);
1072}
1073```