Comparing version 6.12.0 to 6.13.0
143
CHANGELOG.md
@@ -18,2 +18,143 @@ # Changelog | ||
## v6.13.0 (2016-10-21) | ||
### 👓 Spec Compliancy | ||
Property variance type annotations for Flow plugin ([#161](https://github.com/babel/babylon/pull/161)) (Sam Goldman) | ||
> See https://flowtype.org/docs/variance.html for more information | ||
```js | ||
type T = { +p: T }; | ||
interface T { -p: T }; | ||
declare class T { +[k:K]: V }; | ||
class T { -[k:K]: V }; | ||
class C2 { +p: T = e }; | ||
``` | ||
Raise error on duplicate definition of __proto__ ([#183](https://github.com/babel/babylon/pull/183)) (Moti Zilberman) | ||
```js | ||
({ __proto__: 1, __proto__: 2 }) // Throws an error now | ||
``` | ||
### :bug: Bug Fix | ||
Flow: Allow class properties to be named `static` ([#184](https://github.com/babel/babylon/pull/184)) (Moti Zilberman) | ||
```js | ||
declare class A { | ||
static: T; | ||
} | ||
``` | ||
Allow "async" as identifier for object literal property shorthand ([#187](https://github.com/babel/babylon/pull/187)) (Andrew Levine) | ||
```js | ||
var foo = { async, bar }; | ||
``` | ||
### :nail_care: Polish | ||
Fix flowtype and add inType to state ([#189](https://github.com/babel/babylon/pull/189)) (Daniel Tschinder) | ||
> This improves the performance slightly (because of hidden classes) | ||
### :house: Internal | ||
Fix .gitattributes line ending setting ([#191](https://github.com/babel/babylon/pull/191)) (Moti Zilberman) | ||
Increase test coverage ([#175](https://github.com/babel/babylon/pull/175) (Moti Zilberman) | ||
Readd missin .eslinignore for IDEs (Daniel Tschinder) | ||
Error on missing expected.json fixture in CI ([#188](https://github.com/babel/babylon/pull/188)) (Moti Zilberman) | ||
Add .gitattributes and .editorconfig for LF line endings ([#179](https://github.com/babel/babylon/pull/179)) (Moti Zilberman) | ||
Fixes two tests that are failing after the merge of #172 ([#177](https://github.com/babel/babylon/pull/177)) (Moti Zilberman) | ||
## v6.12.0 (2016-10-14) | ||
### 👓 Spec Compliancy | ||
Implement import() syntax ([#163](https://github.com/babel/babylon/pull/163)) (Jordan Gensler) | ||
#### Dynamic Import | ||
- Proposal Repo: https://github.com/domenic/proposal-dynamic-import | ||
- Championed by [@domenic](https://github.com/domenic) | ||
- stage-2 | ||
- [sept-28 tc39 notes](https://github.com/rwaldron/tc39-notes/blob/master/es7/2016-09/sept-28.md#113a-import) | ||
> This repository contains a proposal for adding a "function-like" import() module loading syntactic form to JavaScript | ||
```js | ||
import(`./section-modules/${link.dataset.entryModule}.js`) | ||
.then(module => { | ||
module.loadPageInto(main); | ||
}) | ||
``` | ||
Add EmptyTypeAnnotation ([#171](https://github.com/babel/babylon/pull/171)) (Sam Goldman) | ||
#### EmptyTypeAnnotation | ||
Just wasn't covered before. | ||
```js | ||
type T = empty; | ||
``` | ||
### :bug: Bug Fix | ||
Fix crash when exporting with destructuring and sparse array ([#170](https://github.com/babel/babylon/pull/170)) (Jeroen Engels) | ||
```js | ||
// was failing due to sparse array | ||
export const { foo: [ ,, qux7 ] } = bar; | ||
``` | ||
Allow keyword in Flow object declaration property names with type parameters ([#146](https://github.com/babel/babylon/pull/146)) (Dan Harper) | ||
```js | ||
declare class X { | ||
foobar<T>(): void; | ||
static foobar<T>(): void; | ||
} | ||
``` | ||
Allow keyword in object/class property names with Flow type parameters ([#145](https://github.com/babel/babylon/pull/145)) (Dan Harper) | ||
```js | ||
class Foo { | ||
delete<T>(item: T): T { | ||
return item; | ||
} | ||
} | ||
``` | ||
Allow typeAnnotations for yield expressions ([#174](https://github.com/babel/babylon/pull/174))) (Daniel Tschinder) | ||
```js | ||
function *foo() { | ||
const x = (yield 5: any); | ||
} | ||
``` | ||
### :nail_care: Polish | ||
Annotate more errors with expected token ([#172](https://github.com/babel/babylon/pull/172))) (Moti Zilberman) | ||
```js | ||
// Unexpected token, expected ; (1:6) | ||
{ set 1 } | ||
``` | ||
### :house: Internal | ||
Remove kcheck ([#173](https://github.com/babel/babylon/pull/173))) (Daniel Tschinder) | ||
Also run flow, linting, babel tests on seperate instances (add back node 0.10) | ||
## v6.11.6 (2016-10-12) | ||
@@ -28,3 +169,3 @@ | ||
export const { foo: [ ,, qux7 ] } = bar; | ||
```` | ||
``` | ||
@@ -31,0 +172,0 @@ ## v6.11.5 (2016-10-12) |
@@ -56,2 +56,3 @@ "use strict"; | ||
// istanbul ignore next: non-computed property keys are always one of the above | ||
default: | ||
@@ -61,3 +62,3 @@ return; | ||
if (name === "__proto__" && prop.kind === "init") { | ||
if (name === "__proto__" && !prop.kind) { | ||
if (propHash.proto) this.raise(key.start, "Redefinition of __proto__ property"); | ||
@@ -411,3 +412,3 @@ propHash.proto = true; | ||
if (!this.match(_types.types.parenL)) { | ||
this.unexpected(); | ||
this.unexpected(null, _types.types.parenL); | ||
} | ||
@@ -571,3 +572,3 @@ return this.finishNode(node, "Import"); | ||
pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow, isAsync) { | ||
pp.parseParenAndDistinguishExpression = function (startPos, startLoc, canBeArrow) { | ||
startPos = startPos || this.state.start; | ||
@@ -632,11 +633,7 @@ startLoc = startLoc || this.state.startLoc; | ||
return this.parseArrowExpression(arrowNode, exprList, isAsync); | ||
return this.parseArrowExpression(arrowNode, exprList); | ||
} | ||
if (!exprList.length) { | ||
if (isAsync) { | ||
return; | ||
} else { | ||
this.unexpected(this.state.lastTokStart); | ||
} | ||
this.unexpected(this.state.lastTokStart); | ||
} | ||
@@ -804,3 +801,3 @@ if (optionalCommaStart) this.unexpected(optionalCommaStart); | ||
var asyncId = this.parseIdentifier(); | ||
if (this.match(_types.types.colon) || this.match(_types.types.parenL) || this.match(_types.types.braceR) || this.match(_types.types.eq)) { | ||
if (this.match(_types.types.colon) || this.match(_types.types.parenL) || this.match(_types.types.braceR) || this.match(_types.types.eq) || this.match(_types.types.comma)) { | ||
prop.key = asyncId; | ||
@@ -1094,2 +1091,3 @@ } else { | ||
pp.parseAwait = function (node) { | ||
// istanbul ignore next: this condition is checked at the call site so won't be hit here | ||
if (!this.state.inAsync) { | ||
@@ -1096,0 +1094,0 @@ this.unexpected(); |
@@ -707,3 +707,2 @@ "use strict"; | ||
if (method.static) { | ||
if (isGenerator) this.unexpected(); | ||
isGenerator = this.eat(_types.types.star); | ||
@@ -710,0 +709,0 @@ this.parsePropertyName(method); |
@@ -75,2 +75,3 @@ "use strict"; | ||
} else { | ||
// istanbul ignore next: no such error is expected | ||
throw err; | ||
@@ -258,2 +259,3 @@ } | ||
return function (node) { | ||
delete node.variancePos; | ||
if (this.match(_types.types.colon)) { | ||
@@ -276,2 +278,7 @@ node.typeAnnotation = this.flowParseTypeAnnotation(); | ||
return function (classBody, method, isGenerator, isAsync) { | ||
if (method.variance) { | ||
this.unexpected(method.variancePos); | ||
} | ||
delete method.variance; | ||
delete method.variancePos; | ||
if (this.isRelational("<")) { | ||
@@ -309,5 +316,22 @@ method.typeParameters = this.flowParseTypeParameterDeclaration(); | ||
instance.extend("parsePropertyName", function (inner) { | ||
return function (node) { | ||
var variancePos = this.state.start; | ||
var variance = this.flowParseVariance(); | ||
var key = inner.call(this, node); | ||
node.variance = variance; | ||
node.variancePos = variancePos; | ||
return key; | ||
}; | ||
}); | ||
// parse type parameters for object method shorthand | ||
instance.extend("parseObjPropValue", function (inner) { | ||
return function (prop) { | ||
if (prop.variance) { | ||
this.unexpected(prop.variancePos); | ||
} | ||
delete prop.variance; | ||
delete prop.variancePos; | ||
var typeParameters = void 0; | ||
@@ -448,2 +472,3 @@ | ||
} else { | ||
// istanbul ignore next: no such error is expected | ||
throw err; | ||
@@ -500,2 +525,3 @@ } | ||
} else { | ||
// istanbul ignore next: no such error is expected | ||
throw err; | ||
@@ -736,13 +762,5 @@ } | ||
var variance = void 0; | ||
if (this.match(_types.types.plusMin)) { | ||
if (this.state.value === "+") { | ||
variance = "plus"; | ||
} else if (this.state.value === "-") { | ||
variance = "minus"; | ||
} | ||
this.eat(_types.types.plusMin); | ||
} | ||
var variance = this.flowParseVariance(); | ||
var ident = this.flowParseTypeAnnotatableIdentifier(false, false); | ||
var ident = this.flowParseTypeAnnotatableIdentifier(); | ||
node.name = ident.name; | ||
@@ -767,2 +785,3 @@ node.variance = variance; | ||
// istanbul ignore else: this condition is already checked at all call sites | ||
if (this.isRelational("<") || this.match(_types.types.jsxTagStart)) { | ||
@@ -812,3 +831,3 @@ this.next(); | ||
pp.flowParseObjectTypeIndexer = function (node, isStatic) { | ||
pp.flowParseObjectTypeIndexer = function (node, isStatic, variance) { | ||
node.static = isStatic; | ||
@@ -821,2 +840,3 @@ | ||
node.value = this.flowParseTypeInitialiser(); | ||
node.variance = variance; | ||
@@ -903,3 +923,3 @@ this.flowObjectTypeSemicolon(); | ||
node = this.startNode(); | ||
if (allowStatic && this.isContextual("static")) { | ||
if (allowStatic && this.isContextual("static") && this.lookahead().type !== _types.types.colon) { | ||
this.next(); | ||
@@ -909,14 +929,19 @@ isStatic = true; | ||
var variancePos = this.state.start; | ||
var variance = this.flowParseVariance(); | ||
if (this.match(_types.types.bracketL)) { | ||
nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic)); | ||
nodeStart.indexers.push(this.flowParseObjectTypeIndexer(node, isStatic, variance)); | ||
} else if (this.match(_types.types.parenL) || this.isRelational("<")) { | ||
if (variance) { | ||
this.unexpected(variancePos); | ||
} | ||
nodeStart.callProperties.push(this.flowParseObjectTypeCallProperty(node, allowStatic)); | ||
} else { | ||
if (isStatic && this.match(_types.types.colon)) { | ||
propertyKey = this.parseIdentifier(); | ||
} else { | ||
propertyKey = this.flowParseObjectPropertyKey(); | ||
} | ||
propertyKey = this.flowParseObjectPropertyKey(); | ||
if (this.isRelational("<") || this.match(_types.types.parenL)) { | ||
// This is a method property | ||
if (variance) { | ||
this.unexpected(variancePos); | ||
} | ||
nodeStart.properties.push(this.flowParseObjectTypeMethod(startPos, startLoc, isStatic, propertyKey)); | ||
@@ -931,2 +956,3 @@ } else { | ||
node.static = isStatic; | ||
node.variance = variance; | ||
this.flowObjectTypeSemicolon(); | ||
@@ -1242,22 +1268,8 @@ nodeStart.properties.push(this.finishNode(node, "ObjectTypeProperty")); | ||
pp.flowParseTypeAnnotatableIdentifier = function (requireTypeAnnotation, canBeOptionalParam) { | ||
pp.flowParseTypeAnnotatableIdentifier = function () { | ||
var ident = this.parseIdentifier(); | ||
var isOptionalParam = false; | ||
if (canBeOptionalParam && this.eat(_types.types.question)) { | ||
this.expect(_types.types.question); | ||
isOptionalParam = true; | ||
} | ||
if (requireTypeAnnotation || this.match(_types.types.colon)) { | ||
if (this.match(_types.types.colon)) { | ||
ident.typeAnnotation = this.flowParseTypeAnnotation(); | ||
this.finishNode(ident, ident.type); | ||
} | ||
if (isOptionalParam) { | ||
ident.optional = true; | ||
this.finishNode(ident, ident.type); | ||
} | ||
return ident; | ||
@@ -1270,2 +1282,15 @@ }; | ||
return this.finishNodeAt(node.expression, node.expression.type, node.typeAnnotation.end, node.typeAnnotation.loc.end); | ||
}; | ||
pp.flowParseVariance = function () { | ||
var variance = null; | ||
if (this.match(_types.types.plusMin)) { | ||
if (this.state.value === "+") { | ||
variance = "plus"; | ||
} else if (this.state.value === "-") { | ||
variance = "minus"; | ||
} | ||
this.next(); | ||
} | ||
return variance; | ||
}; |
@@ -456,2 +456,3 @@ "use strict"; | ||
// istanbul ignore next - should never happen | ||
default: | ||
@@ -458,0 +459,0 @@ this.unexpected(); |
@@ -25,3 +25,3 @@ "use strict"; | ||
this.inMethod = this.inFunction = this.inGenerator = this.inAsync = false; | ||
this.inMethod = this.inFunction = this.inGenerator = this.inAsync = this.inType = false; | ||
@@ -28,0 +28,0 @@ this.labels = []; |
{ | ||
"name": "babylon", | ||
"version": "6.12.0", | ||
"version": "6.13.0", | ||
"description": "A JavaScript parser", | ||
@@ -5,0 +5,0 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
242640
5544
1