forked from lightscript/babylon-lightscript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flow opaque type alias backport (babel#644)
* Flow opaque type alias backport * Flow opaque type alias backport tests * Only add support for opaque types * Remove .swp file
- Loading branch information
Showing
53 changed files
with
1,609 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
test/fixtures/flow/opaque-type-aliases/declare_opaque/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare opaque type ID = number; |
3 changes: 3 additions & 0 deletions
3
test/fixtures/flow/opaque-type-aliases/declare_opaque/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "Unexpected token, expected ; (1:23)" | ||
} |
2 changes: 2 additions & 0 deletions
2
test/fixtures/flow/opaque-type-aliases/opaque_collision/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
opaque type opaque = number; | ||
opaque type not_transparent = opaque; |
150 changes: 150 additions & 0 deletions
150
test/fixtures/flow/opaque-type-aliases/opaque_collision/expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 66, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 37 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 66, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 37 | ||
} | ||
}, | ||
"sourceType": "module", | ||
"body": [ | ||
{ | ||
"type": "OpaqueType", | ||
"start": 0, | ||
"end": 28, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 28 | ||
} | ||
}, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 12, | ||
"end": 18, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 12 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 18 | ||
}, | ||
"identifierName": "opaque" | ||
}, | ||
"name": "opaque" | ||
}, | ||
"typeParameters": null, | ||
"supertype": null, | ||
"impltype": { | ||
"type": "NumberTypeAnnotation", | ||
"start": 21, | ||
"end": 27, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 21 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 27 | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "OpaqueType", | ||
"start": 29, | ||
"end": 66, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 37 | ||
} | ||
}, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 41, | ||
"end": 56, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 12 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 27 | ||
}, | ||
"identifierName": "not_transparent" | ||
}, | ||
"name": "not_transparent" | ||
}, | ||
"typeParameters": null, | ||
"supertype": null, | ||
"impltype": { | ||
"type": "GenericTypeAnnotation", | ||
"start": 59, | ||
"end": 65, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 30 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 36 | ||
} | ||
}, | ||
"typeParameters": null, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 59, | ||
"end": 65, | ||
"loc": { | ||
"start": { | ||
"line": 2, | ||
"column": 30 | ||
}, | ||
"end": { | ||
"line": 2, | ||
"column": 36 | ||
}, | ||
"identifierName": "opaque" | ||
}, | ||
"name": "opaque" | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
test/fixtures/flow/opaque-type-aliases/opaque_declare_export_neither/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare export opaque type Foo |
85 changes: 85 additions & 0 deletions
85
test/fixtures/flow/opaque-type-aliases/opaque_declare_export_neither/expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 30, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 30 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 30, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 30 | ||
} | ||
}, | ||
"sourceType": "module", | ||
"body": [ | ||
{ | ||
"type": "DeclareExportDeclaration", | ||
"start": 0, | ||
"end": 30, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 30 | ||
} | ||
}, | ||
"declaration": { | ||
"type": "DeclareOpaqueType", | ||
"start": 15, | ||
"end": 30, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 15 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 30 | ||
} | ||
}, | ||
"id": { | ||
"type": "Identifier", | ||
"start": 27, | ||
"end": 30, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 27 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 30 | ||
}, | ||
"identifierName": "Foo" | ||
}, | ||
"name": "Foo" | ||
}, | ||
"typeParameters": null, | ||
"supertype": null, | ||
"impltype": null | ||
}, | ||
"default": false | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
test/fixtures/flow/opaque-type-aliases/opaque_declare_export_st_no_t/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare export opaque type Foo: Bar |
Oops, something went wrong.