106 Commits

Author SHA1 Message Date
Andy
0545173f66 Test runner: Detect extra property in 'actual' but not in 'expected'. (#407)
* Test runner: Detect extra property in 'actual' but not in 'expected'.

Also update all expected.json where this would result in errors.

* Include rmExpected.js script in case it is needed again
2017-03-19 22:03:11 +01:00
Henry Zhu
5e0cce4974 Merge branch 'master' into 7.0 2017-02-28 14:37:13 -05:00
Brian Ng
cd133ff8e1 Ensure consistent start args for parseParenItem (#386) 2017-02-28 12:56:56 +01:00
Alex Rattray
fab4ca2a18 Fix flow type-parameter-declaration test with unintended semantic (#361) 2017-02-22 16:19:42 +01:00
Daniel Tschinder
50ffa49201
Merge branch 'master' into 7.0
# Conflicts:
#	src/plugins/flow.js
2017-02-20 22:47:17 +01:00
Daniel Tschinder
2ef00a6631 Fix negative number literal typeannotations (#366)
* Fix negative number literal typeannotations

Also use parseLiteral() to parser string and number literal typeannotations
so that future changes (estree) to literals are also reflected to flow.

* Instead of invalid fallthrough throw immediately

* Increase coverage and better error mesage
2017-02-20 22:43:59 +01:00
Daniel Tschinder
d2ccc6ae22 Fix test 2017-02-12 15:39:52 +01:00
Daniel Tschinder
09c1f069f9 Fix test 2017-02-12 15:38:11 +01:00
Daniel Tschinder
d88befdd30
Merge branch 'master' into 7.0
# Conflicts:
#	src/parser/index.js
2017-02-12 13:32:06 +01:00
Daniel Tschinder
1cca7000d1 Reintroduce Variance node (#333)
* Reintroduce Variance node

* Optimize code and coverage

tt.plusMin can only be + or - so no need to have an elseif
2017-02-12 13:28:14 +01:00
Charles Pick
cd3f14921e Rename NumericLiteralTypeAnnotation to NumberLiteralTypeAnnotation (#332) 2017-02-12 13:14:35 +01:00
Daniel Tschinder
407c97c9c2 Fix #321 by allowing question marks in type params (#338)
* Fix #321 by allowing question marks in type params

* Require commas between params
2017-02-10 15:03:15 +01:00
Daniel Tschinder
bc771bd0f9 Fix #336 by correctly setting arrow-param (#337) 2017-02-10 15:01:39 +01:00
Daniel Tschinder
4bd682e90b keywords are not allowed as local specifier (#307)
Also fix some error messages to be more specific
2017-02-10 14:58:44 +01:00
Panagiotis Vekris
e049ec3456 [Flow] Function predicate declaration (#103)
* [Flow] Function predicate declaration

The accepted syntax for function declarations is extended to allow
the following predicate declaration:

  FunctionReturnType :=
    Type
    Predicate
    Type Predicate

  Predicate :=
    %checks
    %checks ( ConditionalExpression )

* [Flow] Minor tweaks and more examples to function predicates

* [Flow] Clean-up and better message for function predicates

* [Flow] Adding abstract function predicate example

* [Flow] Rearranging the `predicate` field to ease babel generator.
2017-02-10 14:55:13 +01:00
Daniel Tschinder
0309a5ba8a
Merge branch 'master' into 7.0
# Conflicts:
#	src/parser/statement.js
#	src/plugins/jsx/index.js
2017-01-27 23:12:20 +01:00
Daniel Tschinder
e614032504 Change location of ObjectTypeIndexer to match flow (#228) 2017-01-27 23:08:20 +01:00
Toru Kobayashi
c424156751 Rename flow AST Type ExistentialTypeParam to ExistsTypeAnnotation (#322) 2017-01-27 19:42:15 +01:00
Daniel Tschinder
0a00aff2fe Do not allow overwritting of primitive types (#314)
* Do not allow overwritting of primitive types

* Better name for method
2017-01-20 22:22:25 +01:00
Daniel Tschinder
55df6631fa Address comments on flow type imports (#312) 2017-01-20 22:20:13 +01:00
Daniel Tschinder
d5cd2c3231 Allow imports in declare module (#315)
* Allow imports in declare module {}

* Rename bodyElement to bodyNode
2017-01-20 22:19:50 +01:00
Daniel Tschinder
999b655ca6 Disallow import type { type a } from … (#305) 2017-01-17 20:34:20 +01:00
Dan Harper
28c467e8fe Fix ObjectTypeCallProperty static (#298)
* add failing test for ObjectTypeCallProperty static (#297)

* fix ObjectTypeCallProperty static
2017-01-16 10:42:13 +01:00
Daniel Tschinder
13bebfdf45 Fail tests that have expected.json and throws-option (#285)
* Fail tests that have expected.json and throws

* Remove obsolete test files
2017-01-12 22:38:41 +01:00
Vladimir Kurchatkin
3267e5f365 Don't set inType flag when parsing property names (#266)
* Don't set inType flag when parsing property names

* Add inPropertyName type definition

* Move inPropertyName check before this.curContext()
2017-01-05 12:25:57 +01:00
Jeff Morrison
9ea4e9dead Add support for Flow shorthand import type (#267) 2017-01-03 10:52:18 +01:00
Vladimir Kurchatkin
3dc403974c flow: allow leading pipes in all positions (#256) 2017-01-02 10:13:53 +01:00
Daniel Tschinder
ad88d461d3
Correctly eat a semicolon at the end of DelcareModuleExports 2016-11-13 14:29:46 +01:00
Bernhard Häussner
01ed943deb Parse flow nested array type annotations like number[][] (#219)
* Parse flow nested array type annotations like number[][]

Fixes #217.

* Do not parse a newline separated array statement into a flow type annotation

* Get rid of lineBreak dependency in flow.js in favor of higher level method
2016-11-13 10:22:16 +01:00
Gabe Levi
643124744f Optional names for function types and object type indexers (#197)
* Use .gitattributes to ignore files with weird newlines

* [Flow] Make parameter names in function types optional

* [Flow] Anonymous function types with single params can omit parens

* [Flow] Optional names for object indexer keys

* Add noAnonFunctionType explicitly to state

* Adjust gitattributes as files have been fixed
2016-11-09 16:22:53 +01:00
Moti Zilberman
e047a1b89a Flow: Allow class properties to be named static (#184)
Related: #158
2016-10-17 15:55:50 -04:00
Moti Zilberman
7c18bf83cc Increase test coverage (#175)
* Increase test coverage

* Test for error when binding `this` in destructuring pattern

* Ignore coverage of inAsync check in parseAwait - already checked externally

* Ignore coverage of default case in checkPropClash

* Remove unused parameter isAsync from parseParenAndDistinguishExpression

* Ignore coverage of an `else` branch in flowParseTypeParameterDeclaration

* Flow: remove unused parameters to flowParseTypeAnnotatableIdentifier

* Flow: ignore coverage of pass-through throw statement in parseConditional

* Flow: Add test for error on property with type param

* Flow: ignore coverage of pass-through throw statements in parseMaybeAssign, parseArrow

* Add test for error on XML-style comment in module code

* Update test for error on method in object pattern

* Test for error: "Only '=' operator can be used for specifying default value"
2016-10-16 15:04:13 +02:00
Sam Goldman
26809e8ce7 Property variance type annotations for Flow plugin (#161)
* Property variance type annotations for Flow plugin

Non-method properties and indexers of object types, declare class, and
interfaces can be "positive" or "negative." Class fields, but again not
methods, can also have variance.

This PR generalizes the variance annotations for type parameters into a
new node type, and reuses that node for those properties.

The code for object types is reused for interfaces and declare classes.
The changes there are straightfoward.

The code for class fields is reused for object literals, which do not
support variance annotations (currently). This code is a bit sketchy,
because we always parse variance annotations in the `parsePropertyName`
extension, then error in a the subsequent parse phase for object
literals (`parseObjPropValue`) or class methods (`parseClassMethod`).

* Remove bogus unreachable code, clarify variance parsing conditional

* Don't use a new node type for variance annotations

Adding a new node type, specifically changing the TypeParameter node's
variance property to be node-valued, is a breaking change. We might
choose to make this breaking change in a later version.

* s/start/variancePos
2016-10-14 23:13:27 +02:00
Dan Harper
99fbcefa65 allow keyword in Flow object declaration property names with type parameters (#146) 2016-10-14 21:15:00 +02:00
Dan Harper
f7c1af1c1f allow keyword in object/class property names with Flow type parameters (#145) 2016-10-14 21:13:00 +02:00
Daniel Tschinder
b31834ad29 Allow typeAnnotations for yield epressions (#174) 2016-10-14 12:07:46 -04:00
Sam Goldman
44f77bd724 Add EmptyTypeAnnotation (#171)
I also noticed that there was missing test coverage for builtin types,
so I added a test for that, which includes the newly added type as well
as the other existing types.
2016-10-13 19:22:13 -04:00
Daniel Tschinder
d4d6d05d25 Slightly better error messages (#150)
* Slightly better errors

Instead of "Unexpected token" we now print
"Unexpected token, expected <type.label>"
2016-10-12 10:38:26 -04:00
Kai Cataldo
650e33376a Disallow duplicate named exports (#107)
fixes #69
2016-09-22 10:20:47 -04:00
Dan Harper
b68918e377 fix static falling through in declare class Flow AST (#135) 2016-09-21 00:17:55 -04:00
Daniel Tschinder
f91da191a1 Include typeParameter location in the arrow function expression (#126) 2016-09-15 19:08:33 -04:00
Dan Harper
64145b07e3 error on invalid flow type annotation with default assignment (#122) 2016-09-15 19:35:03 +02:00
Dan Harper
dc3036627b Fix Flow return types on arrow functions (#124)
* fix: arrow return type on next line is valid

https://github.com/babel/babel-eslint/issues/348

* fix: arrow on line after return type annotation is invalid

* lint
2016-09-15 19:27:11 +02:00
Basil Hosmer
ddbda7dd04 exact object type annotations for Flow plugin (#104)
* exact object type annotations for Flow plugin

* Couple tweaks per suggestions

* s/==/===/

* add test for unexpected token in flowObjectType Semicolon
2016-09-13 10:07:23 -04:00
Daniel Tschinder
27ad69d43f Fix declare class with qualified type identifier (#97)
This makes declare class extends behave the same way as in flow
The ast-token after the extends keyword, might be either Identifier or
QualifiedTypeIdentifier

To do that this commits splits the parseGenericType into two functions,
one for parsing genericType and on for qualifiedTypeIdentifier
2016-08-23 17:29:23 -04:00
Dan Harper
efab40154e Fix arrow functions with destructuring, types & default value (#94)
Flow's "toAssignable" override wasn't calling the inner function,
resulting in the destructuring in an AssignmentPattern not having the
node type changed from ObjectExpression to ObjectPattern, resulting in
"Binding rvalue" thrown from "checkLVal()"
2016-08-23 17:27:39 -04:00
Daniel Tschinder
db0705bc51 Fix issues with flow-types and async function (#95)
the typeAnnotation was not correctly resolved in async
functions
2016-08-23 17:22:01 -04:00
Daniel Tschinder
4506822180 Remove exponentiationOperator, asyncFunctions, trailingFunctionCommas (#98)
* This removes the exponentiationOperator as it is now in es2016

* Remove from tests

* Remove asyncFunctions and restructure test dirs

* Remove trailingFunctionCommas
2016-08-23 17:11:01 -04:00
Sebastian McKenzie
4af484b805 Merge pull request #65 from danez/fix-syntax-error-pos
Fixes SyntaxError position with flow optional type
2016-08-16 15:06:25 +01:00
Sebastian McKenzie
43cdd2f5b0 Merge pull request #57 from danez/fix-arrow-location
Fix arrow param locations with flow types
2016-08-16 15:06:19 +01:00